GroupsController.cs 836 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using EyeSoft.Collections.Generic;
  7. using EyeSoft.IO;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.SignalR;
  10. using MySqlX.XDevAPI.Relational;
  11. using NetUV.Core.Handles;
  12. using NPOI.HSSF.UserModel;
  13. using NPOI.POIFS.Crypt.Dsig;
  14. using NPOI.POIFS.Properties;
  15. using NPOI.SS.Format;
  16. using NPOI.SS.Formula.Functions;
  17. using NPOI.SS.UserModel;
  18. using NPOI.SS.Util;
  19. using NPOI.XSSF.UserModel;
  20. using OASystem.API.Middlewares;
  21. using OASystem.API.OAMethodLib;
  22. using OASystem.API.OAMethodLib.APNs;
  23. using OASystem.API.OAMethodLib.File;
  24. using OASystem.API.OAMethodLib.Hub.HubClients;
  25. using OASystem.API.OAMethodLib.Hub.Hubs;
  26. using OASystem.API.OAMethodLib.JuHeAPI;
  27. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  28. using OASystem.Domain.AesEncryption;
  29. using OASystem.Domain.Dtos.CRM;
  30. using OASystem.Domain.Dtos.FileDto;
  31. using OASystem.Domain.Dtos.Financial;
  32. using OASystem.Domain.Dtos.Groups;
  33. using OASystem.Domain.Entities.Customer;
  34. using OASystem.Domain.Entities.Financial;
  35. using OASystem.Domain.Entities.Groups;
  36. using OASystem.Domain.ViewModels;
  37. using OASystem.Domain.ViewModels.Financial;
  38. using OASystem.Domain.ViewModels.Groups;
  39. using OASystem.Domain.ViewModels.Statistics;
  40. using OASystem.Infrastructure.Repositories.CRM;
  41. using OASystem.Infrastructure.Repositories.Financial;
  42. using OASystem.Infrastructure.Repositories.Groups;
  43. using OfficeOpenXml;
  44. using Org.BouncyCastle.Asn1.Ocsp;
  45. using Quartz.Util;
  46. using SqlSugar;
  47. using SqlSugar.Extensions;
  48. using System.Collections;
  49. using System.Data;
  50. using System.Data.OleDb;
  51. using System.Diagnostics;
  52. using System.Globalization;
  53. using System.IO;
  54. using System.IO.Compression;
  55. using System.Net.Http;
  56. using System.Reflection.PortableExecutable;
  57. using System.Security.Cryptography;
  58. using Ubiety.Dns.Core;
  59. using static NPOI.POIFS.Crypt.CryptoFunctions;
  60. using static OASystem.API.OAMethodLib.JWTHelper;
  61. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  62. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  63. using Bookmark = Aspose.Words.Bookmark;
  64. using Cell = Aspose.Words.Tables.Cell;
  65. using Table = Aspose.Words.Tables.Table;
  66. namespace OASystem.API.Controllers
  67. {
  68. /// <summary>
  69. /// 团组相关
  70. /// </summary>
  71. //[Authorize]
  72. [Route("api/[controller]/[action]")]
  73. public class GroupsController : ControllerBase
  74. {
  75. private readonly ILogger<GroupsController> _logger;
  76. private readonly GrpScheduleRepository _grpScheduleRep;
  77. private readonly IMapper _mapper;
  78. private readonly DelegationInfoRepository _groupRepository;
  79. private readonly TaskAssignmentRepository _taskAssignmentRep;
  80. private readonly AirTicketResRepository _airTicketResRep;
  81. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  82. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  83. private readonly DelegationEnDataRepository _delegationEnDataRep;
  84. private readonly DelegationVisaRepository _delegationVisaRep;
  85. private readonly VisaPriceRepository _visaPriceRep;
  86. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  87. private readonly HotelPriceRepository _hotelPriceRep;
  88. private readonly CustomersRepository _customersRep;
  89. private readonly MessageRepository _message;
  90. private readonly SqlSugarClient _sqlSugar;
  91. private readonly TourClientListRepository _tourClientListRep;
  92. private readonly TeamRateRepository _teamRateRep;
  93. #region 成本相关
  94. private readonly CheckBoxsRepository _checkBoxs;
  95. private readonly GroupCostRepository _GroupCostRepository;
  96. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  97. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  98. #endregion
  99. private readonly SetDataRepository _setDataRep;
  100. private string url;
  101. private string path;
  102. private readonly EnterExitCostRepository _enterExitCostRep;
  103. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  104. private readonly UsersRepository _usersRep;
  105. private readonly IJuHeApiService _juHeApi;
  106. private readonly InvertedListRepository _invertedListRep;
  107. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  108. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  109. private readonly ThreeCodeRepository _threeCodeRepository;
  110. private readonly HotelInquiryRepository _hotelInquiryRep;
  111. private readonly FeeAuditRepository _feeAuditRep;
  112. private readonly VisaCommissionRepository _visaCommissionRep;
  113. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  114. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  115. private readonly List<CurrencyInfo> _currencyInit;
  116. private readonly List<int> _portTypeData;
  117. private readonly TableOperationRecordRepository _tableorRep;
  118. /// <summary>
  119. /// 构造函数
  120. /// </summary>
  121. /// <param name="logger"></param>
  122. /// <param name="mapper"></param>
  123. /// <param name="hubContext"></param>
  124. /// <param name="sqlSugar"></param>
  125. /// <param name="grpScheduleRep"></param>
  126. /// <param name="groupRepository"></param>
  127. /// <param name="taskAssignmentRep"></param>
  128. /// <param name="airTicketResRep"></param>
  129. /// <param name="decreasePaymentsRep"></param>
  130. /// <param name="InvitationOfficialActivitiesRep"></param>
  131. /// <param name="delegationEnDataRep"></param>
  132. /// <param name="enterExitCostRep"></param>
  133. /// <param name="delegationVisaRep"></param>
  134. /// <param name="message"></param>
  135. /// <param name="visaPriceRep"></param>
  136. /// <param name="carTouristGuideGroundRep"></param>
  137. /// <param name="checkBoxs"></param>
  138. /// <param name="GroupCostRepository"></param>
  139. /// <param name="CostTypeHotelNumberRepository"></param>
  140. /// <param name="GroupCostParameterRepository"></param>
  141. /// <param name="hotelPriceRep"></param>
  142. /// <param name="customersRep"></param>
  143. /// <param name="setDataRep"></param>
  144. /// <param name="tourClientListRep"></param>
  145. /// <param name="teamRateRep"></param>
  146. /// <param name="usersRep"></param>
  147. /// <param name="juHeApi"></param>
  148. /// <param name="invertedListRep"></param>
  149. /// <param name="visaFeeInfoRep"></param>
  150. /// <param name="ticketBlackCodeRep"></param>
  151. /// <param name="hotelInquiryRep"></param>
  152. /// <param name="threeCodeRepository"></param>
  153. /// <param name="feeAuditRep"></param>
  154. /// <param name="visaCommissionRep"></param>
  155. /// <param name="ffrRep"></param>
  156. /// <param name="opinionaireRep"></param>
  157. /// <param name="tableorRep"></param>
  158. public GroupsController(
  159. ILogger<GroupsController> logger,
  160. IMapper mapper,
  161. IHubContext<ChatHub, IChatClient> hubContext,
  162. SqlSugarClient sqlSugar,
  163. GrpScheduleRepository grpScheduleRep,
  164. DelegationInfoRepository groupRepository,
  165. TaskAssignmentRepository taskAssignmentRep,
  166. AirTicketResRepository airTicketResRep,
  167. DecreasePaymentsRepository decreasePaymentsRep,
  168. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  169. DelegationEnDataRepository delegationEnDataRep,
  170. EnterExitCostRepository enterExitCostRep,
  171. DelegationVisaRepository delegationVisaRep,
  172. MessageRepository message,
  173. VisaPriceRepository visaPriceRep,
  174. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  175. CheckBoxsRepository checkBoxs,
  176. GroupCostRepository GroupCostRepository,
  177. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  178. GroupCostParameterRepository GroupCostParameterRepository,
  179. HotelPriceRepository hotelPriceRep,
  180. CustomersRepository customersRep,
  181. SetDataRepository setDataRep,
  182. TourClientListRepository tourClientListRep,
  183. TeamRateRepository teamRateRep,
  184. UsersRepository usersRep, IJuHeApiService juHeApi,
  185. InvertedListRepository invertedListRep,
  186. VisaFeeInfoRepository visaFeeInfoRep,
  187. TicketBlackCodeRepository ticketBlackCodeRep,
  188. HotelInquiryRepository hotelInquiryRep,
  189. ThreeCodeRepository threeCodeRepository,
  190. FeeAuditRepository feeAuditRep,
  191. VisaCommissionRepository visaCommissionRep,
  192. ForeignReceivablesRepository ffrRep,
  193. OpinionaireRepository opinionaireRep,
  194. TableOperationRecordRepository tableorRep
  195. )
  196. {
  197. _logger = logger;
  198. _mapper = mapper;
  199. _grpScheduleRep = grpScheduleRep;
  200. _groupRepository = groupRepository;
  201. _taskAssignmentRep = taskAssignmentRep;
  202. _airTicketResRep = airTicketResRep;
  203. _sqlSugar = sqlSugar;
  204. url = AppSettingsHelper.Get("ExcelBaseUrl");
  205. path = AppSettingsHelper.Get("ExcelBasePath");
  206. if (!System.IO.Directory.Exists(path))
  207. {
  208. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  209. }
  210. _decreasePaymentsRep = decreasePaymentsRep;
  211. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  212. _delegationEnDataRep = delegationEnDataRep;
  213. _enterExitCostRep = enterExitCostRep;
  214. _delegationVisaRep = delegationVisaRep;
  215. _message = message;
  216. _visaPriceRep = visaPriceRep;
  217. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  218. _checkBoxs = checkBoxs;
  219. _GroupCostRepository = GroupCostRepository;
  220. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  221. _GroupCostParameterRepository = GroupCostParameterRepository;
  222. _hotelPriceRep = hotelPriceRep;
  223. _customersRep = customersRep;
  224. _setDataRep = setDataRep;
  225. _tourClientListRep = tourClientListRep;
  226. _teamRateRep = teamRateRep;
  227. _hubContext = hubContext;
  228. _usersRep = usersRep;
  229. _juHeApi = juHeApi;
  230. _invertedListRep = invertedListRep;
  231. _visaFeeInfoRep = visaFeeInfoRep;
  232. _ticketBlackCodeRep = ticketBlackCodeRep;
  233. _hotelInquiryRep = hotelInquiryRep;
  234. _threeCodeRepository = threeCodeRepository;
  235. _feeAuditRep = feeAuditRep;
  236. _visaCommissionRep = visaCommissionRep;
  237. _ffrRep = ffrRep;
  238. _opinionaireRep = opinionaireRep;
  239. _currencyInit = new List<CurrencyInfo>()
  240. {
  241. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  242. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  243. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  244. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  245. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  246. };
  247. _portTypeData = new List<int>() { 2, 3 };
  248. _tableorRep = tableorRep;
  249. }
  250. #region 流程管控
  251. /// <summary>
  252. /// 获取团组流程管控信息
  253. /// </summary>
  254. /// <param name="paras">参数Json字符串</param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  259. {
  260. if (string.IsNullOrEmpty(_jsonDto.Paras))
  261. {
  262. return Ok(JsonView(false, "参数为空"));
  263. }
  264. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  265. if (_ScheduleDto != null)
  266. {
  267. if (_ScheduleDto.SearchType == 2)//获取列表
  268. {
  269. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  270. return Ok(JsonView(_grpScheduleViewList));
  271. }
  272. else//获取对象
  273. {
  274. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  275. if (_grpScheduleView != null)
  276. {
  277. return Ok(JsonView(_grpScheduleView));
  278. }
  279. }
  280. }
  281. else
  282. {
  283. return Ok(JsonView(false, "参数反序列化失败"));
  284. }
  285. return Ok(JsonView(false, "暂无数据!"));
  286. }
  287. /// <summary>
  288. /// 修改团组流程管控详细表数据
  289. /// </summary>
  290. /// <param name="paras"></param>
  291. /// <returns></returns>
  292. [HttpPost]
  293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  294. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  295. {
  296. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  297. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  298. .SetColumns(it => it.Duty == _detail.Duty)
  299. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  300. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  301. .SetColumns(it => it.JobContent == _detail.JobContent)
  302. .SetColumns(it => it.Remark == _detail.Remark)
  303. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  304. .Where(s => s.Id == dto.Id)
  305. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  306. .ExecuteCommandAsync();
  307. if (result > 0)
  308. {
  309. return Ok(JsonView(true, "保存成功!"));
  310. }
  311. return Ok(JsonView(false, "保存失败!"));
  312. }
  313. /// <summary>
  314. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  315. /// </summary>
  316. /// <param name="dto"></param>
  317. /// <returns></returns>
  318. [HttpPost]
  319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  320. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  321. {
  322. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  323. _detail.IsDel = 1;
  324. _detail.DeleteUserId = dto.Duty;
  325. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  326. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  327. .SetColumns(it => it.IsDel == _detail.IsDel)
  328. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  329. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  330. .Where(it => it.Id == dto.Id)
  331. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  332. //.WhereColumns(s => s.Id == dto.Id)
  333. .ExecuteCommandAsync();
  334. if (result > 0)
  335. {
  336. return Ok(JsonView(true, "删除成功!"));
  337. }
  338. return Ok(JsonView(false, "删除失败!"));
  339. }
  340. /// <summary>
  341. /// 增加团组流程管控详细表数据
  342. /// </summary>
  343. /// <param name="dto"></param>
  344. /// <returns></returns>
  345. [HttpPost]
  346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  347. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  348. {
  349. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  350. if (DateTime.Now < _detail.ExpectBeginDt)
  351. {
  352. _detail.StepStatus = 0;
  353. }
  354. else
  355. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  356. _detail.StepStatus = 1;
  357. }
  358. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  359. if (result > 0)
  360. {
  361. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  362. return Ok(JsonView(true, "添加成功!", _result));
  363. }
  364. return Ok(JsonView(false, "添加失败!"));
  365. }
  366. #endregion
  367. #region 团组基本信息
  368. /// <summary>
  369. /// 接团信息列表
  370. /// </summary>
  371. /// <param name="dto">团组列表请求dto</param>
  372. /// <returns></returns>
  373. [HttpPost]
  374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  375. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  376. {
  377. var groupData = await _groupRepository.GetGroupList(dto);
  378. if (groupData.Code != 0)
  379. {
  380. return Ok(JsonView(false, groupData.Msg));
  381. }
  382. return Ok(JsonView(groupData.Data));
  383. }
  384. /// <summary>
  385. /// 分页查询团组列表
  386. /// </summary>
  387. /// <param name="dto"></param>
  388. /// <returns></returns>
  389. [HttpPost]
  390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  391. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  392. {
  393. var watch = new Stopwatch();
  394. watch.Start();
  395. RefAsync<int> total = 0;
  396. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  397. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  398. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  399. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  400. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  401. .Distinct()
  402. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  403. watch.Stop();
  404. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  405. }
  406. /// <summary>
  407. /// 接团信息列表 Page
  408. /// </summary>
  409. /// <param name="dto">团组列表请求dto</param>
  410. /// <returns></returns>
  411. [HttpPost]
  412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  413. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  414. {
  415. #region 参数验证
  416. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  417. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  418. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  419. #region 页面操作权限验证
  420. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  421. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  422. #endregion
  423. #endregion
  424. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  425. {
  426. string sqlWhere = string.Empty;
  427. if (dto.IsSure == 0) //未完成
  428. {
  429. sqlWhere += string.Format(@" And IsSure = 0");
  430. }
  431. else if (dto.IsSure == 1) //已完成
  432. {
  433. sqlWhere += string.Format(@" And IsSure = 1");
  434. }
  435. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  436. {
  437. string tj = dto.SearchCriteria;
  438. 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}%')",
  439. tj, tj, tj, tj, tj);
  440. }
  441. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  442. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  443. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  444. JietuanOperator,IsSure,CreateTime,IsBid
  445. From (
  446. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  447. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  448. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  449. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  450. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  451. From Grp_DelegationInfo gdi
  452. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  453. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  454. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  455. Where gdi.IsDel = 0 {0}
  456. ) temp", sqlWhere);
  457. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  458. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  459. #region 处理所属部门
  460. /*
  461. * 1.sq 和 gyy 等显示 市场部
  462. * 2.王鸽和主管及张总还有管理员号统一国交部
  463. * 2-1. 4 管理员 ,21 张海麟
  464. */
  465. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  466. List<int> userIds1 = new List<int>() { 4, 21 };
  467. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  468. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  469. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  470. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  471. .ToList();
  472. foreach (var item in _DelegationList)
  473. {
  474. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  475. }
  476. #endregion
  477. var _view = new
  478. {
  479. PageFuncAuth = pageFunAuthView,
  480. Data = _DelegationList
  481. };
  482. return Ok(JsonView(true, "查询成功!", _view, total));
  483. }
  484. else
  485. {
  486. return Ok(JsonView(false, "查询失败"));
  487. }
  488. }
  489. /// <summary>
  490. /// 团组列表
  491. /// </summary>
  492. /// <returns></returns>
  493. [HttpPost]
  494. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  495. {
  496. #region 参数验证
  497. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  498. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  499. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  500. #region 页面操作权限验证
  501. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  502. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  503. #endregion
  504. #endregion
  505. if (dto.PortType != 1 && dto.PortType != 2)
  506. {
  507. return Ok(JsonView(false, "查询失败!"));
  508. }
  509. string orderbyStr = "order by gdi.CreateTime Desc";
  510. string sqlWhere = string.Empty;
  511. if (dto.IsSure == 0) //未完成
  512. {
  513. sqlWhere += string.Format(@" And IsSure = 0");
  514. }
  515. else if (dto.IsSure == 1) //已完成
  516. {
  517. sqlWhere += string.Format(@" And IsSure = 1");
  518. }
  519. //团组类型
  520. if (dto.TeamDid > 0)
  521. {
  522. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  523. }
  524. //团组名称
  525. if (!string.IsNullOrEmpty(dto.TeamName))
  526. {
  527. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  528. }
  529. //客户名称
  530. if (!string.IsNullOrEmpty(dto.ClientName))
  531. {
  532. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  533. }
  534. //客户单位
  535. if (!string.IsNullOrEmpty(dto.ClientUnit))
  536. {
  537. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  538. }
  539. //出访时间
  540. if (!string.IsNullOrEmpty(dto.visitDataTime))
  541. {
  542. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  543. orderbyStr = "order by gdi.VisitDate";
  544. }
  545. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  546. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  547. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  548. JietuanOperator,IsSure,CreateTime
  549. From (
  550. Select row_number() over({0}) as Row_Number,
  551. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  552. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  553. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  554. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  555. From Grp_DelegationInfo gdi
  556. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  557. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  558. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  559. Where gdi.IsDel = 0 {1}
  560. ) temp ", orderbyStr, sqlWhere);
  561. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  562. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  563. #region 处理所属部门
  564. /*
  565. * 1.sq 和 gyy 等显示 市场部
  566. * 2.王鸽和主管及张总还有管理员号统一国交部
  567. * 2-1. 4 管理员 ,21 张海麟
  568. */
  569. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  570. List<int> userIds1 = new List<int>() { 4, 21 };
  571. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  572. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  573. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  574. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  575. .ToList();
  576. foreach (var item in _DelegationList)
  577. {
  578. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  579. }
  580. #endregion
  581. var _view = new
  582. {
  583. PageFuncAuth = pageFunAuthView,
  584. Data = _DelegationList
  585. };
  586. return Ok(JsonView(true, "查询成功!", _view, total));
  587. }
  588. /// <summary>
  589. /// 接团信息详情
  590. /// </summary>
  591. /// <param name="dto">团组info请求dto</param>
  592. /// <returns></returns>
  593. [HttpPost]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  596. {
  597. var groupData = await _groupRepository.GetGroupInfo(dto);
  598. if (groupData.Code != 0)
  599. {
  600. return Ok(JsonView(false, groupData.Msg));
  601. }
  602. return Ok(JsonView(groupData.Data));
  603. }
  604. /// <summary>
  605. /// 接团信息 编辑添加
  606. /// 基础信息数据源
  607. /// </summary>
  608. /// <param name="dto"></param>
  609. /// <returns></returns>
  610. [HttpPost]
  611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  612. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  613. {
  614. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  615. if (groupData.Code != 0)
  616. {
  617. return Ok(JsonView(false, groupData.Msg));
  618. }
  619. return Ok(JsonView(groupData.Data));
  620. }
  621. /// <summary>
  622. /// 接团信息 操作(增改)
  623. /// </summary>
  624. /// <param name="dto"></param>
  625. /// <returns></returns>
  626. [HttpPost]
  627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  628. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  629. {
  630. try
  631. {
  632. decimal ffrPrice = 0.00M;
  633. DateTime? visitDt = null;
  634. if (dto.Status == 2)
  635. {
  636. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  637. if (groupInfo != null)
  638. {
  639. ffrPrice = groupInfo.PaymentMoney;
  640. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  641. }
  642. }
  643. var groupData = await _groupRepository.GroupOperation(dto);
  644. if (groupData.Code != 0)
  645. {
  646. return Ok(JsonView(false, groupData.Msg));
  647. }
  648. int diId = 0;
  649. //添加时 默认加入团组汇率
  650. if (dto.Status == 1) //添加
  651. {
  652. diId = groupData.Data;
  653. //添加默认币种
  654. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  655. //默认分配权限
  656. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  657. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  658. var _managerIds = new List<int>() { 22, 32, 21 };
  659. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  660. if (userIds.Count > 0)
  661. {
  662. userIds.Add(208);
  663. //创建团组管控
  664. GroupStepForDelegation.CreateWorkStep(diId);
  665. //发送消息
  666. string groupName = dto.TeamName;
  667. string createGroupUser = string.Empty;
  668. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  669. if (userInfo != null) createGroupUser = userInfo.CnName;
  670. string title = $"系统通知";
  671. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  672. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  673. }
  674. //默认创建倒推表
  675. await _invertedListRep._Create(dto.UserId, diId);
  676. }
  677. else if (dto.Status == 2)
  678. {
  679. diId = dto.Id;
  680. }
  681. #region 签证人员团组时间通知
  682. #region 计算出访起止时间
  683. var startTime = new DateTime();
  684. var endTime = new DateTime();
  685. if (DateTime.TryParse(dto.VisitDate, out startTime))
  686. {
  687. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  688. }
  689. #endregion
  690. if (diId > 0)
  691. {
  692. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  693. }
  694. #endregion
  695. #region 团组操作默认添加/修改收款账单
  696. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  697. {
  698. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  699. .Where(x => x.IsDel == 0 &&
  700. x.Diid == diId &&
  701. x.Remark.Equals("预付款")
  702. )
  703. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  704. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  705. .FirstAsync();
  706. ffrInfo = new Fin_ForeignReceivables()
  707. {
  708. Diid = diId,
  709. PriceName = dto.ClientUnit,
  710. Price = dto.PaymentMoney,
  711. Count = 1,
  712. Unit = $"元",
  713. ItemSumPrice = dto.PaymentMoney,
  714. Rate = 1.0000M,
  715. Currency = 836,
  716. AddingWay = 0,
  717. CreateUserId = dto.UserId,
  718. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  719. Remark = $"预付款"
  720. };
  721. if (ffrInfo == null) //Add
  722. {
  723. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  724. }
  725. else //修改
  726. {
  727. await _sqlSugar.Updateable(ffrInfo)
  728. .UpdateColumns(x => new
  729. {
  730. x.PriceName,
  731. x.Price,
  732. x.ItemSumPrice,
  733. x.CreateTime,
  734. x.CreateUserId
  735. })
  736. .WhereColumns(x => x.Id)
  737. .ExecuteCommandAsync();
  738. }
  739. }
  740. #endregion
  741. return Ok(JsonView(true, "操作成功!", diId));
  742. }
  743. catch (Exception ex)
  744. {
  745. Logs("[response]" + JsonConvert.SerializeObject(dto));
  746. Logs(ex.Message);
  747. return Ok(JsonView(false, ex.Message));
  748. }
  749. }
  750. /// <summary>
  751. /// 接团流程操作(增改)
  752. /// 安卓端使用 建团时添加客户名单
  753. /// </summary>
  754. /// <param name="dto"></param>
  755. /// <returns></returns>
  756. [HttpPost]
  757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  758. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  759. {
  760. try
  761. {
  762. #region 参数验证
  763. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  764. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  765. #region 页面操作权限验证
  766. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  767. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  768. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  769. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  770. #endregion
  771. #endregion
  772. _sqlSugar.BeginTran();
  773. decimal ffrPrice = 0.00M;
  774. DateTime? visitDt = null;
  775. if (dto.Status == 2)
  776. {
  777. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  778. if (groupInfo != null)
  779. {
  780. ffrPrice = groupInfo.PaymentMoney;
  781. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  782. }
  783. }
  784. var _dto = new GroupOperationDto();
  785. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  786. var groupData = await _groupRepository.GroupOperation(_dto);
  787. if (groupData.Code != 0)
  788. {
  789. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  790. }
  791. int diId = 0;
  792. //添加时 默认加入团组汇率
  793. if (dto.Status == 1) //添加
  794. {
  795. diId = groupData.Data;
  796. //添加默认币种
  797. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  798. //默认分配权限
  799. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  800. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  801. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  802. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  803. if (userIds.Count > 0)
  804. {
  805. userIds.Add(208);
  806. //创建团组管控
  807. GroupStepForDelegation.CreateWorkStep(diId);
  808. //发送消息
  809. string groupName = dto.TeamName;
  810. string createGroupUser = string.Empty;
  811. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  812. if (userInfo != null) createGroupUser = userInfo.CnName;
  813. string title = $"系统通知";
  814. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  815. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  816. }
  817. #region 应用推送
  818. try
  819. {
  820. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  821. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  822. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  823. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  824. {
  825. List<string> userList = new List<string>() { users.QiyeChatUserId };
  826. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  827. }
  828. }
  829. catch (Exception ex)
  830. {
  831. }
  832. #endregion
  833. //默认创建倒推表
  834. await _invertedListRep._Create(dto.UserId, diId);
  835. }
  836. if (dto.Status == 2)
  837. {
  838. diId = dto.Id;
  839. if (diId == 0)
  840. {
  841. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  842. }
  843. }
  844. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  845. if (viewData.Code != 0)
  846. {
  847. _sqlSugar.RollbackTran();
  848. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  849. }
  850. #region 团组操作默认添加/修改收款账单
  851. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  852. {
  853. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  854. .Where(x => x.IsDel == 0 &&
  855. x.Diid == diId &&
  856. x.Remark.Equals("预付款")
  857. )
  858. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  859. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  860. .FirstAsync();
  861. ffrInfo = new Fin_ForeignReceivables()
  862. {
  863. Diid = diId,
  864. PriceName = dto.ClientUnit,
  865. Price = dto.PaymentMoney,
  866. Count = 1,
  867. Unit = $"元",
  868. ItemSumPrice = dto.PaymentMoney,
  869. Rate = 1.0000M,
  870. Currency = 836,
  871. AddingWay = 0,
  872. CreateUserId = dto.UserId,
  873. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  874. Remark = $"预付款"
  875. };
  876. if (ffrInfo == null) //Add
  877. {
  878. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  879. }
  880. else //修改
  881. {
  882. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  883. .UpdateColumns(x => new
  884. {
  885. x.PriceName,
  886. x.Price,
  887. x.ItemSumPrice,
  888. x.CreateTime,
  889. x.CreateUserId
  890. })
  891. .WhereColumns(x => x.Id)
  892. .ExecuteCommandAsync();
  893. }
  894. }
  895. #endregion
  896. #region 签证人员团组时间通知
  897. #region 计算出访起止时间
  898. var startTime = new DateTime();
  899. var endTime = new DateTime();
  900. if (DateTime.TryParse(dto.VisitDate, out startTime))
  901. {
  902. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  903. }
  904. #endregion
  905. if (diId > 0)
  906. {
  907. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  908. }
  909. #endregion
  910. _sqlSugar.CommitTran();
  911. return Ok(JsonView(true, "添加成功"));
  912. }
  913. catch (Exception ex)
  914. {
  915. _sqlSugar.RollbackTran();
  916. return Ok(JsonView(false, ex.Message));
  917. }
  918. }
  919. /// <summary>
  920. /// 接团信息 操作(删除)
  921. /// </summary>
  922. /// <param name="dto"></param>
  923. /// <returns></returns>
  924. [HttpPost]
  925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  926. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  927. {
  928. var diId = dto.Id;
  929. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  930. #region 删除 验证 (费用录入、出入境费用、收款账单)
  931. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  932. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  933. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  934. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  935. #endregion
  936. var groupData = await _groupRepository.GroupDel(dto);
  937. if (groupData.Code != 0)
  938. {
  939. return Ok(JsonView(false, groupData.Msg));
  940. }
  941. return Ok(JsonView(true));
  942. }
  943. /// <summary>
  944. /// 获取团组销售报价号
  945. /// 团组添加时 使用
  946. /// </summary>
  947. /// <returns></returns>
  948. [HttpPost]
  949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  950. public async Task<IActionResult> GetGroupSalesQuoteNo()
  951. {
  952. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  953. if (groupData.Code != 0)
  954. {
  955. return Ok(JsonView(false, groupData.Msg));
  956. }
  957. object salesQuoteNo = new
  958. {
  959. SalesQuoteNo = groupData.Data
  960. };
  961. return Ok(JsonView(salesQuoteNo));
  962. }
  963. /// <summary>
  964. /// 设置确认出团
  965. /// </summary>
  966. /// <param name="dto"></param>
  967. /// <returns></returns>
  968. [HttpPost]
  969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  970. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  971. {
  972. var groupData = await _groupRepository.ConfirmationGroup(dto);
  973. if (groupData.Code != 0)
  974. {
  975. return Ok(JsonView(false, groupData.Msg));
  976. }
  977. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  978. #region OA消息推送
  979. try
  980. {
  981. string groupName = groupInfo.TeamName;
  982. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  983. string title = $"系统通知";
  984. string content = $"团组[{groupName}]已确认出团!";
  985. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  986. }
  987. catch (Exception ex)
  988. {
  989. }
  990. #endregion
  991. #region 应用推送
  992. try
  993. {
  994. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  995. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  996. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  997. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  998. {
  999. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1000. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1001. }
  1002. }
  1003. catch (Exception ex)
  1004. {
  1005. }
  1006. #endregion
  1007. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1008. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1009. }
  1010. /// <summary>
  1011. /// 获取团组名称data And 签证国别Data
  1012. /// </summary>
  1013. /// <param name="dto"></param>
  1014. /// <returns></returns>
  1015. [HttpPost]
  1016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1017. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1018. {
  1019. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1020. if (groupData.Code != 0)
  1021. {
  1022. return Ok(JsonView(false, groupData.Msg));
  1023. }
  1024. return Ok(JsonView(groupData.Data));
  1025. }
  1026. /// <summary>
  1027. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1028. /// </summary>
  1029. /// <returns></returns>
  1030. [HttpPost]
  1031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1032. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1033. {
  1034. try
  1035. {
  1036. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1037. if (groupData.Code != 0)
  1038. {
  1039. return Ok(JsonView(false, groupData.Msg));
  1040. }
  1041. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1042. }
  1043. catch (Exception ex)
  1044. {
  1045. return Ok(JsonView(false, "程序错误!"));
  1046. throw;
  1047. }
  1048. }
  1049. /// <summary>
  1050. /// 团组清单 Excel
  1051. /// </summary>
  1052. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1053. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1054. /// <returns></returns>
  1055. [HttpGet]
  1056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1057. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1058. {
  1059. DateTime _beginDt, _endDt;
  1060. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1061. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1062. if (!beginBool && !endBool)
  1063. {
  1064. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1065. }
  1066. string sql = string.Format(@"
  1067. SELECT
  1068. ROW_NUMBER,
  1069. Id,
  1070. SalesQuoteNo,
  1071. TourCode,
  1072. TeamTypeId,
  1073. TeamType,
  1074. TeamLevId,
  1075. TeamLev,
  1076. TeamName,
  1077. ClientName,
  1078. ClientUnit,
  1079. VisitDate,
  1080. VisitDays,
  1081. VisitPNumber,
  1082. JietuanOperatorId,
  1083. JietuanOperator,
  1084. IsSure,
  1085. CreateTime,
  1086. IsBid
  1087. FROM
  1088. (
  1089. SELECT
  1090. ROW_NUMBER() OVER(
  1091. ORDER BY
  1092. gdi.CreateTime Desc
  1093. ) AS ROW_NUMBER,
  1094. gdi.Id,
  1095. SalesQuoteNo,
  1096. TourCode,
  1097. ssd.Id TeamTypeId,
  1098. ssd.Name TeamType,
  1099. ssd1.Id TeamLevId,
  1100. ssd1.Name TeamLev,
  1101. TeamName,
  1102. ClientName,
  1103. ClientUnit,
  1104. VisitDate,
  1105. VisitDays,
  1106. VisitPNumber,
  1107. JietuanOperator JietuanOperatorId,
  1108. su.CnName JietuanOperator,
  1109. IsSure,
  1110. gdi.CreateTime,
  1111. gdi.IsBid
  1112. FROM
  1113. Grp_DelegationInfo gdi
  1114. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1115. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1116. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1117. WHERE
  1118. gdi.IsDel = 0
  1119. AND gdi.IsBid = 0
  1120. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1121. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1122. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1123. #region 处理所属部门
  1124. /*
  1125. * 1.sq 和 gyy 等显示 市场部
  1126. * 2.王鸽和主管及张总还有管理员号统一国交部
  1127. * 2-1. 4 管理员 ,21 张海麟
  1128. */
  1129. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1130. List<int> userIds1 = new List<int>() { 4, 21 };
  1131. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1132. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1133. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1134. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1135. .ToListAsync();
  1136. foreach (var item in groupList)
  1137. {
  1138. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1139. }
  1140. #endregion
  1141. #region Excel
  1142. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1143. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1144. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1145. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1146. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1147. //载入模板
  1148. WorkbookDesigner designer = new WorkbookDesigner();
  1149. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1150. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1151. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1152. dt.TableName = "GroupList";
  1153. designer.SetDataSource(dt);
  1154. designer.Process();
  1155. if (!Directory.Exists(savePath))
  1156. {
  1157. Directory.CreateDirectory(savePath);
  1158. }
  1159. string serverPath = $"{savePath}{fileName}";
  1160. designer.Workbook.Save(serverPath);
  1161. string rst = $"{servicePath}{ftpPath}{fileName}";
  1162. #endregion
  1163. return Ok(JsonView(true, "操作成功!", rst));
  1164. }
  1165. #endregion
  1166. #region 团组&签证
  1167. /// <summary>
  1168. /// 根据团组Id获取签证客户信息List
  1169. /// </summary>
  1170. /// <param name="dto">请求dto</param>
  1171. /// <returns></returns>
  1172. [HttpPost]
  1173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1174. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1175. {
  1176. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1177. if (groupData.Code != 0)
  1178. {
  1179. return Ok(JsonView(false, groupData.Msg));
  1180. }
  1181. return Ok(JsonView(groupData.Data));
  1182. }
  1183. /// <summary>
  1184. /// IOS获取团组签证拍照上传进度01(团组列表)
  1185. /// </summary>
  1186. /// <param name="dto">请求dto</param>
  1187. /// <returns></returns>
  1188. [HttpPost]
  1189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1190. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1191. {
  1192. if (dto == null)
  1193. {
  1194. return Ok(JsonView(false, "参数为空"));
  1195. }
  1196. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1197. return Ok(JsonView(visaList));
  1198. }
  1199. /// <summary>
  1200. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1201. /// </summary>
  1202. /// <returns></returns>
  1203. [HttpPost]
  1204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1205. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1206. {
  1207. if (dto == null)
  1208. {
  1209. return Ok(JsonView(false, "请求错误:"));
  1210. }
  1211. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1212. return Ok(JsonView(list));
  1213. }
  1214. /// <summary>
  1215. /// IOS获取团组签证拍照上传进度03(相册)
  1216. /// </summary>
  1217. /// <returns></returns>
  1218. [HttpPost]
  1219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1220. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1221. {
  1222. if (dto == null)
  1223. {
  1224. return Ok(JsonView(false, "请求错误:"));
  1225. }
  1226. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1227. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1228. list.ForEach(s => s.url = url);
  1229. return Ok(JsonView(list));
  1230. }
  1231. /// <summary>
  1232. /// IOS获取团组签证拍照上传进度04(图片上传)
  1233. /// </summary>
  1234. /// <param name="dto"></param>
  1235. /// <returns></returns>
  1236. [HttpPost]
  1237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1238. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1239. {
  1240. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1241. //if (!string.IsNullOrEmpty(result))
  1242. //{
  1243. //}
  1244. //else {
  1245. // return Ok(JsonView(false, "上传失败"));
  1246. //}
  1247. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1248. int sucNum = 0;
  1249. try
  1250. {
  1251. foreach (var item in dto.base64DataList)
  1252. {
  1253. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1254. string result = decodeBase64ToImage(item, imageName);
  1255. if (!string.IsNullOrEmpty(result))
  1256. {
  1257. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1258. pic.CreateUserId = dto.CreateUserId;
  1259. pic.PicName = imageName;
  1260. pic.PicPath = result;
  1261. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1262. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1263. if (insertResult > 0)
  1264. {
  1265. sucNum++;
  1266. }
  1267. }
  1268. }
  1269. }
  1270. catch (Exception ex)
  1271. {
  1272. return Ok(JsonView(false, ex.Message));
  1273. }
  1274. string msg = string.Format(@"成功上传{0}张", sucNum);
  1275. return Ok(JsonView(true, msg));
  1276. }
  1277. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1278. {
  1279. string filename = "";//声明一个string类型的相对路径
  1280. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1281. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1282. try//会有异常抛出,try,catch一下
  1283. {
  1284. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1285. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1286. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1287. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1288. //文件名称
  1289. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1290. //上传的文件的路径
  1291. string filePath = "";
  1292. if (!Directory.Exists(fileDir))
  1293. {
  1294. Directory.CreateDirectory(fileDir);
  1295. }
  1296. //上传的文件的路径
  1297. filePath = fileDir + filename;
  1298. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1299. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1300. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1301. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1302. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1303. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1304. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1305. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1306. bitmap.Dispose();
  1307. }
  1308. catch (Exception e)
  1309. {
  1310. string massage = e.Message;
  1311. Logs("IOS图片上传Error:" + massage);
  1312. //filename = e.Message;
  1313. }
  1314. return filename;//返回相对路径
  1315. }
  1316. /// <summary>
  1317. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1318. /// </summary>
  1319. /// <param name="dto"></param>
  1320. /// <returns></returns>
  1321. [HttpPost]
  1322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1323. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1324. {
  1325. if (dto == null)
  1326. {
  1327. return Ok(JsonView(false, "请求错误:"));
  1328. }
  1329. string msg = "参数错误";
  1330. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1331. {
  1332. try
  1333. {
  1334. //_delegationVisaRep.BeginTran();
  1335. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1336. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1337. .Where(s => s.Id == dto.visaProgressCustomerId)
  1338. .ExecuteCommandAsync();
  1339. if (updCount > 0 && dto.publishCode == 1)
  1340. {
  1341. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1342. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1343. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1344. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1345. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1346. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1347. if (groupData == null)
  1348. {
  1349. _delegationVisaRep.RollbackTran();
  1350. }
  1351. string title = string.Format(@"[签证进度更新]");
  1352. string content = string.Format(@"测试文本");
  1353. bool rst = await _message.AddMsg(new MessageDto()
  1354. {
  1355. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1356. IssuerId = dto.publisher,
  1357. Title = title,
  1358. Content = content,
  1359. ReleaseTime = DateTime.Now,
  1360. UIdList = new List<int> {
  1361. 234
  1362. }
  1363. });
  1364. if (rst)
  1365. {
  1366. return Ok(JsonView(true, "发送通知成功"));
  1367. }
  1368. }
  1369. //_delegationVisaRep.CommitTran();
  1370. }
  1371. catch (Exception)
  1372. {
  1373. //_delegationVisaRep.RollbackTran();
  1374. }
  1375. }
  1376. return Ok(JsonView(true, msg));
  1377. }
  1378. #endregion
  1379. #region 团组任务分配
  1380. /// <summary>
  1381. /// 团组任务分配初始化
  1382. /// </summary>
  1383. /// <param name="dto"></param>
  1384. /// <returns></returns>
  1385. [HttpPost]
  1386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1387. public async Task<IActionResult> GetTaskAssignmen()
  1388. {
  1389. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1390. if (groupData.Code != 0)
  1391. {
  1392. return Ok(JsonView(false, groupData.Msg));
  1393. }
  1394. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1395. }
  1396. /// <summary>
  1397. /// 团组任务分配查询
  1398. /// </summary>
  1399. /// <param name="dto"></param>
  1400. /// <returns></returns>
  1401. [HttpPost]
  1402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1403. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1404. {
  1405. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1406. if (groupData.Code != 0)
  1407. {
  1408. return Ok(JsonView(false, groupData.Msg));
  1409. }
  1410. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1411. }
  1412. /// <summary>
  1413. /// 团组任务分配操作
  1414. /// </summary>
  1415. /// <param name="dto"></param>
  1416. /// <returns></returns>
  1417. [HttpPost]
  1418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1419. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1420. {
  1421. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1422. if (groupData.Code != 0)
  1423. {
  1424. return Ok(JsonView(false, groupData.Msg));
  1425. }
  1426. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1427. }
  1428. /// <summary>
  1429. /// 团组任务分配
  1430. /// 批量分配
  1431. /// 查询团组
  1432. /// </summary>
  1433. /// <param name="dto"></param>
  1434. /// <returns></returns>
  1435. [HttpPost]
  1436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1437. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1438. {
  1439. //参数验证
  1440. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1441. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1442. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1443. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1444. }
  1445. /// <summary>
  1446. /// 团组任务分配
  1447. /// 批量分配
  1448. /// </summary>
  1449. /// <param name="dto"></param>
  1450. /// <returns></returns>
  1451. [HttpPost]
  1452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1453. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1454. {
  1455. //参数验证
  1456. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1457. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1458. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1459. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1460. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1461. }
  1462. #endregion
  1463. #region 团组费用审核
  1464. /// <summary>
  1465. /// 费用审核
  1466. /// 团组列表 Page
  1467. /// </summary>
  1468. /// <param name="_dto">团组列表请求dto</param>
  1469. /// <returns></returns>
  1470. [HttpPost]
  1471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1472. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1473. {
  1474. #region 参数验证
  1475. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1476. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1477. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1478. #region 页面操作权限验证
  1479. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1480. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1481. #endregion
  1482. #endregion
  1483. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1484. {
  1485. string sqlWhere = string.Empty;
  1486. if (_dto.IsSure == 0) //未完成
  1487. {
  1488. sqlWhere += string.Format(@" And IsSure = 0");
  1489. }
  1490. else if (_dto.IsSure == 1) //已完成
  1491. {
  1492. sqlWhere += string.Format(@" And IsSure = 1");
  1493. }
  1494. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1495. {
  1496. string tj = _dto.SearchCriteria;
  1497. 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}%')",
  1498. tj, tj, tj, tj, tj);
  1499. }
  1500. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1501. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1502. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1503. From (
  1504. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1505. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1506. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1507. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1508. From Grp_DelegationInfo gdi
  1509. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1510. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1511. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1512. Where gdi.IsDel = 0 {0}
  1513. ) temp ", sqlWhere);
  1514. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1515. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1516. var _view = new
  1517. {
  1518. PageFuncAuth = pageFunAuthView,
  1519. Data = _DelegationList
  1520. };
  1521. return Ok(JsonView(true, "查询成功!", _view, total));
  1522. }
  1523. else
  1524. {
  1525. return Ok(JsonView(false, "查询失败"));
  1526. }
  1527. }
  1528. /// <summary>
  1529. /// 获取团组费用审核
  1530. /// </summary>
  1531. /// <param name="paras">参数Json字符串</param>
  1532. /// <returns></returns>
  1533. [HttpPost]
  1534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1535. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1536. {
  1537. try
  1538. {
  1539. #region 参数验证
  1540. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1541. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1542. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1543. #region 页面操作权限验证
  1544. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1545. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1546. #endregion
  1547. #endregion
  1548. var _view = new Grp_CreditCardPaymentView();
  1549. var clientNameList = getSimplClientList(_dto.DiId);
  1550. #region 费用清单
  1551. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1552. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1553. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1554. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1555. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1556. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1557. /*
  1558. * 76://酒店预订
  1559. */
  1560. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1561. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1562. /*
  1563. * 79://车/导游地接
  1564. */
  1565. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1566. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1567. /*
  1568. * 80: //签证
  1569. */
  1570. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1571. /*
  1572. *81: //邀请/公务活动
  1573. */
  1574. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1575. /*
  1576. * 82: //团组客户保险
  1577. */
  1578. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1579. /*
  1580. * Lable = 85 机票预订
  1581. */
  1582. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1583. /*
  1584. * 85 机票预定
  1585. */
  1586. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1587. /*
  1588. * 98 其他款项
  1589. */
  1590. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1591. /*
  1592. * 285:收款退还
  1593. */
  1594. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1595. /*
  1596. * 1015: //超支费用
  1597. */
  1598. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1599. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1600. /*
  1601. * 币种信息
  1602. */
  1603. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1604. /*
  1605. * 车/导游地接 费用类型
  1606. */
  1607. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1608. /*
  1609. * 车/导游地接 费用类型
  1610. */
  1611. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1612. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1613. /*
  1614. * 用户信息
  1615. */
  1616. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1617. /*
  1618. * 费用模块
  1619. */
  1620. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1621. string priceModule = string.Empty;
  1622. if (sdPriceName != null)
  1623. {
  1624. priceModule = sdPriceName.Name;
  1625. }
  1626. /*
  1627. * 成本信息
  1628. */
  1629. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1630. decimal _groupRate = 0.0000M;
  1631. string _groupCurrencyCode = "-";
  1632. if (groupCost != null)
  1633. {
  1634. _groupRate = groupCost.Rate;
  1635. if (int.TryParse(groupCost.Currency, out int _currency))
  1636. {
  1637. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1638. }
  1639. else _groupCurrencyCode = groupCost.Currency;
  1640. }
  1641. string costContentSql = $"Select * From Grp_GroupCost";
  1642. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1643. //处理日期为空的天数
  1644. for (int i = 0; i < groupCostDetails.Count; i++)
  1645. if (i != 0)
  1646. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1647. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1648. /*
  1649. * 处理详情数据
  1650. */
  1651. foreach (var entity in entityList)
  1652. {
  1653. var _detail = new Grp_CreditCardPaymentDetailView();
  1654. _detail.Id = entity.Id;
  1655. _detail.PriceName = priceModule;
  1656. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1657. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1658. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1659. //处理金额
  1660. if (entity.CTable == 1015)
  1661. {
  1662. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1663. if (czInfo != null)
  1664. {
  1665. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1666. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1667. }
  1668. }
  1669. /*
  1670. * 应付款金额
  1671. */
  1672. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1673. string PaymentCurrency_WaitPay = "Unknown";
  1674. string hotelCurrncyCode = "Unknown";
  1675. string hotelCurrncyName = "Unknown";
  1676. if (sdPaymentCurrency_WaitPay != null)
  1677. {
  1678. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1679. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1680. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1681. if (hotelCurrncyCode.Equals("CNY"))
  1682. {
  1683. entity.DayRate = 1.0000M;
  1684. }
  1685. }
  1686. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1687. /*
  1688. * 此次付款金额
  1689. */
  1690. decimal CurrPayStr = 0.00M,
  1691. OriginalCurrPay = 0.00M;
  1692. if (entity.PayPercentage == 0)
  1693. {
  1694. if (entity.PayThenMoney != 0)
  1695. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1696. }
  1697. else
  1698. {
  1699. if (entity.PayMoney != 0)
  1700. {
  1701. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1702. }
  1703. }
  1704. //if (_dto.Label == 79)
  1705. //{
  1706. // string original = string.Empty;
  1707. // if (hotelCurrncyCode.Equals("CNY"))
  1708. // {
  1709. // OriginalCurrPay = CurrPayStr;
  1710. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1711. // }
  1712. // else
  1713. // {
  1714. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1715. // //760 EUR(7600.00 CNY)
  1716. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1717. // }
  1718. //}
  1719. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1720. string original = string.Empty;
  1721. if (hotelCurrncyCode.Equals("CNY"))
  1722. {
  1723. OriginalCurrPay = CurrPayStr;
  1724. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1725. }
  1726. else
  1727. {
  1728. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1729. //760 EUR(7600.00 CNY)
  1730. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1731. }
  1732. /*
  1733. * 剩余尾款
  1734. */
  1735. decimal BalanceStr = 0;
  1736. if (CurrPayStr != 0)
  1737. {
  1738. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1739. BalanceStr = 0;
  1740. else
  1741. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1742. }
  1743. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1744. /*
  1745. * Bus名称
  1746. */
  1747. _detail.BusName = "待增加";
  1748. /*
  1749. *费用所属
  1750. */
  1751. switch (entity.CTable)
  1752. {
  1753. case 76://酒店预订
  1754. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1755. if (hotelReservations != null)
  1756. {
  1757. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1758. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1759. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1760. string roomFeeStr = "", roomFeestr1 = "";
  1761. //是否比较房型价格
  1762. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1763. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1764. roomFeeStr += $"<br/>";
  1765. var roomTotal = 0.00M;
  1766. if (hotelReservations.SingleRoomPrice > 0)
  1767. {
  1768. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1769. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1770. __isSingle = true;
  1771. roomTotal += fee;
  1772. }
  1773. if (hotelReservations.DoubleRoomPrice > 0)
  1774. {
  1775. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1776. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1777. __isDouble = true;
  1778. roomTotal += fee;
  1779. }
  1780. if (hotelReservations.SuiteRoomPrice > 0)
  1781. {
  1782. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1783. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1784. __isSuite = true;
  1785. roomTotal += fee;
  1786. }
  1787. if (hotelReservations.OtherRoomPrice > 0)
  1788. {
  1789. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1790. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1791. __isOther = true;
  1792. roomTotal += fee;
  1793. }
  1794. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  1795. else roomFeeStr += " 0.00 * 0";
  1796. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1797. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1798. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1799. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1800. /*
  1801. * 费用类型
  1802. * 1:房费
  1803. * 2:早餐
  1804. * 3:地税
  1805. * 4:城市税
  1806. * </summary>
  1807. */
  1808. //地税
  1809. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1810. if (governmentRentData != null)
  1811. {
  1812. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1813. governmentRentFee = governmentRentData.Price;
  1814. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1815. if (governmentRentCurrData != null)
  1816. {
  1817. governmentRentCode = governmentRentCurrData.Name;
  1818. governmentRentName = $"({governmentRentCurrData.Remark})";
  1819. }
  1820. }
  1821. //城市税
  1822. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1823. if (cityTaxData != null)
  1824. {
  1825. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1826. cityTaxFee = cityTaxData.Price;
  1827. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1828. if (cityTaxCurrData != null)
  1829. {
  1830. cityTaxCode = cityTaxCurrData.Name;
  1831. cityTaxName = $"({cityTaxCurrData.Remark})";
  1832. }
  1833. }
  1834. //酒店早餐
  1835. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1836. if (breakfastData != null)
  1837. {
  1838. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1839. breakfastFee = breakfastData.Price;
  1840. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1841. if (breakfastCurrData != null)
  1842. {
  1843. breakfastCode = breakfastCurrData.Name;
  1844. breakfastName = $"({breakfastCurrData.Remark})";
  1845. }
  1846. }
  1847. //房间费用
  1848. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1849. if (roomData != null)
  1850. {
  1851. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1852. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1853. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1854. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1855. roomFee = roomData.Price;
  1856. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1857. if (roomCurrData != null)
  1858. {
  1859. roomCode = roomCurrData.Name;
  1860. roomName = $"({roomCurrData.Remark})";
  1861. }
  1862. }
  1863. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1864. string hotelCostStr = "";
  1865. decimal hotelCsotTotal = 0.00M;
  1866. if (groupCost != null)
  1867. {
  1868. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1869. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1870. }
  1871. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1872. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1873. string hotelCost_day = "";
  1874. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1875. foreach (var item in hotelCostDetails1)
  1876. {
  1877. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1878. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1879. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1880. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1881. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1882. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1883. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1884. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1885. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1886. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1887. hotelCost_day += @$"<br/>";
  1888. }
  1889. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1890. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  1891. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  1892. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  1893. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1894. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1895. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1896. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1897. $"房间说明: {hotelReservations.Remark} <br/>" +
  1898. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  1899. $"{hotelBreakfastStr}" +
  1900. $"{hotelGovernmentRentStr}" +
  1901. $"{hotelCityTaxStr}";
  1902. _detail.PriceNameContent = hotelReservations.HotelName;
  1903. }
  1904. break;
  1905. case 79://车/导游地接
  1906. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1907. if (touristGuideGroundReservations != null)
  1908. {
  1909. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1910. {
  1911. _detail.BusName = touristGuideGroundReservations.BusName;
  1912. }
  1913. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1914. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1915. //if (isInt)
  1916. //{
  1917. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1918. // if (cityInfo != null)
  1919. // {
  1920. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1921. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1922. // if (carFeeItem != null)
  1923. // {
  1924. // nameContent += $@"({carFeeItem.Name})";
  1925. // }
  1926. // _detail.PriceNameContent = nameContent;
  1927. // }
  1928. //}
  1929. //else
  1930. //{
  1931. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1932. //}
  1933. var touristGuideGroundReservationsContents =
  1934. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1935. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1936. foreach (var item in touristGuideGroundReservationsContents)
  1937. {
  1938. string typeName = "Unknown";
  1939. string carCurrencyCode = "Unknown";
  1940. string carCurrencyName = "Unknown";
  1941. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1942. if (carTypeData != null) typeName = carTypeData.Name;
  1943. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1944. if (currencyData != null)
  1945. {
  1946. carCurrencyCode = currencyData.Name;
  1947. carCurrencyName = currencyData.Remark;
  1948. }
  1949. //op、成本 币种是否一致
  1950. bool IsCurrencyAgreement = false;
  1951. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1952. string opCostStr = string.Empty;
  1953. decimal opCostTypePrice = 0.00M;
  1954. #region 处理成本各项费用
  1955. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1956. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1957. if (opCost.Count > 0)
  1958. {
  1959. switch (item.SId)
  1960. {
  1961. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1962. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1963. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1964. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1965. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1966. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1967. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1968. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1969. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1970. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1971. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1972. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1973. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1974. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1975. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1976. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1977. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1978. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1979. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1980. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1981. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1982. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1983. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1984. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1985. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1986. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1987. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1988. }
  1989. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1990. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1991. }
  1992. #endregion
  1993. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1994. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1995. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1996. $"{opTypeStr} {opCostStr}<br/>" +
  1997. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1998. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1999. }
  2000. _detail.PriceMsgContent = priceMsg;
  2001. }
  2002. break;
  2003. case 80: //签证
  2004. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2005. if (visaInfo != null)
  2006. {
  2007. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2008. _detail.PriceNameContent = visaInfo.VisaDescription;
  2009. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2010. }
  2011. break;
  2012. case 81: //邀请/公务活动
  2013. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2014. if (_ioa != null)
  2015. {
  2016. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2017. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2018. sendCurrName = "Unknown", //快递费用币种 Name
  2019. sendCurrCode = "Unknown", //快递费用币种 Code
  2020. eventsCurrName = "Unknown", //公务活动费币种 Name
  2021. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2022. translateCurrName = "Unknown", //公务翻译费 Name
  2023. translateCurrCode = "Unknown"; //公务翻译费 Code
  2024. #region 处理费用币种
  2025. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2026. if (inviteCurrData != null)
  2027. {
  2028. inviteCurrName = inviteCurrData.Remark;
  2029. inviteCurrCode = inviteCurrData.Name;
  2030. }
  2031. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2032. if (sendCurrData != null)
  2033. {
  2034. sendCurrName = sendCurrData.Remark;
  2035. sendCurrCode = sendCurrData.Name;
  2036. }
  2037. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2038. if (eventsCurrData != null)
  2039. {
  2040. eventsCurrName = eventsCurrData.Remark;
  2041. eventsCurrCode = eventsCurrData.Name;
  2042. }
  2043. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2044. if (translateCurrData != null)
  2045. {
  2046. translateCurrName = translateCurrData.Remark;
  2047. translateCurrCode = translateCurrData.Name;
  2048. }
  2049. #endregion
  2050. _detail.PriceNameContent = _ioa.InviterArea;
  2051. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2052. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2053. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2054. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2055. $@"备注:" + _ioa.Remark + "<br/>";
  2056. }
  2057. break;
  2058. case 82: //团组客户保险
  2059. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2060. if (customers != null)
  2061. {
  2062. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2063. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2064. }
  2065. break;
  2066. case 85: //机票预订
  2067. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2068. if (jpRes != null)
  2069. {
  2070. string FlightsDescription = jpRes.FlightsDescription;
  2071. string PriceDescription = jpRes.PriceDescription;
  2072. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2073. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2074. }
  2075. break;
  2076. case 98://其他款项
  2077. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2078. if (gdpRes != null)
  2079. {
  2080. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2081. _detail.PriceNameContent = gdpRes.PriceName;
  2082. }
  2083. break;
  2084. case 285://收款退还
  2085. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2086. if (refundAndOtherMoney != null)
  2087. {
  2088. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2089. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2090. }
  2091. break;
  2092. case 751://酒店早餐
  2093. break;
  2094. case 1015://超支费用
  2095. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2096. if (groupExtraCost != null)
  2097. {
  2098. _detail.PriceNameContent = groupExtraCost.PriceName;
  2099. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2100. }
  2101. break;
  2102. default:
  2103. break;
  2104. }
  2105. /*
  2106. * 申请人
  2107. */
  2108. string operatorName = " - ";
  2109. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2110. if (_opUser != null)
  2111. {
  2112. operatorName = _opUser.CnName;
  2113. }
  2114. _detail.OperatorName = operatorName;
  2115. /*
  2116. * 审核人
  2117. */
  2118. string auditOperatorName = "Unknown";
  2119. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2120. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2121. else
  2122. {
  2123. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2124. if (_adUser != null)
  2125. {
  2126. auditOperatorName = _adUser.CnName;
  2127. }
  2128. }
  2129. _detail.AuditOperatorName = auditOperatorName;
  2130. /*
  2131. * 超预算比例
  2132. */
  2133. string overBudgetStr = "";
  2134. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2135. else if (entity.ExceedBudget == 0)
  2136. {
  2137. if (entity.CTable == 76 || entity.CTable == 79)
  2138. {
  2139. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2140. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2141. }
  2142. else
  2143. {
  2144. overBudgetStr = "未超预算";
  2145. }
  2146. }
  2147. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2148. _detail.OverBudget = overBudgetStr;
  2149. decimal auditFee = 0.00M; //已审核金额 人名币
  2150. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2151. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2152. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2153. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2154. {
  2155. auditedFeeOriginal = entity.PayMoney;
  2156. auditFee = CurrPayStr;
  2157. }
  2158. else if (entity.IsAuditGM == 0)
  2159. {
  2160. unAuditFeeCNY = CurrPayStr;
  2161. unAuditFeeOriginal = OriginalCurrPay;
  2162. OriginalCurrPay = 0.00M;
  2163. }
  2164. /*
  2165. * 费用总计
  2166. */
  2167. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2168. {
  2169. CurrencyId = entity.PaymentCurrency,
  2170. CurrencyName = PaymentCurrency_WaitPay,
  2171. AmountPayable = entity.PayMoney,
  2172. ThisPayment = OriginalCurrPay,
  2173. BalancePayment = BalanceStr,
  2174. AuditedFunds = auditFee,
  2175. AuditedFundsOriginal = auditedFeeOriginal,
  2176. UnAuditFundsCNY = unAuditFeeCNY,
  2177. UnAuditFundsOriginal = unAuditFeeOriginal
  2178. });
  2179. _detail.IsAuditGM = entity.IsAuditGM;
  2180. detailList.Add(_detail);
  2181. }
  2182. #endregion
  2183. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2184. /*
  2185. * 下方描述处理
  2186. */
  2187. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2188. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2189. if (ccpCurrencyPrice != null)
  2190. {
  2191. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2192. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2193. }
  2194. else
  2195. {
  2196. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2197. }
  2198. string amountPayableStr = string.Format(@"应付款总金额: ");
  2199. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2200. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2201. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2202. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2203. foreach (var item in nonDuplicat)
  2204. {
  2205. var currencyName = item.CurrencyName;
  2206. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2207. if (strs.Count > 0)
  2208. {
  2209. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2210. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2211. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2212. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2213. //单独处理此次付款金额
  2214. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2215. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2216. //单独处理已审核费用
  2217. //if (item.CurrencyId == 836) //人民币
  2218. //{
  2219. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2220. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2221. //}
  2222. //else
  2223. //{
  2224. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2225. //}
  2226. if (currencyName.Equals("CNY"))
  2227. {
  2228. //已审核费用
  2229. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AuditedFundsOriginal).ToString("#0.00"), currencyName);
  2230. //未审核费用
  2231. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2232. }
  2233. else
  2234. {
  2235. //已审核费用
  2236. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.AuditedFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2237. //未审核费用
  2238. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  2239. }
  2240. }
  2241. }
  2242. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2243. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2244. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2245. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2246. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2247. var _view1 = new
  2248. {
  2249. PageFuncAuth = pageFunAuthView,
  2250. Data = _view
  2251. };
  2252. return Ok(JsonView(_view1));
  2253. }
  2254. catch (Exception ex)
  2255. {
  2256. return Ok(JsonView(false, ex.Message));
  2257. }
  2258. }
  2259. /// <summary>
  2260. /// 费用审核
  2261. /// 修改团组费用审核状态
  2262. /// </summary>
  2263. /// <param name="_dto">参数Json字符串</param>
  2264. /// <returns></returns>
  2265. [HttpPost]
  2266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2267. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2268. {
  2269. #region 参数验证
  2270. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2271. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2272. #endregion
  2273. #region 页面操作权限验证
  2274. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2275. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2276. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2277. #endregion
  2278. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2279. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2280. DateTime dtNow = DateTime.Now;
  2281. _groupRepository.BeginTran();
  2282. int rst = 0;
  2283. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2284. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2285. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2286. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2287. List<dynamic> msgDatas = new List<dynamic>();
  2288. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2289. foreach (var item in idList)
  2290. {
  2291. int CreditId = int.Parse(item);
  2292. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2293. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2294. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2295. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2296. .Where(s => s.Id == CreditId)
  2297. .ExecuteCommandAsync();
  2298. if (result < 1)
  2299. {
  2300. rst = -1;
  2301. _groupRepository.RollbackTran();
  2302. return Ok(JsonView(false, "操作失败并回滚!"));
  2303. }
  2304. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2305. if (creditData != null)
  2306. {
  2307. #region 应用通知配置
  2308. try
  2309. {
  2310. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2311. }
  2312. catch (Exception ex)
  2313. {
  2314. }
  2315. #endregion
  2316. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2317. string groupNameStr = string.Empty;
  2318. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2319. if (groupData != null) groupNameStr = groupData.TeamName;
  2320. string creditTypeStr = string.Empty;
  2321. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2322. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2323. string creditCurrency = string.Empty;
  2324. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2325. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2326. if (creditCurrency.Equals("CNY"))
  2327. {
  2328. creditData.DayRate = 1.0000M;
  2329. }
  2330. if (creditData.PayPercentage == 0.00M)
  2331. {
  2332. creditData.PayPercentage = 100M;
  2333. }
  2334. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2335. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2336. string msgContent = "";
  2337. if (creditCurrency.Equals("CNY"))
  2338. {
  2339. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2340. }
  2341. else
  2342. {
  2343. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2344. }
  2345. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2346. }
  2347. }
  2348. if (rst == 0)
  2349. {
  2350. _groupRepository.CommitTran();
  2351. foreach (var item in msgDatas)
  2352. {
  2353. //发送消息
  2354. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2355. }
  2356. #region 应用推送
  2357. try
  2358. {
  2359. foreach (var ccpId in dic_ccp_user.Keys)
  2360. {
  2361. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2362. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2363. }
  2364. }
  2365. catch (Exception)
  2366. {
  2367. }
  2368. #endregion
  2369. return Ok(JsonView(true, "操作成功!"));
  2370. }
  2371. return Ok(JsonView(false, "操作失败!"));
  2372. }
  2373. #endregion
  2374. #region 机票费用录入
  2375. /// <summary>
  2376. /// 机票录入当前登录人可操作团组
  2377. /// </summary>
  2378. /// <param name="dto"></param>
  2379. /// <returns></returns>
  2380. [HttpPost]
  2381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2382. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2383. {
  2384. try
  2385. {
  2386. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2387. if (groupData.Code != 0)
  2388. {
  2389. return Ok(JsonView(false, groupData.Msg));
  2390. }
  2391. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2392. }
  2393. catch (Exception ex)
  2394. {
  2395. return Ok(JsonView(false, "程序错误!"));
  2396. throw;
  2397. }
  2398. }
  2399. /// <summary>
  2400. /// 机票费用录入列表
  2401. /// </summary>
  2402. /// <param name="dto"></param>
  2403. /// <returns></returns>
  2404. [HttpPost]
  2405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2406. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2407. {
  2408. try
  2409. {
  2410. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2411. if (groupData.Code != 0)
  2412. {
  2413. return Ok(JsonView(false, groupData.Msg));
  2414. }
  2415. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2416. }
  2417. catch (Exception ex)
  2418. {
  2419. return Ok(JsonView(false, ex.Message));
  2420. throw;
  2421. }
  2422. }
  2423. /// <summary>
  2424. /// 根据id查询费用录入信息
  2425. /// </summary>
  2426. /// <param name="dto"></param>
  2427. /// <returns></returns>
  2428. [HttpPost]
  2429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2430. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2431. {
  2432. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2433. if (groupData.Code != 0)
  2434. {
  2435. return Ok(JsonView(false, groupData.Msg));
  2436. }
  2437. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2438. }
  2439. /// <summary>
  2440. /// 机票费用录入操作(Status:1.新增,2.修改)
  2441. /// </summary>
  2442. /// <param name="dto"></param>
  2443. /// <returns></returns>
  2444. [HttpPost]
  2445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2446. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2447. {
  2448. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2449. if (groupData.Code != 0)
  2450. {
  2451. return Ok(JsonView(false, groupData.Msg));
  2452. }
  2453. #region 应用推送
  2454. try
  2455. {
  2456. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2457. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2458. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2459. //2024-10-21 新增LZ UID
  2460. var userIds = new List<int>() { 21 };
  2461. string title = $"系统通知";
  2462. string content = "";
  2463. var diId = dto.AirTicketResOpData.DiId;
  2464. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2465. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2466. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2467. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2468. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2469. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2470. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2471. }
  2472. catch (Exception ex)
  2473. {
  2474. }
  2475. #endregion
  2476. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2477. }
  2478. /// <summary>
  2479. /// 根据舱位类型查询接团客户名单信息
  2480. /// </summary>
  2481. /// <param name="dto"></param>
  2482. /// <returns></returns>
  2483. [HttpPost]
  2484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2485. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2486. {
  2487. try
  2488. {
  2489. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2490. if (crm_Groups.Count != 0)
  2491. {
  2492. List<dynamic> Customer = new List<dynamic>();
  2493. foreach (var item in crm_Groups)
  2494. {
  2495. var data = new
  2496. {
  2497. Id = item.Id,
  2498. Pinyin = item.Pinyin,
  2499. Name = item.LastName + item.FirstName
  2500. };
  2501. Customer.Add(data);
  2502. }
  2503. return Ok(JsonView(true, "查询成功!", Customer));
  2504. }
  2505. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2506. }
  2507. catch (Exception ex)
  2508. {
  2509. return Ok(JsonView(false, "程序错误!"));
  2510. throw;
  2511. }
  2512. }
  2513. /// <summary>
  2514. /// 根据团号获取客户信息
  2515. /// </summary>
  2516. /// <param name="dto"></param>
  2517. /// <returns></returns>
  2518. [HttpPost]
  2519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2520. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2521. {
  2522. var jw = JsonView(false);
  2523. if (dto.DIID < 1)
  2524. {
  2525. jw.Msg += "请输入正确的diid";
  2526. return Ok(jw);
  2527. }
  2528. var arr = getSimplClientList(dto.DIID);
  2529. jw = JsonView(true, "获取成功!", arr);
  2530. return Ok(jw);
  2531. }
  2532. private List<SimplClientInfo> getSimplClientList(int diId)
  2533. {
  2534. 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);
  2535. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2536. foreach (var item in arr)
  2537. {
  2538. EncryptionProcessor.DecryptProperties(item);
  2539. }
  2540. return arr;
  2541. }
  2542. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2543. {
  2544. string result = origin;
  2545. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2546. {
  2547. string[] temparr = origin.Split(',');
  2548. string fistrStr = temparr[0];
  2549. int count = temparr.Count();
  2550. int tempId;
  2551. bool success = int.TryParse(fistrStr, out tempId);
  2552. if (success)
  2553. {
  2554. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2555. if (tempInfo != null)
  2556. {
  2557. if (count > 1)
  2558. {
  2559. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2560. }
  2561. else
  2562. {
  2563. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2564. }
  2565. }
  2566. }
  2567. }
  2568. return result;
  2569. }
  2570. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2571. {
  2572. string result = origin;
  2573. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2574. {
  2575. string[] temparr = origin.Split(',');
  2576. result = "";
  2577. foreach (var item in temparr)
  2578. {
  2579. int tempId;
  2580. bool success = int.TryParse(item, out tempId);
  2581. if (success)
  2582. {
  2583. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2584. if (tempInfo != null)
  2585. {
  2586. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2587. }
  2588. }
  2589. }
  2590. }
  2591. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2592. return result;
  2593. }
  2594. /// <summary>
  2595. /// 机票费用录入,删除
  2596. /// </summary>
  2597. /// <param name="dto"></param>
  2598. /// <returns></returns>
  2599. [HttpPost]
  2600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2601. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2602. {
  2603. try
  2604. {
  2605. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2606. if (res)
  2607. {
  2608. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2609. {
  2610. IsDel = 1,
  2611. DeleteUserId = dto.DeleteUserId,
  2612. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2613. }).ExecuteCommandAsync();
  2614. return Ok(JsonView(true, "删除成功!"));
  2615. }
  2616. return Ok(JsonView(false, "删除失败!"));
  2617. }
  2618. catch (Exception ex)
  2619. {
  2620. return Ok(JsonView(false, "程序错误!"));
  2621. throw;
  2622. }
  2623. }
  2624. /// <summary>
  2625. /// 导出机票录入报表
  2626. /// </summary>
  2627. /// <param name="dto"></param>
  2628. /// <returns></returns>
  2629. [HttpPost]
  2630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2631. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2632. {
  2633. try
  2634. {
  2635. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2636. if (groupData.Code != 0)
  2637. {
  2638. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2639. }
  2640. else
  2641. {
  2642. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2643. if (AirTicketReservations.Count != 0)
  2644. {
  2645. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2646. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2647. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2648. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2649. WorkbookDesigner designer = new WorkbookDesigner();
  2650. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2651. decimal countCost = 0;
  2652. foreach (var item in AirTicketReservations)
  2653. {
  2654. #region 处理客人姓名
  2655. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2656. item.ClientName = clientNames;
  2657. #endregion
  2658. if (item.BankType == "其他")
  2659. {
  2660. item.BankNo = "--";
  2661. }
  2662. else
  2663. {
  2664. if (!string.IsNullOrEmpty(item.BankType))
  2665. {
  2666. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2667. }
  2668. }
  2669. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2670. item.Price = System.Decimal.Round(item.Price, 2);
  2671. countCost += Convert.ToDecimal(item.Price);
  2672. }
  2673. designer.SetDataSource("Export", AirTicketReservations);
  2674. designer.SetDataSource("ExportDiCode", diCode);
  2675. designer.SetDataSource("ExportDiName", diName);
  2676. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2677. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2678. designer.Process();
  2679. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2680. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2681. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2682. return Ok(JsonView(true, "成功", url = rst));
  2683. }
  2684. else
  2685. {
  2686. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2687. }
  2688. }
  2689. }
  2690. catch (Exception ex)
  2691. {
  2692. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2693. throw;
  2694. }
  2695. }
  2696. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2697. /// <summary>
  2698. /// 行程单导出
  2699. /// </summary>
  2700. /// <param name="dto"></param>
  2701. /// <returns></returns>
  2702. [HttpPost]
  2703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2704. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2705. {
  2706. try
  2707. {
  2708. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2709. if (groupData.Code != 0)
  2710. {
  2711. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2712. }
  2713. else
  2714. {
  2715. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2716. if (dto.Language == "CN")
  2717. {
  2718. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2719. DocumentBuilder builder = new DocumentBuilder(doc);
  2720. int tableIndex = 0;//表格索引
  2721. //得到文档中的第一个表格
  2722. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2723. foreach (var item in _AirTicketReservations)
  2724. {
  2725. #region 处理固定数据
  2726. string[] FlightsCode = item.FlightsCode.Split('/');
  2727. if (FlightsCode.Length != 0)
  2728. {
  2729. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2730. if (_AirCompany != null)
  2731. {
  2732. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2733. }
  2734. else
  2735. {
  2736. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2737. }
  2738. }
  2739. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2740. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2741. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2742. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2743. string name = "";
  2744. foreach (string clientName in nameArray)
  2745. {
  2746. if (!name.Contains(clientName))
  2747. {
  2748. name += clientName + ",";
  2749. }
  2750. }
  2751. if (!string.IsNullOrWhiteSpace(name))
  2752. {
  2753. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2754. }
  2755. else
  2756. {
  2757. table.Range.Bookmarks["ClientName"].Text = "--";
  2758. }
  2759. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2760. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2761. table.Range.Bookmarks["JointTicket"].Text = "--";
  2762. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2763. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2764. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2765. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2766. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2767. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2768. #endregion
  2769. #region 循环数据处理
  2770. List<AirInfo> airs = new List<AirInfo>();
  2771. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2772. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2773. for (int i = 0; i < FlightsCode.Length; i++)
  2774. {
  2775. AirInfo air = new AirInfo();
  2776. string[] tempstr = DayArray[i]
  2777. .Replace("\r\n", string.Empty)
  2778. .Replace("\\r\\n", string.Empty)
  2779. .TrimStart().TrimEnd()
  2780. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2781. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2782. string starCity = "";
  2783. if (star_Three != null)
  2784. {
  2785. starCity = star_Three.AirPort;
  2786. }
  2787. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2788. string EndCity = "";
  2789. if (End_Three != null)
  2790. {
  2791. EndCity = End_Three.AirPort;
  2792. }
  2793. air.Destination = starCity + "/" + EndCity;
  2794. air.Flight = FlightsCode[i];
  2795. air.SeatingClass = item.CTypeName;
  2796. string dateTime = tempstr[2];
  2797. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2798. air.FlightDate = DateTemp;
  2799. air.DepartureTime = tempstr[5];
  2800. air.LandingTime = tempstr[6];
  2801. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2802. air.TicketStatus = "--";
  2803. air.Luggage = "--";
  2804. air.DepartureTerminal = "--";
  2805. air.LandingTerminal = "--";
  2806. airs.Add(air);
  2807. }
  2808. int row = 13;
  2809. for (int i = 0; i < airs.Count; i++)
  2810. {
  2811. if (airs.Count > 2)
  2812. {
  2813. for (int j = 0; j < airs.Count - 2; j++)
  2814. {
  2815. var CopyRow = table.Rows[12].Clone(true);
  2816. table.Rows.Add(CopyRow);
  2817. }
  2818. }
  2819. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2820. int index = 0;
  2821. foreach (PropertyInfo property in properties)
  2822. {
  2823. string value = property.GetValue(airs[i]).ToString();
  2824. Cell ishcel0 = table.Rows[row].Cells[index];
  2825. Paragraph p = new Paragraph(doc);
  2826. string s = value;
  2827. p.AppendChild(new Run(doc, s));
  2828. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2829. ishcel0.AppendChild(p);
  2830. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2831. index++;
  2832. }
  2833. row++;
  2834. }
  2835. #endregion
  2836. Paragraph lastParagraph = new Paragraph(doc);
  2837. //第一个表格末尾加段落
  2838. table.ParentNode.InsertAfter(lastParagraph, table);
  2839. //复制第一个表格
  2840. Table cloneTable = (Table)table.Clone(true);
  2841. //在文档末尾段落后面加入复制的表格
  2842. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2843. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2844. {
  2845. int rownewsIndex = 13;
  2846. for (int i = 0; i < 2; i++)
  2847. {
  2848. var CopyRow = table.Rows[12].Clone(true);
  2849. table.Rows.RemoveAt(13);
  2850. table.Rows.Add(CopyRow);
  2851. rownewsIndex++;
  2852. }
  2853. }
  2854. else
  2855. {
  2856. table.Rows.RemoveAt(12);
  2857. }
  2858. cloneTable.Rows.RemoveAt(12);
  2859. }
  2860. if (_AirTicketReservations.Count != 0)
  2861. {
  2862. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2863. if (FlightsCode.Length != 0)
  2864. {
  2865. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2866. if (_AirCompany != null)
  2867. {
  2868. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2869. }
  2870. else
  2871. {
  2872. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2873. }
  2874. }
  2875. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2876. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2877. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2878. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2879. string name = "";
  2880. foreach (string clientName in nameArray)
  2881. {
  2882. if (!name.Contains(clientName))
  2883. {
  2884. name += clientName + ",";
  2885. }
  2886. }
  2887. if (!string.IsNullOrWhiteSpace(name))
  2888. {
  2889. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2890. }
  2891. else
  2892. {
  2893. table.Range.Bookmarks["ClientName"].Text = "--";
  2894. }
  2895. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2896. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2897. table.Range.Bookmarks["JointTicket"].Text = "--";
  2898. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2899. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2900. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2901. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2902. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2903. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2904. }
  2905. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2906. //保存合并后的文档
  2907. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2908. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2909. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2910. return Ok(JsonView(true, "成功!", rst));
  2911. }
  2912. else
  2913. {
  2914. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2915. DocumentBuilder builder = new DocumentBuilder(doc);
  2916. int tableIndex = 0;//表格索引
  2917. //得到文档中的第一个表格
  2918. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2919. List<string> texts = new List<string>();
  2920. foreach (var item in _AirTicketReservations)
  2921. {
  2922. string[] FlightsCode = item.FlightsCode.Split('/');
  2923. if (FlightsCode.Length != 0)
  2924. {
  2925. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2926. if (_AirCompany != null)
  2927. {
  2928. if (!transDic.ContainsKey(_AirCompany.CnName))
  2929. {
  2930. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2931. }
  2932. }
  2933. else
  2934. {
  2935. if (!transDic.ContainsKey("--"))
  2936. {
  2937. transDic.Add("--", "--");
  2938. }
  2939. }
  2940. }
  2941. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2942. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2943. string name = "";
  2944. foreach (string clientName in nameArray)
  2945. {
  2946. name += clientName + ",";
  2947. }
  2948. if (!texts.Contains(name))
  2949. {
  2950. texts.Add(name);
  2951. }
  2952. List<AirInfo> airs = new List<AirInfo>();
  2953. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2954. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2955. for (int i = 0; i < FlightsCode.Length; i++)
  2956. {
  2957. AirInfo air = new AirInfo();
  2958. string[] tempstr = DayArray[i]
  2959. .Replace("\r\n", string.Empty)
  2960. .Replace("\\r\\n", string.Empty)
  2961. .TrimStart().TrimEnd()
  2962. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2963. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2964. if (star_Three != null)
  2965. {
  2966. if (!transDic.ContainsKey(star_Three.AirPort))
  2967. {
  2968. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2969. }
  2970. }
  2971. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2972. if (End_Three != null)
  2973. {
  2974. if (!transDic.ContainsKey(End_Three.AirPort))
  2975. {
  2976. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2977. }
  2978. }
  2979. if (!texts.Contains(item.CTypeName))
  2980. {
  2981. texts.Add(item.CTypeName);
  2982. }
  2983. }
  2984. }
  2985. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2986. if (transData.Count > 0)
  2987. {
  2988. foreach (TranslateResult item in transData)
  2989. {
  2990. if (!transDic.ContainsKey(item.Query))
  2991. {
  2992. transDic.Add(item.Query, item.Translation);
  2993. }
  2994. }
  2995. }
  2996. foreach (var item in _AirTicketReservations)
  2997. {
  2998. #region 处理固定数据
  2999. string[] FlightsCode = item.FlightsCode.Split('/');
  3000. if (FlightsCode.Length != 0)
  3001. {
  3002. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3003. if (_AirCompany != null)
  3004. {
  3005. string str = "--";
  3006. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3007. if (!string.IsNullOrEmpty(translateResult))
  3008. {
  3009. str = translateResult;
  3010. str = _airTicketResRep.Processing(str);
  3011. }
  3012. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3013. }
  3014. else
  3015. {
  3016. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3017. }
  3018. }
  3019. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3020. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3021. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3022. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3023. string names = "";
  3024. foreach (string clientName in nameArray)
  3025. {
  3026. names += clientName + ",";
  3027. }
  3028. if (!string.IsNullOrWhiteSpace(names))
  3029. {
  3030. string str = "--";
  3031. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3032. if (!string.IsNullOrEmpty(translateResult))
  3033. {
  3034. str = translateResult;
  3035. str = _airTicketResRep.Processing(str);
  3036. }
  3037. table.Range.Bookmarks["ClientName"].Text = str;
  3038. }
  3039. else
  3040. {
  3041. table.Range.Bookmarks["ClientName"].Text = "--";
  3042. }
  3043. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3044. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3045. table.Range.Bookmarks["JointTicket"].Text = "--";
  3046. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3047. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3048. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3049. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3050. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3051. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3052. #endregion
  3053. #region 循环数据处理
  3054. List<AirInfo> airs = new List<AirInfo>();
  3055. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3056. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3057. for (int i = 0; i < FlightsCode.Length; i++)
  3058. {
  3059. AirInfo air = new AirInfo();
  3060. string[] tempstr = DayArray[i]
  3061. .Replace("\r\n", string.Empty)
  3062. .Replace("\\r\\n", string.Empty)
  3063. .TrimStart().TrimEnd()
  3064. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3065. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3066. string starCity = "";
  3067. if (star_Three != null)
  3068. {
  3069. string str2 = "--";
  3070. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3071. if (!string.IsNullOrEmpty(translateResult2))
  3072. {
  3073. str2 = translateResult2;
  3074. str2 = _airTicketResRep.Processing(str2);
  3075. }
  3076. starCity = str2;
  3077. }
  3078. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3079. string EndCity = "";
  3080. if (End_Three != null)
  3081. {
  3082. string str1 = "--";
  3083. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3084. if (!string.IsNullOrEmpty(translateResult1))
  3085. {
  3086. str1 = translateResult1;
  3087. str1 = _airTicketResRep.Processing(str1);
  3088. }
  3089. EndCity = str1;
  3090. }
  3091. air.Destination = starCity + "/" + EndCity;
  3092. air.Flight = FlightsCode[i];
  3093. string str = "--";
  3094. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3095. if (!string.IsNullOrEmpty(translateResult))
  3096. {
  3097. str = translateResult;
  3098. str = _airTicketResRep.Processing(str);
  3099. }
  3100. air.SeatingClass = str;
  3101. string dateTime = tempstr[2];
  3102. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3103. air.FlightDate = DateTemp;
  3104. air.DepartureTime = tempstr[5];
  3105. air.LandingTime = tempstr[6];
  3106. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3107. air.TicketStatus = "--";
  3108. air.Luggage = "--";
  3109. air.DepartureTerminal = "--";
  3110. air.LandingTerminal = "--";
  3111. airs.Add(air);
  3112. }
  3113. int row = 13;
  3114. for (int i = 0; i < airs.Count; i++)
  3115. {
  3116. if (airs.Count > 2)
  3117. {
  3118. for (int j = 0; j < airs.Count - 2; j++)
  3119. {
  3120. var CopyRow = table.Rows[12].Clone(true);
  3121. table.Rows.Add(CopyRow);
  3122. }
  3123. }
  3124. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3125. int index = 0;
  3126. foreach (PropertyInfo property in properties)
  3127. {
  3128. string value = property.GetValue(airs[i]).ToString();
  3129. Cell ishcel0 = table.Rows[row].Cells[index];
  3130. Paragraph p = new Paragraph(doc);
  3131. string s = value;
  3132. p.AppendChild(new Run(doc, s));
  3133. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3134. ishcel0.AppendChild(p);
  3135. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3136. //ishcel0.CellFormat.VerticalAlignment=
  3137. index++;
  3138. }
  3139. row++;
  3140. }
  3141. #endregion
  3142. Paragraph lastParagraph = new Paragraph(doc);
  3143. //第一个表格末尾加段落
  3144. table.ParentNode.InsertAfter(lastParagraph, table);
  3145. //复制第一个表格
  3146. Table cloneTable = (Table)table.Clone(true);
  3147. //在文档末尾段落后面加入复制的表格
  3148. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3149. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3150. {
  3151. int rownewsIndex = 13;
  3152. for (int i = 0; i < 2; i++)
  3153. {
  3154. var CopyRow = table.Rows[12].Clone(true);
  3155. table.Rows.RemoveAt(13);
  3156. table.Rows.Add(CopyRow);
  3157. rownewsIndex++;
  3158. }
  3159. }
  3160. else
  3161. {
  3162. table.Rows.RemoveAt(12);
  3163. }
  3164. cloneTable.Rows.RemoveAt(12);
  3165. }
  3166. if (_AirTicketReservations.Count != 0)
  3167. {
  3168. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3169. if (FlightsCode.Length != 0)
  3170. {
  3171. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3172. if (_AirCompany != null)
  3173. {
  3174. string str = "--";
  3175. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3176. if (!string.IsNullOrEmpty(translateResult))
  3177. {
  3178. str = translateResult;
  3179. str = _airTicketResRep.Processing(str);
  3180. }
  3181. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3182. }
  3183. else
  3184. {
  3185. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3186. }
  3187. }
  3188. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3189. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3190. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3191. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3192. string names = "";
  3193. foreach (string clientName in nameArray)
  3194. {
  3195. names += clientName + ",";
  3196. }
  3197. if (!string.IsNullOrWhiteSpace(names))
  3198. {
  3199. string str = "--";
  3200. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3201. if (!string.IsNullOrEmpty(translateResult))
  3202. {
  3203. str = translateResult;
  3204. str = _airTicketResRep.Processing(str);
  3205. }
  3206. table.Range.Bookmarks["ClientName"].Text = str;
  3207. }
  3208. else
  3209. {
  3210. table.Range.Bookmarks["ClientName"].Text = "--";
  3211. }
  3212. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3213. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3214. table.Range.Bookmarks["JointTicket"].Text = "--";
  3215. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3216. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3217. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3218. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3219. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3220. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3221. }
  3222. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3223. //保存合并后的文档
  3224. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3225. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3226. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3227. return Ok(JsonView(true, "成功!", rst));
  3228. }
  3229. }
  3230. }
  3231. catch (Exception ex)
  3232. {
  3233. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3234. throw;
  3235. }
  3236. }
  3237. #endregion
  3238. #region 团组增减款项 --> 其他款项
  3239. /// <summary>
  3240. /// 团组增减款项下拉框绑定
  3241. /// </summary>
  3242. /// <param name="dto"></param>
  3243. /// <returns></returns>
  3244. [HttpPost]
  3245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3246. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3247. {
  3248. #region 参数验证
  3249. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3250. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3251. #endregion
  3252. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3253. }
  3254. /// <summary>
  3255. /// 根据团组Id查询团组增减款项
  3256. /// </summary>
  3257. /// <param name="dto"></param>
  3258. /// <returns></returns>
  3259. [HttpPost]
  3260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3261. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3262. {
  3263. #region 参数验证
  3264. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3265. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3266. #endregion
  3267. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3268. }
  3269. /// <summary>
  3270. /// 团组增减款项操作(Status:1.新增,2.修改)
  3271. /// </summary>
  3272. /// <param name="dto"></param>
  3273. /// <returns></returns>
  3274. [HttpPost]
  3275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3276. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3277. {
  3278. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3279. if (groupData.Code != 200)
  3280. {
  3281. return Ok(JsonView(false, groupData.Msg));
  3282. }
  3283. #region 应用推送
  3284. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3285. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3286. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3287. //自动审核
  3288. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3289. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3290. //2024-10-21 新增LZ UID
  3291. var userIds = new List<int>() { 21 };
  3292. string title = $"系统通知";
  3293. string content = "";
  3294. var diId = dto.DiId;
  3295. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3296. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3297. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3298. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3299. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3300. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3301. #endregion
  3302. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3303. }
  3304. /// <summary>
  3305. /// 团组增减款项操作 删除
  3306. /// </summary>
  3307. /// <param name="dto"></param>
  3308. /// <returns></returns>
  3309. [HttpPost]
  3310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3311. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3312. {
  3313. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3314. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3315. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3316. if (res.Code == 0)
  3317. {
  3318. return Ok(JsonView(true, "删除成功!"));
  3319. }
  3320. return Ok(JsonView(false, "删除失败!"));
  3321. }
  3322. /// <summary>
  3323. /// 根据团组增减款项Id查询
  3324. /// </summary>
  3325. /// <param name="dto"></param>
  3326. /// <returns></returns>
  3327. [HttpPost]
  3328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3329. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3330. {
  3331. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3332. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3333. }
  3334. /// <summary>
  3335. /// 查询供应商名称
  3336. /// </summary>
  3337. /// <param name="dto"></param>
  3338. /// <returns></returns>
  3339. [HttpPost]
  3340. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3341. {
  3342. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3343. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3344. ?? new List<Grp_DecreasePayments>();
  3345. dbResult = dbResult.Distinct(new
  3346. ProductComparer()).ToList();
  3347. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3348. {
  3349. x.Id,
  3350. x.SupplierAddress,
  3351. x.SupplierArea,
  3352. x.SupplierContact,
  3353. x.SupplierContactNumber,
  3354. x.SupplierEmail,
  3355. x.SupplierName,
  3356. x.SupplierSocialAccount,
  3357. x.SupplierTypeId,
  3358. }).ToList());
  3359. return Ok(jw);
  3360. }
  3361. /// <summary>
  3362. /// 团组增减款项 OTA匹配
  3363. /// </summary>
  3364. /// <param name="file"></param>
  3365. /// <returns></returns>
  3366. [HttpPost]
  3367. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3368. {
  3369. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3370. string fileName = file.FileName;
  3371. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3372. {
  3373. return Ok(JsonView(false, "请上传Excel文件!"));
  3374. }
  3375. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3376. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3377. if (!Directory.Exists(path))
  3378. {
  3379. Directory.CreateDirectory(path);
  3380. }
  3381. var filePath = @$"{path}/{fileName}";
  3382. //保存文件
  3383. using (FileStream fs = System.IO.File.Create(filePath))
  3384. {
  3385. file.CopyTo(fs);
  3386. fs.Flush();
  3387. }
  3388. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3389. //读取ExcelFile
  3390. DataTable dt = ConvertExcelToDataTable(filePath);
  3391. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3392. dt.TableName = "TB";
  3393. //修改table列名
  3394. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3395. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3396. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3397. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3398. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3399. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3400. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3401. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3402. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3403. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3404. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3405. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3406. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3407. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3408. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3409. var otaOrderNos = new List<string>();
  3410. foreach (DataRow item in dt.Rows)
  3411. {
  3412. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3413. }
  3414. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3415. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3416. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3417. .Select((dp, di) => new
  3418. {
  3419. dp.PriceName,
  3420. dp.OTAOrderNo,
  3421. dp.FeeTotal,
  3422. di.TeamName,
  3423. })
  3424. .ToListAsync();
  3425. foreach (DataRow item in dt.Rows)
  3426. {
  3427. var otaOrderNo = item["OTAOrderNo"].ToString();
  3428. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3429. if (oaData == null) continue;
  3430. item["GroupName"] = oaData.TeamName;
  3431. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3432. }
  3433. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3434. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3435. List<DataTable> datas = new List<DataTable>();
  3436. datas.Add(dt);
  3437. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3438. return Ok(JsonView(true, "操作成功", new { url = url }));
  3439. }
  3440. #region
  3441. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3442. {
  3443. // 创建Workbook对象
  3444. Workbook workbook = new Workbook(excelFilePath);
  3445. // 获取第一个工作表
  3446. Worksheet worksheet = workbook.Worksheets[0];
  3447. // 将工作表转换为DataTable
  3448. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3449. return dataTable;
  3450. }
  3451. #endregion
  3452. #endregion
  3453. #region 文件上传、删除
  3454. /// <summary>
  3455. /// region 文件上传 可以带参数
  3456. /// </summary>
  3457. /// <param name="file"></param>
  3458. /// <returns></returns>
  3459. [HttpPost]
  3460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3461. public async Task<IActionResult> UploadProject(IFormFile file)
  3462. {
  3463. //var TypeName = Request.Headers["TypeName"].ToString();
  3464. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3465. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3466. ////文件名称
  3467. //string projectFileName = file.FileName;
  3468. ////上传的文件的路径
  3469. //string filePath = $"{fileDir}/{projectFileName}";
  3470. //if (TypeName == "A")//A代表团组增减款项
  3471. //{
  3472. // filePath = fileDir + $@"\团组增减款项相关文件";
  3473. // if (!Directory.Exists(filePath))
  3474. // {
  3475. // Directory.CreateDirectory(filePath);
  3476. // }
  3477. // //上传的文件的路径
  3478. // filePath += $@"\{projectFileName}";
  3479. //}
  3480. //else if (TypeName == "B")//B代表商邀相关文件
  3481. //{
  3482. // //上传的文件的路径
  3483. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3484. // if (!Directory.Exists(filePath))
  3485. // {
  3486. // Directory.CreateDirectory(filePath);
  3487. // }
  3488. // //上传的文件的路径
  3489. // filePath = $@"\{projectFileName}";
  3490. //}
  3491. //try
  3492. //{
  3493. // using (FileStream fs = System.IO.File.Create(filePath))
  3494. // {
  3495. // file.CopyTo(fs);
  3496. // fs.Flush();
  3497. // }
  3498. //}
  3499. //catch (Exception ex)
  3500. //{
  3501. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3502. //}
  3503. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3504. try
  3505. {
  3506. var TypeName = Request.Headers["TypeName"].ToString();
  3507. if (file != null)
  3508. {
  3509. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3510. //文件名称
  3511. string projectFileName = file.FileName;
  3512. //上传的文件的路径
  3513. string filePath = $"{fileDir}/{projectFileName}";
  3514. if (TypeName == "A")//A代表团组增减款项
  3515. {
  3516. if (!Directory.Exists(fileDir))
  3517. {
  3518. Directory.CreateDirectory(fileDir);
  3519. }
  3520. //上传的文件的路径
  3521. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3522. }
  3523. else if (TypeName == "B")//B代表商邀相关文件
  3524. {
  3525. if (!Directory.Exists(fileDir))
  3526. {
  3527. Directory.CreateDirectory(fileDir);
  3528. }
  3529. //上传的文件的路径
  3530. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3531. }
  3532. using (FileStream fs = System.IO.File.Create(filePath))
  3533. {
  3534. file.CopyTo(fs);
  3535. fs.Flush();
  3536. }
  3537. return Ok(JsonView(true, "上传成功!", projectFileName));
  3538. }
  3539. else
  3540. {
  3541. return Ok(JsonView(false, "上传失败!"));
  3542. }
  3543. }
  3544. catch (Exception ex)
  3545. {
  3546. return Ok(JsonView(false, "程序错误!"));
  3547. }
  3548. }
  3549. /// <summary>
  3550. /// 删除指定文件
  3551. /// </summary>
  3552. /// <param name="dto"></param>
  3553. /// <returns></returns>
  3554. [HttpPost]
  3555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3556. public async Task<IActionResult> DelFile(DelFileDto dto)
  3557. {
  3558. try
  3559. {
  3560. var TypeName = Request.Headers["TypeName"].ToString();
  3561. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3562. string filePath = "";
  3563. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3564. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3565. int id = 0;
  3566. if (TypeName == "A")
  3567. {
  3568. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3569. // 删除该文件
  3570. System.IO.File.Delete(filePath);
  3571. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3572. .Where(a => a.Id == dto.Id)
  3573. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3574. .ExecuteCommandAsync();
  3575. }
  3576. else if (TypeName == "B")
  3577. {
  3578. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3579. // 删除该文件
  3580. System.IO.File.Delete(filePath);
  3581. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3582. if (info != null)
  3583. {
  3584. string[] files = new string[] { };
  3585. if (!string.IsNullOrEmpty(info.Attachment))
  3586. {
  3587. try
  3588. {
  3589. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3590. }
  3591. catch (Exception)
  3592. {
  3593. files = new List<string>() { info.Attachment }.ToArray();
  3594. }
  3595. }
  3596. if (files.Length > 0)
  3597. {
  3598. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3599. string filePath2 = string.Empty;
  3600. if (files1.Length > 0)
  3601. {
  3602. filePath2 = JsonConvert.SerializeObject(files1);
  3603. }
  3604. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3605. .Where(a => a.Id == dto.Id)
  3606. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3607. .ExecuteCommandAsync();
  3608. }
  3609. }
  3610. }
  3611. if (id != 0)
  3612. {
  3613. return Ok(JsonView(true, "成功!"));
  3614. }
  3615. else
  3616. {
  3617. return Ok(JsonView(false, "失败!"));
  3618. }
  3619. }
  3620. catch (Exception ex)
  3621. {
  3622. return Ok(JsonView(false, "程序错误!"));
  3623. throw;
  3624. }
  3625. }
  3626. /// <summary>
  3627. /// 文件上传多个文件 可以带参数
  3628. /// </summary>
  3629. /// <param name="file"></param>
  3630. /// <returns></returns>
  3631. [HttpPost]
  3632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3633. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3634. {
  3635. try
  3636. {
  3637. var TypeName = Request.Headers["TypeName"].ToString();
  3638. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3639. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3640. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3641. var filePahts = new List<string>();
  3642. foreach (var file in files)
  3643. {
  3644. //文件名称
  3645. string projectFileName = file.FileName;
  3646. //上传的文件的路径
  3647. string filePath = $"{fileDir}/{projectFileName}";
  3648. if (TypeName == "A")//A代表团组增减款项
  3649. {
  3650. if (!Directory.Exists(fileDir))
  3651. {
  3652. Directory.CreateDirectory(fileDir);
  3653. }
  3654. //上传的文件的路径
  3655. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3656. }
  3657. else if (TypeName == "B")//B代表商邀相关文件
  3658. {
  3659. if (!Directory.Exists(fileDir))
  3660. {
  3661. Directory.CreateDirectory(fileDir);
  3662. }
  3663. //上传的文件的路径
  3664. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3665. }
  3666. using (FileStream fs = System.IO.File.Create(filePath))
  3667. {
  3668. file.CopyTo(fs);
  3669. fs.Flush();
  3670. }
  3671. filePahts.Add(projectFileName);
  3672. }
  3673. return Ok(JsonView(true, "上传成功!", filePahts));
  3674. }
  3675. catch (Exception ex)
  3676. {
  3677. return Ok(JsonView(false, "程序错误!"));
  3678. }
  3679. }
  3680. #endregion
  3681. #region 商邀费用录入
  3682. /// <summary>
  3683. /// 根据团组Id查询商邀费用列表
  3684. /// </summary>
  3685. /// <param name="dto"></param>
  3686. /// <returns></returns>
  3687. [HttpPost]
  3688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3689. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3690. {
  3691. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3692. if (groupData.Code != 0)
  3693. {
  3694. return Ok(JsonView(false, groupData.Msg));
  3695. }
  3696. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3697. }
  3698. /// <summary>
  3699. /// 商邀费用列表
  3700. /// 下载文件
  3701. /// </summary>
  3702. /// <param name="dto"></param>
  3703. /// <returns></returns>
  3704. [HttpGet("{id}")]
  3705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3706. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3707. {
  3708. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3709. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3710. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3711. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3712. var filePaths = new List<string>();
  3713. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3714. try
  3715. {
  3716. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3717. }
  3718. catch (Exception ex)
  3719. {
  3720. filePaths.Add(info.Attachment);
  3721. }
  3722. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3723. for (int i = 0; i < filePaths.Count; i++)
  3724. {
  3725. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3726. }
  3727. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3728. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3729. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3730. {
  3731. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3732. {
  3733. foreach (string filePath in filePaths)
  3734. {
  3735. if (System.IO.File.Exists(filePath))
  3736. {
  3737. // 获取文件名
  3738. string fileName = Path.GetFileName(filePath);
  3739. // 将文件添加到ZIP归档中
  3740. zipArchive.CreateEntryFromFile(filePath, fileName);
  3741. }
  3742. }
  3743. }
  3744. }
  3745. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3746. }
  3747. /// <summary>
  3748. /// 商邀费用 Info Page 基础数据源
  3749. /// </summary>
  3750. /// <param name="dto"></param>
  3751. /// <returns></returns>
  3752. [HttpPost]
  3753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3754. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3755. {
  3756. try
  3757. {
  3758. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3759. if (groupData.Code != 0)
  3760. {
  3761. return Ok(JsonView(false, groupData.Msg));
  3762. }
  3763. return Ok(JsonView(true, "操作成功", groupData.Data));
  3764. }
  3765. catch (Exception ex)
  3766. {
  3767. return Ok(JsonView(false, ex.Message));
  3768. throw;
  3769. }
  3770. }
  3771. /// <summary>
  3772. /// 根据商邀费用ID查询C表和商邀费用数据
  3773. /// </summary>
  3774. /// <param name="dto"></param>
  3775. /// <returns></returns>
  3776. [HttpPost]
  3777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3778. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3779. {
  3780. try
  3781. {
  3782. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3783. if (groupData.Code != 0)
  3784. {
  3785. return Ok(JsonView(false, groupData.Msg));
  3786. }
  3787. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3788. }
  3789. catch (Exception ex)
  3790. {
  3791. return Ok(JsonView(false, ex.Message));
  3792. throw;
  3793. }
  3794. }
  3795. /// <summary>
  3796. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3797. /// </summary>
  3798. /// <param name="dto"></param>
  3799. /// <returns></returns>
  3800. [HttpPost]
  3801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3802. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3803. {
  3804. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3805. if (groupData.Code != 0)
  3806. {
  3807. return Ok(JsonView(false, groupData.Msg));
  3808. }
  3809. #region 应用推送
  3810. try
  3811. {
  3812. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3813. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3814. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3815. //2024-10-21 新增LZ UID
  3816. var userIds = new List<int>() { 21 };
  3817. string title = $"系统通知";
  3818. string content = "";
  3819. var diId = dto.DiId;
  3820. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3821. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3822. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3823. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3824. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3825. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3826. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3827. }
  3828. catch (Exception ex)
  3829. {
  3830. }
  3831. #endregion
  3832. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3833. }
  3834. /// <summary>
  3835. /// 商邀删除
  3836. /// </summary>
  3837. /// <param name="dto"></param>
  3838. /// <returns></returns>
  3839. [HttpPost]
  3840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3841. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3842. {
  3843. try
  3844. {
  3845. _sqlSugar.BeginTran();
  3846. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3847. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3848. {
  3849. IsDel = 1,
  3850. DeleteUserId = dto.DeleteUserId,
  3851. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3852. })
  3853. .Where(it => it.Id == dto.Id)
  3854. .ExecuteCommand();
  3855. if (res1 > 0)
  3856. {
  3857. int _diId = 0;
  3858. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3859. if (_ioaInfo != null)
  3860. {
  3861. _diId = _ioaInfo.DiId;
  3862. }
  3863. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3864. .SetColumns(a => new Grp_CreditCardPayment()
  3865. {
  3866. IsDel = 1,
  3867. DeleteUserId = dto.DeleteUserId,
  3868. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3869. })
  3870. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3871. .ExecuteCommand();
  3872. if (res2 > 0)
  3873. {
  3874. _sqlSugar.CommitTran();
  3875. return Ok(JsonView(true, "删除成功!"));
  3876. }
  3877. }
  3878. _sqlSugar.RollbackTran();
  3879. return Ok(JsonView(false, "删除失败"));
  3880. }
  3881. catch (Exception ex)
  3882. {
  3883. _sqlSugar.RollbackTran();
  3884. return Ok(JsonView(false, ex.Message));
  3885. }
  3886. }
  3887. /// <summary>
  3888. /// 团组模块文件上传
  3889. /// </summary>
  3890. /// <param name="dto"></param>
  3891. /// <returns></returns>
  3892. [HttpPost]
  3893. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3894. {
  3895. var jw = JsonView(false);
  3896. long M = 1024 * 1024;
  3897. if (dto.Files == null || dto.Files.Count == 0)
  3898. {
  3899. jw.Msg = "无文件信息!";
  3900. return Ok(jw);
  3901. }
  3902. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3903. {
  3904. jw.Msg = "文件大小超过20M!";
  3905. return Ok(jw);
  3906. }
  3907. //var nameSp = dto.File.FileName.Split(".");
  3908. //if (nameSp.Length < 2)
  3909. //{
  3910. // jw.Msg = "拓展名称有误!";
  3911. // return Ok(jw);
  3912. //}
  3913. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3914. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3915. //{
  3916. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3917. // return Ok(jw);
  3918. //}
  3919. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3920. if (Ctable == null)
  3921. {
  3922. jw.Msg = "Ctable指向有误!";
  3923. return Ok(jw);
  3924. }
  3925. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3926. if (groupInfo == null)
  3927. {
  3928. jw.Msg = "团组信息不存在!";
  3929. return Ok(jw);
  3930. }
  3931. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3932. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3933. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3934. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3935. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3936. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3937. try
  3938. {
  3939. if (!Directory.Exists(fileBase))
  3940. {
  3941. Directory.CreateDirectory(fileBase);
  3942. }
  3943. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3944. foreach (var fileStream in dto.Files)
  3945. {
  3946. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3947. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3948. {
  3949. Cid = dto.Cid,
  3950. CreateTime = DateTime.Now,
  3951. CreateUserId = dto.Userid,
  3952. Ctable = dto.Ctable,
  3953. Diid = dto.Diid,
  3954. IsDel = 0,
  3955. FilePath = saveFilePath,
  3956. FileName = fileStream.FileName
  3957. };
  3958. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3959. {
  3960. fileStream.CopyTo(fs);
  3961. fs.Flush();
  3962. }
  3963. saveArr.Add(file);
  3964. }
  3965. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3966. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3967. jw = JsonView(true, "保存成功!", new
  3968. {
  3969. count = addResult,
  3970. filesName = saveArr.Select(x => x.FileName)
  3971. });
  3972. }
  3973. catch (Exception ex)
  3974. {
  3975. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3976. {
  3977. count = 0,
  3978. filesName = new string[0],
  3979. });
  3980. }
  3981. return Ok(jw);
  3982. }
  3983. /// <summary>
  3984. /// 查询各模块已保存文件
  3985. /// </summary>
  3986. /// <param name="dto"></param>
  3987. /// <returns></returns>
  3988. [HttpPost]
  3989. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3990. {
  3991. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3992. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3993. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3994. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3995. {
  3996. expression = Expressionable.Create<Grp_GroupModelFile>()
  3997. .And(x => visaIds.Contains(x.CreateUserId));
  3998. }
  3999. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4000. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4001. .Where(expression.ToExpression())
  4002. .ToList();
  4003. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4004. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4005. {
  4006. x.FileName,
  4007. x.Id,
  4008. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4009. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4010. })));
  4011. }
  4012. /// <summary>
  4013. /// 下载该团组下的所有文件
  4014. /// </summary>
  4015. /// <param name="dto"></param>
  4016. /// <returns></returns>
  4017. [HttpPost]
  4018. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4019. {
  4020. var jw = JsonView(false);
  4021. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4022. if (groupInfo == null)
  4023. {
  4024. jw.Msg = "团组信息不存在!";
  4025. return Ok(jw);
  4026. }
  4027. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4028. var isModule = Convert.ToBoolean(dto.isModule);
  4029. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4030. IOOperatorHelper io = new IOOperatorHelper();
  4031. if (isModule)
  4032. {
  4033. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4034. foreach (var moduleArr in moduleGroup)
  4035. {
  4036. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4037. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4038. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4039. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4040. foreach (var item in moduleArr)
  4041. {
  4042. if (System.IO.File.Exists(item.FilePath))
  4043. {
  4044. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4045. {
  4046. byte[] bytes = new byte[fileStream.Length];
  4047. fileStream.Read(bytes, 0, bytes.Length);
  4048. fileStream.Close();
  4049. Stream stream = new MemoryStream(bytes);
  4050. chiZips.Add(item.FileName, stream);
  4051. }
  4052. }
  4053. }
  4054. if (chiZips.Count > 0)
  4055. {
  4056. var byts = io.ConvertZipStream(chiZips);
  4057. Stream stream = new MemoryStream(byts);
  4058. Zips.Add(key.Name + "_.zip", stream);
  4059. }
  4060. }
  4061. }
  4062. else
  4063. {
  4064. foreach (var item in dbQuery)
  4065. {
  4066. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4067. {
  4068. byte[] bytes = new byte[fileStream.Length];
  4069. fileStream.Read(bytes, 0, bytes.Length);
  4070. fileStream.Close();
  4071. Stream stream = new MemoryStream(bytes);
  4072. while (Zips.Keys.Contains(item.FileName))
  4073. {
  4074. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4075. }
  4076. Zips.Add(item.FileName, stream);
  4077. }
  4078. }
  4079. }
  4080. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4081. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4082. if (Zips.Count > 0)
  4083. {
  4084. var byts = io.ConvertZipStream(Zips);
  4085. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4086. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4087. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4088. }
  4089. else
  4090. {
  4091. jw.Msg = "暂无生成文件!";
  4092. }
  4093. return Ok(jw);
  4094. }
  4095. /// <summary>
  4096. /// 下载该团组下此模块的所有文件
  4097. /// </summary>
  4098. /// <param name="dto"></param>
  4099. /// <returns></returns>
  4100. [HttpPost]
  4101. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4102. {
  4103. var jw = JsonView(false);
  4104. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4105. if (groupInfo == null)
  4106. {
  4107. jw.Msg = "团组信息不存在!";
  4108. return Ok(jw);
  4109. }
  4110. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4111. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4112. && x.IsDel == 0);
  4113. if (key == null)
  4114. {
  4115. jw.Msg = "Ctable指向错误!";
  4116. return Ok(jw);
  4117. }
  4118. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4119. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4120. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4121. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4122. IOOperatorHelper io = new IOOperatorHelper();
  4123. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4124. foreach (var item in dbQuery)
  4125. {
  4126. if (System.IO.File.Exists(item.FilePath))
  4127. {
  4128. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4129. {
  4130. byte[] bytes = new byte[fileStream.Length];
  4131. fileStream.Read(bytes, 0, bytes.Length);
  4132. fileStream.Close();
  4133. Stream stream = new MemoryStream(bytes);
  4134. while (Zips.Keys.Contains(item.FileName))
  4135. {
  4136. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4137. }
  4138. Zips.Add(item.FileName, stream);
  4139. }
  4140. }
  4141. }
  4142. if (Zips.Count > 0)
  4143. {
  4144. var byts = io.ConvertZipStream(Zips);
  4145. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4146. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4147. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4148. }
  4149. else
  4150. {
  4151. jw.Msg = "暂无生成文件!";
  4152. }
  4153. return Ok(jw);
  4154. }
  4155. /// <summary>
  4156. /// 删除该团组下的指定文件
  4157. /// </summary>
  4158. /// <param name="dto"></param>
  4159. /// <returns></returns>
  4160. [HttpPost]
  4161. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4162. {
  4163. var jw = JsonView(false);
  4164. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4165. if (sing == null)
  4166. {
  4167. jw.Msg = "暂无";
  4168. return Ok(jw);
  4169. }
  4170. if (System.IO.File.Exists(sing.FilePath))
  4171. {
  4172. try
  4173. {
  4174. System.IO.File.Delete(sing.FilePath);
  4175. }
  4176. catch (Exception ex)
  4177. {
  4178. jw.Msg = "删除失败!" + ex.Message;
  4179. return Ok(jw);
  4180. }
  4181. }
  4182. sing.IsDel = 1;
  4183. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4184. sing.DeleteUserId = dto.UserId;
  4185. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4186. jw = JsonView(true, "删除成功!");
  4187. return Ok(jw);
  4188. }
  4189. #endregion
  4190. #region 团组英文资料
  4191. /// <summary>
  4192. /// 查询团组英文所有资料
  4193. /// </summary>
  4194. /// <param name="dto"></param>
  4195. /// <returns></returns>
  4196. [HttpPost]
  4197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4198. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4199. {
  4200. try
  4201. {
  4202. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4203. if (groupData.Code != 0)
  4204. {
  4205. return Ok(JsonView(false, groupData.Msg));
  4206. }
  4207. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4208. }
  4209. catch (Exception ex)
  4210. {
  4211. return Ok(JsonView(false, "程序错误!"));
  4212. throw;
  4213. }
  4214. }
  4215. /// <summary>
  4216. /// 团组英文资料操作(Status:1.新增,2.修改)
  4217. /// </summary>
  4218. /// <param name="dto"></param>
  4219. /// <returns></returns>
  4220. [HttpPost]
  4221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4222. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4223. {
  4224. try
  4225. {
  4226. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4227. if (groupData.Code != 0)
  4228. {
  4229. return Ok(JsonView(false, groupData.Msg));
  4230. }
  4231. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4232. }
  4233. catch (Exception ex)
  4234. {
  4235. return Ok(JsonView(false, "程序错误!"));
  4236. throw;
  4237. }
  4238. }
  4239. /// <summary>
  4240. /// 团组英文资料Id查询数据
  4241. /// </summary>
  4242. /// <param name="dto"></param>
  4243. /// <returns></returns>
  4244. [HttpPost]
  4245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4246. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4247. {
  4248. try
  4249. {
  4250. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4251. if (_DelegationEnData != null)
  4252. {
  4253. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4254. }
  4255. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4256. }
  4257. catch (Exception ex)
  4258. {
  4259. return Ok(JsonView(false, "程序错误!"));
  4260. throw;
  4261. }
  4262. }
  4263. /// <summary>
  4264. /// 团组英文资料删除
  4265. /// </summary>
  4266. /// <param name="dto"></param>
  4267. /// <returns></returns>
  4268. [HttpPost]
  4269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4270. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4271. {
  4272. try
  4273. {
  4274. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4275. if (!res)
  4276. {
  4277. return Ok(JsonView(false, "删除失败"));
  4278. }
  4279. return Ok(JsonView(true, "删除成功!"));
  4280. }
  4281. catch (Exception ex)
  4282. {
  4283. return Ok(JsonView(false, "程序错误!"));
  4284. throw;
  4285. }
  4286. }
  4287. #endregion
  4288. #region 导出邀请函
  4289. /// <summary>
  4290. /// 导出邀请函页面初始化
  4291. /// </summary>
  4292. /// <param name="dto"></param>
  4293. /// <returns></returns>
  4294. [HttpPost]
  4295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4296. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4297. {
  4298. try
  4299. {
  4300. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4301. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4302. if (dto.DiId == 0)
  4303. {
  4304. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4305. }
  4306. else
  4307. {
  4308. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4309. }
  4310. return Ok(JsonView(true, "查询成功!", new
  4311. {
  4312. deleClient = crm_Deles,
  4313. delegations = grp_Delegations
  4314. }));
  4315. }
  4316. catch (Exception ex)
  4317. {
  4318. return Ok(JsonView(false, "程序错误!"));
  4319. throw;
  4320. }
  4321. }
  4322. /// <summary>
  4323. /// 导出邀请函
  4324. /// </summary>
  4325. /// <param name="dto"></param>
  4326. /// <returns></returns>
  4327. [HttpPost]
  4328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4329. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4330. {
  4331. #region 参数验证
  4332. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4333. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4334. #endregion
  4335. try
  4336. {
  4337. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4338. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4339. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4340. From Grp_TourClientList tcl
  4341. Left Join
  4342. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4343. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4344. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4345. From Crm_DeleClient dc
  4346. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4347. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4348. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4349. Where dc.IsDel = 0) temp
  4350. On temp.DcId =tcl.ClientId
  4351. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4352. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4353. List<string> texts = new List<string>();
  4354. if (datas.Count != 0)
  4355. {
  4356. foreach (TourClientListDetailsView item in datas)
  4357. {
  4358. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4359. {
  4360. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4361. }
  4362. else
  4363. {
  4364. string name = item.LastName + item.FirstName;
  4365. texts.Add(name);
  4366. }
  4367. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4368. {
  4369. if (!transDic.ContainsKey(item.Job))
  4370. {
  4371. texts.Add(item.Job);
  4372. }
  4373. }
  4374. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4375. {
  4376. texts.Add(item.CompanyFullName);
  4377. }
  4378. }
  4379. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4380. if (transData.Count > 0)
  4381. {
  4382. foreach (TranslateResult item in transData)
  4383. {
  4384. if (!transDic.ContainsKey(item.Query))
  4385. {
  4386. transDic.Add(item.Query, item.Translation);
  4387. }
  4388. }
  4389. }
  4390. List<GuestList> list = new List<GuestList>();
  4391. foreach (TourClientListDetailsView dele in datas)
  4392. {
  4393. GuestList guestList = new GuestList();
  4394. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4395. {
  4396. guestList.Name = dele.Pinyin;
  4397. }
  4398. else
  4399. {
  4400. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4401. guestList.Name = Name;
  4402. }
  4403. if (dele.Sex == 0)
  4404. {
  4405. guestList.Sex = "Male";
  4406. }
  4407. else if (dele.Sex == 1)
  4408. {
  4409. guestList.Sex = "Female";
  4410. }
  4411. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4412. if (!string.IsNullOrEmpty(dele.Job))
  4413. {
  4414. guestList.Job = dele.Job;
  4415. }
  4416. list.Add(guestList);
  4417. }
  4418. //载入模板
  4419. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4420. DocumentBuilder builder = new DocumentBuilder(doc);
  4421. //获取word里所有表格
  4422. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4423. //获取所填表格的序数
  4424. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4425. var rowStart = tableOne.Rows[0]; //获取第1行
  4426. //循环赋值
  4427. for (int i = 0; i < list.Count; i++)
  4428. {
  4429. builder.MoveToCell(0, i + 1, 0, 0);
  4430. builder.Write(list[i].Name.ToString());
  4431. builder.MoveToCell(0, i + 1, 1, 0);
  4432. builder.Write(list[i].Sex.ToString());
  4433. builder.MoveToCell(0, i + 1, 2, 0);
  4434. builder.Write(list[i].DOB.ToString());
  4435. builder.MoveToCell(0, i + 1, 3, 0);
  4436. builder.Write(list[i].Job.ToString());
  4437. }
  4438. //删除多余行
  4439. while (tableOne.Rows.Count > list.Count + 1)
  4440. {
  4441. tableOne.Rows.RemoveAt(list.Count + 1);
  4442. }
  4443. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4444. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4445. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4446. doc.Save(filePath);
  4447. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4448. return Ok(JsonView(true, "操作成功!", Url));
  4449. }
  4450. else
  4451. {
  4452. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4453. }
  4454. }
  4455. catch (Exception ex)
  4456. {
  4457. return Ok(JsonView(false, ex.Message));
  4458. throw;
  4459. }
  4460. }
  4461. #endregion
  4462. #region 团组经理模块 出入境费用
  4463. /// <summary>
  4464. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4465. /// </summary>
  4466. /// <returns></returns>
  4467. [HttpPost]
  4468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4469. public async Task<IActionResult> SetDayAndCostAreaChange()
  4470. {
  4471. try
  4472. {
  4473. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4474. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4475. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4476. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4477. foreach (var item in unite) //处理交集数据
  4478. {
  4479. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4480. }
  4481. foreach (var item in merge) //处理差集数据
  4482. {
  4483. int nationalTravelFeeId = 0;
  4484. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4485. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4486. else
  4487. {
  4488. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4489. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4490. }
  4491. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4492. }
  4493. //只更新dayAndCost 的 nationalTravelFeeId;
  4494. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4495. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4496. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4497. }
  4498. catch (Exception ex)
  4499. {
  4500. return Ok(JsonView(false, ex.Message));
  4501. throw;
  4502. }
  4503. }
  4504. /// <summary>
  4505. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4506. /// </summary>
  4507. /// <returns></returns>
  4508. [HttpPost]
  4509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4510. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4511. {
  4512. try
  4513. {
  4514. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4515. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4516. //SetDataInfoView
  4517. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4518. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4519. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4520. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4521. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4522. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4523. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4524. //默认币种显示
  4525. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4526. {
  4527. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4528. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4529. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4530. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4531. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4532. };
  4533. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4534. if (_currencyRate.Count > 0)
  4535. {
  4536. foreach (var item in _currencyInfos)
  4537. {
  4538. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4539. if (rateInfo != null)
  4540. {
  4541. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4542. rate1 *= 1.035M;
  4543. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4544. }
  4545. }
  4546. }
  4547. return Ok(JsonView(true, "查询成功!", new
  4548. {
  4549. GroupNameData = groupNameData.Data,
  4550. CurrencyData = _CurrencyData,
  4551. WordTypeData = _WordTypeData,
  4552. ExcelTypeData = _ExcelTypeData,
  4553. CurrencyInit = _currencyInfos
  4554. }));
  4555. }
  4556. catch (Exception ex)
  4557. {
  4558. return Ok(JsonView(false, ex.Message));
  4559. throw;
  4560. }
  4561. }
  4562. /// <summary>
  4563. /// 团组模块 - 出入境费用
  4564. /// 实时汇率 tips
  4565. /// 签证费用 tips
  4566. /// 机票费用 tips
  4567. /// </summary>
  4568. /// <returns></returns>
  4569. [HttpPost]
  4570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4571. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4572. {
  4573. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4574. //默认币种显示
  4575. var _currencyInfos = _currencyInit;
  4576. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4577. List<dynamic> reteInfos = new List<dynamic>();
  4578. if (_currencyRate.Count > 0)
  4579. {
  4580. foreach (var item in _currencyInfos)
  4581. {
  4582. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4583. if (rateInfo != null)
  4584. {
  4585. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4586. decimal rate1 = item.Rate;
  4587. rate1 *= 1.03M;
  4588. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4589. reteInfos.Add(new
  4590. {
  4591. currCode = item.CurrencyCode,
  4592. currName = item.CurrencyName,
  4593. rate = rate2,
  4594. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4595. });
  4596. }
  4597. }
  4598. }
  4599. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4600. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4601. return Ok(JsonView(true, "查询成功!", new
  4602. {
  4603. //GroupNameData = groupNameData.Data,
  4604. visaData = visaData.Data,
  4605. airData = airData.Data,
  4606. reteInfos = reteInfos
  4607. }));
  4608. }
  4609. /// <summary>
  4610. /// 团组模块 - 出入境费用 - Info
  4611. /// </summary>
  4612. /// <returns></returns>
  4613. [HttpPost]
  4614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4615. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4616. {
  4617. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4618. }
  4619. /// <summary>
  4620. /// 团组模块 - 出入境费用 - Add And Update
  4621. /// </summary>
  4622. /// <returns></returns>
  4623. [HttpPost]
  4624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4625. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4626. {
  4627. try
  4628. {
  4629. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4630. if (dto.DayOtherPriceData.Any())
  4631. {
  4632. var inserList = dto.DayOtherPriceData
  4633. .Where(x => x.Id == 0)
  4634. .Select(x => new Grp_DayOtherPrice
  4635. {
  4636. Cost = x.Cost,
  4637. Id = x.Id,
  4638. CreateTime = DateTime.Now,
  4639. CreateUserId = dto.UserId,
  4640. Currency = x.Currency,
  4641. Diid = x.DiId,
  4642. Index = x.Index,
  4643. IsDel = 0,
  4644. SetDataId = x.SetDataId,
  4645. SubTotal = x.SubTotal,
  4646. Remark = x.Remark
  4647. })
  4648. .ToList();
  4649. var updateList = dto.DayOtherPriceData
  4650. .Where(x => x.Id != 0)
  4651. .Select(x => new Grp_DayOtherPrice
  4652. {
  4653. Cost = x.Cost,
  4654. Id = x.Id,
  4655. CreateTime = DateTime.Now,
  4656. CreateUserId = dto.UserId,
  4657. Currency = x.Currency,
  4658. Diid = x.DiId,
  4659. Index = x.Index,
  4660. IsDel = 0,
  4661. SetDataId = x.SetDataId,
  4662. SubTotal = x.SubTotal,
  4663. Remark = x.Remark
  4664. })
  4665. .ToList();
  4666. //添加
  4667. _sqlSugar.BeginTran();
  4668. if (inserList.Any())
  4669. {
  4670. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4671. }
  4672. if (updateList.Any())
  4673. {
  4674. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4675. }
  4676. _sqlSugar.CommitTran();
  4677. }
  4678. if (data.Code != 0)
  4679. {
  4680. return Ok(JsonView(false, data.Msg));
  4681. }
  4682. //生成默认文件pdf并且通知人员
  4683. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4684. {
  4685. DiId = dto.DiId,
  4686. ExportType = 1,
  4687. SubTypeId = 1005
  4688. }, "pdf");
  4689. //发送通知
  4690. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4691. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4692. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4693. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4694. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4695. //汇率信息记录
  4696. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4697. return Ok(JsonView(true, data.Msg, data.Data));
  4698. }
  4699. catch (Exception ex)
  4700. {
  4701. return Ok(JsonView(false, ex.Message));
  4702. }
  4703. }
  4704. /// <summary>
  4705. /// 团组模块 - 出入境费用 - Confirm 费用
  4706. /// </summary>
  4707. /// <returns></returns>
  4708. [HttpPost]
  4709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4710. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4711. {
  4712. //TODO:测试完毕需把对应的用户ID更改
  4713. //1、数据表添加字段
  4714. //2、更改字段接口()
  4715. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4716. //3、确认成功 给财务发送消息
  4717. if (_view.Code == 200)
  4718. {
  4719. if (dto.Type == 1)
  4720. {
  4721. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4722. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4723. }
  4724. }
  4725. return Ok(_view);
  4726. }
  4727. /// <summary>
  4728. /// 团组模块 - 出入境费用 - File downlaod
  4729. /// </summary>
  4730. /// <param name="dto"></param>
  4731. /// <returns></returns>
  4732. [HttpPost]
  4733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4734. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4735. {
  4736. try
  4737. {
  4738. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4739. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4740. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4741. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4742. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4743. 3 团组成员名单 1 团组成员名单", ""));
  4744. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4745. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4746. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4747. //数据源
  4748. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4749. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4750. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4751. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4752. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4753. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4754. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4755. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4756. .Select((x, a, b) => new
  4757. {
  4758. x.Index,
  4759. itemName = a.Name,
  4760. CurrencyStr = b.Name,
  4761. x.Cost,
  4762. x.SubTotal,
  4763. x.Remark
  4764. })
  4765. .OrderBy((x) => x.Index)
  4766. .ToList(); //其他款项费用
  4767. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4768. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4769. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4770. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4771. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4772. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4773. .Select((tcl, dc, cc) => new ClientInfo
  4774. {
  4775. LastName = dc.LastName,
  4776. FirstName = dc.FirstName,
  4777. Sex = dc.Sex,
  4778. Birthday = dc.BirthDay,
  4779. Company = cc.CompanyFullName,
  4780. Job = dc.Job
  4781. })
  4782. .ToList();
  4783. foreach (var item in DeleClientList)
  4784. {
  4785. EncryptionProcessor.DecryptProperties(item);
  4786. }
  4787. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4788. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4789. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4790. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4791. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4792. if (dto.ExportType == 1) //明细表
  4793. {
  4794. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4795. {
  4796. //获取模板
  4797. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4798. //载入模板
  4799. Document doc = new Document(tempPath);
  4800. DocumentBuilder builder = new DocumentBuilder(doc);
  4801. //利用键值对存放数据
  4802. Dictionary<string, string> dic = new Dictionary<string, string>();
  4803. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  4804. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  4805. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  4806. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  4807. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  4808. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  4809. //境内费用(其他费用)
  4810. if (_EnterExitCosts.ChoiceOne == 1)
  4811. {
  4812. string row1_1 = "";
  4813. if (_EnterExitCosts.Visa > 0)
  4814. {
  4815. //insidePayTotal += _EnterExitCosts.Visa;
  4816. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4817. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4818. {
  4819. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4820. }
  4821. }
  4822. string row1_2 = "";
  4823. if (_EnterExitCosts.YiMiao > 0)
  4824. {
  4825. //insidePayTotal += _EnterExitCosts.YiMiao;
  4826. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4827. }
  4828. if (_EnterExitCosts.HeSuan > 0)
  4829. {
  4830. //insidePayTotal += _EnterExitCosts.HeSuan;
  4831. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4832. }
  4833. if (_EnterExitCosts.Service > 0)
  4834. {
  4835. //insidePayTotal += _EnterExitCosts.Service;
  4836. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4837. }
  4838. string row1_3 = "";
  4839. if (_EnterExitCosts.Safe > 0)
  4840. {
  4841. //insidePayTotal += _EnterExitCosts.Safe;
  4842. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4843. }
  4844. if (_EnterExitCosts.Ticket > 0)
  4845. {
  4846. //insidePayTotal += _EnterExitCosts.Ticket;
  4847. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4848. }
  4849. string row1 = "";
  4850. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4851. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4852. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4853. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4854. dic.Add("Row1Str", row1);
  4855. }
  4856. string airTotalStr = string.Empty,
  4857. airPriceStr = string.Empty;
  4858. //经济舱
  4859. if (_EnterExitCosts.SumJJC == 1)
  4860. {
  4861. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4862. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4863. }
  4864. //公务舱
  4865. if (_EnterExitCosts.SumGWC == 1)
  4866. {
  4867. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4868. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4869. }
  4870. //头等舱
  4871. if (_EnterExitCosts.SumTDC == 1)
  4872. {
  4873. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4874. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4875. }
  4876. dic.Add("AirTotalStr", airTotalStr);
  4877. dic.Add("AirPriceStr", airPriceStr);
  4878. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4879. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4880. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4881. int table1Row = 0,
  4882. table2Row = 0,
  4883. table3Row = 0,
  4884. table4Row = 0,
  4885. table5Row = 0;
  4886. //住宿费
  4887. if (_EnterExitCosts.ChoiceThree == 1)
  4888. {
  4889. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4890. table1Row = dac1.Count;
  4891. #region 填充word表格内容
  4892. for (int i = 0; i < dac1.Count; i++)
  4893. {
  4894. Grp_DayAndCost dac = dac1[i];
  4895. if (dac == null) continue;
  4896. builder.MoveToCell(0, i, 0, 0);
  4897. builder.Write("第" + dac.Days.ToString() + "晚:");
  4898. builder.MoveToCell(0, i, 1, 0);
  4899. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4900. //builder.Write(dac.Place == null ? "" : dac.Place);
  4901. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4902. builder.MoveToCell(0, i, 2, 0);
  4903. builder.Write("费用标准:");
  4904. string curr = "";
  4905. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4906. if (currData != null)
  4907. {
  4908. curr = currData.Name;
  4909. }
  4910. builder.MoveToCell(0, i, 3, 0);
  4911. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4912. builder.MoveToCell(0, i, 4, 0);
  4913. builder.Write("费用小计:");
  4914. builder.MoveToCell(0, i, 5, 0);
  4915. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4916. }
  4917. #endregion
  4918. }
  4919. else dic.Add("SubZS", "0.00");
  4920. //删除多余行
  4921. while (table1.Rows.Count > table1Row)
  4922. {
  4923. table1.Rows.RemoveAt(table1Row);
  4924. }
  4925. //伙食费
  4926. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4927. if (_EnterExitCosts.ChoiceFour == 1)
  4928. {
  4929. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4930. table2Row = dac2.Count;
  4931. #region 填充word表格内容
  4932. for (int i = 0; i < dac2.Count; i++)
  4933. {
  4934. Grp_DayAndCost dac = dac2[i];
  4935. if (dac == null) continue;
  4936. builder.MoveToCell(1, i, 0, 0);
  4937. builder.Write("第" + dac.Days.ToString() + "天:");
  4938. builder.MoveToCell(1, i, 1, 0);
  4939. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4940. builder.MoveToCell(1, i, 2, 0);
  4941. builder.Write("费用标准:");
  4942. string curr = "";
  4943. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4944. if (currData != null)
  4945. {
  4946. curr = currData.Name;
  4947. }
  4948. builder.MoveToCell(1, i, 3, 0);
  4949. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4950. builder.MoveToCell(1, i, 4, 0);
  4951. builder.Write("费用小计:");
  4952. builder.MoveToCell(1, i, 5, 0);
  4953. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4954. }
  4955. #endregion
  4956. }
  4957. else dic.Add("SubHS", "0.00");
  4958. //删除多余行
  4959. while (table2.Rows.Count > table2Row)
  4960. {
  4961. table2.Rows.RemoveAt(table2Row);
  4962. }
  4963. //公杂费
  4964. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4965. if (_EnterExitCosts.ChoiceFive == 1)
  4966. {
  4967. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4968. table3Row = dac3.Count;
  4969. #region 填充word表格内容
  4970. for (int i = 0; i < dac3.Count; i++)
  4971. {
  4972. Grp_DayAndCost dac = dac3[i];
  4973. if (dac == null) continue;
  4974. builder.MoveToCell(2, i, 0, 0);
  4975. builder.Write("第" + dac.Days.ToString() + "天:");
  4976. builder.MoveToCell(2, i, 1, 0);
  4977. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4978. builder.MoveToCell(2, i, 2, 0);
  4979. builder.Write("费用标准:");
  4980. string curr = "";
  4981. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4982. if (currData != null)
  4983. {
  4984. curr = currData.Name;
  4985. }
  4986. builder.MoveToCell(2, i, 3, 0);
  4987. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4988. builder.MoveToCell(2, i, 4, 0);
  4989. builder.Write("费用小计:");
  4990. builder.MoveToCell(2, i, 5, 0);
  4991. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4992. }
  4993. //删除多余行
  4994. while (table3.Rows.Count > table3Row)
  4995. {
  4996. table3.Rows.RemoveAt(table3Row);
  4997. }
  4998. #endregion
  4999. }
  5000. else dic.Add("SubGZF", "0.00");
  5001. //删除多余行
  5002. while (table3.Rows.Count > table3Row)
  5003. {
  5004. table3.Rows.RemoveAt(table3Row);
  5005. }
  5006. //培训费
  5007. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5008. if (_EnterExitCosts.ChoiceSix == 1)
  5009. {
  5010. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5011. dic.Add("SubPX", pxStr);
  5012. table4Row = dac4.Count;
  5013. #region 填充word表格内容
  5014. for (int i = 0; i < dac4.Count; i++)
  5015. {
  5016. Grp_DayAndCost dac = dac4[i];
  5017. if (dac == null) continue;
  5018. builder.MoveToCell(3, i, 0, 0);
  5019. builder.Write("第" + dac.Days.ToString() + "天:");
  5020. builder.MoveToCell(3, i, 1, 0);
  5021. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5022. builder.MoveToCell(3, i, 2, 0);
  5023. builder.Write("费用标准:");
  5024. string curr = "";
  5025. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5026. if (currData != null)
  5027. {
  5028. curr = currData.Name;
  5029. }
  5030. builder.MoveToCell(3, i, 3, 0);
  5031. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5032. builder.MoveToCell(3, i, 4, 0);
  5033. builder.Write("费用小计:");
  5034. builder.MoveToCell(3, i, 5, 0);
  5035. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5036. }
  5037. #endregion
  5038. }
  5039. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5040. //删除多余行
  5041. while (table4.Rows.Count > table4Row)
  5042. {
  5043. table4.Rows.RemoveAt(table4Row);
  5044. }
  5045. //其他费用
  5046. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5047. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5048. {
  5049. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5050. dic.Add("titleQi", qtStr);
  5051. table5Row = dac5.Count;
  5052. #region 填充word表格内容
  5053. for (int i = 0; i < dac5.Count; i++)
  5054. {
  5055. var dac = dac5[i];
  5056. if (dac == null) continue;
  5057. builder.MoveToCell(4, i, 0, 0);
  5058. builder.Write("第" + dac.Index.ToString() + "项:");
  5059. builder.MoveToCell(4, i, 1, 0);
  5060. builder.Write(dac.itemName);
  5061. builder.MoveToCell(4, i, 2, 0);
  5062. builder.Write("费用标准:");
  5063. builder.MoveToCell(4, i, 3, 0);
  5064. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5065. builder.MoveToCell(4, i, 4, 0);
  5066. builder.Write("费用小计:");
  5067. builder.MoveToCell(4, i, 5, 0);
  5068. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5069. builder.MoveToCell(4, i, 6, 0);
  5070. builder.Write("备注:");
  5071. builder.MoveToCell(4, i, 7, 0);
  5072. builder.Write(dac.Remark);
  5073. }
  5074. #endregion
  5075. }
  5076. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5077. //删除多余行
  5078. while (table5.Rows.Count > table5Row)
  5079. {
  5080. table5.Rows.RemoveAt(table5Row);
  5081. }
  5082. //加上其他费用
  5083. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5084. decimal subJJC = 0.00M,
  5085. subGWC = 0.00M,
  5086. subTDC = 0.00M;
  5087. //经济舱
  5088. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5089. //公务舱
  5090. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5091. //头等舱
  5092. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5093. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5094. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5095. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5096. #region 填充word模板书签内容
  5097. foreach (var key in dic.Keys)
  5098. {
  5099. Bookmark bookmark = doc.Range.Bookmarks[key];
  5100. if (bookmark != null)
  5101. {
  5102. builder.MoveToBookmark(key);
  5103. builder.Write(dic[key]);
  5104. }
  5105. }
  5106. #endregion
  5107. //文件名
  5108. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5109. AsposeHelper.removewatermark_v2180();
  5110. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5111. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5112. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5113. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5114. }
  5115. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5116. {
  5117. //获取模板
  5118. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5119. //载入模板
  5120. Document doc = new Document(tempPath);
  5121. DocumentBuilder builder = new DocumentBuilder(doc);
  5122. Dictionary<string, string> dic = new Dictionary<string, string>();
  5123. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5124. {
  5125. List<string> list = new List<string>();
  5126. try
  5127. {
  5128. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5129. foreach (var item in spilitArr)
  5130. {
  5131. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5132. var depCode = spDotandEmpty[2].Substring(0, 3);
  5133. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5134. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5135. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5136. list.Add(depName);
  5137. list.Add(arrName);
  5138. }
  5139. list = list.Distinct().ToList();
  5140. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5141. }
  5142. catch (Exception)
  5143. {
  5144. dic.Add("ReturnCode", "行程录入不正确!");
  5145. }
  5146. }
  5147. else
  5148. {
  5149. dic.Add("ReturnCode", "未录入行程!");
  5150. }
  5151. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5152. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5153. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5154. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5155. {
  5156. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5157. dic.Add("Day", sp.Days.ToString());
  5158. }
  5159. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5160. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5161. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5162. //dic.Add("Names", Names);
  5163. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5164. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5165. decimal dac1totalPrice = 0.00M;
  5166. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5167. foreach (var dac in dac1)
  5168. {
  5169. if (dac.SubTotal == 0.00M)
  5170. {
  5171. continue;
  5172. }
  5173. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5174. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5175. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5176. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5177. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5178. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5179. builder.Write(currency);//币种
  5180. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5181. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5182. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5183. builder.Write("");//人数
  5184. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5185. builder.Write("");//天数
  5186. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5187. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5188. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5189. decimal rate = 0.00M;
  5190. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5191. builder.Write(rate.ToString("#0.0000"));//汇率
  5192. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5193. decimal rbmPrice = dac.SubTotal;
  5194. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5195. accommodationStartIndex++;
  5196. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5197. }
  5198. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5199. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5200. {
  5201. table1.Rows.RemoveAt(i - 1);
  5202. foodandotherStartIndex--;
  5203. }
  5204. if (dac2.Count == dac3.Count)//国家 币种 金额
  5205. {
  5206. for (int i = 0; i < dac2.Count; i++)
  5207. {
  5208. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5209. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5210. }
  5211. }
  5212. decimal dac2totalPrice = 0.00M;
  5213. foreach (var dac in dac2)
  5214. {
  5215. if (dac.SubTotal == 0)
  5216. {
  5217. continue;
  5218. }
  5219. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5220. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5221. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5222. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5223. builder.Write(currency);//币种
  5224. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5225. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5226. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5227. builder.Write("");//人数
  5228. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5229. builder.Write("");//天数
  5230. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5231. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5232. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5233. decimal rate = 0.00M;
  5234. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5235. builder.Write(rate.ToString("#0.0000"));//汇率
  5236. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5237. decimal rbmPrice = dac.SubTotal;
  5238. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5239. foodandotherStartIndex++;
  5240. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5241. }
  5242. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5243. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5244. {
  5245. table1.Rows.RemoveAt(i - 1);
  5246. }
  5247. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5248. string otherFeeStr = "";
  5249. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5250. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5251. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5252. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5253. foreach (var otherInfo in dac5)
  5254. {
  5255. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5256. }
  5257. #endregion
  5258. if (otherFeeStr.Length > 0)
  5259. {
  5260. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5261. otherFeeStr = $"({otherFeeStr})";
  5262. dic.Add("OtherFeeStr", otherFeeStr);
  5263. }
  5264. //总计
  5265. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5266. //国际旅费
  5267. string outsideAir = string.Empty;
  5268. string allPriceAir = string.Empty;
  5269. if (_EnterExitCosts.SumJJC == 1)
  5270. {
  5271. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5272. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5273. }
  5274. if (_EnterExitCosts.SumGWC == 1)
  5275. {
  5276. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5277. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5278. }
  5279. if (_EnterExitCosts.SumTDC == 1)
  5280. {
  5281. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5282. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5283. }
  5284. dic.Add("InTravelPrice", $"({outsideAir})");
  5285. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5286. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5287. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5288. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5289. foreach (var key in dic.Keys)
  5290. {
  5291. builder.MoveToBookmark(key);
  5292. builder.Write(dic[key]);
  5293. }
  5294. //模板文件名
  5295. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5296. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5297. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5298. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5299. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5300. }
  5301. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5302. {
  5303. //获取模板
  5304. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5305. //载入模板
  5306. WorkbookDesigner designer = new WorkbookDesigner();
  5307. designer.Workbook = new Workbook(tempPath);
  5308. Dictionary<string, string> dic = new Dictionary<string, string>();
  5309. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5310. {
  5311. List<string> list = new List<string>();
  5312. try
  5313. {
  5314. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5315. foreach (var item in spilitArr)
  5316. {
  5317. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5318. var depCode = spDotandEmpty[2].Substring(0, 3);
  5319. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5320. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5321. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5322. list.Add(depName);
  5323. list.Add(arrName);
  5324. }
  5325. list = list.Distinct().ToList();
  5326. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5327. }
  5328. catch (Exception)
  5329. {
  5330. dic.Add("ReturnCode", "行程录入不正确!");
  5331. }
  5332. }
  5333. else
  5334. {
  5335. dic.Add("ReturnCode", "未录入行程!");
  5336. }
  5337. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5338. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5339. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5340. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5341. {
  5342. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5343. dic.Add("Day", sp.Days.ToString());
  5344. }
  5345. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5346. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5347. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5348. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5349. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5350. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5351. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5352. designer.SetDataSource("Name", Names);
  5353. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5354. designer.SetDataSource("Day", dic["Day"] + "天");
  5355. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5356. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5357. int startIndex = 10;
  5358. const int startIndexcopy = 10;
  5359. if (dac2.Count == dac3.Count)//国家 币种 金额
  5360. {
  5361. for (int i = 0; i < dac2.Count; i++)
  5362. {
  5363. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5364. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5365. }
  5366. }
  5367. DataTable dtdac1 = new DataTable();
  5368. List<string> place = new List<string>();
  5369. dtdac1.Columns.AddRange(new DataColumn[] {
  5370. new DataColumn(){ ColumnName = "city"},
  5371. new DataColumn(){ ColumnName = "curr"},
  5372. new DataColumn(){ ColumnName = "criterion"},
  5373. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5374. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5375. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5376. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5377. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5378. });
  5379. DataTable dtdac2 = new DataTable();
  5380. dtdac2.Columns.AddRange(new DataColumn[] {
  5381. new DataColumn(){ ColumnName = "city"},
  5382. new DataColumn(){ ColumnName = "curr"},
  5383. new DataColumn(){ ColumnName = "criterion"},
  5384. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5385. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5386. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5387. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5388. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5389. });
  5390. dtdac1.TableName = "tb1";
  5391. dtdac2.TableName = "tb2";
  5392. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5393. foreach (var item in dac1)
  5394. {
  5395. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5396. if (place.Contains(item.Place))
  5397. {
  5398. continue;
  5399. }
  5400. DataRow row = dtdac1.NewRow();
  5401. row["city"] = item.Place;
  5402. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5403. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5404. row["curr"] = currency;
  5405. row["rate"] = rate.ToString("#0.0000");
  5406. row["criterion"] = item.Cost.ToString("#0.00");
  5407. row["number"] = 1;
  5408. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5409. //row["costRMB"] = rbmPrice;
  5410. dtdac1.Rows.Add(row);
  5411. place.Add(item.Place);
  5412. }
  5413. place = new List<string>();
  5414. foreach (var item in dac2)
  5415. {
  5416. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5417. if (place.Contains(item.Place))
  5418. {
  5419. continue;
  5420. }
  5421. DataRow row = dtdac2.NewRow();
  5422. row["city"] = item.Place;
  5423. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5424. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5425. row["curr"] = currency;
  5426. row["rate"] = rate.ToString("#0.0000");
  5427. row["criterion"] = item.Cost.ToString("#0.00");
  5428. row["number"] = 1;
  5429. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5430. //row["cost"] = item.SubTotal;
  5431. //row["costRMB"] = rbmPrice;
  5432. dtdac2.Rows.Add(row);
  5433. place.Add(item.Place);
  5434. //dac2totalPrice += rbmPrice;
  5435. }
  5436. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5437. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5438. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5439. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5440. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5441. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5442. string cell4Str1 = string.Empty;
  5443. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5444. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5445. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5446. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5447. string cellStr = $" 5.其他费用(";
  5448. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5449. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5450. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5451. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5452. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5453. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5454. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5455. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5456. foreach (var otherInfo in dac5)
  5457. {
  5458. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5459. }
  5460. #endregion
  5461. if (cellStr.Length > 8)
  5462. {
  5463. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5464. }
  5465. cellStr += ")";
  5466. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5467. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5468. decimal pxFee = dac4.Sum(it => it.Cost);
  5469. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5470. string celllastStr1 = "";
  5471. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5472. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5473. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5474. celllastStr1 += $",国际旅费 元";
  5475. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5476. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5477. designer.SetDataSource("cell4Str", cell4Str);
  5478. designer.SetDataSource("cellStr", cellStr);
  5479. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5480. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5481. designer.SetDataSource("celllastStr", celllastStr);
  5482. Workbook wb = designer.Workbook;
  5483. var sheet = wb.Worksheets[0];
  5484. //绑定datatable数据集
  5485. designer.SetDataSource(dtdac1);
  5486. designer.SetDataSource(dtdac2);
  5487. designer.Process();
  5488. var rowStart = dtdac1.Rows.Count;
  5489. while (rowStart > 0)
  5490. {
  5491. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5492. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5493. startIndex++;
  5494. rowStart--;
  5495. }
  5496. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5497. startIndex += 1; //总计行
  5498. rowStart = dtdac2.Rows.Count;
  5499. while (rowStart > 0)
  5500. {
  5501. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5502. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5503. startIndex++;
  5504. rowStart--;
  5505. }
  5506. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5507. wb.CalculateFormula(true);
  5508. //模板文件名
  5509. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5510. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5511. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5512. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5513. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5514. }
  5515. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5516. {
  5517. //获取模板
  5518. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5519. //载入模板
  5520. Document doc = new Document(tempPath);
  5521. DocumentBuilder builder = new DocumentBuilder(doc);
  5522. Dictionary<string, string> dic = new Dictionary<string, string>();
  5523. dic.Add("GroupName", _DelegationInfo.TeamName);
  5524. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5525. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5526. string missionLeaderJob = "";//负责人job
  5527. int groupNumber = 0; //团人数
  5528. if (DeleClientList.Count > 0)
  5529. {
  5530. missionLeader = DeleClientList[0]?.Name ?? "";
  5531. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5532. }
  5533. dic.Add("MissionLeader", missionLeader); //团负责人
  5534. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5535. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5536. #region MyRegion
  5537. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5538. //{
  5539. // List<string> list = new List<string>();
  5540. // try
  5541. // {
  5542. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5543. // foreach (var item in spilitArr)
  5544. // {
  5545. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5546. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5547. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5548. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5549. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5550. // list.Add(depName);
  5551. // list.Add(arrName);
  5552. // }
  5553. // list = list.Distinct().ToList();
  5554. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5555. // }
  5556. // catch (Exception)
  5557. // {
  5558. // dic.Add("ReturnCode", "行程录入不正确!");
  5559. // }
  5560. //}
  5561. //else
  5562. //{
  5563. // dic.Add("ReturnCode", "未录入行程!");
  5564. //}
  5565. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5566. dic.Add("ReturnCode", string.Join("、", countrys));
  5567. #endregion
  5568. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5569. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5570. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5571. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5572. //{
  5573. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5574. // dic.Add("Day", sp.Days.ToString());
  5575. //}
  5576. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5577. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5578. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5579. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5580. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5581. //培训人员名单
  5582. int cultivateRowIndex = 7;
  5583. foreach (var item in DeleClientList)
  5584. {
  5585. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5586. builder.Write(item.Name);
  5587. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5588. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5589. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5590. string birthDay = "";
  5591. if (item.Birthday != null)
  5592. {
  5593. DateTime dt = Convert.ToDateTime(item.Birthday);
  5594. birthDay = $"{dt.Year}.{dt.Month}";
  5595. }
  5596. builder.Write(birthDay);
  5597. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5598. builder.Write(item.Company);
  5599. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5600. builder.Write(item.Job);
  5601. cultivateRowIndex++;
  5602. }
  5603. //删除多余行
  5604. //cultivateRowIndex -= 2;
  5605. int delRows = 10 + 7 - cultivateRowIndex;
  5606. if (delRows > 0)
  5607. {
  5608. for (int i = 0; i < delRows; i++)
  5609. {
  5610. table1.Rows.RemoveAt(cultivateRowIndex);
  5611. //cultivateRowIndex++;
  5612. }
  5613. }
  5614. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5615. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5616. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5617. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5618. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5619. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5620. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5621. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5622. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5623. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5624. //其他费用
  5625. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5626. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5627. //其他费用合计
  5628. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5629. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5630. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5631. //公务舱合计
  5632. //国际旅费
  5633. string outsideJJ = "";
  5634. string allPriceJJ = "";
  5635. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5636. {
  5637. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5638. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5639. }
  5640. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5641. {
  5642. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5643. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5644. }
  5645. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5646. {
  5647. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5648. dic.Add("AirFeeTotal", airFeeTotalStr);
  5649. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5650. dic.Add("FeeTotal", feeTotalStr);
  5651. }
  5652. foreach (var key in dic.Keys)
  5653. {
  5654. builder.MoveToBookmark(key);
  5655. builder.Write(dic[key]);
  5656. }
  5657. //模板文件名
  5658. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5659. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5660. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5661. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5662. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5663. }
  5664. }
  5665. else if (dto.ExportType == 2) //表格
  5666. {
  5667. //利用键值对存放数据
  5668. Dictionary<string, string> dic = new Dictionary<string, string>();
  5669. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5670. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5671. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5672. dic.Add("Day", sp.Days.ToString());
  5673. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5674. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5675. {
  5676. //获取模板
  5677. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5678. //载入模板
  5679. Document doc = new Document(tempPath);
  5680. DocumentBuilder builder = new DocumentBuilder(doc);
  5681. dic.Add("TeamName", _DelegationInfo.TeamName);
  5682. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5683. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5684. string missionLeaderName = "",
  5685. missionLeaderJob = "";
  5686. if (DeleClientList.Count > 0)
  5687. {
  5688. missionLeaderName = DeleClientList[0].Name;
  5689. missionLeaderJob = DeleClientList[0].Job;
  5690. }
  5691. dic.Add("MissionLeaderName", missionLeaderName);
  5692. dic.Add("MissionLeaderJob", missionLeaderJob);
  5693. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5694. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5695. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5696. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5697. int rowCount = 10;//总人数行
  5698. int startRowIndex = 7; //起始行
  5699. for (int i = 0; i < DeleClientList.Count; i++)
  5700. {
  5701. builder.MoveToCell(0, startRowIndex, 0, 0);
  5702. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5703. builder.MoveToCell(0, startRowIndex, 1, 0);
  5704. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5705. builder.Write(sex);//性别
  5706. builder.MoveToCell(0, startRowIndex, 2, 0);
  5707. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5708. builder.MoveToCell(0, startRowIndex, 3, 0);
  5709. builder.Write(DeleClientList[i].Company);//工作单位
  5710. builder.MoveToCell(0, startRowIndex, 4, 0);
  5711. builder.Write(DeleClientList[i].Job);//职务及级别
  5712. builder.MoveToCell(0, startRowIndex, 5, 0);
  5713. builder.Write("");//人员属性
  5714. builder.MoveToCell(0, startRowIndex, 6, 0);
  5715. builder.Write("");//上次出国时间
  5716. startRowIndex++;
  5717. }
  5718. int nullRow = rowCount - DeleClientList.Count;//空行
  5719. for (int i = 0; i < nullRow; i++)
  5720. {
  5721. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5722. }
  5723. foreach (var key in dic.Keys)
  5724. {
  5725. builder.MoveToBookmark(key);
  5726. builder.Write(dic[key]);
  5727. }
  5728. //模板文件名
  5729. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5730. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5731. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5732. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5733. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5734. }
  5735. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5736. {
  5737. //获取模板
  5738. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5739. //载入模板
  5740. Document doc = new Document(tempPath);
  5741. DocumentBuilder builder = new DocumentBuilder(doc);
  5742. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5743. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5744. dic.Add("Names", Names);
  5745. int accommodationRows = 12, foodandotherRows = 12;
  5746. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5747. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5748. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5749. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5750. int accommodationStartIndex = 6;
  5751. decimal dac1totalPrice = 0.00M;
  5752. foreach (var dac in dac1)
  5753. {
  5754. if (dac.SubTotal == 0)
  5755. {
  5756. continue;
  5757. }
  5758. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5759. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5760. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5761. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5762. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5763. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5764. builder.Write(currency);//币种
  5765. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5766. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5767. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5768. builder.Write("");//人数
  5769. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5770. builder.Write("");//天数
  5771. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5772. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5773. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5774. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5775. builder.Write(rate.ToString("#0.0000"));//汇率
  5776. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5777. decimal rbmPrice = rate * dac.SubTotal;
  5778. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5779. accommodationStartIndex++;
  5780. dac1totalPrice += rbmPrice;
  5781. }
  5782. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5783. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5784. builder.Write("小计");
  5785. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5786. builder.Write(dac1totalPrice.ToString("#0.00"));
  5787. accommodationStartIndex++;
  5788. int nullRow = accommodationRows - dac1.Count;
  5789. //删除空行
  5790. //if (nullRow > 0)
  5791. //{
  5792. // int rowIndex = accommodationStartIndex;
  5793. // for (int i = 0; i < nullRow; i++)
  5794. // {
  5795. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5796. // row.Remove();
  5797. // rowIndex++;
  5798. // }
  5799. //}
  5800. if (dac2.Count == dac3.Count)//国家 币种 金额
  5801. {
  5802. for (int i = 0; i < dac2.Count; i++)
  5803. {
  5804. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5805. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5806. }
  5807. }
  5808. int foodandotherStartIndex = 19;//
  5809. decimal dac2totalPrice = 0.00M;
  5810. foreach (var dac in dac2)
  5811. {
  5812. if (dac.SubTotal == 0)
  5813. {
  5814. continue;
  5815. }
  5816. //foodandotherStartIndex = 12;
  5817. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5818. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5819. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5820. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5821. builder.Write(currency);//币种
  5822. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5823. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5824. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5825. builder.Write("");//人数
  5826. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5827. builder.Write("");//天数
  5828. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5829. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5830. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5831. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5832. builder.Write(rate.ToString("#0.0000"));//汇率
  5833. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5834. decimal rbmPrice = rate * dac.SubTotal;
  5835. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5836. foodandotherStartIndex++;
  5837. dac2totalPrice += rbmPrice;
  5838. }
  5839. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5840. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5841. //删除空行
  5842. //if (dac2.Count < foodandotherRows)
  5843. //{
  5844. // while (table2.Rows.Count > dac2.Count)
  5845. // {
  5846. // table2.Rows.RemoveAt(dac2.Count);
  5847. // }
  5848. //}
  5849. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5850. string otherFeeStr = "";
  5851. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5852. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5853. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5854. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5855. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5856. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5857. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5858. foreach (var otherInfo in dac5)
  5859. {
  5860. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5861. }
  5862. #endregion
  5863. if (otherFeeStr.Length > 0)
  5864. {
  5865. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5866. otherFeeStr = $"({otherFeeStr})";
  5867. dic.Add("OtherFeeStr", otherFeeStr);
  5868. }
  5869. foreach (var key in dic.Keys)
  5870. {
  5871. builder.MoveToBookmark(key);
  5872. builder.Write(dic[key]);
  5873. }
  5874. //模板文件名
  5875. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5876. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5877. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5878. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5879. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5880. }
  5881. }
  5882. else if (dto.ExportType == 3)
  5883. {
  5884. if (dto.SubTypeId == 1) //团组成员名单
  5885. {
  5886. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  5887. //获取模板
  5888. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5889. //载入模板
  5890. Document doc = new Document(tempPath);
  5891. DocumentBuilder builder = new DocumentBuilder(doc);
  5892. //获取word里所有表格
  5893. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5894. //获取所填表格的序数
  5895. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5896. var rowStart = tableOne.Rows[0]; //获取第1行
  5897. //循环赋值
  5898. for (int i = 0; i < DeleClientList.Count; i++)
  5899. {
  5900. builder.MoveToCell(0, i + 1, 0, 0);
  5901. builder.Write(DeleClientList[i].Name);
  5902. builder.MoveToCell(0, i + 1, 1, 0);
  5903. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5904. builder.Write(sex);
  5905. builder.MoveToCell(0, i + 1, 2, 0);
  5906. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5907. builder.MoveToCell(0, i + 1, 3, 0);
  5908. builder.Write(DeleClientList[i].Company);
  5909. builder.MoveToCell(0, i + 1, 4, 0);
  5910. builder.Write(DeleClientList[i].Job);
  5911. }
  5912. //删除多余行
  5913. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5914. {
  5915. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5916. }
  5917. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5918. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5919. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5920. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5921. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5922. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5923. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5924. }
  5925. }
  5926. return Ok(JsonView(400, "操作失败!", ""));
  5927. }
  5928. catch (Exception ex)
  5929. {
  5930. return Ok(JsonView(400, ex.Message, ""));
  5931. }
  5932. }
  5933. /// <summary>
  5934. /// 获取三公费用标准city
  5935. /// </summary>
  5936. /// <param name="placeData"></param>
  5937. /// <param name="nationalTravelFeeId"></param>
  5938. /// <returns></returns>
  5939. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5940. {
  5941. string _city = string.Empty;
  5942. if (placeData.Count < 1) return _city;
  5943. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5944. if (data == null) return _city;
  5945. string country = data.Country;
  5946. string city = data.City;
  5947. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5948. else _city = city;
  5949. return _city;
  5950. }
  5951. /// <summary>
  5952. /// 团组模块 - 出入境费用 - 明细表导出
  5953. /// </summary>
  5954. /// <returns></returns>
  5955. [HttpPost]
  5956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5957. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5958. {
  5959. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5960. if (data.Code != 0)
  5961. {
  5962. return Ok(JsonView(false, data.Msg));
  5963. }
  5964. return Ok(JsonView(true, data.Msg, data.Data));
  5965. }
  5966. /// <summary>
  5967. /// 团组模块 - 出入境费用 - 一键清空
  5968. /// </summary>
  5969. /// <returns></returns>
  5970. [HttpPost]
  5971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5972. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5973. {
  5974. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5975. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5976. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5977. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5978. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5979. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5980. .SetColumns(x => new Grp_DayOtherPrice
  5981. {
  5982. IsDel = 1,
  5983. DeleteUserId = dto.UserId,
  5984. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5985. })
  5986. .ExecuteCommandAsync();
  5987. if (_view.Code == 0)
  5988. {
  5989. return Ok(JsonView(true, "操作成功"));
  5990. }
  5991. return Ok(JsonView(false, "操作失败"));
  5992. }
  5993. /// <summary>
  5994. /// 团组模块 - 出入境费用 - 子项删除
  5995. /// </summary>
  5996. /// <returns></returns>
  5997. [HttpPost]
  5998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5999. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6000. {
  6001. try
  6002. {
  6003. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6004. if (data.Code != 0)
  6005. {
  6006. return Ok(JsonView(false, data.Msg));
  6007. }
  6008. return Ok(JsonView(true, "操作成功!", data.Data));
  6009. }
  6010. catch (Exception ex)
  6011. {
  6012. return Ok(JsonView(false, ex.Message));
  6013. }
  6014. }
  6015. /// <summary>
  6016. /// 删除三公其他费用
  6017. /// </summary>
  6018. /// <param name="dto"></param>
  6019. /// <returns></returns>
  6020. [HttpPost]
  6021. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6022. {
  6023. var jw = JsonView(false,"删除失败!");
  6024. var data = new Grp_DayOtherPrice()
  6025. {
  6026. Id = dto.Id,
  6027. IsDel = 1,
  6028. DeleteUserId = dto.DeleteUserId,
  6029. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6030. };
  6031. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6032. if (del > 0)
  6033. {
  6034. jw.Code = 200;
  6035. jw.Msg = "删除成功!";
  6036. }
  6037. return Ok(jw);
  6038. }
  6039. /// <summary>
  6040. /// 团组模块 - 出入境国家费用标准 List
  6041. /// </summary>
  6042. /// <returns></returns>
  6043. [HttpPost]
  6044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6045. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6046. {
  6047. try
  6048. {
  6049. Stopwatch sw = new Stopwatch();
  6050. sw.Start();
  6051. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6052. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6053. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6054. Where gntf.Isdel = 0");
  6055. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6056. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6057. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6058. //foreach (var item in nationalTravel)
  6059. //{
  6060. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6061. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6062. // if (otherData != null)
  6063. // {
  6064. // cityData.Remove(otherData);
  6065. // cityData.Add(otherData);
  6066. // }
  6067. // nationalTravelFeeData1.Add(new
  6068. // {
  6069. // Country = item.Country,
  6070. // CityData = cityData
  6071. // });
  6072. //}
  6073. sw.Stop();
  6074. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6075. }
  6076. catch (Exception ex)
  6077. {
  6078. return Ok(JsonView(false, ex.Message));
  6079. throw;
  6080. }
  6081. }
  6082. /// <summary>
  6083. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6084. /// </summary>
  6085. /// <returns></returns>
  6086. [HttpPost]
  6087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6088. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6089. {
  6090. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6091. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6092. List<string> countryData = new List<string>();
  6093. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6094. countryData = countryData.Distinct().ToList();
  6095. List<dynamic> dataSource = new List<dynamic>();
  6096. foreach (var item in countryData)
  6097. {
  6098. List<string> cityData1 = new List<string>();
  6099. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6100. var countryData2 = new
  6101. {
  6102. CountryName = item,
  6103. CityData = cityData1
  6104. };
  6105. dataSource.Add(countryData2);
  6106. }
  6107. return Ok(JsonView(true, "查询成功!", dataSource));
  6108. }
  6109. /// <summary>
  6110. /// 团组模块 - 出入境国家费用标准 Page List
  6111. /// </summary>
  6112. /// <returns></returns>
  6113. [HttpPost]
  6114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6115. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6116. {
  6117. int portId = dto.PortType;
  6118. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6119. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6120. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6121. string whereSql = string.Empty;
  6122. if (!string.IsNullOrEmpty(dto.Country))
  6123. {
  6124. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6125. }
  6126. if (!string.IsNullOrEmpty(dto.City))
  6127. {
  6128. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6129. }
  6130. string pageSql = string.Format(@"Select * From (
  6131. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6132. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6133. From Grp_NationalTravelFee gntf
  6134. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6135. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6136. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6137. RefAsync<int> total = 0;
  6138. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6139. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6140. }
  6141. /// <summary>
  6142. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6143. /// </summary>
  6144. /// <returns></returns>
  6145. [HttpPost]
  6146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6147. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6148. {
  6149. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6150. int portId = dto.PortType;
  6151. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6152. string whereSql = string.Empty;
  6153. if (!string.IsNullOrEmpty(dto.Country))
  6154. {
  6155. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6156. }
  6157. if (!string.IsNullOrEmpty(dto.City))
  6158. {
  6159. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6160. }
  6161. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6162. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6163. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6164. From Grp_NationalTravelFee gntf
  6165. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6166. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6167. Where gntf.Isdel = 0 {0} ", whereSql);
  6168. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6169. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6170. }
  6171. /// <summary>
  6172. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6173. /// </summary>
  6174. /// <returns></returns>
  6175. [HttpPost]
  6176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6177. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6178. {
  6179. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6180. if (data.Code != 0)
  6181. {
  6182. return Ok(JsonView(false, data.Msg));
  6183. }
  6184. return Ok(JsonView(true, "操作成功!", data.Data));
  6185. }
  6186. /// <summary>
  6187. /// 团组模块 - 出入境国家费用标准 - Del
  6188. /// </summary>
  6189. /// <returns></returns>
  6190. [HttpPost]
  6191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6192. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6193. {
  6194. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6195. {
  6196. Id = dto.Id,
  6197. DeleteUserId = dto.DeleteUserId,
  6198. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6199. IsDel = 1
  6200. };
  6201. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6202. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6203. .WhereColumns(it => new { it.Id })
  6204. .ExecuteCommandAsync();
  6205. if (delStatus <= 0)
  6206. {
  6207. return Ok(JsonView(false, "删除失败!"));
  6208. }
  6209. return Ok(JsonView(true, "操作成功!"));
  6210. }
  6211. /// <summary>
  6212. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6213. /// 注:Get 请求Headers 加 Token
  6214. /// </summary>
  6215. /// <param name="groupId"></param>
  6216. /// <returns></returns>
  6217. [HttpGet("{groupId}")]
  6218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6219. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6220. {
  6221. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6222. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6223. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6224. data.ForEach(x =>
  6225. {
  6226. x.CreateUserId = _currUserInfo.UserId;
  6227. });
  6228. if (data.Any())
  6229. {
  6230. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6231. if (add > 0)
  6232. {
  6233. return Ok(JsonView(true, "操作成功!"));
  6234. }
  6235. }
  6236. return Ok(JsonView(false, "未操作!"));
  6237. }
  6238. #endregion
  6239. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6240. /// <summary>
  6241. /// 获取币种基础数据(含逻辑处理)
  6242. /// </summary>
  6243. /// <returns></returns>
  6244. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  6245. {
  6246. //默认币种显示
  6247. var _currencyInfos = _currencyInit;
  6248. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6249. if (_currencyRate.Count > 0)
  6250. {
  6251. foreach (var item in _currencyInfos)
  6252. {
  6253. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6254. if (rateInfo != null)
  6255. {
  6256. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6257. rate1 *= 1.035M;
  6258. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6259. }
  6260. }
  6261. }
  6262. return _currencyInfos;
  6263. }
  6264. /// <summary>
  6265. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6266. /// </summary>
  6267. /// <returns></returns>
  6268. [HttpPost]
  6269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6270. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  6271. {
  6272. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6273. //SetDataInfoView
  6274. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6275. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6276. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6277. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6278. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6279. //默认币种显示
  6280. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  6281. return Ok(JsonView(true, "查询成功!", new
  6282. {
  6283. WordTypeData = _WordTypeData,
  6284. ExcelTypeData = _ExcelTypeData,
  6285. CurrencyInit = _currencyInfos
  6286. }));
  6287. }
  6288. /// <summary>
  6289. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6290. /// </summary>
  6291. /// <returns></returns>
  6292. [HttpPost]
  6293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6294. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6295. {
  6296. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6297. RefAsync<int> total = 0;
  6298. int diId = 0;
  6299. var status = int.TryParse(dto.GroupName, out diId);
  6300. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6301. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6302. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  6303. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  6304. .Select(x => new
  6305. {
  6306. Id = x.Id,
  6307. GroupName = x.TeamName
  6308. })
  6309. .OrderByDescending(x => x.Id)
  6310. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6311. return Ok(JsonView(true, "查询成功!", data, total));
  6312. }
  6313. /// <summary>
  6314. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6315. /// </summary>
  6316. /// <returns></returns>
  6317. [HttpPost]
  6318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6319. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6320. {
  6321. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6322. RefAsync<int> total = 0;
  6323. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6324. .Where(x => x.IsDel == 0 && x.STid == 66)
  6325. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6326. .Select(x => new
  6327. {
  6328. id = x.Id,
  6329. name = x.Name,
  6330. remark = x.Remark,
  6331. })
  6332. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6333. return Ok(JsonView(true, "查询成功!", data, total));
  6334. }
  6335. /// <summary>
  6336. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  6337. /// </summary>
  6338. /// <returns></returns>
  6339. [HttpPost]
  6340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6341. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  6342. {
  6343. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6344. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6345. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  6346. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  6347. var groupOtherRateData = groupRateData.TeamRates;
  6348. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6349. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  6350. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  6351. groupOtherRateData = groupOtherRateData
  6352. .Select(x => new TeamRateDescAddCurrencyIdView {
  6353. CurrencyId = x.CurrencyId,
  6354. CurrencyName = x.CurrencyName,
  6355. CurrencyCode = x.CurrencyCode,
  6356. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  6357. }).ToList();
  6358. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  6359. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  6360. }
  6361. /// <summary>
  6362. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6363. /// </summary>
  6364. /// <returns></returns>
  6365. [HttpPost]
  6366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6367. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6368. {
  6369. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6370. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6371. var tipsData = new List<int>() {1,2,3 };
  6372. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6373. if (dto.TipsType == 1)
  6374. {
  6375. //默认币种显示
  6376. var _currencyInfos = _currencyInit;
  6377. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6378. List<dynamic> reteInfos = new List<dynamic>();
  6379. if (_currencyRate.Count > 0)
  6380. {
  6381. foreach (var item in _currencyInfos)
  6382. {
  6383. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6384. if (rateInfo != null)
  6385. {
  6386. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6387. decimal rate1 = item.Rate;
  6388. rate1 *= 1.03M;
  6389. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6390. reteInfos.Add(new
  6391. {
  6392. currCode = item.CurrencyCode,
  6393. currName = item.CurrencyName,
  6394. rate = rate2,
  6395. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6396. });
  6397. }
  6398. }
  6399. }
  6400. return Ok(JsonView(true, "查询成功!", reteInfos));
  6401. }
  6402. else if (dto.TipsType == 2)
  6403. {
  6404. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6405. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6406. }
  6407. else if (dto.TipsType == 3)
  6408. {
  6409. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6410. return Ok(JsonView(true, "查询成功!", airData.Data));
  6411. }
  6412. return Ok(JsonView(false));
  6413. }
  6414. /// <summary>
  6415. /// 团组模块 - 出入境国家费用标准-移动端 List
  6416. /// </summary>
  6417. /// <returns></returns>
  6418. [HttpPost]
  6419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6420. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6421. {
  6422. Stopwatch sw = new Stopwatch();
  6423. sw.Start();
  6424. RefAsync<int> total = 0;
  6425. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6426. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6427. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6428. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6429. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6430. .Select((ntf, sd, u) => new
  6431. {
  6432. Id = ntf.Id,
  6433. Area = $"{ntf.Country}-{ntf.City}",
  6434. Currency = ntf.Currency,
  6435. CurrencyCode = sd.Name,
  6436. CurrencyName = sd.Remark,
  6437. RoomCost = ntf.RoomCost,
  6438. FoodCost = ntf.FoodCost,
  6439. PublicCost = ntf.PublicCost,
  6440. LastUpdateUserId = ntf.LastUpdateUserId,
  6441. LastUpdateUserName = u.CnName,
  6442. LastUpdateTime = ntf.LastUpdateTime,
  6443. })
  6444. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6445. sw.Stop();
  6446. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6447. }
  6448. /// <summary>
  6449. /// 团组模块 - 出入境费用-移动端 - Info
  6450. /// </summary>
  6451. /// <returns></returns>
  6452. [HttpPost]
  6453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6454. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  6455. {
  6456. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6457. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6458. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  6459. return Ok(data);
  6460. }
  6461. /// <summary>
  6462. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  6463. /// </summary>
  6464. /// <returns></returns>
  6465. [HttpPost]
  6466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6467. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  6468. {
  6469. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6470. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6471. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6472. var mobileInfo = new EnterExitCostMobileParentInfoView();
  6473. mobileInfo.DiId = dto.DiId;
  6474. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  6475. if (eecInfo == null) return Ok(mobileInfo);
  6476. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  6477. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  6478. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6479. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6480. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6481. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6482. {
  6483. SubId = dac.Id,
  6484. DiId = dac.DiId,
  6485. Type = dac.Type,
  6486. Days = dac.Days,
  6487. NationalTravelFeeId = dac.NationalTravelFeeId,
  6488. Arae = $"{ntf.Country}-{ntf.City}",
  6489. Cost = dac.Cost,
  6490. Currency = dac.Currency,
  6491. CurrencyName = sd.Name,
  6492. SubTotal = dac.SubTotal,
  6493. })
  6494. .ToList();
  6495. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  6496. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  6497. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  6498. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  6499. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  6500. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  6501. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  6502. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  6503. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  6504. //其他款项
  6505. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6506. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6507. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6508. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6509. .OrderBy((dop, sd1, sd2) => dop.Index)
  6510. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6511. {
  6512. SubId = dop.Id,
  6513. DiId = dop.Diid,
  6514. Index = dop.Index,
  6515. SetDataId = dop.SetDataId,
  6516. SetDataName = sd1.Name,
  6517. Cost = dop.Cost,
  6518. Currency = dop.Currency,
  6519. CurrencyName = sd2.Remark,
  6520. SubTotal = dop.SubTotal,
  6521. Remark = dop.Remark,
  6522. })
  6523. .ToArray();
  6524. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  6525. return Ok(mobileInfo);
  6526. }
  6527. /// <summary>
  6528. /// 团组模块 - 出入境费用-移动端 - SubInfo
  6529. /// </summary>
  6530. /// <returns></returns>
  6531. [HttpPost]
  6532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6533. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  6534. {
  6535. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6536. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6537. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  6538. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  6539. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6540. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  6541. var subType = dto.SubType;
  6542. if (subType == 1) //1:境内费用
  6543. {
  6544. var oneData = new ChoiceOneMobileSubInfoView()
  6545. {
  6546. Id = eecInfo.Id,
  6547. ChoiceOne = eecInfo.ChoiceOne,
  6548. ChoiceOneTotalCost = eecInfo.InsidePay,
  6549. Visa = eecInfo.Visa,
  6550. VisaRemark = eecInfo.VisaRemark,
  6551. YiMiao = eecInfo.YiMiao,
  6552. HeSuan = eecInfo.HeSuan,
  6553. Service = eecInfo.Service,
  6554. Ticket = eecInfo.Ticket,
  6555. Safe = eecInfo.Safe,
  6556. };
  6557. return Ok(JsonView(oneData));
  6558. }
  6559. else if (subType == 2) //2:国际旅费
  6560. {
  6561. var twoData = new ChoiceTwoMobileSubInfoView() {
  6562. Id = eecInfo.Id,
  6563. ChoiceTwoJJ = eecInfo.SumJJC,
  6564. OutsideJJPay = eecInfo.OutsideJJPay,
  6565. ChoiceTwoGW = eecInfo.SumGWC,
  6566. OutsideGWPay = eecInfo.OutsideGWPay,
  6567. ChoiceTwoTD = eecInfo.SumTDC,
  6568. OutsideTDPay = eecInfo.OutsideTDPay,
  6569. AirJJ = eecInfo.AirJJ,
  6570. AirGW = eecInfo.AirGW,
  6571. AirTD = eecInfo.AirTD,
  6572. CityTranffic = eecInfo.CityTranffic
  6573. };
  6574. return Ok(JsonView(twoData));
  6575. }
  6576. else if (subType == 3) //3:住宿费
  6577. {
  6578. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6579. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6580. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6581. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  6582. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6583. {
  6584. SubId = dac.Id,
  6585. DiId = dac.DiId,
  6586. Type = dac.Type,
  6587. Days = dac.Days,
  6588. NationalTravelFeeId = dac.NationalTravelFeeId,
  6589. Arae = $"{ntf.Country}-{ntf.City}",
  6590. Cost = dac.Cost,
  6591. Currency = dac.Currency,
  6592. CurrencyName = sd.Name,
  6593. SubTotal = dac.SubTotal,
  6594. })
  6595. .ToArray();
  6596. var data = new ChoiceMobileSubInfo3To6View() {
  6597. ParentId = eecInfo.Id,
  6598. Choice = eecInfo.ChoiceThree,
  6599. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6600. Details = dayAndCostDatas
  6601. };
  6602. return Ok(JsonView(data));
  6603. }
  6604. else if (subType == 4) //4:伙食费
  6605. {
  6606. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6607. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6608. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6609. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  6610. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6611. {
  6612. SubId = dac.Id,
  6613. DiId = dac.DiId,
  6614. Type = dac.Type,
  6615. Days = dac.Days,
  6616. NationalTravelFeeId = dac.NationalTravelFeeId,
  6617. Arae = $"{ntf.Country}-{ntf.City}",
  6618. Cost = dac.Cost,
  6619. Currency = dac.Currency,
  6620. CurrencyName = sd.Name,
  6621. SubTotal = dac.SubTotal,
  6622. })
  6623. .ToArray();
  6624. var data = new ChoiceMobileSubInfo3To6View()
  6625. {
  6626. ParentId = eecInfo.Id,
  6627. Choice = eecInfo.ChoiceFour,
  6628. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6629. Details = dayAndCostDatas
  6630. };
  6631. return Ok(JsonView(data));
  6632. }
  6633. else if (subType == 5) //5:公杂费
  6634. {
  6635. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6636. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6637. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6638. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  6639. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6640. {
  6641. SubId = dac.Id,
  6642. DiId = dac.DiId,
  6643. Type = dac.Type,
  6644. Days = dac.Days,
  6645. NationalTravelFeeId = dac.NationalTravelFeeId,
  6646. Arae = $"{ntf.Country}-{ntf.City}",
  6647. Cost = dac.Cost,
  6648. Currency = dac.Currency,
  6649. CurrencyName = sd.Name,
  6650. SubTotal = dac.SubTotal,
  6651. })
  6652. .ToArray();
  6653. var data = new ChoiceMobileSubInfo3To6View()
  6654. {
  6655. ParentId = eecInfo.Id,
  6656. Choice = eecInfo.ChoiceFive,
  6657. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6658. Details = dayAndCostDatas
  6659. };
  6660. return Ok(JsonView(data));
  6661. }
  6662. else if (subType == 6) //6:培训费
  6663. {
  6664. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6665. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6666. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6667. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  6668. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6669. {
  6670. SubId = dac.Id,
  6671. DiId = dac.DiId,
  6672. Type = dac.Type,
  6673. Days = dac.Days,
  6674. NationalTravelFeeId = dac.NationalTravelFeeId,
  6675. Arae = $"{ntf.Country}-{ntf.City}",
  6676. Cost = dac.Cost,
  6677. Currency = dac.Currency,
  6678. CurrencyName = sd.Name,
  6679. SubTotal = dac.SubTotal,
  6680. })
  6681. .ToArray();
  6682. var data = new ChoiceMobileSubInfo3To6View()
  6683. {
  6684. ParentId = eecInfo.Id,
  6685. Choice = eecInfo.ChoiceSix,
  6686. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6687. Details = dayAndCostDatas
  6688. };
  6689. return Ok(JsonView(data));
  6690. }
  6691. else if (subType == 7) //7:其他
  6692. {
  6693. //其他款项
  6694. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6695. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6696. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6697. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6698. .OrderBy((dop, sd1, sd2) => dop.Index)
  6699. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6700. {
  6701. SubId = dop.Id,
  6702. DiId = dop.Diid,
  6703. Index = dop.Index,
  6704. SetDataId = dop.SetDataId,
  6705. SetDataName = sd1.Name,
  6706. Cost = dop.Cost,
  6707. Currency = dop.Currency,
  6708. CurrencyName = sd2.Name,
  6709. SubTotal = dop.SubTotal,
  6710. Remark = dop.Remark,
  6711. })
  6712. .ToArray();
  6713. var data = new ChoiceSevenMobileSubInfoView()
  6714. {
  6715. ParentId = eecInfo.Id,
  6716. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  6717. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  6718. Details = otherData
  6719. };
  6720. return Ok(JsonView(data));
  6721. }
  6722. return Ok(JsonView(false));
  6723. }
  6724. #region op
  6725. /// <summary>
  6726. /// 移动端更新费用消息通知
  6727. /// </summary>
  6728. /// <param name="diid"></param>
  6729. /// <param name="id"></param>
  6730. /// <param name="currUserId"></param>
  6731. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  6732. {
  6733. try
  6734. {
  6735. ////生成默认文件pdf并且通知人员
  6736. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6737. //{
  6738. // DiId = diid,
  6739. // ExportType = 1,
  6740. // SubTypeId = 1005
  6741. //}, "pdf");
  6742. ////发送通知
  6743. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6744. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  6745. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  6746. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  6747. ////汇率信息记录
  6748. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  6749. }
  6750. catch (Exception ex)
  6751. {
  6752. //记录日志
  6753. throw;
  6754. }
  6755. }
  6756. /// <summary>
  6757. /// 验证出入境费用数据是否存在
  6758. /// 不存在添加
  6759. /// </summary>
  6760. /// <param name="diId"></param>
  6761. /// <param name="currUserId"></param>
  6762. /// <returns></returns>
  6763. /// <exception cref="CustomException"></exception>
  6764. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  6765. {
  6766. var parentId = 0;
  6767. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  6768. if (info != null) parentId = info.Id;
  6769. else
  6770. {
  6771. var currencys = await EnterExitCostMobileGetCurrencyInit();
  6772. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  6773. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  6774. parentId = addId;
  6775. }
  6776. return parentId;
  6777. }
  6778. /// <summary>
  6779. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  6780. /// </summary>
  6781. /// <returns></returns>
  6782. [HttpPost]
  6783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6784. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  6785. {
  6786. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6787. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6788. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6789. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  6790. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  6791. int id = dto.Id;
  6792. if (id <= 0) //add
  6793. {
  6794. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  6795. if (add < 1) return Ok(JsonView(false));
  6796. id = add;
  6797. }
  6798. else //update
  6799. {
  6800. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  6801. if (upd < 1) return Ok(JsonView(false));
  6802. }
  6803. #region 汇率变更时更改币种相关费用
  6804. var opDayCosts = new List<Grp_DayAndCost>();
  6805. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  6806. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  6807. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  6808. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  6809. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6810. .Select((dac, sd) => new {
  6811. dac.Id,
  6812. dac.DiId,
  6813. CurrencyCode = sd.Name,
  6814. dac.Cost
  6815. })
  6816. .ToList();
  6817. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6818. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  6819. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6820. .Select((dop, sd) => new {
  6821. dop.Id,
  6822. dop.Diid,
  6823. CurrencyCode = sd.Name,
  6824. dop.Cost
  6825. })
  6826. .ToList();
  6827. if (dayCosts.Count > 0)
  6828. {
  6829. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6830. foreach (var dc in new_dayCosts)
  6831. {
  6832. var thisCurrency = dc.Key.ToUpper();
  6833. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6834. if (thisRate == 0.00M) continue;
  6835. foreach (var dcSub in dc)
  6836. {
  6837. opDayCosts.Add(new Grp_DayAndCost() {
  6838. Id = dcSub.Id,
  6839. DiId = dcSub.DiId,
  6840. Cost = dcSub.Cost,
  6841. SubTotal = dcSub.Cost * thisRate,
  6842. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6843. });
  6844. }
  6845. }
  6846. if (opDayCosts.Count > 0)
  6847. {
  6848. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6849. }
  6850. }
  6851. if (dayOtherCosts.Count > 0)
  6852. {
  6853. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6854. foreach (var dc in new_dayOtherCosts)
  6855. {
  6856. var thisCurrency = dc.Key.ToUpper();
  6857. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6858. if (thisRate == 0.00M) continue;
  6859. foreach (var dcSub in dc)
  6860. {
  6861. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  6862. {
  6863. Id = dcSub.Id,
  6864. Diid = dcSub.Diid,
  6865. Cost = dcSub.Cost,
  6866. SubTotal = dcSub.Cost * thisRate,
  6867. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6868. });
  6869. }
  6870. }
  6871. if (opDayOtherCosts.Count > 0)
  6872. {
  6873. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6874. }
  6875. }
  6876. #endregion
  6877. //消息通知
  6878. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  6879. //汇率信息记录
  6880. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  6881. return Ok(JsonView(new { parentId = id }));
  6882. }
  6883. /// <summary>
  6884. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  6885. /// </summary>
  6886. /// <returns></returns>
  6887. [HttpPost]
  6888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6889. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  6890. {
  6891. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6892. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6893. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6894. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  6895. int id = dto.Id;
  6896. if (id <= 0) //add
  6897. {
  6898. checkboxInfo.CreateUserId = dto.CurrUserId;
  6899. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  6900. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6901. if (add < 1) return Ok(JsonView(false));
  6902. }
  6903. else //update
  6904. {
  6905. var upd = await _sqlSugar.Updateable(checkboxInfo)
  6906. .UpdateColumns(x => new {
  6907. x.ChoiceOne,
  6908. x.ChoiceTwo,
  6909. x.SumJJC,
  6910. x.SumGWC,
  6911. x.SumTDC,
  6912. x.ChoiceThree,
  6913. x.ChoiceFour,
  6914. x.ChoiceFive,
  6915. x.ChoiceSix,
  6916. x.OtherExpenses_Checked
  6917. })
  6918. .Where(x => x.Id == id)
  6919. .ExecuteCommandAsync();
  6920. if (upd < 1) return Ok(JsonView(false));
  6921. }
  6922. return Ok(JsonView(new { parentId = id }));
  6923. }
  6924. /// <summary>
  6925. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  6926. /// </summary>
  6927. /// <returns></returns>
  6928. [HttpPost]
  6929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6930. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  6931. {
  6932. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  6933. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  6934. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6935. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6936. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6937. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  6938. var checkboxInfo = new Grp_EnterExitCost() {
  6939. Id = id,
  6940. DiId = diId,
  6941. CreateUserId = currUserId
  6942. };
  6943. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  6944. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  6945. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  6946. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  6947. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  6948. if (id <= 0) //add
  6949. {
  6950. checkboxInfo.CreateUserId = dto.CurrUserId;
  6951. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  6952. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6953. if (add < 1) return Ok(JsonView(false));
  6954. }
  6955. else //update
  6956. {
  6957. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  6958. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  6959. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  6960. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  6961. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  6962. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  6963. .Where(x => x.Id == id)
  6964. .ExecuteCommandAsync();
  6965. if (upd < 1) return Ok(JsonView(false));
  6966. }
  6967. return Ok(JsonView(new { parentId = id }));
  6968. }
  6969. /// <summary>
  6970. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  6971. /// </summary>
  6972. /// <returns></returns>
  6973. [HttpPost]
  6974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6975. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  6976. {
  6977. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6978. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6979. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6980. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6981. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  6982. int id = dto.Id;
  6983. if (id <= 0) //add
  6984. {
  6985. info.CreateUserId = dto.CurrUserId;
  6986. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  6987. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  6988. if (add < 1) return Ok(JsonView(false));
  6989. id = add;
  6990. }
  6991. else //update
  6992. {
  6993. var upd = await _sqlSugar.Updateable(info)
  6994. .UpdateColumns(x => new {
  6995. x.ChoiceOne,
  6996. x.InsidePay,
  6997. x.VisaRemark,
  6998. x.Visa,
  6999. x.Service,
  7000. x.Safe,
  7001. x.Ticket,
  7002. x.HeSuan,
  7003. x.YiMiao,
  7004. })
  7005. .Where(x => x.Id == id)
  7006. .ExecuteCommandAsync();
  7007. if (upd < 1) return Ok(JsonView(false));
  7008. }
  7009. //消息通知
  7010. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7011. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  7012. }
  7013. /// <summary>
  7014. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  7015. /// </summary>
  7016. /// <returns></returns>
  7017. [HttpPost]
  7018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7019. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  7020. {
  7021. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7022. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7023. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7024. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  7025. info.OutsideJJPay = dto.OutsideJJPay;
  7026. info.OutsideGWPay = dto.OutsideGWPay;
  7027. info.OutsideTDPay = dto.OutsideTDPay;
  7028. info.AirJJ = dto.AirJJ;
  7029. info.AirGW = dto.AirGW;
  7030. info.AirTD = dto.AirTD;
  7031. info.CityTranffic = dto.CityTranffic;
  7032. info.SumJJC = dto.ChoiceTwoJJ;
  7033. info.SumGWC = dto.ChoiceTwoGW;
  7034. info.SumTDC = dto.ChoiceTwoTD;
  7035. int id = dto.Id;
  7036. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  7037. if (id <= 0) //add
  7038. {
  7039. info.CreateUserId = dto.CurrUserId;
  7040. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  7041. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  7042. if (addId <= 0) return Ok(JsonView(false));
  7043. id = addId;
  7044. }
  7045. else //update
  7046. {
  7047. var upd = await _sqlSugar.Updateable(info)
  7048. .UpdateColumns(x => new {
  7049. x.SumJJC,
  7050. x.OutsideJJPay,
  7051. x.SumGWC,
  7052. x.OutsideGWPay,
  7053. x.SumTDC,
  7054. x.OutsideTDPay,
  7055. x.AirJJ,
  7056. x.AirGW,
  7057. x.AirTD,
  7058. x.CityTranffic
  7059. })
  7060. .Where(x => x.Id == id)
  7061. .ExecuteCommandAsync();
  7062. if (upd <1) return Ok(JsonView(false));
  7063. }
  7064. jjcItemTotal = info.AirJJ + info.CityTranffic;
  7065. gwcItemTotal = info.AirGW + info.CityTranffic;
  7066. tdcItemTotal = info.AirTD + info.CityTranffic;
  7067. //消息通知
  7068. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7069. return Ok(JsonView(new
  7070. {
  7071. parentId = id,
  7072. choiceTwoJJ = dto.ChoiceTwoJJ,
  7073. jjcItemTotal = jjcItemTotal,
  7074. choiceTwoGW = dto.ChoiceTwoGW,
  7075. gwcItemTotal = gwcItemTotal,
  7076. choiceTwoTD = dto.ChoiceTwoTD,
  7077. tdcItemTotal = tdcItemTotal
  7078. }));
  7079. }
  7080. /// <summary>
  7081. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  7082. /// </summary>
  7083. /// <returns></returns>
  7084. [HttpPost]
  7085. [ApiExplorerSettings(IgnoreApi = true)]
  7086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7087. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  7088. {
  7089. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7090. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7091. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7092. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  7093. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  7094. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7095. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  7096. var infos = infos1.Select(x => new Grp_DayAndCost
  7097. {
  7098. Id = x.Id,
  7099. DiId = dto.DiId,
  7100. Type = dto.FeeType,
  7101. Days = x.Days,
  7102. NationalTravelFeeId = x.NationalTravelFeeId,
  7103. Cost = x.Cost,
  7104. Currency = x.Currency,
  7105. SubTotal = x.SubTotal,
  7106. CreateUserId = dto.CurrUserId
  7107. })
  7108. .ToList();
  7109. var adds = infos.Where(x => x.Id <= 0).ToList();
  7110. var upds = infos.Where(x => x.Id > 0).ToList();
  7111. if (adds.Count > 0)
  7112. {
  7113. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7114. if (add < 1) return Ok(JsonView(false));
  7115. }
  7116. if (upds.Count > 0)
  7117. {
  7118. var upd = await _sqlSugar.Updateable(adds)
  7119. .UpdateColumns(x => new
  7120. {
  7121. x.Days,
  7122. x.NationalTravelFeeId,
  7123. x.Cost,
  7124. x.Currency,
  7125. x.SubTotal
  7126. })
  7127. .WhereColumns(x => new { x.Id })
  7128. .ExecuteCommandAsync();
  7129. if (upd < 1) return Ok(JsonView(false));
  7130. }
  7131. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7132. //消息通知
  7133. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7134. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7135. return Ok(JsonView(new { itemTotal = itemTotal }));
  7136. }
  7137. /// <summary>
  7138. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  7139. /// </summary>
  7140. /// <returns></returns>
  7141. [HttpPost]
  7142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7143. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  7144. {
  7145. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  7146. int subId = dto.SubId, feeType = dto.FeeType;
  7147. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7148. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7149. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7150. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7151. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  7152. subInfo.Id = subId;
  7153. subInfo.DiId = dto.DiId;
  7154. if (feeType == 3) subInfo.Type = 1;
  7155. else if (feeType == 4) subInfo.Type = 2;
  7156. else if (feeType == 5) subInfo.Type = 3;
  7157. else if (feeType == 6) subInfo.Type = 4;
  7158. subInfo.CreateUserId = dto.CurrUserId;
  7159. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  7160. if (parentId < 1) return Ok(JsonView(false));
  7161. //子表op
  7162. if (subId < 1)
  7163. {
  7164. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7165. if (subAdd < 1) return Ok(JsonView(false));
  7166. }
  7167. else
  7168. {
  7169. var subUpd = await _sqlSugar.Updateable(subInfo)
  7170. .UpdateColumns(x => new
  7171. {
  7172. x.Days,
  7173. x.NationalTravelFeeId,
  7174. x.Cost,
  7175. x.Currency,
  7176. x.SubTotal
  7177. })
  7178. .WhereColumns(x => new { x.Id })
  7179. .ExecuteCommandAsync();
  7180. if (subUpd < 1) return Ok(JsonView(false));
  7181. }
  7182. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  7183. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7184. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  7185. }
  7186. /// <summary>
  7187. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7188. /// </summary>
  7189. /// <returns></returns>
  7190. [HttpPost]
  7191. [ApiExplorerSettings(IgnoreApi = true)]
  7192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7193. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  7194. {
  7195. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7196. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7197. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7198. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  7199. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  7200. {
  7201. Id = x.Id,
  7202. Diid = dto.DiId,
  7203. SetDataId = x.SetDataId,
  7204. Index = x.Index,
  7205. Cost = x.Cost,
  7206. Currency = x.Currency,
  7207. SubTotal = x.SubTotal,
  7208. CreateUserId = dto.CurrUserId,
  7209. Remark = x.Remark
  7210. }).ToList();
  7211. var adds = infos.Where(x => x.Id <= 0).ToList();
  7212. var upds = infos.Where(x => x.Id > 0).ToList();
  7213. if (adds.Count > 0)
  7214. {
  7215. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7216. if (add < 1) return Ok(JsonView(false));
  7217. }
  7218. if (upds.Count > 0)
  7219. {
  7220. var upd = await _sqlSugar.Updateable(adds)
  7221. .UpdateColumns(x => new
  7222. {
  7223. x.Index,
  7224. x.SetDataId,
  7225. x.Cost,
  7226. x.Currency,
  7227. x.SubTotal,
  7228. x.Remark
  7229. })
  7230. .WhereColumns(x => new { x.Id })
  7231. .ExecuteCommandAsync();
  7232. if (upd < 1) return Ok(JsonView(false));
  7233. }
  7234. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7235. //消息通知
  7236. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7237. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7238. return Ok(JsonView(new { itemTotal = itemTotal }));
  7239. }
  7240. /// <summary>
  7241. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  7242. /// </summary>
  7243. /// <returns></returns>
  7244. [HttpPost]
  7245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7246. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  7247. {
  7248. int subId = dto.SubId;
  7249. int diId = dto.Diid;
  7250. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7251. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7252. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7253. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  7254. subInfo.Id = subId;
  7255. subInfo.Diid = dto.Diid;
  7256. subInfo.CreateUserId = dto.CurrUserId;
  7257. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  7258. if (parentId < 1) return Ok(JsonView(false));
  7259. #region 子表op
  7260. if (subId < 1)//add
  7261. {
  7262. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7263. if (subAdd < 1) return Ok(JsonView(false));
  7264. }
  7265. else //upd
  7266. {
  7267. var subUpd = await _sqlSugar.Updateable(subInfo)
  7268. .UpdateColumns(x => new
  7269. {
  7270. x.Index,
  7271. x.SetDataId,
  7272. x.Cost,
  7273. x.Currency,
  7274. x.SubTotal,
  7275. x.Remark
  7276. })
  7277. .WhereColumns(x => new { x.Id })
  7278. .ExecuteCommandAsync();
  7279. if (subUpd < 1) return Ok(JsonView(false));
  7280. }
  7281. #endregion
  7282. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  7283. //消息通知
  7284. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  7285. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  7286. }
  7287. /// <summary>
  7288. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  7289. /// </summary>
  7290. /// <returns></returns>
  7291. [HttpPost]
  7292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7293. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  7294. {
  7295. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7296. if (data.Code != 0)
  7297. {
  7298. return Ok(JsonView(false, data.Msg));
  7299. }
  7300. return Ok(JsonView(true, "操作成功!", data.Data));
  7301. }
  7302. /// <summary>
  7303. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  7304. /// </summary>
  7305. /// <param name="dto"></param>
  7306. /// <returns></returns>
  7307. [HttpPost]
  7308. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  7309. {
  7310. var data = new Grp_DayOtherPrice()
  7311. {
  7312. Id = dto.Id,
  7313. IsDel = 1,
  7314. DeleteUserId = dto.DeleteUserId,
  7315. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7316. };
  7317. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7318. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  7319. return Ok(JsonView(false,"删除失败!"));
  7320. }
  7321. #endregion
  7322. #endregion
  7323. #region 签证费用录入
  7324. /// <summary>
  7325. /// 根据diid查询签证费用列表
  7326. /// </summary>
  7327. /// <param name="dto"></param>
  7328. /// <returns></returns>
  7329. [HttpPost]
  7330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7331. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  7332. {
  7333. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  7334. if (groupData.Code != 0)
  7335. {
  7336. return Ok(JsonView(false, groupData.Msg));
  7337. }
  7338. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7339. }
  7340. /// <summary>
  7341. /// 根据签证费用Id查询单条数据及c表数据
  7342. /// </summary>
  7343. /// <param name="dto"></param>
  7344. /// <returns></returns>
  7345. [HttpPost]
  7346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7347. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  7348. {
  7349. Result groupData = await _visaPriceRep.PostVisaById(dto);
  7350. if (groupData.Code != 0)
  7351. {
  7352. return Ok(JsonView(false, groupData.Msg));
  7353. }
  7354. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7355. }
  7356. /// <summary>
  7357. /// 签证费用删除
  7358. /// </summary>
  7359. /// <param name="dto"></param>
  7360. /// <returns></returns>
  7361. [HttpPost]
  7362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7363. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  7364. {
  7365. _sqlSugar.BeginTran();
  7366. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  7367. if (!res)
  7368. {
  7369. _sqlSugar.RollbackTran();
  7370. return Ok(JsonView(false, "删除失败"));
  7371. }
  7372. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  7373. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  7374. .SetColumns(a => new Grp_CreditCardPayment()
  7375. {
  7376. IsDel = 1,
  7377. DeleteUserId = dto.DeleteUserId,
  7378. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7379. })
  7380. .ExecuteCommand();
  7381. if (resSub < 1)
  7382. {
  7383. _sqlSugar.RollbackTran();
  7384. return Ok(JsonView(false, "删除失败"));
  7385. }
  7386. _sqlSugar.CommitTran();
  7387. return Ok(JsonView(true, "删除成功!"));
  7388. }
  7389. /// <summary>
  7390. /// 签证费用录入下拉框初始化
  7391. /// </summary>
  7392. /// <returns></returns>
  7393. [HttpPost]
  7394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7395. public async Task<IActionResult> VisaPriceAddSelect()
  7396. {
  7397. //支付方式
  7398. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  7399. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  7400. //币种
  7401. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  7402. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  7403. //乘客类型
  7404. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  7405. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  7406. //卡类型
  7407. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  7408. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  7409. //代办费类型
  7410. var agencyFeeTypeData = new List<dynamic>() {
  7411. new { id = 0 , Text = "未选择" },
  7412. new { id = 1 , Text = "小公务" },
  7413. new { id = 2 , Text = "大公务" },
  7414. };
  7415. //签证费用标准国家Data
  7416. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  7417. var data = new
  7418. {
  7419. Payment = _Payment,
  7420. CurrencyList = _CurrencyList,
  7421. PassengerType = _PassengerType,
  7422. BankCard = _BankCard,
  7423. AgencyFeeType = agencyFeeTypeData,
  7424. CountryFeeData = visaCountryFeeData
  7425. };
  7426. return Ok(JsonView(true, "查询成功!", data));
  7427. }
  7428. /// <summary>
  7429. /// 签证费用录入操作(Status:1.新增,2.修改)
  7430. /// </summary>
  7431. /// <param name="dto"></param>
  7432. /// <returns></returns>
  7433. [HttpPost]
  7434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7435. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  7436. {
  7437. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  7438. if (groupData.Code != 0)
  7439. {
  7440. return Ok(JsonView(false, groupData.Msg));
  7441. }
  7442. #region 应用推送
  7443. try
  7444. {
  7445. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7446. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7447. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7448. //2024-10-21 新增LZ UID
  7449. var userIds = new List<int>() { 21 };
  7450. string title = $"系统通知";
  7451. string content = "";
  7452. var diId = dto.DiId;
  7453. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7454. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7455. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7456. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7457. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7458. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7459. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7460. }
  7461. catch (Exception ex)
  7462. {
  7463. }
  7464. #endregion
  7465. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7466. }
  7467. #endregion
  7468. #region 签证提成录入
  7469. /// <summary>
  7470. /// 签证提成录入
  7471. /// 基础数据
  7472. /// </summary>
  7473. /// <param name="_dto"></param>
  7474. /// <returns></returns>
  7475. [HttpGet]
  7476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7477. public async Task<IActionResult> VisaCommissionInit()
  7478. {
  7479. return Ok(await _visaCommissionRep.Init());
  7480. }
  7481. /// <summary>
  7482. /// 签证提成录入
  7483. /// Item
  7484. /// </summary>
  7485. /// <param name="_dto"></param>
  7486. /// <returns></returns>
  7487. [HttpPost]
  7488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7489. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  7490. {
  7491. var validator = new VisaCommissionItemDtoValidator();
  7492. var validatorRes = await validator.ValidateAsync(_dto);
  7493. if (!validatorRes.IsValid)
  7494. {
  7495. StringBuilder sb = new StringBuilder();
  7496. foreach (var item in validatorRes.Errors)
  7497. {
  7498. sb.AppendLine(item.ErrorMessage);
  7499. }
  7500. return Ok(JsonView(false, sb.ToString()));
  7501. }
  7502. return Ok(await _visaCommissionRep.Item(_dto));
  7503. }
  7504. /// <summary>
  7505. /// 签证提成录入
  7506. /// Save
  7507. /// </summary>
  7508. /// <param name="_dto"></param>
  7509. /// <returns></returns>
  7510. [HttpPost]
  7511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7512. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  7513. {
  7514. //参数验证
  7515. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  7516. foreach (var item in _dto.Items)
  7517. {
  7518. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  7519. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  7520. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  7521. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  7522. }
  7523. return Ok(await _visaCommissionRep.Save(_dto));
  7524. }
  7525. /// <summary>
  7526. /// 签证提成录入
  7527. /// Create
  7528. /// </summary>
  7529. /// <param name="_dto"></param>
  7530. /// <returns></returns>
  7531. [HttpPost]
  7532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7533. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  7534. {
  7535. var validator = new VisaCommissionCreateDtoValidator();
  7536. var validatorRes = await validator.ValidateAsync(_dto);
  7537. if (!validatorRes.IsValid)
  7538. {
  7539. StringBuilder sb = new StringBuilder();
  7540. foreach (var item in validatorRes.Errors)
  7541. {
  7542. sb.AppendLine(item.ErrorMessage);
  7543. }
  7544. return Ok(JsonView(false, sb.ToString()));
  7545. }
  7546. return Ok(await _visaCommissionRep.Create(_dto));
  7547. }
  7548. /// <summary>
  7549. /// 签证提成录入
  7550. /// Put(编辑)
  7551. /// </summary>
  7552. /// <param name="id"></param>
  7553. /// <param name="_dto"></param>
  7554. /// <returns></returns>
  7555. [HttpPut]
  7556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7557. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  7558. {
  7559. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7560. var validator = new VisaCommissionCreateDtoValidator();
  7561. var validatorRes = await validator.ValidateAsync(_dto);
  7562. if (!validatorRes.IsValid)
  7563. {
  7564. StringBuilder sb = new StringBuilder();
  7565. foreach (var item in validatorRes.Errors)
  7566. {
  7567. sb.AppendLine(item.ErrorMessage);
  7568. }
  7569. return Ok(JsonView(false, sb.ToString()));
  7570. }
  7571. return Ok(await _visaCommissionRep.Edit(id, _dto));
  7572. }
  7573. /// <summary>
  7574. /// 签证提成录入
  7575. /// Del
  7576. /// </summary>
  7577. /// <param name="id"></param>
  7578. /// <param name="currUserId"></param>
  7579. /// <returns></returns>
  7580. [HttpPost]
  7581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7582. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  7583. {
  7584. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7585. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  7586. return Ok(await _visaCommissionRep.Del(id, currUserId));
  7587. }
  7588. #endregion
  7589. #region op费用录入
  7590. /// <summary>
  7591. /// 根据diid查询op费用列表
  7592. /// </summary>
  7593. /// <param name="dto"></param>
  7594. /// <returns></returns>
  7595. [HttpPost]
  7596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7597. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  7598. {
  7599. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  7600. if (groupData.Code != 0)
  7601. {
  7602. return Ok(JsonView(false, groupData.Msg));
  7603. }
  7604. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7605. }
  7606. /// <summary>
  7607. /// 根据op费用Id查询单条数据及c表数据
  7608. /// </summary>
  7609. /// <param name="dto"></param>
  7610. /// <returns></returns>
  7611. [HttpPost]
  7612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7613. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  7614. {
  7615. try
  7616. {
  7617. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  7618. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  7619. var data = new
  7620. {
  7621. CarTouristGuideGround = _groupData,
  7622. CreditCardPayment = _creditCardPayment
  7623. };
  7624. return Ok(JsonView(true, "查询成功!", data));
  7625. }
  7626. catch (Exception ex)
  7627. {
  7628. return Ok(JsonView(false, "程序错误!"));
  7629. }
  7630. }
  7631. /// <summary>
  7632. /// op费用删除
  7633. /// </summary>
  7634. /// <param name="dto"></param>
  7635. /// <returns></returns>
  7636. [HttpPost]
  7637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7638. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  7639. {
  7640. try
  7641. {
  7642. _sqlSugar.BeginTran();
  7643. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7644. if (!res)
  7645. {
  7646. return Ok(JsonView(false, "删除失败"));
  7647. }
  7648. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  7649. {
  7650. IsDel = 1,
  7651. DeleteUserId = dto.DeleteUserId,
  7652. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7653. }).ExecuteCommandAsync();
  7654. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  7655. {
  7656. IsDel = 1,
  7657. DeleteUserId = dto.DeleteUserId,
  7658. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7659. }).ExecuteCommandAsync();
  7660. #region 删除超支相关数据
  7661. //删除导入的超支数据
  7662. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  7663. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  7664. {
  7665. IsDel = 1,
  7666. DeleteUserId = dto.DeleteUserId,
  7667. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7668. }).ExecuteCommand();
  7669. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  7670. {
  7671. IsDel = 1,
  7672. DeleteUserId = dto.DeleteUserId,
  7673. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7674. }).ExecuteCommand();
  7675. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  7676. {
  7677. IsDel = 1,
  7678. DeleteUserId = dto.DeleteUserId,
  7679. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7680. }).ExecuteCommand();
  7681. #endregion
  7682. _sqlSugar.CommitTran();
  7683. return Ok(JsonView(true, "删除成功!"));
  7684. }
  7685. catch (Exception ex)
  7686. {
  7687. _sqlSugar.RollbackTran();
  7688. return Ok(JsonView(false, "程序错误!" + ex.Message));
  7689. }
  7690. }
  7691. /// <summary>
  7692. /// op费用录入操作(Status:1.新增,2.修改)
  7693. /// </summary>
  7694. /// <param name="dto"></param>
  7695. /// <returns></returns>
  7696. [HttpPost]
  7697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7698. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  7699. {
  7700. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  7701. if (groupData.Code != 0)
  7702. {
  7703. return Ok(JsonView(false, groupData.Msg));
  7704. }
  7705. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7706. }
  7707. /// <summary>
  7708. /// 填写费用详细页面初始化绑定
  7709. /// </summary>
  7710. /// <param name="dto"></param>
  7711. /// <returns></returns>
  7712. [HttpPost]
  7713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7714. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  7715. {
  7716. try
  7717. {
  7718. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  7719. if (groupData.Code != 0)
  7720. {
  7721. return Ok(JsonView(false, groupData.Msg));
  7722. }
  7723. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7724. }
  7725. catch (Exception ex)
  7726. {
  7727. return Ok(JsonView(false, ex.Message));
  7728. }
  7729. }
  7730. /// <summary>
  7731. /// 根据op费用Id查询详细数据
  7732. /// </summary>
  7733. /// <param name="dto"></param>
  7734. /// <returns></returns>
  7735. [HttpPost]
  7736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7737. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  7738. {
  7739. try
  7740. {
  7741. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  7742. if (groupData.Code != 0)
  7743. {
  7744. return Ok(JsonView(false, groupData.Msg));
  7745. }
  7746. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7747. }
  7748. catch (Exception ex)
  7749. {
  7750. return Ok(JsonView(false, ex.Message));
  7751. }
  7752. }
  7753. /// <summary>
  7754. /// OP费用录入填写详情
  7755. /// </summary>
  7756. /// <param name="dto"></param>
  7757. /// <returns></returns>
  7758. [HttpPost]
  7759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7760. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  7761. {
  7762. try
  7763. {
  7764. #region 参数校验
  7765. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  7766. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  7767. if (di == null) return Ok(JsonView(false, "团组错误!"));
  7768. #endregion
  7769. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  7770. if (groupData.Code != 0)
  7771. {
  7772. return Ok(JsonView(false, groupData.Msg));
  7773. }
  7774. //自动审核
  7775. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  7776. #region 应用推送
  7777. try
  7778. {
  7779. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7780. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7781. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7782. //2024-10-21 新增LZ UID
  7783. var userIds = new List<int>() { 21 };
  7784. string title = $"系统通知";
  7785. var diId = dto.DiId;
  7786. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7787. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7788. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  7789. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7790. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7791. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7792. }
  7793. catch (Exception ex)
  7794. {
  7795. }
  7796. #endregion
  7797. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7798. }
  7799. catch (Exception ex)
  7800. {
  7801. return Ok(JsonView(false, ex.Message));
  7802. }
  7803. }
  7804. /// <summary>
  7805. /// 获取三公详细所有城市
  7806. /// </summary>
  7807. /// <returns></returns>
  7808. [HttpGet]
  7809. public IActionResult OpCarCityResult()
  7810. {
  7811. var jw = JsonView(false);
  7812. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  7813. {
  7814. x.Id,
  7815. x.Country,
  7816. x.City,
  7817. }).ToList();
  7818. if (data.Count > 0)
  7819. {
  7820. jw = JsonView(true, "获取成功!", data);
  7821. }
  7822. else
  7823. {
  7824. jw.Msg = "城市数据为空!";
  7825. jw.Data = new string[0];
  7826. }
  7827. return Ok(jw);
  7828. }
  7829. /// <summary>
  7830. /// 导出地接费用明细
  7831. /// </summary>
  7832. /// <param name="dto"></param>
  7833. /// <returns></returns>
  7834. [HttpPost]
  7835. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  7836. {
  7837. var jw = JsonView(false);
  7838. if (dto.Diid < 1)
  7839. {
  7840. jw.Msg = "请输入正确的diid!";
  7841. return Ok(jw);
  7842. }
  7843. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  7844. if (group == null)
  7845. {
  7846. jw.Msg = "未找到团组信息!";
  7847. return Ok(jw);
  7848. }
  7849. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  7850. if (localGuideArr.Count == 0)
  7851. {
  7852. jw.Msg = "该团组暂无地接信息!";
  7853. return Ok(jw);
  7854. }
  7855. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  7856. var overspendSoure = new Dictionary<int, int>
  7857. {
  7858. { 91, 982 }, //车
  7859. { 92 , 1059} ,//导游
  7860. { 994 , 1073}, //翻译
  7861. { 988 , 1074 }, //早餐
  7862. { 93 , 1075 }, //午餐
  7863. { 989 , 1076 }, //晚餐
  7864. };
  7865. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  7866. foreach (var groupArr in localGroup)
  7867. {
  7868. var keyValue = groupArr.Key;
  7869. if (int.TryParse(keyValue, out int cityid))
  7870. {
  7871. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  7872. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  7873. }
  7874. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  7875. foreach (var item in groupArr)
  7876. {
  7877. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  7878. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  7879. new Grp_CarTouristGuideGroundReservationsContentExtend
  7880. {
  7881. Count = a.Count,
  7882. CreateTime = a.CreateTime,
  7883. CreateUserId = a.CreateUserId,
  7884. CTGGRId = a.CTGGRId,
  7885. Currency = a.Currency,
  7886. DatePrice = a.DatePrice,
  7887. DeleteTime = a.DeleteTime,
  7888. DeleteUserId = a.DeleteUserId,
  7889. DiId = a.DiId,
  7890. Id = a.Id,
  7891. IsDel = a.IsDel,
  7892. Price = a.Price,
  7893. PriceContent = a.PriceContent,
  7894. Remark = a.Remark,
  7895. SId = a.SId,
  7896. SidName = b.Name,
  7897. Units = a.Units,
  7898. }
  7899. ).ToList();
  7900. if (content.Count > 0)
  7901. {
  7902. contentArr.Add(content);
  7903. }
  7904. }
  7905. //open excel
  7906. //set excel
  7907. //save excel
  7908. try
  7909. {
  7910. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  7911. IWorkbook workbook;
  7912. if (Path.GetExtension(filePath).ToLower() == ".xls")
  7913. {
  7914. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7915. }
  7916. else
  7917. {
  7918. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7919. }
  7920. ISheet sheet = workbook.GetSheetAt(0);
  7921. var rowStartIndex = 2;
  7922. var clounmCount = 10;
  7923. var initStyleRow = sheet.GetRow(2);
  7924. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7925. //var overspendArrDetail =
  7926. var existsId = new List<CarCompare>();
  7927. var lastElem = arr.Last();
  7928. var thisSid = -1;
  7929. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7930. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7931. {
  7932. Name = "未知币种!",
  7933. Remark = "未知币种!",
  7934. };
  7935. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7936. Action cloneRowFn = () =>
  7937. {
  7938. rowStartIndex++;
  7939. var cloneRow = sheet.CreateRow(rowStartIndex);
  7940. // 复制样式
  7941. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7942. {
  7943. ICell sourceCell = initStyleRow.GetCell(i);
  7944. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7945. // 确保单元格存在样式
  7946. if (sourceCell.CellStyle != null)
  7947. {
  7948. targetCell.CellStyle = sourceCell.CellStyle;
  7949. }
  7950. }
  7951. };
  7952. var mergeRow = () =>
  7953. {
  7954. for (int i = 2; i < sheet.LastRowNum; i++)
  7955. {
  7956. var row = sheet.GetRow(i);
  7957. var cellFirst = row.GetCell(0);
  7958. var thisIndex = i + 1;
  7959. while (thisIndex < sheet.LastRowNum)
  7960. {
  7961. var nextRow = sheet.GetRow(thisIndex);
  7962. var nextCellFirst = nextRow.GetCell(0);
  7963. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7964. {
  7965. thisIndex++;
  7966. }
  7967. else
  7968. {
  7969. break;
  7970. }
  7971. }
  7972. thisIndex--;
  7973. if (thisIndex != i)
  7974. {
  7975. //合并row
  7976. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7977. i, // 起始行索引(0-based)
  7978. thisIndex, // 结束行索引(0-based)
  7979. 0, // 起始列索引(0-based)
  7980. 0 // 结束列索引(0-based)
  7981. );
  7982. sheet.AddMergedRegion(cellRangeAddress);
  7983. i = thisIndex;
  7984. }
  7985. }
  7986. };
  7987. var chaoshiNumber = 0;
  7988. var totalNumber = 0.00M;
  7989. string lastStr = "";
  7990. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7991. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7992. {
  7993. b.IsAuditGM,
  7994. x.Id,
  7995. x.Area,
  7996. b.PayPercentage,
  7997. b.PayMoney,
  7998. }).ToList();
  7999. string yesPayment = "", noPayment = "";
  8000. foreach (var item in queryCarArrByCityAndDiid)
  8001. {
  8002. if (item.IsAuditGM == 1)
  8003. {
  8004. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  8005. }
  8006. else
  8007. {
  8008. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  8009. }
  8010. }
  8011. lastStr = yesPayment + noPayment;
  8012. foreach (var item in arr)
  8013. {
  8014. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  8015. {
  8016. if (thisSid != item.SId)
  8017. {
  8018. if (thisSid == -1)
  8019. {
  8020. thisSid = item.SId;
  8021. }
  8022. else
  8023. {
  8024. //合并小计行
  8025. //创建合并区域的实例
  8026. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8027. rowStartIndex, // 起始行索引(0-based)
  8028. rowStartIndex, // 结束行索引(0-based)
  8029. 0, // 起始列索引(0-based)
  8030. 3 // 结束列索引(0-based)
  8031. );
  8032. sheet.AddMergedRegion(cellRangeAddress);
  8033. var CellStyle = workbook.CreateCellStyle();
  8034. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8035. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8036. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8037. for (int i = 0; i <= clounmCount; i++)
  8038. {
  8039. if (i > 6)
  8040. {
  8041. var CellStyle1 = workbook.CreateCellStyle();
  8042. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8043. IFont Font = workbook.CreateFont(); // 创建字体
  8044. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8045. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8046. CellStyle1.SetFont(Font);
  8047. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8048. }
  8049. else
  8050. {
  8051. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8052. }
  8053. }
  8054. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8055. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8056. //超时合计
  8057. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8058. //超时数
  8059. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8060. //超时合计费用
  8061. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8062. thisSid = item.SId;
  8063. cloneRowFn();
  8064. chaoshiNumber = 0;
  8065. totalNumber = 0;
  8066. }
  8067. }
  8068. IRow row = sheet.GetRow(rowStartIndex);
  8069. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8070. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  8071. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  8072. if (isOpenOverspendSoure)
  8073. {
  8074. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8075. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  8076. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  8077. }
  8078. for (int i = 0; i <= clounmCount; i++)
  8079. {
  8080. var cell = row.GetCell(i);
  8081. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  8082. if (cell == null)
  8083. {
  8084. cell = row.CreateCell(i);
  8085. }
  8086. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  8087. fontRed.CloneStyleFrom(cell.CellStyle);
  8088. IFont Font = workbook.CreateFont(); // 创建字体
  8089. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  8090. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8091. fontRed.SetFont(Font);
  8092. byte[] rgb = new byte[3] { 255, 242, 204 };
  8093. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  8094. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  8095. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  8096. if (workbook is XSSFWorkbook)
  8097. {
  8098. BackgroundColor255_242_204.FillForegroundColor = 0;
  8099. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  8100. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  8101. }
  8102. else
  8103. {
  8104. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  8105. }
  8106. if (i == 1 || i > 6)
  8107. {
  8108. if (i > 6)
  8109. {
  8110. fontRed.FillForegroundColor = 0;
  8111. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  8112. fontRed.FillPattern = FillPattern.SolidForeground;
  8113. }
  8114. cell.CellStyle = fontRed;
  8115. }
  8116. if (i > 2 && i < 7)
  8117. {
  8118. cell.CellStyle = BackgroundColor255_242_204;
  8119. }
  8120. cell.SetCellValue(setCellValue); //写入单元格
  8121. }
  8122. if (overspendSoure.ContainsKey(thisSid))
  8123. {
  8124. var overspendId = overspendSoure[thisSid];
  8125. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8126. }
  8127. cloneRowFn();
  8128. existsId.Add(new CarCompare
  8129. {
  8130. DataPrice = item.DatePrice.ObjToDate(),
  8131. Sid = item.SId
  8132. });
  8133. }
  8134. if (item.Equals(lastElem))
  8135. {
  8136. //合并小计行
  8137. //创建合并区域的实例
  8138. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8139. rowStartIndex, // 起始行索引(0-based)
  8140. rowStartIndex, // 结束行索引(0-based)
  8141. 0, // 起始列索引(0-based)
  8142. 3 // 结束列索引(0-based)
  8143. );
  8144. sheet.AddMergedRegion(cellRangeAddress);
  8145. var CellStyle = workbook.CreateCellStyle();
  8146. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8147. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8148. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8149. for (int i = 0; i <= clounmCount; i++)
  8150. {
  8151. if (i > 6)
  8152. {
  8153. var CellStyle1 = workbook.CreateCellStyle();
  8154. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8155. IFont Font = workbook.CreateFont(); // 创建字体
  8156. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8157. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8158. CellStyle1.SetFont(Font);
  8159. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8160. }
  8161. else
  8162. {
  8163. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8164. }
  8165. }
  8166. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8167. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8168. //超时合计
  8169. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8170. //超时数
  8171. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8172. //超时合计费用
  8173. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8174. cloneRowFn();
  8175. // 创建合并区域的实例
  8176. cellRangeAddress = new CellRangeAddress(
  8177. rowStartIndex, // 起始行索引(0-based)
  8178. rowStartIndex, // 结束行索引(0-based)
  8179. 0, // 起始列索引(0-based)
  8180. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  8181. );
  8182. // 添加合并区域
  8183. sheet.AddMergedRegion(cellRangeAddress);
  8184. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  8185. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  8186. }
  8187. }
  8188. mergeRow();
  8189. // 保存修改后的Excel文件到新文件
  8190. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  8191. // new FileStream(newFilePath, FileMode.CreateNew)
  8192. using (var stream = new MemoryStream())
  8193. {
  8194. workbook.Write(stream, true);
  8195. stream.Flush();
  8196. stream.Seek(0, SeekOrigin.Begin);
  8197. MemoryStream memoryStream = new MemoryStream();
  8198. stream.CopyTo(memoryStream);
  8199. memoryStream.Seek(0, SeekOrigin.Begin);
  8200. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  8201. }
  8202. workbook.Close();
  8203. workbook.Dispose();
  8204. }
  8205. catch (Exception ex)
  8206. {
  8207. jw.Msg = "出现异常!" + ex.Message;
  8208. return Ok(jw);
  8209. }
  8210. }
  8211. if (Zips.Count > 0)
  8212. {
  8213. IOOperatorHelper io = new IOOperatorHelper();
  8214. var byts = io.ConvertZipStream(Zips);
  8215. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  8216. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  8217. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  8218. }
  8219. else
  8220. {
  8221. jw.Msg = "暂无生成文件!";
  8222. }
  8223. return Ok(jw);
  8224. }
  8225. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  8226. {
  8227. string outStr = string.Empty;
  8228. switch (i)
  8229. {
  8230. case 0:
  8231. outStr = arr[0].SidName;
  8232. break;
  8233. case 1:
  8234. outStr = arr[0].DataPriceStr;
  8235. break;
  8236. case 2:
  8237. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  8238. break;
  8239. case 4:
  8240. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  8241. break;
  8242. case 7:
  8243. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8244. {
  8245. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  8246. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  8247. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  8248. }
  8249. break;
  8250. case 8:
  8251. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8252. {
  8253. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  8254. }
  8255. break;
  8256. case 9:
  8257. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8258. {
  8259. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  8260. }
  8261. break;
  8262. case 10:
  8263. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8264. {
  8265. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  8266. }
  8267. break;
  8268. }
  8269. return outStr;
  8270. }
  8271. #region OP行程单
  8272. /// <summary>
  8273. /// OP行程单初始化
  8274. /// </summary>
  8275. /// <param name="dto"></param>
  8276. /// <returns></returns>
  8277. [HttpPost]
  8278. public IActionResult InitOpTravel(InitOpTravelDto dto)
  8279. {
  8280. var jw = JsonView(false);
  8281. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  8282. var group = groupList.First();
  8283. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  8284. if (group == null)
  8285. {
  8286. jw.Msg = "暂无团组!";
  8287. return Ok(jw);
  8288. }
  8289. group = groupList.Find(x => x.Id == diid);
  8290. if (group == null)
  8291. {
  8292. jw.Msg = "请输入正确的团组ID!";
  8293. return Ok(jw);
  8294. }
  8295. string city = string.Empty;
  8296. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  8297. if (blackCode.Count > 0)
  8298. {
  8299. var black = blackCode.First();
  8300. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  8301. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  8302. if (blackSp.Length > 0)
  8303. {
  8304. try
  8305. {
  8306. var cityArrCode = new List<string>(20);
  8307. foreach (var item in blackSp)
  8308. {
  8309. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  8310. var IndexSelect = itemSp[2];
  8311. var cityArrCodeLength = cityArrCode.Count - 1;
  8312. var startCity = IndexSelect.Substring(0, 3);
  8313. if (cityArrCodeLength > 0)
  8314. {
  8315. var arrEndCity = cityArrCode[cityArrCodeLength];
  8316. if (arrEndCity != startCity)
  8317. {
  8318. cityArrCode.Add(startCity.ToUpper());
  8319. }
  8320. }
  8321. else
  8322. {
  8323. cityArrCode.Add(startCity.ToUpper());
  8324. }
  8325. var endCity = IndexSelect.Substring(3, 3);
  8326. cityArrCode.Add(endCity.ToUpper());
  8327. }
  8328. var cityThree = string.Empty;
  8329. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  8330. cityThree = cityThree.TrimEnd(',');
  8331. if (string.IsNullOrWhiteSpace(cityThree))
  8332. {
  8333. throw new
  8334. Exception("error");
  8335. }
  8336. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  8337. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  8338. foreach (var item in cityArrCode)
  8339. {
  8340. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  8341. if (find != null)
  8342. {
  8343. city += find.City + "/";
  8344. }
  8345. else
  8346. {
  8347. city += item + "三字码未收入/";
  8348. }
  8349. }
  8350. city = city.TrimEnd('/');
  8351. }
  8352. catch (Exception e)
  8353. {
  8354. city = "黑屏代码格式不正确!";
  8355. }
  8356. }
  8357. }
  8358. else
  8359. {
  8360. city = "未录入黑屏代码";
  8361. }
  8362. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  8363. {
  8364. Date = x.Date,
  8365. Days = x.Days,
  8366. Diffgroup = x.Diffgroup,
  8367. Diid = x.Diid,
  8368. Traffic_First = x.Traffic_First,
  8369. Traffic_Second = x.Traffic_Second,
  8370. Trip = x.Trip,
  8371. WeekDay = x.WeekDay,
  8372. Id = x.Id
  8373. }).ToList();
  8374. jw.Data = new
  8375. {
  8376. groupList = groupList.Select(x => new
  8377. {
  8378. x.Id,
  8379. x.TeamName,
  8380. x.TourCode
  8381. }).ToList(),
  8382. groupInfo = new
  8383. {
  8384. group.VisitDays,
  8385. group.TourCode,
  8386. group.VisitPNumber,
  8387. group.TeamName,
  8388. city
  8389. },
  8390. OpTravelList
  8391. };
  8392. jw.Code = 200;
  8393. jw.Msg = "操作成功!";
  8394. return Ok(jw);
  8395. }
  8396. /// <summary>
  8397. /// 删除团组行程单
  8398. /// </summary>
  8399. /// <returns></returns>
  8400. [HttpPost]
  8401. public IActionResult DelTravel(DelOpTravelDto dto)
  8402. {
  8403. var jw = JsonView(false);
  8404. if (dto.UserId <= 0 || dto.Diid <= 0)
  8405. {
  8406. jw.Msg = "请输入正确的参数!";
  8407. return Ok(jw);
  8408. }
  8409. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  8410. .SetColumns(x => new Grp_TravelList
  8411. {
  8412. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8413. DeleteUserId = dto.UserId,
  8414. IsDel = 1,
  8415. }).ExecuteCommand();
  8416. jw = JsonView(true);
  8417. return Ok(jw);
  8418. }
  8419. /// <summary>
  8420. /// 行程单保存
  8421. /// </summary>
  8422. /// <returns></returns>
  8423. [HttpPost]
  8424. public IActionResult TravelSave(TravelSaveDto dto)
  8425. {
  8426. var jw = JsonView(false);
  8427. if (dto.Arr.Count > 0)
  8428. {
  8429. try
  8430. {
  8431. _sqlSugar.BeginTran();
  8432. foreach (var item in dto.Arr)
  8433. {
  8434. if (item.Id == 0)
  8435. {
  8436. throw new Exception("请传入正确的Id");
  8437. }
  8438. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  8439. .SetColumns(x => new Grp_TravelList
  8440. {
  8441. Trip = item.Trip
  8442. }).ExecuteCommand();
  8443. }
  8444. _sqlSugar.CommitTran();
  8445. jw = JsonView(true);
  8446. }
  8447. catch (Exception ex)
  8448. {
  8449. _sqlSugar.RollbackTran();
  8450. jw.Msg = "程序异常!" + ex.Message;
  8451. }
  8452. }
  8453. else
  8454. {
  8455. jw.Msg = "请传入正确的参数!";
  8456. }
  8457. return Ok(jw);
  8458. }
  8459. /// <summary>
  8460. /// 导出行程单
  8461. /// </summary>
  8462. /// <param name="dto"></param>
  8463. /// <returns></returns>
  8464. [HttpPost]
  8465. public IActionResult ExportTravel(ExportTravelDto dto)
  8466. {
  8467. var jw = JsonView(false);
  8468. jw.Data = "";
  8469. int diid = 0;
  8470. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  8471. if (Find == null)
  8472. {
  8473. jw.Msg = "请选择正确的团组!";
  8474. return Ok(jw);
  8475. }
  8476. else
  8477. {
  8478. diid = Find.Id;
  8479. }
  8480. //数据源
  8481. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  8482. DataTable dtBlack = null;
  8483. try
  8484. {
  8485. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  8486. }
  8487. catch (Exception)
  8488. {
  8489. jw.Msg = "机票黑屏代码有误!";
  8490. return Ok(jw);
  8491. }
  8492. string CityStr = string.Empty;
  8493. if (dtBlack.Rows.Count == 0)
  8494. {
  8495. jw.Msg = "机票黑屏代码有误!";
  8496. return Ok(jw);
  8497. }
  8498. else
  8499. {
  8500. foreach (DataRow row in dtBlack.Rows)
  8501. {
  8502. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  8503. {
  8504. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  8505. return Ok(jw);
  8506. }
  8507. }
  8508. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  8509. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  8510. }
  8511. //创建数据源Table
  8512. DataTable dtSource = new DataTable();
  8513. dtSource.Columns.Add("Days", typeof(string));
  8514. dtSource.Columns.Add("Date", typeof(string));
  8515. dtSource.Columns.Add("Week", typeof(string));
  8516. dtSource.Columns.Add("Traffic", typeof(string));
  8517. dtSource.Columns.Add("Trip", typeof(string));
  8518. //获取数据,放到datatable
  8519. foreach (var item in _travelList)
  8520. {
  8521. DataRow dr = dtSource.NewRow();
  8522. dr["Days"] = item.Days;
  8523. dr["Date"] = item.Date;
  8524. dr["Week"] = item.WeekDay;
  8525. dr["Traffic"] = item.Traffic_First
  8526. + "\r\n"
  8527. + item.Traffic_Second;
  8528. dr["Trip"] = item.Trip;
  8529. dtSource.Rows.Add(dr);
  8530. }
  8531. Dictionary<string, string> dic = new Dictionary<string, string>();
  8532. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  8533. dic.Add("City", CityStr);
  8534. dic.Add("Days", Find.VisitDays.ToString());
  8535. dic.Add("DeleCode", Find.TourCode);
  8536. dic.Add("Pnum", Find.VisitPNumber.ToString());
  8537. //模板路径
  8538. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  8539. //载入模板
  8540. Document doc = null;
  8541. DocumentBuilder builder = null;
  8542. try
  8543. {
  8544. //载入模板
  8545. doc = new Document(tempPath);
  8546. builder = new DocumentBuilder(doc);
  8547. }
  8548. catch (Exception)
  8549. {
  8550. jw.Msg = "模板位置不存在!";
  8551. return Ok(jw);
  8552. }
  8553. foreach (var key in dic.Keys)
  8554. {
  8555. Bookmark bookmark = doc.Range.Bookmarks[key];
  8556. if (bookmark != null)
  8557. {
  8558. builder.MoveToBookmark(key);
  8559. builder.Write(dic[key]);
  8560. }
  8561. }
  8562. //获取word里所有表格
  8563. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8564. //获取所填表格的序数
  8565. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8566. try
  8567. {
  8568. //循环赋值
  8569. for (int i = 0; i < dtSource.Rows.Count; i++)
  8570. {
  8571. builder.MoveToCell(0, i + 1, 0, 0);
  8572. builder.Write(dtSource.Rows[i]["Days"].ToString());
  8573. builder.MoveToCell(0, i + 1, 1, 0);
  8574. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  8575. builder.MoveToCell(0, i + 1, 2, 0);
  8576. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  8577. var trip = dtSource.Rows[i]["Trip"].ToString();
  8578. builder.MoveToCell(0, i + 1, 3, 0);
  8579. builder.Write(trip);
  8580. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  8581. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8582. // 获取特定索引的段落
  8583. Paragraph paragraph = (Paragraph)paragraphs[0];
  8584. Run run = paragraph.Runs[0];
  8585. Aspose.Words.Font font = run.Font;
  8586. font.Name = "黑体";
  8587. //设置双休红色
  8588. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  8589. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8590. paragraph = (Paragraph)paragraphs[1];
  8591. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  8592. {
  8593. run = paragraph.Runs[0];
  8594. font = run.Font;
  8595. font.Color = Color.Red;
  8596. }
  8597. }
  8598. }
  8599. catch (Exception ex)
  8600. {
  8601. }
  8602. //删除多余行
  8603. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  8604. {
  8605. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  8606. }
  8607. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  8608. if (!Directory.Exists(savePath))
  8609. {
  8610. try
  8611. {
  8612. Directory.CreateDirectory(savePath);
  8613. }
  8614. catch
  8615. {
  8616. }
  8617. }
  8618. string path = savePath + Find.TeamName + "出访日程";
  8619. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  8620. try
  8621. {
  8622. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  8623. string postfix = ".docx";
  8624. if (dto.IsPDF == 1)
  8625. {
  8626. saveFormat = Aspose.Words.SaveFormat.Pdf;
  8627. postfix = ".pdf";
  8628. }
  8629. doc.Save(path + postfix, saveFormat);
  8630. jw = JsonView(true, "导出成功", ftpPath + postfix);
  8631. }
  8632. catch (Exception)
  8633. {
  8634. jw = JsonView(false);
  8635. }
  8636. return Ok(jw);
  8637. }
  8638. /// <summary>
  8639. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  8640. /// </summary>
  8641. /// <param name="num"></param>
  8642. /// <returns></returns>
  8643. string GetNum(string num)
  8644. {
  8645. string str = "";
  8646. switch (num)
  8647. {
  8648. case "1":
  8649. str = "一";
  8650. break;
  8651. case "2":
  8652. str = "二";
  8653. break;
  8654. case "3":
  8655. str = "三";
  8656. break;
  8657. case "4":
  8658. str = "四";
  8659. break;
  8660. case "5":
  8661. str = "五";
  8662. break;
  8663. case "6":
  8664. str = "六";
  8665. break;
  8666. case "7":
  8667. str = "七";
  8668. break;
  8669. case "8":
  8670. str = "八";
  8671. break;
  8672. case "9":
  8673. str = "九";
  8674. break;
  8675. case "10":
  8676. str = "十";
  8677. break;
  8678. case "11":
  8679. str = "十一";
  8680. break;
  8681. case "12":
  8682. str = "十二";
  8683. break;
  8684. case "一":
  8685. str = "1";
  8686. break;
  8687. case "二":
  8688. str = "2";
  8689. break;
  8690. case "三":
  8691. str = "3";
  8692. break;
  8693. case "四":
  8694. str = "4";
  8695. break;
  8696. case "五":
  8697. str = "5";
  8698. break;
  8699. case "六":
  8700. str = "6";
  8701. break;
  8702. case "七":
  8703. str = "7";
  8704. break;
  8705. case "八":
  8706. str = "8";
  8707. break;
  8708. case "九":
  8709. str = "9";
  8710. break;
  8711. case "十":
  8712. str = "10";
  8713. break;
  8714. case "十一":
  8715. str = "11";
  8716. break;
  8717. case "十二":
  8718. str = "12";
  8719. break;
  8720. }
  8721. return str;
  8722. }
  8723. #endregion
  8724. #endregion
  8725. #region 团组成本
  8726. /// <summary>
  8727. /// 团组成本数据初始化
  8728. /// </summary>
  8729. /// <param name="dto"></param>
  8730. /// <returns></returns>
  8731. [HttpPost]
  8732. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  8733. {
  8734. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  8735. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  8736. WHEN COUNT(*) >= 0 THEN 'True'
  8737. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  8738. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  8739. ").ToList(); //团组列表
  8740. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  8741. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  8742. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  8743. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  8744. if (groupinfoValue != null)
  8745. {
  8746. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  8747. var spArr = new string[1] { countryArr };
  8748. if (countryArr.Contains("|"))
  8749. {
  8750. spArr = countryArr.Split("|");
  8751. }
  8752. else if (countryArr.Contains("、"))
  8753. {
  8754. spArr = countryArr.Split("、");
  8755. }
  8756. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  8757. {
  8758. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  8759. if (dbQueryCountry != null)
  8760. {
  8761. visaCountryInfoArr.Add(dbQueryCountry);
  8762. }
  8763. }
  8764. }
  8765. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  8766. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  8767. var create = _GroupCostRepository.
  8768. CreateGroupCostByBlackCode(dto.Diid);
  8769. if (groupCost.Count == 0 && create.Code == 0)
  8770. {
  8771. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  8772. }
  8773. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  8774. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  8775. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  8776. groupCostMap = groupCostMap.Select(x =>
  8777. {
  8778. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  8779. {
  8780. x.Date = dataForamt.ToString("yyyy-MM-dd");
  8781. }
  8782. return x;
  8783. }).ToList();
  8784. //GroupCostParameter.Add(new
  8785. // Grp_GroupCostParameter());
  8786. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  8787. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  8788. return Ok(JsonView(new
  8789. {
  8790. groupList,
  8791. groupInfo,
  8792. groupChecks,
  8793. groupCost = groupCostMap,
  8794. hotelNumber,
  8795. GroupCostParameter = GroupCostParameterMap,
  8796. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  8797. {
  8798. x.VisaCountry,
  8799. x.VisaPrice,
  8800. x.Id,
  8801. }).ToList(),
  8802. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  8803. blackCodeIsTrue = create.Code == 0 ? true : false,
  8804. hotelIsTrue = hotelIsTrue,
  8805. }));
  8806. }
  8807. /// <summary>
  8808. /// 团组成本信息保存
  8809. /// </summary>
  8810. /// <param name="dto"></param>
  8811. /// <returns></returns>
  8812. [HttpPost]
  8813. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  8814. {
  8815. if (dto.Diid <= 0 || dto.Userid <= 0)
  8816. {
  8817. return Ok(JsonView(false));
  8818. }
  8819. JsonView jw = null;
  8820. bool isTrue = false;
  8821. #region 复制团组成本
  8822. //if (dto.Diid == 2581)
  8823. //{
  8824. // dto.Diid = 2599;
  8825. // dto.CheckBoxs.ForEach(x =>
  8826. // {
  8827. // x.Diid = 2599;
  8828. // });
  8829. // dto.GroupCosts.ForEach(x =>
  8830. // {
  8831. // x.Diid = 2599;
  8832. // });
  8833. // dto.CostTypeHotelNumbers.ForEach(x =>
  8834. // {
  8835. // x.Diid = 2599;
  8836. // });
  8837. // dto.GroupCostParameters.ForEach(x =>
  8838. // {
  8839. // x.DiId = 2599;
  8840. // });
  8841. //}
  8842. #endregion
  8843. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  8844. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  8845. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  8846. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  8847. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  8848. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  8849. try
  8850. {
  8851. _sqlSugar.BeginTran();
  8852. isTrue = await _GroupCostRepository.
  8853. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  8854. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  8855. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  8856. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  8857. _sqlSugar.CommitTran();
  8858. jw = JsonView(true, "保存成功!", isTrue);
  8859. }
  8860. catch (Exception)
  8861. {
  8862. _sqlSugar.RollbackTran();
  8863. jw = JsonView(false);
  8864. }
  8865. return Ok(jw);
  8866. }
  8867. /// <summary>
  8868. /// 司兼导数据
  8869. /// </summary>
  8870. /// <param name="dto"></param>
  8871. /// <returns></returns>
  8872. [HttpPost]
  8873. public IActionResult GetCarGuides(CarGuidesDto dto)
  8874. {
  8875. JsonView jw = null;
  8876. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  8877. jw = JsonView(true, "获取成功!", Data);
  8878. return Ok(jw);
  8879. }
  8880. /// <summary>
  8881. /// 导游数据
  8882. /// </summary>
  8883. /// <param name="dto"></param>
  8884. /// <returns></returns>
  8885. [HttpPost]
  8886. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  8887. {
  8888. JsonView jw = null;
  8889. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  8890. // 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
  8891. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  8892. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  8893. jw = JsonView(true, "获取成功!", Data);
  8894. return Ok(jw);
  8895. }
  8896. /// <summary>
  8897. /// 成本车数据
  8898. /// </summary>
  8899. /// <param name="dto"></param>
  8900. /// <returns></returns>
  8901. [HttpPost]
  8902. public IActionResult GetCarInfo(CarGuidesDto dto)
  8903. {
  8904. JsonView jw = null;
  8905. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  8906. jw = JsonView(true, "获取成功!", Data);
  8907. return Ok(jw);
  8908. }
  8909. /// <summary>
  8910. /// 景点数据
  8911. /// </summary>
  8912. /// <param name="dto"></param>
  8913. /// <returns></returns>
  8914. [HttpPost]
  8915. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  8916. {
  8917. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  8918. return Ok(JsonView(true, "获取成功!", Data));
  8919. }
  8920. /// <summary>
  8921. /// 成本通知
  8922. /// </summary>
  8923. /// <param name="dto"></param>
  8924. /// <returns></returns>
  8925. [HttpPost]
  8926. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8927. {
  8928. if (dto.Diid < 0)
  8929. {
  8930. return Ok(JsonView(false));
  8931. }
  8932. JsonView jw = null;
  8933. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8934. if (GroupCostParameter != null)
  8935. {
  8936. int IsShare = 0;
  8937. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8938. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8939. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8940. string msg = string.Empty;
  8941. if (isTrue)
  8942. {
  8943. if (IsShare == 0)
  8944. {
  8945. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8946. }
  8947. else
  8948. {
  8949. #region 企微通知对应岗位用户
  8950. try
  8951. {
  8952. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8953. }
  8954. catch (Exception ex)
  8955. {
  8956. }
  8957. #endregion
  8958. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8959. }
  8960. jw = JsonView(isTrue, msg, new { IsShare });
  8961. }
  8962. else
  8963. {
  8964. msg = "修改失败!";
  8965. jw = JsonView(isTrue, msg);
  8966. }
  8967. }
  8968. else
  8969. {
  8970. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8971. }
  8972. return Ok(jw);
  8973. }
  8974. /// <summary>
  8975. /// 导出报价单
  8976. /// </summary>
  8977. /// <param name="dto"></param>
  8978. /// <returns></returns>
  8979. [HttpPost]
  8980. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8981. {
  8982. if (dto.Diid == 0)
  8983. {
  8984. return Ok(JsonView(false, "请传递团组id"));
  8985. }
  8986. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8987. if (deleInfo.Code != 0)
  8988. {
  8989. return Ok(JsonView(false, "团组信息查询失败!"));
  8990. }
  8991. var di = deleInfo.Data as DelegationInfoWebView;
  8992. if (di != null)
  8993. {
  8994. di.TeamName = di.TeamName.Replace("|", "、");
  8995. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8996. //文件名
  8997. string strFileName = di.TeamName + "-收款账单.doc";
  8998. //获取模板
  8999. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  9000. //载入模板
  9001. Document doc = new Document(tmppath);
  9002. decimal TotalPrice = 0.00M;
  9003. string itemStr = string.Empty;
  9004. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  9005. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  9006. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  9007. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  9008. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  9009. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  9010. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  9011. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  9012. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  9013. foreach (var cost in groupCostType)
  9014. {
  9015. var List = cost.ToList();
  9016. if (cost.Key == "A")
  9017. {
  9018. foreach (var ListItem in List)
  9019. {
  9020. if (ListItem.number > 0)
  9021. {
  9022. if (ListItem.code.Contains("TBR"))
  9023. {
  9024. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9025. }
  9026. else
  9027. {
  9028. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9029. }
  9030. TotalPrice += (ListItem.number * ListItem.price);
  9031. }
  9032. }
  9033. }
  9034. else
  9035. {
  9036. itemStr = itemStr.Insert(0, "A段\r\n");
  9037. itemStr += "B段\r\n";
  9038. foreach (var ListItem in List)
  9039. {
  9040. if (ListItem.number > 0)
  9041. {
  9042. if (ListItem.code.Contains("TBR"))
  9043. {
  9044. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9045. }
  9046. else
  9047. {
  9048. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9049. }
  9050. TotalPrice += (ListItem.number * ListItem.price);
  9051. }
  9052. }
  9053. }
  9054. }
  9055. #region 替换Word模板书签内容
  9056. Dictionary<string, string> marks = new Dictionary<string, string>();
  9057. marks.Add("To", di.ClientUnit);//付款方
  9058. marks.Add("ToTel", di.TellPhone);//付款方电话
  9059. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  9060. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  9061. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  9062. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  9063. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  9064. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  9065. marks.Add("PayItemContent", itemStr);//详细信息
  9066. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  9067. #endregion
  9068. ////注
  9069. //if (doc.Range.Bookmarks["Attention"] != null)
  9070. //{
  9071. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  9072. // mark.Text = frList[0].Attention;
  9073. //}
  9074. foreach (var item in marks.Keys)
  9075. {
  9076. if (doc.Range.Bookmarks[item] != null)
  9077. {
  9078. Bookmark mark = doc.Range.Bookmarks[item];
  9079. mark.Text = marks[item];
  9080. }
  9081. }
  9082. byte[] bytes = null;
  9083. using (MemoryStream stream = new MemoryStream())
  9084. {
  9085. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9086. bytes = stream.ToArray();
  9087. }
  9088. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  9089. return Ok(JsonView(true, "", new
  9090. {
  9091. Data = bytes,
  9092. strFileName,
  9093. }));
  9094. }
  9095. else
  9096. {
  9097. return Ok(JsonView(false, "团组信息不存在!"));
  9098. }
  9099. }
  9100. /// <summary>
  9101. /// 导出团组成本
  9102. /// </summary>
  9103. /// <param name="dto"></param>
  9104. /// <returns></returns>
  9105. [HttpPost]
  9106. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  9107. {
  9108. var jw = JsonView(false);
  9109. if (dto.Diid == 0)
  9110. {
  9111. return Ok(JsonView(false, "请传递团组id"));
  9112. }
  9113. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9114. if (deleInfo.Code != 0)
  9115. {
  9116. return Ok(JsonView(false, "团组信息查询失败!"));
  9117. }
  9118. var di = deleInfo.Data as DelegationInfoWebView;
  9119. if (di == null)
  9120. {
  9121. return Ok(JsonView(false, "团组信息查询失败!"));
  9122. }
  9123. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  9124. WorkbookDesigner designer = new WorkbookDesigner();
  9125. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  9126. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  9127. for (int i = 0; i < List_GC.Count; i++)
  9128. {
  9129. GroupCost_Excel gc = new GroupCost_Excel();
  9130. gc.Id = List_GC[i].Id;
  9131. gc.Diid = List_GC[i].Diid.ToString();
  9132. gc.DAY = List_GC[i].DAY;
  9133. string week = "";
  9134. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  9135. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  9136. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  9137. gc.ITIN = List_GC[i].ITIN;
  9138. gc.CarType = List_GC[i].CarType;
  9139. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  9140. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  9141. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  9142. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  9143. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  9144. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  9145. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  9146. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  9147. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  9148. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  9149. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  9150. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  9151. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9152. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9153. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  9154. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  9155. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  9156. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  9157. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  9158. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  9159. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  9160. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  9161. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  9162. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  9163. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  9164. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  9165. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  9166. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  9167. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  9168. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  9169. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  9170. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  9171. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  9172. List_GC1.Add(gc);
  9173. }
  9174. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  9175. dt.TableName = "TB";
  9176. //报表标题等不用dt的值
  9177. designer.SetDataSource("TeamName", dto.title.TeamName);
  9178. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  9179. designer.SetDataSource("Tax", dto.title.Tax);
  9180. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  9181. designer.SetDataSource("Currency", dto.title.Currency);
  9182. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  9183. designer.SetDataSource("Rate", dto.title.Rate);
  9184. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  9185. var Aparams = hotels.Find(x => x.Type == "Default");
  9186. if (Aparams == null)
  9187. {
  9188. return Ok(jw);
  9189. }
  9190. //酒店数量
  9191. var txtSGRNumber = Aparams.SGR.ToString();
  9192. var txtTBRNumber = Aparams.TBR.ToString();
  9193. var txtJSESNumber = Aparams.JSES.ToString();
  9194. var txtSUITENumbe = Aparams.SUITE.ToString();
  9195. if (dto.costType == "B")
  9196. {
  9197. Aparams = hotels.Find(x => x.Type == "A");
  9198. var Bparams = hotels.Find(x => x.Type == "B");
  9199. if (Aparams == null || Bparams == null)
  9200. {
  9201. return Ok(jw);
  9202. }
  9203. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  9204. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  9205. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  9206. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  9207. }
  9208. designer.SetDataSource("SGRNumber", txtSGRNumber);
  9209. designer.SetDataSource("TBRNumber", txtTBRNumber);
  9210. designer.SetDataSource("JSESNumber", txtJSESNumber);
  9211. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  9212. var ws = designer.Workbook.Worksheets[0];
  9213. int Row = List_GC.Count;
  9214. int startIndex = 11;
  9215. int HideRows = 0;
  9216. List<int> hideRowsList = new List<int>();
  9217. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  9218. #region A段left数据
  9219. var left = dto.leftInfo.Find(x => x.Type == "A");
  9220. if (left == null)
  9221. {
  9222. return Ok(jw);
  9223. }
  9224. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  9225. if (leftBindData != null)
  9226. {
  9227. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  9228. designer.SetDataSource("VisaRS", leftBindData.rs);
  9229. designer.SetDataSource("VisaXS", leftBindData.xs);
  9230. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9231. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9232. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9233. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9234. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9235. }
  9236. else
  9237. {
  9238. hideRowsList.Add(Row + startIndex + HideRows);
  9239. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9240. }
  9241. HideRows += 2;
  9242. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  9243. if (leftBindData != null)
  9244. {
  9245. designer.SetDataSource("BXDRCB", leftBindData.cb);
  9246. designer.SetDataSource("BXRS", leftBindData.rs);
  9247. designer.SetDataSource("BXXS", leftBindData.xs);
  9248. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9249. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9250. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9251. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9252. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9253. }
  9254. else
  9255. {
  9256. hideRowsList.Add(Row + startIndex + HideRows);
  9257. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9258. }
  9259. HideRows += 2;
  9260. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9261. if (leftBindData != null)
  9262. {
  9263. designer.SetDataSource("HSDRCB", leftBindData.cb);
  9264. designer.SetDataSource("HSRS", leftBindData.rs);
  9265. designer.SetDataSource("HSXS", leftBindData.xs);
  9266. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9267. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9268. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9269. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9270. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9271. }
  9272. else
  9273. {
  9274. hideRowsList.Add(Row + startIndex + HideRows);
  9275. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9276. }
  9277. HideRows += 2;
  9278. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9279. if (leftBindData != null)
  9280. {
  9281. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  9282. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  9283. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  9284. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9285. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9286. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9287. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9288. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9289. }
  9290. else
  9291. {
  9292. hideRowsList.Add(Row + startIndex + HideRows);
  9293. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9294. }
  9295. HideRows += 2;
  9296. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9297. if (leftBindData != null)
  9298. {
  9299. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  9300. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  9301. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  9302. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9303. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9304. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9305. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9306. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9307. }
  9308. else
  9309. {
  9310. hideRowsList.Add(Row + startIndex + HideRows);
  9311. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9312. }
  9313. HideRows += 2;
  9314. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9315. if (leftBindData != null)
  9316. {
  9317. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  9318. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  9319. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  9320. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9321. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9322. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9323. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9324. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9325. }
  9326. else
  9327. {
  9328. hideRowsList.Add(Row + startIndex + HideRows);
  9329. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9330. }
  9331. HideRows += 2;
  9332. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9333. if (leftBindData != null)
  9334. {
  9335. ////TBR
  9336. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  9337. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  9338. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  9339. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9340. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9341. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9342. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9343. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9344. }
  9345. else
  9346. {
  9347. hideRowsList.Add(Row + startIndex + HideRows);
  9348. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9349. }
  9350. HideRows += 2;
  9351. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9352. if (leftBindData != null)
  9353. {
  9354. ////SGR
  9355. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  9356. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  9357. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  9358. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9359. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9360. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9361. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9362. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9363. }
  9364. else
  9365. {
  9366. hideRowsList.Add(Row + startIndex + HideRows);
  9367. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9368. }
  9369. HideRows += 2;
  9370. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9371. if (leftBindData != null)
  9372. {
  9373. ////JS/ES
  9374. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  9375. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  9376. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  9377. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9378. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9379. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9380. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9381. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9382. }
  9383. else
  9384. {
  9385. hideRowsList.Add(Row + startIndex + HideRows);
  9386. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9387. }
  9388. HideRows += 2;
  9389. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9390. if (leftBindData != null)
  9391. {
  9392. ////SUITE
  9393. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  9394. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  9395. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  9396. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9397. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9398. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9399. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9400. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9401. }
  9402. else
  9403. {
  9404. hideRowsList.Add(Row + startIndex + HideRows);
  9405. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9406. }
  9407. HideRows += 2;
  9408. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9409. if (leftBindData != null)
  9410. {
  9411. designer.SetDataSource("DJDRCB", leftBindData.cb);
  9412. designer.SetDataSource("DJRS", leftBindData.rs);
  9413. designer.SetDataSource("DJXS", leftBindData.xs);
  9414. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9415. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9416. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9417. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9418. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9419. }
  9420. else
  9421. {
  9422. hideRowsList.Add(Row + startIndex + HideRows);
  9423. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9424. }
  9425. HideRows += 2;
  9426. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9427. if (leftBindData != null)
  9428. {
  9429. designer.SetDataSource("HCPCB", leftBindData.cb);
  9430. designer.SetDataSource("HCPRS", leftBindData.rs);
  9431. designer.SetDataSource("HCPXS", leftBindData.xs);
  9432. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9433. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9434. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9435. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9436. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9437. }
  9438. else
  9439. {
  9440. hideRowsList.Add(Row + startIndex + HideRows);
  9441. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9442. }
  9443. HideRows += 2;
  9444. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9445. if (leftBindData != null)
  9446. {
  9447. designer.SetDataSource("CPCB", leftBindData.cb);
  9448. designer.SetDataSource("CPRS", leftBindData.rs);
  9449. designer.SetDataSource("CPXS", leftBindData.xs);
  9450. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9451. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9452. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9453. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9454. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9455. }
  9456. else
  9457. {
  9458. hideRowsList.Add(Row + startIndex + HideRows);
  9459. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9460. }
  9461. HideRows += 2;
  9462. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9463. if (leftBindData != null)
  9464. {
  9465. designer.SetDataSource("GWDRCD", leftBindData.cb);
  9466. designer.SetDataSource("GWRS", leftBindData.rs);
  9467. designer.SetDataSource("GWXS", leftBindData.xs);
  9468. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9469. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9470. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9471. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9472. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9473. }
  9474. else
  9475. {
  9476. hideRowsList.Add(Row + startIndex + HideRows);
  9477. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9478. }
  9479. HideRows += 2;
  9480. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9481. if (leftBindData != null)
  9482. {
  9483. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  9484. designer.SetDataSource("LYJRS", leftBindData.rs);
  9485. designer.SetDataSource("LYJXS", leftBindData.xs);
  9486. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9487. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9488. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9489. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9490. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9491. }
  9492. else
  9493. {
  9494. hideRowsList.Add(Row + startIndex + HideRows);
  9495. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9496. }
  9497. #endregion
  9498. #region A段Right信息
  9499. var right = dto.rightInfo.Find(x => x.Type == "A");
  9500. if (right == null)
  9501. {
  9502. return Ok(jw);
  9503. }
  9504. HideRows += 4;
  9505. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9506. if (rightBindData != null)
  9507. {
  9508. //经济舱 + 双人间 TBR
  9509. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  9510. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  9511. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9512. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  9513. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9514. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9515. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9516. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9517. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9518. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9519. }
  9520. else
  9521. {
  9522. hideRowsList.Add(Row + startIndex + HideRows);
  9523. }
  9524. HideRows += 2;
  9525. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9526. if (rightBindData != null)
  9527. {
  9528. //经济舱 + 单人间 SGR
  9529. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  9530. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  9531. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9532. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  9533. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9534. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9535. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9536. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9537. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9538. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9539. }
  9540. else
  9541. {
  9542. hideRowsList.Add(Row + startIndex + HideRows);
  9543. }
  9544. HideRows += 2;
  9545. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9546. if (rightBindData != null)
  9547. {
  9548. //公务舱 + 单人间 SGR
  9549. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  9550. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  9551. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9552. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  9553. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9554. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9555. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9556. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9557. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9558. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9559. }
  9560. else
  9561. {
  9562. hideRowsList.Add(Row + startIndex + HideRows);
  9563. }
  9564. HideRows += 2;
  9565. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9566. if (rightBindData != null)
  9567. {
  9568. //公务舱 + 小套房 JSES
  9569. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  9570. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  9571. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9572. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  9573. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9574. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9575. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9576. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9577. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9578. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9579. }
  9580. else
  9581. {
  9582. hideRowsList.Add(Row + startIndex + HideRows);
  9583. }
  9584. HideRows += 2;
  9585. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9586. if (rightBindData != null)
  9587. {
  9588. //公务舱 + 小套房 JSES
  9589. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  9590. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  9591. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9592. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  9593. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9594. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9595. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9596. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9597. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9598. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9599. }
  9600. else
  9601. {
  9602. hideRowsList.Add(Row + startIndex + HideRows);
  9603. }
  9604. HideRows += 2;
  9605. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9606. if (rightBindData != null)
  9607. {
  9608. //经济舱 + 大套房
  9609. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  9610. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  9611. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9612. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  9613. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9614. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9615. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9616. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9617. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9618. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9619. }
  9620. else
  9621. {
  9622. hideRowsList.Add(Row + startIndex + HideRows);
  9623. }
  9624. HideRows += 2;
  9625. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9626. if (rightBindData != null)
  9627. {
  9628. //头等舱 + 小套房 JSES
  9629. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  9630. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  9631. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9632. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  9633. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9634. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9635. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9636. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9637. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9638. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9639. }
  9640. else
  9641. {
  9642. hideRowsList.Add(Row + startIndex + HideRows);
  9643. }
  9644. HideRows += 2;
  9645. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9646. if (rightBindData != null)
  9647. {
  9648. //头等舱 + 大套房
  9649. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  9650. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  9651. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9652. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  9653. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9654. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9655. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9656. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9657. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9658. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9659. }
  9660. else
  9661. {
  9662. hideRowsList.Add(Row + startIndex + HideRows);
  9663. }
  9664. #endregion
  9665. #region B段标题清空
  9666. designer.SetDataSource("CostBDRCB", "");
  9667. designer.SetDataSource("CostBRS", "");
  9668. designer.SetDataSource("CostBXS", "");
  9669. designer.SetDataSource("CostBZCB", "");
  9670. designer.SetDataSource("CostBDRBJ", "");
  9671. designer.SetDataSource("CostBZBJ", "");
  9672. designer.SetDataSource("CostBDRLR", "");
  9673. designer.SetDataSource("CostBZLR", "");
  9674. designer.SetDataSource("CostBDRCBOM", "");
  9675. designer.SetDataSource("CostBRSOM", "");
  9676. designer.SetDataSource("CostBZCBOM", "");
  9677. designer.SetDataSource("CostBDRBJOM", "");
  9678. designer.SetDataSource("CostBZBJOM", "");
  9679. designer.SetDataSource("CostBDRLROM", "");
  9680. designer.SetDataSource("CostBZLROM", "");
  9681. #endregion
  9682. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  9683. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  9684. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  9685. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  9686. designer.SetDataSource("DJName", "地接(CNY)");
  9687. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  9688. designer.SetDataSource("CPName", "地接-船票(CNY)");
  9689. designer.SetDataSource("GWName", "公务(CNY)");
  9690. designer.SetDataSource("YQHName", "邀请函(CNY)");
  9691. designer.SetDataSource("LYJName", "零用金(CNY)");
  9692. designer.SetDataSource("HSName", "核酸检测(CNY)");
  9693. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  9694. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  9695. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  9696. designer.SetDataSource("BXName", "保险(CNY)");
  9697. designer.SetDataSource("VisaName", "签证(CNY)");
  9698. #region B段基本数据
  9699. if (dto.costType == "B")
  9700. {
  9701. left = dto.leftInfo.Find(x => x.Type == "B");
  9702. if (left == null)
  9703. {
  9704. return Ok(jw);
  9705. }
  9706. #region B段left数据
  9707. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9708. if (leftBindData != null)
  9709. {
  9710. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  9711. designer.SetDataSource("BHSRS", leftBindData.rs);
  9712. designer.SetDataSource("BHSXS", leftBindData.xs);
  9713. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9714. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9715. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9716. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9717. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9718. }
  9719. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9720. if (leftBindData != null)
  9721. {
  9722. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  9723. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  9724. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  9725. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9726. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9727. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9728. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9729. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9730. }
  9731. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9732. if (leftBindData != null)
  9733. {
  9734. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  9735. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  9736. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  9737. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9738. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9739. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9740. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9741. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9742. }
  9743. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9744. if (leftBindData != null)
  9745. {
  9746. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  9747. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  9748. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  9749. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9750. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9751. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9752. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9753. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9754. }
  9755. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9756. if (leftBindData != null)
  9757. {
  9758. designer.SetDataSource("BHCPCB", leftBindData.cb);
  9759. designer.SetDataSource("BHCPRS", leftBindData.rs);
  9760. designer.SetDataSource("BHCPXS", leftBindData.xs);
  9761. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9762. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9763. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9764. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9765. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9766. }
  9767. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9768. if (leftBindData != null)
  9769. {
  9770. designer.SetDataSource("BCPCB", leftBindData.cb);
  9771. designer.SetDataSource("BCPRS", leftBindData.rs);
  9772. designer.SetDataSource("BCPXS", leftBindData.xs);
  9773. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9774. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9775. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9776. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9777. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9778. }
  9779. //TBR
  9780. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9781. if (leftBindData != null)
  9782. {
  9783. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  9784. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  9785. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  9786. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9787. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9788. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9789. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9790. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9791. }
  9792. //SGR
  9793. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9794. if (leftBindData != null)
  9795. {
  9796. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  9797. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  9798. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  9799. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9800. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9801. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9802. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9803. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9804. }
  9805. //JS/ES
  9806. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9807. if (leftBindData != null)
  9808. {
  9809. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  9810. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  9811. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  9812. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9813. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9814. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9815. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9816. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9817. }
  9818. //SUITE
  9819. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9820. if (leftBindData != null)
  9821. {
  9822. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  9823. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  9824. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  9825. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9826. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9827. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9828. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9829. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9830. }
  9831. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9832. if (leftBindData != null)
  9833. {
  9834. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  9835. designer.SetDataSource("BDJRS", leftBindData.rs);
  9836. designer.SetDataSource("BDJXS", leftBindData.xs);
  9837. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9838. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9839. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9840. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9841. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9842. }
  9843. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9844. if (leftBindData != null)
  9845. {
  9846. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  9847. designer.SetDataSource("BGWRS", leftBindData.rs);
  9848. designer.SetDataSource("BGWXS", leftBindData.xs);
  9849. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9850. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9851. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9852. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9853. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9854. }
  9855. #region 优化方案
  9856. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  9857. //excelBind.Add("零用金", new {
  9858. //cb="",
  9859. //rs="",
  9860. //xs ="",
  9861. //zcb = "",
  9862. //});
  9863. #endregion
  9864. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9865. if (leftBindData != null)
  9866. {
  9867. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  9868. designer.SetDataSource("BLYJRS", leftBindData.rs);
  9869. designer.SetDataSource("BLYJXS", leftBindData.xs);
  9870. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9871. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9872. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9873. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9874. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9875. }
  9876. #endregion
  9877. #region B段Right信息
  9878. right = dto.rightInfo.Find(x => x.Type == "B");
  9879. if (right == null)
  9880. {
  9881. return Ok(jw);
  9882. }
  9883. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9884. if (rightBindData != null)
  9885. {
  9886. //经济舱 + 双人间 TBR
  9887. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  9888. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  9889. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9890. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  9891. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9892. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9893. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9894. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9895. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9896. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9897. }
  9898. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9899. if (rightBindData != null)
  9900. {
  9901. //经济舱 + 单人间 SGR
  9902. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  9903. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  9904. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9905. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  9906. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9907. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9908. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9909. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9910. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9911. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9912. }
  9913. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9914. if (rightBindData != null)
  9915. {
  9916. //公务舱 + 单人间 SGR
  9917. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  9918. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  9919. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9920. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  9921. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9922. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9923. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9924. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9925. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9926. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9927. }
  9928. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9929. if (rightBindData != null)
  9930. {
  9931. //公务舱 + 小套房 JSES
  9932. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9933. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9934. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9935. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9936. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9937. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9938. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9939. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9940. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9941. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9942. }
  9943. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9944. if (rightBindData != null)
  9945. {
  9946. //公务舱 + 小套房 JSES
  9947. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9948. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9949. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9950. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9951. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9952. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9953. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9954. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9955. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9956. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9957. }
  9958. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9959. if (rightBindData != null)
  9960. {
  9961. //经济舱 + 大套房
  9962. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9963. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9964. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9965. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9966. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9967. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9968. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9969. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9970. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9971. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9972. }
  9973. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9974. if (rightBindData != null)
  9975. {
  9976. //头等舱 + 小套房 JSES
  9977. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9978. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9979. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9980. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9981. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9982. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9983. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9984. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9985. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9986. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9987. }
  9988. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9989. if (rightBindData != null)
  9990. {
  9991. //头等舱 + 大套房
  9992. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9993. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9994. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9995. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9996. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9997. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9998. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9999. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10000. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10001. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10002. }
  10003. #endregion
  10004. #region 标题
  10005. designer.SetDataSource("CostBDRCB", "单人成本");
  10006. designer.SetDataSource("CostBRS", "人数");
  10007. designer.SetDataSource("CostBXS", "系数");
  10008. designer.SetDataSource("CostBZCB", "总成本");
  10009. designer.SetDataSource("CostBDRBJ", "单人报价");
  10010. designer.SetDataSource("CostBZBJ", "总报价");
  10011. designer.SetDataSource("CostBDRLR", "单人利润");
  10012. designer.SetDataSource("CostBZLR", "总利润");
  10013. designer.SetDataSource("CostBDRCBOM", "单人成本");
  10014. designer.SetDataSource("CostBRSOM", "人数");
  10015. designer.SetDataSource("CostBZCBOM", "总成本");
  10016. designer.SetDataSource("CostBDRBJOM", "单人报价");
  10017. designer.SetDataSource("CostBZBJOM", "总报价");
  10018. designer.SetDataSource("CostBDRLROM", "单人利润");
  10019. designer.SetDataSource("CostBZLROM", "总利润");
  10020. #endregion
  10021. }
  10022. #endregion
  10023. designer.SetDataSource("TzZCB2", TzZCB2);
  10024. designer.SetDataSource("TzZBJ2", TzZBJ2);
  10025. designer.SetDataSource("TzZLR2", TzZLR2);
  10026. string[] dataSourceKeys = new string[]
  10027. {
  10028. "VF",
  10029. "TGS",
  10030. "TGOF",
  10031. "TGM",
  10032. "TGA",
  10033. "TGTF",
  10034. "TGEF",
  10035. "CFM",
  10036. "CFOF",
  10037. "B",
  10038. "L",
  10039. "D",
  10040. "TBR",
  10041. "SGR",
  10042. "JSES",
  10043. "Suite",
  10044. "TV",
  10045. "1L",
  10046. "IF",
  10047. "EF",
  10048. "BRF",
  10049. "TE",
  10050. "TGT",
  10051. "DRVT",
  10052. "PC",
  10053. "TLF",
  10054. "ECT"
  10055. };
  10056. foreach (var item in dataSourceKeys)
  10057. {
  10058. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  10059. if (find != null)
  10060. {
  10061. designer.SetDataSource(item, find.text);
  10062. }
  10063. else
  10064. {
  10065. designer.SetDataSource(item, 0);
  10066. }
  10067. }
  10068. designer.SetDataSource(dt);
  10069. //根据数据源处理生成报表内容
  10070. designer.Process();
  10071. designer.Workbook.Worksheets[0].Name = "清单";
  10072. Worksheet sheet = designer.Workbook.Worksheets[0];
  10073. foreach (var Rowindex in hideRowsList)
  10074. {
  10075. ws.Cells.HideRows(Rowindex, 2);
  10076. }
  10077. byte[] bytes = null;
  10078. string strFileName = di.TeamName + "-团组-成本.xls";
  10079. using (MemoryStream stream = new MemoryStream())
  10080. {
  10081. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  10082. bytes = stream.ToArray();
  10083. }
  10084. return Ok(JsonView(true, "", new
  10085. {
  10086. Data = bytes,
  10087. strFileName,
  10088. }));
  10089. }
  10090. /// <summary>
  10091. /// 导出客户报表
  10092. /// </summary>
  10093. /// <returns></returns>
  10094. [HttpPost]
  10095. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  10096. {
  10097. var jw = JsonView(false);
  10098. if (dto.Diid == 0)
  10099. {
  10100. return Ok(JsonView(false, "请传递团组id"));
  10101. }
  10102. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10103. if (deleInfo.Code != 0)
  10104. {
  10105. return Ok(JsonView(false, "团组信息查询失败!"));
  10106. }
  10107. var di = deleInfo.Data as DelegationInfoWebView;
  10108. if (di == null)
  10109. {
  10110. return Ok(JsonView(false, "团组信息查询失败!"));
  10111. }
  10112. //文件名
  10113. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  10114. //获取模板
  10115. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  10116. //载入模板
  10117. Document doc = new Document(tmppath);
  10118. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  10119. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  10120. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  10121. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  10122. var AParameter = ParameterList.Find(x => x.CostType == "A");
  10123. var BParameter = ParameterList.Find(x => x.CostType == "B");
  10124. if (AParameter == null)
  10125. {
  10126. return Ok(JsonView(false, "系数不存在!"));
  10127. }
  10128. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  10129. , TzAirDesc, TzZCost;
  10130. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  10131. = TzAirDesc = TzZCost = string.Empty;
  10132. TzNumber = AParameter.CostTypenumber.ToString();
  10133. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  10134. CarGuides1 = dto.CarGuides1;
  10135. Meal = dto.Meal;
  10136. SubsidizedMeals = dto.SubsidizedMeals;
  10137. NightRepair = dto.NightRepair;
  10138. AttractionsTickets = dto.AttractionsTickets;
  10139. MiscellaneousFees = dto.MiscellaneousFees;
  10140. ATip = dto.ATip;
  10141. TzHotelDesc = "";
  10142. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  10143. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  10144. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  10145. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  10146. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  10147. TzAirDesc = "";
  10148. TzZCost = dto.TzZCost;
  10149. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  10150. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  10151. var index = 1;
  10152. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  10153. foreach (var item in TzHotelDescArr)
  10154. {
  10155. if (AinfoArr != null)
  10156. {
  10157. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10158. if (Ainfo != null)
  10159. {
  10160. if (int.Parse(Ainfo.rs) <= 0)
  10161. {
  10162. continue;
  10163. }
  10164. var hotelText = string.Empty;
  10165. switch (item)
  10166. {
  10167. case "SGR":
  10168. hotelText = "单人间";
  10169. break;
  10170. case "JSES":
  10171. hotelText = "小套房";
  10172. break;
  10173. case "SUITE":
  10174. hotelText = "套房";
  10175. break;
  10176. case "TBR":
  10177. hotelText = "双人间";
  10178. break;
  10179. }
  10180. if (item != "TBR")
  10181. {
  10182. 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";
  10183. }
  10184. else
  10185. {
  10186. 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";
  10187. }
  10188. index++;
  10189. }
  10190. }
  10191. }
  10192. index = 1;
  10193. foreach (var item in TzAirDescArr)
  10194. {
  10195. if (AinfoArr != null)
  10196. {
  10197. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10198. if (Ainfo != null)
  10199. {
  10200. if (int.Parse(Ainfo.rs) <= 0)
  10201. {
  10202. continue;
  10203. }
  10204. 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";
  10205. index++;
  10206. }
  10207. }
  10208. }
  10209. if (dto.costType == "B")
  10210. {
  10211. if (BParameter == null)
  10212. {
  10213. return Ok(JsonView(false, "B段系数不存在!"));
  10214. }
  10215. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  10216. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  10217. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  10218. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  10219. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  10220. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  10221. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  10222. foreach (var item in TzHotelDescArr)
  10223. {
  10224. if (AinfoArr != null)
  10225. {
  10226. TzHotelDesc += "B段信息 \r\n";
  10227. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10228. if (Ainfo != null)
  10229. {
  10230. if (int.Parse(Ainfo.rs) <= 0)
  10231. {
  10232. continue;
  10233. }
  10234. var hotelText = string.Empty;
  10235. switch (item)
  10236. {
  10237. case "SGR":
  10238. hotelText = "单人间";
  10239. break;
  10240. case "JSES":
  10241. hotelText = "小套房";
  10242. break;
  10243. case "SUITE":
  10244. hotelText = "套房";
  10245. break;
  10246. case "TBR":
  10247. hotelText = "双人间";
  10248. break;
  10249. }
  10250. if (item != "TBR")
  10251. {
  10252. 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";
  10253. }
  10254. else
  10255. {
  10256. 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";
  10257. }
  10258. index++;
  10259. }
  10260. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  10261. }
  10262. }
  10263. index = 1;
  10264. foreach (var item in TzAirDescArr)
  10265. {
  10266. if (AinfoArr != null)
  10267. {
  10268. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10269. if (Ainfo != null)
  10270. {
  10271. if (int.Parse(Ainfo.rs) <= 0)
  10272. {
  10273. continue;
  10274. }
  10275. 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";
  10276. index++;
  10277. }
  10278. }
  10279. }
  10280. }
  10281. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  10282. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  10283. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  10284. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  10285. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  10286. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  10287. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  10288. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  10289. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  10290. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  10291. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  10292. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  10293. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  10294. DickeyValue.Add("Visa", Visa); // 签证单人报价
  10295. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  10296. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  10297. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  10298. DickeyValue.Add("TzZCost", TzZCost);
  10299. foreach (var key in DickeyValue.Keys)
  10300. {
  10301. if (doc.Range.Bookmarks[key] != null)
  10302. {
  10303. Bookmark mark = doc.Range.Bookmarks[key];
  10304. mark.Text = DickeyValue[key];
  10305. }
  10306. }
  10307. byte[] bytes = null;
  10308. string strFileName = di.TeamName + "-客户报价.doc";
  10309. using (MemoryStream stream = new MemoryStream())
  10310. {
  10311. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10312. bytes = stream.ToArray();
  10313. }
  10314. return Ok(JsonView(true, "", new
  10315. {
  10316. Data = bytes,
  10317. strFileName,
  10318. }));
  10319. }
  10320. /// <summary>
  10321. /// 团组成本 各模块(酒店,地接,机票)成本提示
  10322. /// </summary>
  10323. /// <param name="dto"></param>
  10324. /// <returns></returns>
  10325. [HttpPost]
  10326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10327. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  10328. {
  10329. try
  10330. {
  10331. #region 参数验证
  10332. if (dto.DiId < 0)
  10333. {
  10334. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  10335. }
  10336. List<int> cTableIds = new List<int>() {
  10337. 76 ,//酒店预订
  10338. 77 ,//行程
  10339. 79 ,//车/导游地接
  10340. 80 ,//签证
  10341. 81 ,//邀请/公务活
  10342. 82 ,//团组客户保险
  10343. 85 ,//机票预订
  10344. 98 ,//其他款项
  10345. 285 ,//收款退还
  10346. 751 ,//酒店早餐
  10347. 1015 // 超支费用
  10348. };
  10349. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  10350. {
  10351. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  10352. }
  10353. #endregion
  10354. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  10355. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  10356. if (_GroupCostParameters.Count <= 0)
  10357. {
  10358. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  10359. }
  10360. if (_GroupCostParameters[0].IsShare == 0)
  10361. {
  10362. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  10363. }
  10364. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10365. //处理date为空问题
  10366. if (_GroupCosts.Count > 0)
  10367. {
  10368. for (int i = 0; i < _GroupCosts.Count; i++)
  10369. {
  10370. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  10371. {
  10372. if (i > 0)
  10373. {
  10374. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  10375. }
  10376. }
  10377. }
  10378. }
  10379. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  10380. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  10381. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  10382. string currCode = "";
  10383. #region currCode 验证
  10384. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  10385. if (isInt)
  10386. {
  10387. var currData = currDatas.Find(it => it.Id == intCurrency);
  10388. if (currData != null)
  10389. {
  10390. currCode = currData.Name;
  10391. }
  10392. }
  10393. else
  10394. {
  10395. currCode = _GroupCostParameters[0].Currency.Trim();
  10396. }
  10397. #endregion
  10398. //op,酒店单段模式存储
  10399. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  10400. {
  10401. CurrencyCode = currCode,
  10402. Rate = _GroupCostParameters[0].Rate,
  10403. CostType = _GroupCostParameters[0].CostType,
  10404. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  10405. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  10406. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  10407. };
  10408. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  10409. if (_GroupCostParameters.Count == 2)
  10410. {
  10411. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  10412. }
  10413. foreach (var item in _GroupCostParameters)
  10414. {
  10415. decimal _rate = 1;
  10416. decimal _rate1 = item.Rate;
  10417. decimal _scale = 1;
  10418. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  10419. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  10420. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  10421. //if (userInfo != null)
  10422. //{
  10423. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  10424. // {
  10425. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  10426. // {
  10427. // _scale = 1.00M;
  10428. // }
  10429. // }
  10430. //}
  10431. #endregion
  10432. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  10433. {
  10434. CurrencyCode = currCode,
  10435. Rate = _rate1,
  10436. CostType = item.CostType,
  10437. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  10438. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  10439. CostTypeNumber = item.CostTypenumber
  10440. };
  10441. if (_GroupCostParameters.Count > 1)
  10442. {
  10443. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  10444. }
  10445. else
  10446. {
  10447. modulePromptInfo.CostTypeNumber = item.LYJRS;
  10448. }
  10449. if (dto.CTable == 79)//
  10450. {
  10451. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  10452. modulePromptInfo.TotalCost = item.DJCB;
  10453. }
  10454. List<string> costTypes = new List<string>() { "A", "B" };
  10455. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  10456. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  10457. if (_GroupCostsDuplicates.Count() == 1)
  10458. {
  10459. _GroupCostsTypeData = _GroupCosts;
  10460. }
  10461. else
  10462. {
  10463. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  10464. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  10465. }
  10466. /*
  10467. * 76 酒店预订
  10468. * 77 行程
  10469. * 79 车/导游地接
  10470. * 80 签证
  10471. * 81 邀请/公务活动
  10472. * 82 团组客户保险
  10473. * 85 机票预订
  10474. * 98 其他款项
  10475. * 285 收款退还
  10476. * 751 酒店早餐
  10477. * 1015 超支费用
  10478. */
  10479. switch (dto.CTable)
  10480. {
  10481. case 76: // 酒店预订
  10482. _ModuleSubPromptInfo.AddRange(
  10483. _GroupCostsTypeData.Select(it => new
  10484. {
  10485. it.DAY,
  10486. it.Date,
  10487. it.ACCON,
  10488. it.ITIN,
  10489. it.SGR,
  10490. it.TBR,
  10491. it.JS_ES,
  10492. it.Suite
  10493. })
  10494. );
  10495. break;
  10496. case 79: // 车/导游地接
  10497. _ModuleSubPromptInfo.AddRange(
  10498. _GroupCostsTypeData.Select(it => new
  10499. {
  10500. Date = it.Date, //日期
  10501. CarFee = it.CarCost * _rate * _scale, //车费用
  10502. CarType = it.CarType, //车型
  10503. DriverFee = it.CFS * _rate * _scale, //司机工资
  10504. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  10505. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  10506. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  10507. GuideFee = it.TGS * _rate * _scale, //导游费用
  10508. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  10509. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  10510. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  10511. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  10512. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  10513. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  10514. Breakfast = it.B * _rate * _scale, //早餐费
  10515. Lunch = it.L * _rate * _scale, //午餐费
  10516. Dinner = it.D * _rate * _scale, //晚餐费
  10517. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  10518. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  10519. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  10520. TicketFee = it.EF * _rate * _scale, //门票费
  10521. TicketRemark = it.EFR, //门票费描述
  10522. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  10523. TravelSupplies = it.TE * _rate * _scale, //出行物资
  10524. SpentCash = it.PC * _rate * _scale, //零用金
  10525. LeadersFee = it.TLF * _rate * _scale, //领队费
  10526. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  10527. })
  10528. );
  10529. break;
  10530. case 85: // 机票
  10531. List<dynamic> datas = new List<dynamic>();
  10532. datas.Add(
  10533. new
  10534. {
  10535. AirType = "经济舱",
  10536. AirNum = item.JJCRS,
  10537. AirDRCB = item.JJCCB,
  10538. AirZCB = (item.JJCRS * item.JJCCB)
  10539. }
  10540. );
  10541. datas.Add(
  10542. new
  10543. {
  10544. AirType = "公务舱",
  10545. AirNum = item.GWCRS,
  10546. AirDRCB = item.GWCCB,
  10547. AirZCB = (item.GWCRS * item.GWCCB)
  10548. }
  10549. );
  10550. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10551. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  10552. modulePromptInfo.Data = new
  10553. {
  10554. airFeeData = datas,
  10555. airInitData = initDatas
  10556. };
  10557. _ModulePromptInfos.Add(modulePromptInfo);
  10558. break;
  10559. default:
  10560. break;
  10561. }
  10562. }
  10563. if (dto.CTable != 85)
  10564. {
  10565. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  10566. _ModulePromptInfos.Add(_ModulePromptInfo);
  10567. }
  10568. _view.ModulePromptInfos = _ModulePromptInfos;
  10569. return Ok(JsonView(true, "操作成功!", _view));
  10570. }
  10571. catch (Exception ex)
  10572. {
  10573. return Ok(JsonView(false, ex.Message));
  10574. }
  10575. }
  10576. /// <summary>
  10577. /// 根据黑屏代码重新生成行程
  10578. /// </summary>
  10579. /// <param name="dto"></param>
  10580. /// <returns></returns>
  10581. [HttpPost]
  10582. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  10583. {
  10584. var jw = JsonView(false);
  10585. var Create = _GroupCostRepository.
  10586. CreateGroupCostByBlackCode(dto.Diid);
  10587. jw.Msg = Create.Msg;
  10588. if (Create.Code == 0)
  10589. {
  10590. jw.Code = 200;
  10591. jw.Data = new
  10592. {
  10593. groupCost = Create.Data,
  10594. blackCodeIsTrue = true
  10595. };
  10596. }
  10597. else
  10598. {
  10599. jw.Code = 400;
  10600. jw.Data = new
  10601. {
  10602. groupCost = Create.Data,
  10603. blackCodeIsTrue = false,
  10604. };
  10605. }
  10606. return Ok(jw);
  10607. }
  10608. /// <summary>
  10609. /// 成本获取OP历史车费用
  10610. /// </summary>
  10611. /// <param name="dto"></param>
  10612. /// <returns></returns>
  10613. [HttpPost]
  10614. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  10615. {
  10616. var jw = JsonView(false);
  10617. try
  10618. {
  10619. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  10620. //获取现有所有车的数据
  10621. if (!dto.Param.IsNullOrWhiteSpace())
  10622. {
  10623. string sql = $@"
  10624. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  10625. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  10626. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  10627. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  10628. AND gctggr.ServiceEndTime is not NULL
  10629. ORDER by gctggrc.id DESC
  10630. ";
  10631. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  10632. var numeberResult = await Task.Run(() =>
  10633. {
  10634. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  10635. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  10636. return numberArr;
  10637. });
  10638. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  10639. foreach (var item in numeberResult)
  10640. {
  10641. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  10642. {
  10643. Country = "数据异常!",
  10644. City = string.Empty,
  10645. };
  10646. item.Area = find.Country + " " + find.City;
  10647. }
  10648. dbResult.AddRange(numeberResult);
  10649. if (dto.Param.Contains("、"))
  10650. {
  10651. var sp = dto.Param.Split("、");
  10652. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10653. .Where(x =>
  10654. {
  10655. return System.Array.Exists(sp, e =>
  10656. {
  10657. bool where = false;
  10658. if (x.Area != null)
  10659. {
  10660. where = x.Area.Contains(e);
  10661. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10662. {
  10663. return false;
  10664. }
  10665. }
  10666. if (x.PriceName != null && !where)
  10667. {
  10668. where = x.PriceName.Contains(e);
  10669. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10670. {
  10671. return false;
  10672. }
  10673. }
  10674. return where;
  10675. });
  10676. }).ToList();
  10677. }
  10678. else
  10679. {
  10680. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10681. .Where(x =>
  10682. {
  10683. bool where = false;
  10684. if (x.Area != null)
  10685. {
  10686. where = x.Area.Contains(dto.Param);
  10687. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10688. {
  10689. return false;
  10690. }
  10691. }
  10692. if (x.PriceName != null && !where)
  10693. {
  10694. where = x.PriceName.Contains(dto.Param);
  10695. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10696. {
  10697. return false;
  10698. }
  10699. }
  10700. return where;
  10701. }
  10702. )
  10703. .ToList();
  10704. }
  10705. }
  10706. var view = dbResult.Select(x =>
  10707. {
  10708. decimal dp = 0.00M;
  10709. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  10710. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  10711. if (string.IsNullOrWhiteSpace(x.DatePrice))
  10712. {
  10713. if (startB && endB)
  10714. {
  10715. var timesp = endD.Subtract(startD);
  10716. if ((timesp.Days + 1) != 0)
  10717. {
  10718. dp = x.Price / (timesp.Days + 1);
  10719. }
  10720. }
  10721. }
  10722. else
  10723. {
  10724. dp = x.Price;
  10725. }
  10726. return new
  10727. {
  10728. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  10729. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  10730. x.Area,
  10731. x.id,
  10732. price = x.Price.ToString("F2"),
  10733. x.PriceName,
  10734. x.PriceContent,
  10735. x.TeamName,
  10736. x.DatePrice,
  10737. dayPrice = dp.ToString("F2"),
  10738. };
  10739. }).OrderByDescending(x => x.id).ToList();
  10740. jw = JsonView(true, "获取成功!", view);
  10741. }
  10742. catch (Exception e)
  10743. {
  10744. jw = JsonView(false, e.Message);
  10745. }
  10746. return Ok(jw);
  10747. }
  10748. #endregion
  10749. #region 酒店预订 新 雷怡 2023-12-28 17:45
  10750. /// <summary>
  10751. /// 酒店预订
  10752. /// 酒店费用列表 根据团组Id查询
  10753. /// </summary>
  10754. /// <param name="_dto"></param>
  10755. /// <returns></returns>
  10756. [HttpPost]
  10757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10758. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  10759. {
  10760. #region 参数验证
  10761. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10762. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10763. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10764. #region 团组操作权限验证 76 酒店预定模块
  10765. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10766. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10767. #endregion
  10768. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10769. #region 页面操作权限验证
  10770. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10771. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10772. #endregion
  10773. #endregion
  10774. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  10775. }
  10776. /// <summary>
  10777. /// 酒店预订
  10778. /// 基础数据
  10779. /// </summary>
  10780. /// <param name="_dto"></param>
  10781. /// <returns></returns>
  10782. [HttpPost]
  10783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10784. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  10785. {
  10786. #region 参数验证
  10787. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10788. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10789. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10790. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10791. #region 页面操作权限验证
  10792. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10793. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10794. #endregion
  10795. #region 团组操作权限验证 76 酒店预定模块
  10796. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10797. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10798. #endregion
  10799. #endregion
  10800. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  10801. }
  10802. /// <summary>
  10803. /// 酒店预订
  10804. /// 创建 入住卷号码
  10805. /// </summary>
  10806. /// <param name="_dto"></param>
  10807. /// <returns></returns>
  10808. [HttpPost]
  10809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10810. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  10811. {
  10812. #region 参数验证
  10813. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10814. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10815. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10816. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10817. #region 页面操作权限验证
  10818. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10819. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10820. #endregion
  10821. #region 团组操作权限验证 76 酒店预定模块
  10822. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10823. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10824. #endregion
  10825. #endregion
  10826. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  10827. if (data.Code != 0)
  10828. {
  10829. return Ok(JsonView(false, data.Msg));
  10830. }
  10831. return Ok(JsonView(true, data.Msg, data.Data));
  10832. }
  10833. /// <summary>
  10834. /// 酒店预订
  10835. /// 详情
  10836. /// </summary>
  10837. /// <param name="_dto"></param>
  10838. /// <returns></returns>
  10839. [HttpPost]
  10840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10841. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  10842. {
  10843. #region 参数验证
  10844. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  10845. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10846. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  10847. #region 团组操作权限验证 76 酒店预定模块
  10848. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10849. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10850. #endregion
  10851. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10852. #region 页面操作权限验证
  10853. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10854. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10855. #endregion
  10856. #endregion
  10857. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  10858. }
  10859. /// <summary>
  10860. /// 酒店预订
  10861. /// Add Or Edit
  10862. /// </summary>
  10863. /// <param name="_dto"></param>
  10864. /// <returns></returns>
  10865. [HttpPost]
  10866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10867. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  10868. {
  10869. #region 参数验证
  10870. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10871. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10872. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10873. #region 团组操作权限验证 76 酒店预定模块
  10874. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10875. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10876. #endregion
  10877. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10878. #region 页面操作权限验证
  10879. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10880. if (_dto.Id == 0) // Add
  10881. {
  10882. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10883. }
  10884. else if (_dto.Id > 1) // Edit
  10885. {
  10886. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10887. }
  10888. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  10889. #endregion
  10890. #endregion
  10891. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  10892. if (_view.Code != 200)
  10893. {
  10894. return Ok(_view);
  10895. }
  10896. #region 成本无酒店价格数据进入超支
  10897. _sqlSugar.BeginTran();
  10898. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  10899. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  10900. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  10901. for (int i = 0; i < groupCost.Count; i++)
  10902. {
  10903. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  10904. {
  10905. groupCost[i].Date = groupCost[i - 1].Date;
  10906. }
  10907. }
  10908. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  10909. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  10910. List<Fin_GroupExtraCostDto_OP>();
  10911. if (start_Bool && end_Bool)
  10912. {
  10913. while (start_Time < end_Time)
  10914. {
  10915. foreach (var item in groupCost_Grp)
  10916. {
  10917. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  10918. {
  10919. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  10920. {
  10921. extraCostList.Add(new
  10922. Fin_GroupExtraCostDto_OP
  10923. {
  10924. Area = _dto.AreaId,
  10925. coefficient = 1.5M,
  10926. createUser = _dto.UserId,
  10927. currency = _dto.CardPriceCurrency,
  10928. diId = _dto.DiId,
  10929. ManagerConfirm = 0,
  10930. SupervisorConfirm = 0,
  10931. SYsupervisorConfirm = 0,
  10932. editType = 1,
  10933. PortType = 1,
  10934. price = _dto.CardPrice,
  10935. PriceCount = 1,
  10936. priceType = 1027,
  10937. priceDetailType = 1044,
  10938. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  10939. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  10940. });
  10941. }
  10942. }
  10943. }
  10944. start_Time = start_Time.AddDays(1);
  10945. }
  10946. }
  10947. if (extraCostList.Any())
  10948. {
  10949. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  10950. }
  10951. _sqlSugar.CommitTran();
  10952. #endregion
  10953. #region 应用推送
  10954. try
  10955. {
  10956. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10957. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10958. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10959. var diId = _dto.DiId;
  10960. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10961. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10962. #region 操作记录
  10963. var opInfo = new Crm_TableOperationRecord() {
  10964. TableName = "Grp_HotelReservations",
  10965. PortType = _dto.PortType,
  10966. DataId = hotelId,
  10967. CreateUserId = _dto.UserId
  10968. };
  10969. var opStatus = OperationEnum.NoOperation;
  10970. if (_dto.Id<1) //添加操作
  10971. {
  10972. opInfo.OperationItem = OperationEnum.Add;
  10973. }
  10974. else if (_dto.Id > 0)
  10975. {
  10976. opInfo.OperationItem = OperationEnum.Edit;
  10977. }
  10978. string opRemark = string.Empty;
  10979. if (ccpInfo != null)
  10980. {
  10981. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  10982. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  10983. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  10984. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  10985. }
  10986. opInfo.Remark = opRemark;
  10987. await _tableorRep.AddAsync(opInfo);
  10988. #endregion
  10989. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  10990. //2024-10-21 新增LZ UID
  10991. var userIds = new List<int>() { 21 };
  10992. string title = $"费用审核";
  10993. string content = "";
  10994. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10995. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10996. try
  10997. {
  10998. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10999. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  11000. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  11001. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  11002. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  11003. }
  11004. catch (Exception ex )
  11005. {
  11006. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  11007. }
  11008. }
  11009. catch (Exception ex)
  11010. {
  11011. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  11012. }
  11013. try
  11014. {
  11015. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  11016. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  11017. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  11018. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11019. //自动审核
  11020. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  11021. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  11022. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  11023. //2024-10-21 新增LZ UID
  11024. var userIds = new List<int>() { 21 };
  11025. string title = $"系统通知";
  11026. var diId = _dto.DiId;
  11027. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11028. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11029. string content = "";
  11030. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11031. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11032. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11033. }
  11034. catch (Exception ex)
  11035. {
  11036. }
  11037. #endregion
  11038. return Ok(_view);
  11039. }
  11040. /// <summary>
  11041. /// 酒店自动审核测试
  11042. /// Add Or Edit
  11043. /// </summary>
  11044. /// <param name="_dto"></param>
  11045. /// <returns></returns>
  11046. [HttpPost]
  11047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11048. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  11049. {
  11050. #region 应用推送
  11051. try
  11052. {
  11053. //自动审核
  11054. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  11055. }
  11056. catch (Exception ex)
  11057. {
  11058. return Ok(JsonView(false, "操作失败"));
  11059. }
  11060. #endregion
  11061. return Ok(JsonView(false, "操作成功"));
  11062. }
  11063. /// <summary>
  11064. /// 酒店预订
  11065. /// Del
  11066. /// </summary>
  11067. /// <param name="_dto"></param>
  11068. /// <returns></returns>
  11069. [HttpPost]
  11070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11071. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  11072. {
  11073. #region 参数验证
  11074. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11075. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11076. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11077. #region 团组操作权限验证 76 酒店预定模块
  11078. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11079. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11080. #endregion
  11081. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11082. #region 页面操作权限验证
  11083. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11084. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11085. #endregion
  11086. #endregion
  11087. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  11088. #region 操作记录
  11089. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  11090. {
  11091. TableName = "Grp_HotelReservations",
  11092. PortType = _dto.PortType,
  11093. OperationItem = OperationEnum.Del,
  11094. DataId = _dto.Id,
  11095. CreateUserId = _dto.UserId
  11096. });
  11097. #endregion
  11098. return Ok(data);
  11099. }
  11100. /// <summary>
  11101. /// 酒店预订
  11102. /// 生成VOUCHER
  11103. /// 2024.05.06 之前版本
  11104. /// </summary>
  11105. /// <param name="_dto"></param>
  11106. /// <returns></returns>
  11107. [HttpPost]
  11108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11109. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  11110. {
  11111. try
  11112. {
  11113. #region 参数验证
  11114. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11115. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11116. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11117. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  11118. #region 团组操作权限验证 76 酒店预定模块
  11119. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11120. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11121. #endregion
  11122. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11123. #region 页面操作权限验证
  11124. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11125. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11126. #endregion
  11127. #endregion
  11128. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  11129. //判断数据是否完整
  11130. if (hr != null)
  11131. {
  11132. if (!string.IsNullOrEmpty(hr.DetermineNo))
  11133. {
  11134. string strFileName = "HotelStatement/";
  11135. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11136. if (dele != null)
  11137. strFileName += dele.TourCode;
  11138. //载入模板
  11139. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  11140. Document doc = new Document(sss);
  11141. DocumentBuilder builder = new DocumentBuilder(doc);
  11142. #region 替换Word模板书签内容
  11143. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  11144. //入住卷预定号码
  11145. if (doc.Range.Bookmarks["VNO"] != null)
  11146. {
  11147. Bookmark mark = doc.Range.Bookmarks["VNO"];
  11148. mark.Text = hr.CheckNumber;
  11149. }
  11150. //酒店时间
  11151. if (doc.Range.Bookmarks["Date"] != null)
  11152. {
  11153. Bookmark mark = doc.Range.Bookmarks["Date"];
  11154. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11155. }
  11156. //团号
  11157. if (doc.Range.Bookmarks["TNo"] != null)
  11158. {
  11159. Bookmark mark = doc.Range.Bookmarks["TNo"];
  11160. mark.Text = dele.TourCode;
  11161. }
  11162. //预定号码
  11163. if (doc.Range.Bookmarks["BookingId"] != null)
  11164. {
  11165. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  11166. mark.Text = hr.ReservationsNo;
  11167. }
  11168. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  11169. {
  11170. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  11171. mark.Text = hr.DetermineNo;
  11172. }
  11173. //酒店城市
  11174. if (doc.Range.Bookmarks["City"] != null)
  11175. {
  11176. Bookmark mark = doc.Range.Bookmarks["City"];
  11177. mark.Text = hr.City;
  11178. }
  11179. //酒店名称
  11180. if (doc.Range.Bookmarks["HName"] != null)
  11181. {
  11182. Bookmark mark = doc.Range.Bookmarks["HName"];
  11183. mark.Text = hr.HotelName;
  11184. }
  11185. //酒店地址
  11186. if (doc.Range.Bookmarks["Address"] != null)
  11187. {
  11188. Bookmark mark = doc.Range.Bookmarks["Address"];
  11189. mark.Text = hr.HotelAddress;
  11190. }
  11191. //酒店电话
  11192. if (doc.Range.Bookmarks["Tel"] != null)
  11193. {
  11194. Bookmark mark = doc.Range.Bookmarks["Tel"];
  11195. mark.Text = hr.HotelTel;
  11196. }
  11197. //酒店传真
  11198. if (doc.Range.Bookmarks["Fax"] != null)
  11199. {
  11200. Bookmark mark = doc.Range.Bookmarks["Fax"];
  11201. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  11202. {
  11203. mark.Text = hr.HotelFax;
  11204. }
  11205. }
  11206. //入住时间
  11207. if (doc.Range.Bookmarks["CIn"] != null)
  11208. {
  11209. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11210. Bookmark mark = doc.Range.Bookmarks["CIn"];
  11211. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  11212. }
  11213. //退房时间
  11214. if (doc.Range.Bookmarks["COut"] != null)
  11215. {
  11216. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11217. Bookmark mark = doc.Range.Bookmarks["COut"];
  11218. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11219. }
  11220. //客户名称
  11221. if (doc.Range.Bookmarks["GName"] != null)
  11222. {
  11223. string guestName = "";
  11224. string[] clients = new string[] { };
  11225. if (hr.GuestName.Contains(","))
  11226. {
  11227. clients = hr.GuestName.Split(",");
  11228. }
  11229. else
  11230. {
  11231. clients = new string[] { hr.GuestName };
  11232. }
  11233. List<int> clientIds_int = new List<int>();
  11234. if (clients.Length > 0)
  11235. {
  11236. foreach (var item in clients)
  11237. {
  11238. if (item.IsNumeric())
  11239. {
  11240. clientIds_int.Add(int.Parse(item));
  11241. }
  11242. }
  11243. }
  11244. if (clientIds_int.Count > 0)
  11245. {
  11246. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  11247. foreach (var client in _clientDatas)
  11248. {
  11249. //男
  11250. if (client.Sex == 0) guestName += $"Mr.";
  11251. //女
  11252. else if (client.Sex == 1) guestName += $"Ms.";
  11253. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  11254. {
  11255. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  11256. }
  11257. //guestName += $"{client.Pinyin},";
  11258. }
  11259. if (guestName.Length > 0)
  11260. {
  11261. guestName = guestName.Substring(0, guestName.Length - 1);
  11262. }
  11263. }
  11264. else
  11265. {
  11266. guestName = hr.GuestName;
  11267. }
  11268. Bookmark mark = doc.Range.Bookmarks["GName"];
  11269. mark.Text = guestName;
  11270. }
  11271. //房间介绍
  11272. if (doc.Range.Bookmarks["ROOM"] != null)
  11273. {
  11274. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  11275. mark.Text = hr.RoomExplanation;
  11276. }
  11277. //报价描述
  11278. if (doc.Range.Bookmarks["NOTE"] != null)
  11279. {
  11280. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  11281. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  11282. if (ss != null)
  11283. mark.Text = ss.Name;
  11284. }
  11285. //入住时间
  11286. if (doc.Range.Bookmarks["CheckIn"] != null)
  11287. {
  11288. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11289. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  11290. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11291. }
  11292. //退房时间
  11293. if (doc.Range.Bookmarks["CheckOut"] != null)
  11294. {
  11295. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11296. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  11297. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11298. }
  11299. //日期
  11300. if (doc.Range.Bookmarks["DT"] != null)
  11301. {
  11302. Bookmark mark = doc.Range.Bookmarks["DT"];
  11303. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11304. }
  11305. //名称
  11306. if (doc.Range.Bookmarks["VName"] != null)
  11307. {
  11308. Bookmark mark = doc.Range.Bookmarks["VName"];
  11309. mark.Text = hr.HotelName;
  11310. }
  11311. //号码
  11312. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  11313. {
  11314. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  11315. mark.Text = hr.CheckNumber;
  11316. }
  11317. #endregion
  11318. strFileName += "VOUCHER.doc";
  11319. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11320. doc.Save(fileDir);
  11321. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11322. return Ok(JsonView(true, "操作成功!", Url));
  11323. }
  11324. else
  11325. {
  11326. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  11327. }
  11328. }
  11329. else
  11330. {
  11331. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  11332. }
  11333. }
  11334. catch (Exception ex)
  11335. {
  11336. return Ok(JsonView(false, ex.Message));
  11337. }
  11338. }
  11339. /// <summary>
  11340. /// 酒店预订
  11341. /// 生成VOUCHER
  11342. /// 2024.05.06 之后版本
  11343. /// </summary>
  11344. /// <param name="_dto"></param>
  11345. /// <returns></returns>
  11346. [HttpPost]
  11347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11348. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  11349. {
  11350. #region 参数验证
  11351. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11352. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11353. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11354. #region 团组操作权限验证 76 酒店预定模块
  11355. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11356. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11357. #endregion
  11358. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11359. #region 页面操作权限验证
  11360. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11361. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11362. #endregion
  11363. #endregion
  11364. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  11365. //判断数据是否完整
  11366. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11367. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11368. string strFileName = "HotelStatement/";
  11369. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11370. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  11371. #region 数据处理
  11372. List<int> guestIds = new List<int>();
  11373. int index = 0;
  11374. foreach (var item in hrDtas)
  11375. {
  11376. if (item.GuestName.Contains(","))
  11377. {
  11378. string[] guestIdArr = item.GuestName.Split(',');
  11379. foreach (var guestIdStr in guestIdArr)
  11380. {
  11381. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  11382. if (guestBool)
  11383. {
  11384. guestIds.Add(guestId);
  11385. }
  11386. }
  11387. }
  11388. else guestNames += item.GuestName;
  11389. var voucherInfo = new HotelVoucherInfoView()
  11390. {
  11391. HotelName = item.HotelName,
  11392. CheckInDate = item.CheckInDate,
  11393. CheckOutDate = item.CheckOutDate,
  11394. ConfirmationNumber = item.DetermineNo.Trim(),
  11395. RoomType = item.RoomExplanation
  11396. };
  11397. vouchers.Add(voucherInfo);
  11398. }
  11399. if (guestIds.Count > 0)
  11400. {
  11401. guestIds = guestIds.Distinct().ToList();
  11402. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  11403. if (guestDatas.Count > 0)
  11404. {
  11405. guestNames = "";
  11406. foreach (var guest in guestDatas)
  11407. {
  11408. string guestName = "";
  11409. if (guest.Sex == 0) guestName += @"MR.";
  11410. else if (guest.Sex == 1) guestName += @"MS.";
  11411. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11412. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11413. guestNames += @$"{guestName.Trim()}、";
  11414. }
  11415. if (guestNames.Length > 0)
  11416. {
  11417. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11418. }
  11419. }
  11420. }
  11421. #endregion
  11422. //载入模板
  11423. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  11424. Document doc = new Document(sss);
  11425. DocumentBuilder builder = new DocumentBuilder(doc);
  11426. if (doc.Range.Bookmarks["GuestName"] != null)
  11427. {
  11428. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  11429. mark.Text = guestNames;
  11430. }
  11431. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11432. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  11433. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  11434. for (int i = 1; i <= vouchers.Count; i++)
  11435. {
  11436. HotelVoucherInfoView hviv = vouchers[i - 1];
  11437. builder.MoveToCell(0, i, 0, 0);
  11438. builder.Write(hviv.HotelName);
  11439. builder.MoveToCell(0, i, 1, 0);
  11440. builder.Write(hviv.CheckInDate);
  11441. builder.MoveToCell(0, i, 2, 0);
  11442. builder.Write(hviv.CheckOutDate);
  11443. builder.MoveToCell(0, i, 3, 0);
  11444. builder.Write(hviv.RoomType);
  11445. builder.MoveToCell(0, i, 4, 0);
  11446. builder.Write(hviv.ConfirmationNumber);
  11447. }
  11448. //删除多余行
  11449. int currRowIndex = vouchers.Count + 1;
  11450. int delRows = 21 - currRowIndex;
  11451. if (delRows > 0)
  11452. {
  11453. for (int i = 0; i < delRows; i++)
  11454. {
  11455. table.Rows.RemoveAt(currRowIndex);
  11456. //cultivateRowIndex++;
  11457. }
  11458. }
  11459. strFileName += "VOUCHER.docx";
  11460. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11461. doc.Save(fileDir);
  11462. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11463. return Ok(JsonView(true, "操作成功!", Url));
  11464. }
  11465. /// <summary>
  11466. /// 酒店预订
  11467. /// 生成VOUCHER 批量生成
  11468. /// New
  11469. /// </summary>
  11470. /// <param name="_dto"></param>
  11471. /// <returns></returns>
  11472. [HttpPost]
  11473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11474. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  11475. {
  11476. #region 参数验证
  11477. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11478. if (_dto.PageId < 1) _dto.PageId = 28;
  11479. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11480. #region 团组操作权限验证 76 酒店预定模块
  11481. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11482. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11483. #endregion
  11484. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11485. #region 页面操作权限验证
  11486. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11487. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11488. #endregion
  11489. #endregion
  11490. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  11491. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  11492. .OrderBy(x => x.CheckInDate)
  11493. .ToListAsync();
  11494. //判断数据是否完整
  11495. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11496. string strFileName = "HotelStatement/";
  11497. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11498. if (dele != null)
  11499. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  11500. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  11501. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  11502. .Where(it => it.IsDel == 0)
  11503. .ToListAsync();
  11504. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  11505. for (int i = 0; i < hrDtas.Count; i++)
  11506. {
  11507. string guestNames = string.Empty;
  11508. List<int> guestIds = new List<int>();
  11509. var item = hrDtas[i];
  11510. //处理客户姓名
  11511. if (item.GuestName.Contains(","))
  11512. {
  11513. string[] guestIdArr = item.GuestName.Split(',');
  11514. foreach (var guestIdStr in guestIdArr)
  11515. if (int.TryParse(guestIdStr, out int guestId))
  11516. guestIds.Add(guestId);
  11517. }
  11518. else
  11519. {
  11520. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  11521. if (guestIdBool)
  11522. {
  11523. guestIds.Add(guestId);
  11524. }
  11525. //NaN
  11526. if (item.GuestName.Contains("NaN"))
  11527. {
  11528. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  11529. }
  11530. }
  11531. if (guestIds.Count > 0)
  11532. {
  11533. guestIds = guestIds.Distinct().ToList();
  11534. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  11535. if (guestDatas1.Count > 0)
  11536. {
  11537. guestNames = "";
  11538. foreach (var guest in guestDatas1)
  11539. {
  11540. string guestName = "";
  11541. if (guest.Sex == 0) guestName += @"MR.";
  11542. else if (guest.Sex == 1) guestName += @"MS.";
  11543. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11544. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11545. guestNames += @$"{guestName.Trim()}、";
  11546. }
  11547. if (guestNames.Length > 0)
  11548. {
  11549. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11550. }
  11551. }
  11552. }
  11553. //if (!string.IsNullOrEmpty(guestNames))
  11554. //{
  11555. hrDtas[i].GuestName = guestNames;
  11556. //}
  11557. }
  11558. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11559. Document doc = new Document();
  11560. DocumentBuilder builder = new DocumentBuilder(doc);
  11561. try
  11562. {
  11563. builder.MoveToDocumentStart();
  11564. foreach (var item in hrDtas)
  11565. {
  11566. //标题
  11567. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11568. builder.ParagraphFormat.LineSpacing = 1;
  11569. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11570. builder.ParagraphFormat.Style.Font.Size = 9;
  11571. builder.ParagraphFormat.Style.Font.Bold = true;
  11572. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11573. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  11574. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11575. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11576. builder.ParagraphFormat.LineSpacing = 1;
  11577. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11578. builder.ParagraphFormat.Style.Font.Size = 9;
  11579. builder.ParagraphFormat.Style.Font.Bold = true;
  11580. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  11581. builder.StartTable();
  11582. // 设置边框颜色
  11583. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  11584. //设置边框样式
  11585. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  11586. //表格
  11587. #region 第一行
  11588. builder.InsertCell();
  11589. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11590. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11591. //builder.CellFormat.AllowAutoFit = false;
  11592. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11593. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11594. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11595. builder.CellFormat.WrapText = true; //自动换行
  11596. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11597. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  11598. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11599. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11600. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11601. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11602. builder.Write("TOUR NO:");
  11603. builder.InsertCell();
  11604. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11605. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11606. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11607. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11608. builder.ParagraphFormat.Style.Font.Bold = false;
  11609. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11610. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11611. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11612. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11613. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11614. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11615. builder.Write($"{dele?.TourCode ?? "-"}");
  11616. builder.InsertCell();
  11617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11618. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11619. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11620. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11621. builder.ParagraphFormat.Style.Font.Bold = false;
  11622. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11623. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11624. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11625. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11626. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11627. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11628. builder.Write($"CITY:");
  11629. builder.InsertCell();
  11630. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11631. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11632. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11633. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11634. builder.ParagraphFormat.Style.Font.Bold = false;
  11635. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11636. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11637. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11638. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11639. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11640. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11641. builder.Write($"{item.City}");
  11642. builder.EndRow();
  11643. #endregion
  11644. #region 第二行
  11645. builder.InsertCell();
  11646. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11647. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11648. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11649. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11650. builder.ParagraphFormat.Style.Font.Bold = false;
  11651. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11652. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11653. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11654. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11655. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11656. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11657. builder.Write("CONFIRMATION NO:");
  11658. builder.InsertCell();
  11659. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11660. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11661. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11662. builder.ParagraphFormat.Style.Font.Bold = false;
  11663. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11664. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11665. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11666. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11667. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11668. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11669. builder.CellFormat.VerticalMerge = CellMerge.None;
  11670. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11671. builder.Write($"{item.DetermineNo}");
  11672. builder.InsertCell();
  11673. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11674. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11675. builder.InsertCell();
  11676. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11677. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11678. builder.EndRow();
  11679. #endregion
  11680. #region 第三行
  11681. builder.InsertCell();
  11682. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11683. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11684. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11685. builder.ParagraphFormat.Style.Font.Bold = false;
  11686. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11687. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11688. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11689. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11690. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11691. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11692. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11693. builder.Write($"HOTEL NAME:");
  11694. builder.InsertCell();
  11695. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11696. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11697. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11698. builder.ParagraphFormat.Style.Font.Bold = false;
  11699. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11700. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11701. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11702. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11703. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11704. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11705. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11706. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11707. builder.Write($"{item.HotelName}");
  11708. builder.InsertCell();
  11709. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11710. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11711. builder.InsertCell();
  11712. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11713. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11714. builder.EndRow();
  11715. #endregion
  11716. #region 第四行
  11717. builder.InsertCell();
  11718. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11719. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11720. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11721. builder.ParagraphFormat.Style.Font.Bold = false;
  11722. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11723. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11724. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11725. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11726. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11727. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11728. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11729. builder.Write($"HOTEL ADDRESS:");
  11730. builder.InsertCell();
  11731. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11732. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11733. builder.ParagraphFormat.Style.Font.Size = 8;
  11734. builder.ParagraphFormat.Style.Font.Bold = false;
  11735. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11736. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11737. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11738. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11739. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11740. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11741. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11742. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11743. builder.Write($"{item.HotelAddress}");
  11744. builder.InsertCell();
  11745. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11746. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11747. builder.InsertCell();
  11748. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11749. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11750. builder.EndRow();
  11751. #endregion
  11752. #region 第五行
  11753. builder.InsertCell();
  11754. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11755. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11756. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11757. builder.ParagraphFormat.Style.Font.Bold = false;
  11758. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11759. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11760. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11761. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11762. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11763. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11764. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11765. builder.Write("TEL:");
  11766. builder.InsertCell();
  11767. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11768. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11769. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11770. builder.ParagraphFormat.Style.Font.Bold = false;
  11771. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11772. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11773. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11774. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11775. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11776. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11777. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11778. builder.Write($"{item.HotelTel}");
  11779. builder.InsertCell();
  11780. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11781. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11782. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11783. builder.ParagraphFormat.Style.Font.Bold = false;
  11784. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11785. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11786. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11787. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11788. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11789. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11790. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11791. builder.Write($"FAX:");
  11792. builder.InsertCell();
  11793. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11794. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11795. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11796. builder.ParagraphFormat.Style.Font.Bold = false;
  11797. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11798. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11799. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11800. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11801. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11802. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11803. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11804. builder.Write($"{item.HotelFax}");
  11805. builder.EndRow();
  11806. #endregion
  11807. #region 第六行
  11808. builder.InsertCell();
  11809. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11810. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11811. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11812. builder.ParagraphFormat.Style.Font.Bold = false;
  11813. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11814. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11815. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11816. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11817. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11818. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11819. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11820. builder.Write("CHECK IN:");
  11821. builder.InsertCell();
  11822. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11823. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11824. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11825. builder.ParagraphFormat.Style.Font.Bold = false;
  11826. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11827. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11828. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11829. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11830. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11831. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11832. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11833. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  11834. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11835. builder.Write($"{checkInStr}");
  11836. builder.InsertCell();
  11837. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11838. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11839. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11840. builder.ParagraphFormat.Style.Font.Bold = false;
  11841. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11842. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11843. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11844. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11845. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11846. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11847. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11848. builder.Write($"CHECK OUT:");
  11849. builder.InsertCell();
  11850. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11851. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11852. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11853. builder.ParagraphFormat.Style.Font.Bold = false;
  11854. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11855. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11856. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11857. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11858. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11859. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11860. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11861. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  11862. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  11863. builder.Write($"{checkOutStr}");
  11864. builder.EndRow();
  11865. #endregion
  11866. #region 第七行
  11867. builder.InsertCell();
  11868. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11869. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11870. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11871. builder.ParagraphFormat.Style.Font.Bold = false;
  11872. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11873. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11874. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11875. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11876. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11877. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11878. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11879. builder.Write($"GUEST NAME:");
  11880. builder.InsertCell();
  11881. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11882. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11883. builder.ParagraphFormat.Style.Font.Size = 8;
  11884. builder.ParagraphFormat.Style.Font.Bold = false;
  11885. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11886. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11887. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11888. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11889. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11890. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11891. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11892. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11893. builder.Write($"{item.GuestName}");
  11894. builder.InsertCell();
  11895. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11896. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11897. builder.InsertCell();
  11898. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11899. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11900. builder.EndRow();
  11901. #endregion
  11902. #region 第八行
  11903. builder.InsertCell();
  11904. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11905. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11906. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11907. builder.ParagraphFormat.Style.Font.Bold = false;
  11908. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11909. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11910. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11911. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11912. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11913. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11914. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11915. builder.Write($"ROOM TYPE:");
  11916. builder.InsertCell();
  11917. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11918. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11919. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11920. builder.ParagraphFormat.Style.Font.Bold = false;
  11921. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11922. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11923. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11924. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11925. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11926. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11927. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11928. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11929. builder.Write($"{item.RoomExplanation}");
  11930. builder.InsertCell();
  11931. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11932. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11933. builder.InsertCell();
  11934. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11935. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11936. builder.EndRow();
  11937. #endregion
  11938. #region 第九行
  11939. builder.InsertCell();
  11940. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11941. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11942. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11943. builder.ParagraphFormat.Style.Font.Bold = false;
  11944. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11945. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11946. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11947. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11948. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11949. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11950. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11951. builder.Write($"NOTE:");
  11952. builder.InsertCell();
  11953. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11954. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11955. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11956. builder.ParagraphFormat.Style.Font.Bold = false;
  11957. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11958. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11959. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11960. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11961. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  11962. builder.InsertCell();
  11963. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11964. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11965. builder.InsertCell();
  11966. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11967. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11968. builder.EndRow();
  11969. #endregion
  11970. builder.EndTable();
  11971. //换行
  11972. builder.Writeln("");
  11973. builder.Writeln("");
  11974. }
  11975. #region 获取文档中的所有表格 设置文字自适应
  11976. // 获取文档中的所有表格。
  11977. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11978. {
  11979. // 遍历表格中的所有行。
  11980. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11981. {
  11982. foreach (Cell cell in row.Cells)
  11983. {
  11984. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  11985. cellFormat.Width = 0;
  11986. }
  11987. }
  11988. }
  11989. #endregion
  11990. #region 设置页眉
  11991. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  11992. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  11993. if (System.IO.File.Exists(voucherHeaderPath))
  11994. {
  11995. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  11996. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  11997. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  11998. Shape shape = builder.InsertImage(imageBytes);
  11999. // 调整图片位置
  12000. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  12001. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  12002. shape.Top = 50; // 将图片距离页眉上边缘的距离
  12003. shape.Left = 0; // 将图片距离页面左边缘的距离
  12004. shape.Width = 81; // 设置图片宽度
  12005. shape.Height = 36; // 设置图片高度
  12006. }
  12007. //靠右
  12008. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  12009. //// 设置页脚上下边距
  12010. //builder.PageSetup.HeaderDistance = 42;
  12011. // 添加页眉线
  12012. Aspose.Words.Border borderHeader = null;
  12013. try
  12014. {
  12015. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  12016. }
  12017. catch (Exception e)
  12018. {
  12019. // TODO Auto-generated catch block
  12020. //e.printStackTrace();
  12021. }
  12022. borderHeader.Shadow = true;
  12023. borderHeader.DistanceFromText = 2;
  12024. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  12025. #endregion
  12026. }
  12027. catch (Exception ex)
  12028. {
  12029. }
  12030. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12031. doc.Save(fileDir);
  12032. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12033. return Ok(JsonView(true, "操作成功!", Url));
  12034. }
  12035. /// <summary>
  12036. /// 酒店预订
  12037. /// 生成 预定成本 Excel
  12038. /// </summary>
  12039. /// <param name="_dto"></param>
  12040. /// <returns></returns>
  12041. [HttpPost]
  12042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12043. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  12044. {
  12045. #region 参数验证
  12046. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  12047. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  12048. if (!vadalitorRes.IsValid)
  12049. {
  12050. var errors = new StringBuilder();
  12051. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  12052. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  12053. }
  12054. #region 团组操作权限验证 76 酒店预定模块
  12055. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12056. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12057. #endregion
  12058. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12059. #region 页面操作权限验证
  12060. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12061. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12062. #endregion
  12063. #endregion
  12064. decimal _rate = 1.00M;
  12065. string _currency = string.Empty;
  12066. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  12067. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  12068. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  12069. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  12070. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  12071. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  12072. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  12073. if (_GroupCostParameter == null)
  12074. {
  12075. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  12076. bool isIntType = int.TryParse(_currency, out int currId);
  12077. if (isIntType)
  12078. {
  12079. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12080. }
  12081. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12082. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12083. if (currInfo == null)
  12084. {
  12085. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12086. }
  12087. else _rate = currInfo.Rate;
  12088. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  12089. {
  12090. _rate = _GroupCostParameter.Rate;
  12091. }
  12092. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12093. string strFileName = "HotelStatement/";
  12094. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12095. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12096. var rateDatas = new List<dynamic>();
  12097. #region 数据处理
  12098. foreach (var item in hrDtas)
  12099. {
  12100. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12101. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12102. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12103. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12104. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12105. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  12106. {
  12107. continue;
  12108. }
  12109. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12110. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  12111. string singleRoomFeeStr = string.Empty,
  12112. doubleRoomFeeStr = string.Empty,
  12113. suiteRoomFeeStr = string.Empty,
  12114. otherRoomFeeStr = string.Empty,
  12115. payMoneyStr = string.Empty,
  12116. cardPriceStr = string.Empty;
  12117. if (roomCurr.Equals("CNY"))
  12118. {
  12119. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  12120. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12121. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12122. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12123. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12124. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  12125. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  12126. }
  12127. else
  12128. {
  12129. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12130. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12131. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12132. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12133. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12134. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12135. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12136. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12137. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12138. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12139. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  12140. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  12141. if (ccpPaymentCurrency.Equals("CNY"))
  12142. {
  12143. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  12144. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12145. }
  12146. else
  12147. {
  12148. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  12149. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  12150. }
  12151. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  12152. if (hotelcardPriceCurrency.Equals("CNY"))
  12153. {
  12154. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12155. }
  12156. else
  12157. {
  12158. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  12159. }
  12160. }
  12161. string breakfastPriceStr = string.Empty,
  12162. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12163. governmentRentStr = string.Empty,
  12164. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12165. cityTaxStr = string.Empty,
  12166. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12167. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  12168. if (!string.IsNullOrEmpty(breakfastCurrency1))
  12169. {
  12170. if (breakfastCurrency1.Equals("CNY"))
  12171. {
  12172. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12173. }
  12174. else
  12175. {
  12176. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  12177. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  12178. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  12179. }
  12180. }
  12181. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12182. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  12183. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  12184. {
  12185. if (governmentRentCurrency.Equals("CNY"))
  12186. {
  12187. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12188. }
  12189. else
  12190. {
  12191. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  12192. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  12193. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  12194. }
  12195. }
  12196. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12197. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  12198. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  12199. {
  12200. if (cityTaxStrCurrency1.Equals("CNY"))
  12201. {
  12202. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12203. }
  12204. else
  12205. {
  12206. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  12207. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  12208. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  12209. }
  12210. }
  12211. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12212. int payDId = roomInfo?.PayDId ?? 0;
  12213. pcfds.Add(new HotelReservations_PCFD_View()
  12214. {
  12215. City = item.City,
  12216. HotelName = item.HotelName,
  12217. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12218. // SingleRoomCount = item.SingleRoomCount,
  12219. SingleRoomPrice = singleRoomFeeStr,
  12220. // DoubleRoomCount = item.DoubleRoomCount,
  12221. DoubleRoomPrice = doubleRoomFeeStr,
  12222. //SuiteRoomCount = item.SuiteRoomCount,
  12223. SuiteRoomPrice = suiteRoomFeeStr,
  12224. OtherRoomPrice = otherRoomFeeStr,
  12225. //OtherRoomCount = item.OtherRoomCount,
  12226. BreakfastPrice = breakfastPriceStr,
  12227. GovernmentRent = governmentRentStr,
  12228. CityTax = cityTaxStr,
  12229. RoomExplanation = item.RoomExplanation,
  12230. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12231. PayTime = roomInfo?.ConsumptionDate,
  12232. BankNo = roomInfo?.BankNo,
  12233. PayMoney = payMoneyStr,
  12234. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12235. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12236. CardPrice = cardPriceStr,
  12237. Remark = ccpInfo.Remark
  12238. });
  12239. }
  12240. #endregion
  12241. //载入模板
  12242. WorkbookDesigner designer = new WorkbookDesigner();
  12243. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12244. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12245. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12246. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12247. var rateDatas1 = rateDatas.Distinct();
  12248. var rateStr = string.Empty;
  12249. foreach (var item in rateDatas1)
  12250. {
  12251. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  12252. }
  12253. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  12254. designer.SetDataSource("Opertor", userInfo.CnName);
  12255. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12256. dt.TableName = "ViewMyHotelReservations";
  12257. designer.SetDataSource(dt);
  12258. designer.Process();
  12259. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12260. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12261. designer.Workbook.Save(serverPath);
  12262. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12263. #region 删除指定行
  12264. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12265. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12266. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12267. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12268. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12269. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12270. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12271. cssIndex = dt.Columns["CityTax"].Ordinal,
  12272. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12273. remarkIndex = dt.Columns["Remark"].Ordinal;
  12274. //删除指定列
  12275. foreach (DataRow item in dt.Rows)
  12276. {
  12277. string singleStr = item["SingleRoomPrice"].ToString();
  12278. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12279. if (containsDigitButNotZero1) singleDel = false;
  12280. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12281. string doubleStr = item["DoubleRoomPrice"].ToString();
  12282. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12283. if (containsDigitButNotZero2) doubleDel = false;
  12284. string suiteStr = item["SuiteRoomPrice"].ToString();
  12285. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12286. if (containsDigitButNotZero3) suiteDel = false;
  12287. string otherStr = item["OtherRoomPrice"].ToString();
  12288. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12289. if (containsDigitButNotZero4) otherDel = false;
  12290. string zcStr = item["BreakfastPrice"].ToString();
  12291. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12292. if (containsDigitButNotZero5) zcDel = false;
  12293. string dsStr = item["GovernmentRent"].ToString();
  12294. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12295. if (containsDigitButNotZero6) dsDel = false;
  12296. string cssStr = item["CityTax"].ToString();
  12297. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12298. if (containsDigitButNotZero7) cssDel = false;
  12299. string cpStr = item["ConsumptionPatterns"].ToString();
  12300. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12301. string remarkStr = item["Remark"].ToString();
  12302. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12303. }
  12304. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12305. DeleteColumn(serverPath, cpIndex, cpDel);
  12306. DeleteColumn(serverPath, dsIndex, dsDel);
  12307. DeleteColumn(serverPath, cssIndex, cssDel);
  12308. DeleteColumn(serverPath, zcIndex, zcDel);
  12309. DeleteColumn(serverPath, otherIndex, otherDel);
  12310. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12311. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12312. DeleteColumn(serverPath, singleIndex, singleDel);
  12313. #endregion
  12314. //只保留第一个表格
  12315. DeleteSheet(serverPath);
  12316. return Ok(JsonView(true, "操作成功", url = rst));
  12317. }
  12318. else
  12319. {
  12320. _currency = _GroupCostParameter.Currency;
  12321. bool isIntType = int.TryParse(_currency, out int currId);
  12322. if (isIntType)
  12323. {
  12324. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12325. }
  12326. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12327. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12328. if (currInfo == null)
  12329. {
  12330. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12331. }
  12332. if (!_currency.ToUpper().Equals("CNY"))
  12333. {
  12334. _rate = _GroupCostParameter.Rate;
  12335. }
  12336. _rate = currInfo.Rate;
  12337. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12338. string strFileName = "HotelStatement/";
  12339. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12340. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12341. #region 数据处理
  12342. foreach (var item in hrDtas)
  12343. {
  12344. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12345. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12346. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12347. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12348. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12349. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12350. string singleRoomFeeStr = string.Empty,
  12351. doubleRoomFeeStr = string.Empty,
  12352. suiteRoomFeeStr = string.Empty,
  12353. otherRoomFeeStr = string.Empty,
  12354. payMoneyStr = string.Empty,
  12355. cardPriceStr = string.Empty;
  12356. if (roomCurr.Equals(_currency))
  12357. {
  12358. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  12359. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  12360. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  12361. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  12362. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  12363. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  12364. }
  12365. else
  12366. {
  12367. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12368. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12369. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12370. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12371. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12372. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12373. }
  12374. string breakfastPriceStr = string.Empty,
  12375. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12376. governmentRentStr = string.Empty,
  12377. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12378. cityTaxStrStr = string.Empty,
  12379. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12380. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  12381. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  12382. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  12383. int payDId = roomInfo?.PayDId ?? 0;
  12384. pcfds.Add(new HotelReservations_PCFD_View()
  12385. {
  12386. City = item.City,
  12387. HotelName = item.HotelName,
  12388. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12389. // SingleRoomCount = item.SingleRoomCount,
  12390. SingleRoomPrice = singleRoomFeeStr,
  12391. // DoubleRoomCount = item.DoubleRoomCount,
  12392. DoubleRoomPrice = doubleRoomFeeStr,
  12393. //SuiteRoomCount = item.SuiteRoomCount,
  12394. SuiteRoomPrice = suiteRoomFeeStr,
  12395. OtherRoomPrice = otherRoomFeeStr,
  12396. //OtherRoomCount = item.OtherRoomCount,
  12397. BreakfastPrice = breakfastPriceStr,
  12398. GovernmentRent = governmentRentStr,
  12399. CityTax = cityTaxStrStr,
  12400. RoomExplanation = item.RoomExplanation,
  12401. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12402. PayTime = roomInfo?.ConsumptionDate,
  12403. BankNo = roomInfo?.BankNo,
  12404. PayMoney = payMoneyStr,
  12405. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12406. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12407. CardPrice = cardPriceStr,
  12408. Remark = ccpInfo.Remark
  12409. });
  12410. }
  12411. #endregion
  12412. //载入模板
  12413. WorkbookDesigner designer = new WorkbookDesigner();
  12414. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12415. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12416. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12417. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12418. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  12419. designer.SetDataSource("Opertor", userInfo.CnName);
  12420. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12421. dt.TableName = "ViewMyHotelReservations";
  12422. designer.SetDataSource(dt);
  12423. designer.Process();
  12424. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12425. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12426. designer.Workbook.Save(serverPath);
  12427. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12428. #region 删除指定行
  12429. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12430. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12431. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12432. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12433. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12434. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12435. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12436. cssIndex = dt.Columns["CityTax"].Ordinal,
  12437. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12438. remarkIndex = dt.Columns["Remark"].Ordinal;
  12439. //删除指定列
  12440. foreach (DataRow item in dt.Rows)
  12441. {
  12442. string singleStr = item["SingleRoomPrice"].ToString();
  12443. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12444. if (containsDigitButNotZero1) singleDel = false;
  12445. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12446. string doubleStr = item["DoubleRoomPrice"].ToString();
  12447. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12448. if (containsDigitButNotZero2) doubleDel = false;
  12449. string suiteStr = item["SuiteRoomPrice"].ToString();
  12450. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12451. if (containsDigitButNotZero3) suiteDel = false;
  12452. string otherStr = item["OtherRoomPrice"].ToString();
  12453. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12454. if (containsDigitButNotZero4) otherDel = false;
  12455. string zcStr = item["BreakfastPrice"].ToString();
  12456. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12457. if (containsDigitButNotZero5) zcDel = false;
  12458. string dsStr = item["GovernmentRent"].ToString();
  12459. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12460. if (containsDigitButNotZero6) dsDel = false;
  12461. string cssStr = item["CityTax"].ToString();
  12462. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12463. if (containsDigitButNotZero7) cssDel = false;
  12464. string cpStr = item["ConsumptionPatterns"].ToString();
  12465. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12466. string remarkStr = item["Remark"].ToString();
  12467. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12468. }
  12469. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12470. DeleteColumn(serverPath, cpIndex, cpDel);
  12471. DeleteColumn(serverPath, dsIndex, dsDel);
  12472. DeleteColumn(serverPath, cssIndex, cssDel);
  12473. DeleteColumn(serverPath, zcIndex, zcDel);
  12474. DeleteColumn(serverPath, otherIndex, otherDel);
  12475. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12476. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12477. DeleteColumn(serverPath, singleIndex, singleDel);
  12478. #endregion
  12479. //只保留第一个表格
  12480. DeleteSheet(serverPath);
  12481. return Ok(JsonView(true, "操作成功", url = rst));
  12482. }
  12483. return Ok(JsonView(false));
  12484. }
  12485. /// <summary>
  12486. /// 删除指定列
  12487. /// </summary>
  12488. /// <param name="file"></param>
  12489. /// <param name="columnIndex"></param>
  12490. /// <param name="isDel"></param>
  12491. private void DeleteColumn(string file, int columnIndex, bool isDel)
  12492. {
  12493. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12494. //wb.Save(file);
  12495. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  12496. if (sheet1 != null)
  12497. {
  12498. if (isDel)
  12499. {
  12500. Cells cells = sheet1.Cells;
  12501. cells.DeleteColumn(columnIndex);
  12502. }
  12503. }
  12504. wb.Save(file);
  12505. }
  12506. /// <summary>
  12507. /// 删除sheet
  12508. /// </summary>
  12509. /// <param name="file"></param>
  12510. /// <param name="sheetName"></param>
  12511. private void DeleteSheet(string file, string sheetName = "")
  12512. {
  12513. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12514. //wb.Save(file);
  12515. List<string> sheets = new List<string>();
  12516. foreach (var item in wb.Worksheets)
  12517. {
  12518. sheets.Add(item.Name);
  12519. }
  12520. if (sheets.Count > 0)
  12521. {
  12522. sheets.RemoveAt(0);//不删除第一个sheet
  12523. foreach (var item in sheets)
  12524. {
  12525. wb.Worksheets.RemoveAt(item);
  12526. }
  12527. }
  12528. wb.Save(file);
  12529. }
  12530. /// <summary>
  12531. /// 酒店预订
  12532. /// 确认单
  12533. /// </summary>
  12534. /// <param name="_dto"></param>
  12535. /// <returns></returns>
  12536. [HttpPost]
  12537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12538. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  12539. {
  12540. try
  12541. {
  12542. #region 参数验证
  12543. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12544. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12545. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12546. #region 团组操作权限验证 76 酒店预定模块
  12547. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12548. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12549. #endregion
  12550. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12551. #region 页面操作权限验证
  12552. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12553. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12554. #endregion
  12555. #endregion
  12556. //团组信息
  12557. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  12558. //酒店数据
  12559. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  12560. if (listhoteldata.Count < 0)
  12561. {
  12562. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  12563. }
  12564. //利datatable存储
  12565. DataTable dt = new DataTable();
  12566. dt.Columns.Add("CheckInDate", typeof(string));
  12567. dt.Columns.Add("City", typeof(string));
  12568. dt.Columns.Add("Hotel", typeof(string));
  12569. dt.Columns.Add("Room", typeof(string));
  12570. for (int i = 0; i < listhoteldata.Count; i++)
  12571. {
  12572. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  12573. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  12574. while (dayStart < dayEnd)
  12575. {
  12576. string temp = "";
  12577. DataRow row = dt.NewRow();
  12578. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  12579. row["City"] = listhoteldata[i].City;
  12580. row["Hotel"] = listhoteldata[i].HotelName;
  12581. if (listhoteldata[i].SingleRoomCount > 0)
  12582. {
  12583. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  12584. }
  12585. if (listhoteldata[i].DoubleRoomCount > 0)
  12586. {
  12587. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  12588. }
  12589. if (listhoteldata[i].SuiteRoomCount > 0)
  12590. {
  12591. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  12592. }
  12593. if (listhoteldata[i].OtherRoomCount > 0)
  12594. {
  12595. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  12596. }
  12597. row["Room"] = temp;
  12598. dt.Rows.Add(row);
  12599. dayStart = dayStart.AddDays(1);
  12600. }
  12601. }
  12602. Dictionary<string, string> dic = new Dictionary<string, string>();
  12603. dic.Add("Dele", di.TeamName);
  12604. dic.Add("City", di.VisitCountry);
  12605. //模板路径
  12606. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  12607. //载入模板
  12608. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  12609. DocumentBuilder builder = new DocumentBuilder(doc);
  12610. foreach (var key in dic.Keys)
  12611. {
  12612. builder.MoveToBookmark(key);
  12613. builder.Write(dic[key]);
  12614. }
  12615. //获取word里所有表格
  12616. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12617. //获取所填表格的序数
  12618. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12619. var rowStart = tableOne.Rows[0]; //获取第1行
  12620. //循环赋值
  12621. for (int i = 0; i < dt.Rows.Count; i++)
  12622. {
  12623. builder.MoveToCell(0, i + 1, 0, 0);
  12624. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  12625. builder.MoveToCell(0, i + 1, 1, 0);
  12626. builder.Write(dt.Rows[i]["City"].ToString());
  12627. builder.MoveToCell(0, i + 1, 2, 0);
  12628. builder.Write(dt.Rows[i]["Hotel"].ToString());
  12629. builder.MoveToCell(0, i + 1, 3, 0);
  12630. builder.Write(dt.Rows[i]["Room"].ToString());
  12631. }
  12632. //删除多余行
  12633. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  12634. {
  12635. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  12636. }
  12637. string strFileName = di.TeamName + "酒店确认单.doc";
  12638. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  12639. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  12640. return Ok(JsonView(true, "成功", url));
  12641. }
  12642. catch (Exception ex)
  12643. {
  12644. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  12645. }
  12646. }
  12647. #endregion
  12648. #region 团组状态
  12649. /// <summary>
  12650. /// 团组状态列表 Page
  12651. /// </summary>
  12652. /// <param name="dto">团组列表请求dto</param>
  12653. /// <returns></returns>
  12654. [HttpPost]
  12655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12656. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  12657. {
  12658. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12659. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  12660. {
  12661. string sqlWhere = string.Empty;
  12662. if (dto.IsSure == 0) //未完成
  12663. {
  12664. sqlWhere += string.Format(@" And IsSure = 0");
  12665. }
  12666. else if (dto.IsSure == 1) //已完成
  12667. {
  12668. sqlWhere += string.Format(@" And IsSure = 1");
  12669. }
  12670. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  12671. {
  12672. string tj = dto.SearchCriteria;
  12673. 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}%')",
  12674. tj, tj, tj, tj, tj);
  12675. }
  12676. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  12677. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  12678. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  12679. From (
  12680. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  12681. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  12682. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  12683. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  12684. From Grp_DelegationInfo gdi
  12685. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  12686. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  12687. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  12688. Where gdi.IsDel = 0 {0}
  12689. ) temp ", sqlWhere);
  12690. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  12691. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  12692. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  12693. }
  12694. else
  12695. {
  12696. return Ok(JsonView(false, "查询失败"));
  12697. }
  12698. }
  12699. /// <summary>
  12700. /// 团组状态
  12701. /// 设置操作完成
  12702. /// </summary>
  12703. /// <param name="dto">团组列表请求dto</param>
  12704. /// <returns></returns>
  12705. [HttpPost]
  12706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12707. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  12708. {
  12709. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12710. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  12711. {
  12712. Id = dto.Id,
  12713. IsSure = 1
  12714. };
  12715. var result = await _sqlSugar.Updateable(_DelegationInfo)
  12716. .UpdateColumns(it => new { it.IsSure })
  12717. .WhereColumns(it => new { it.Id })
  12718. .ExecuteCommandAsync();
  12719. if (result > 0)
  12720. {
  12721. return Ok(JsonView(true, "操作完成!"));
  12722. }
  12723. return Ok(JsonView(false, "操作失败!"));
  12724. }
  12725. #endregion
  12726. #region 保险费用录入
  12727. /// <summary>
  12728. /// 根据团组Id查询保险费用列表
  12729. /// </summary>
  12730. /// <param name="dto"></param>
  12731. /// <returns></returns>
  12732. [HttpPost]
  12733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12734. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  12735. {
  12736. Result groupData = await _customersRep.CustomersByDiId(dto);
  12737. if (groupData.Code != 0)
  12738. {
  12739. return Ok(JsonView(false, groupData.Msg));
  12740. }
  12741. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12742. }
  12743. /// <summary>
  12744. /// 根据保险费用Id查询保险费用详细
  12745. /// </summary>
  12746. /// <param name="dto"></param>
  12747. /// <returns></returns>
  12748. [HttpPost]
  12749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12750. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  12751. {
  12752. try
  12753. {
  12754. Result groupData = await _customersRep.CustomersById(dto);
  12755. if (groupData.Code != 0)
  12756. {
  12757. return Ok(JsonView(false, groupData.Msg));
  12758. }
  12759. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12760. }
  12761. catch (Exception ex)
  12762. {
  12763. return Ok(JsonView(false, ex.Message));
  12764. }
  12765. }
  12766. /// <summary>
  12767. /// 保险费用录入页面初始化绑定
  12768. /// </summary>
  12769. /// <param name="dto"></param>
  12770. /// <returns></returns>
  12771. [HttpPost]
  12772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12773. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  12774. {
  12775. try
  12776. {
  12777. Result groupData = await _customersRep.CustomersInitialize(dto);
  12778. if (groupData.Code != 0)
  12779. {
  12780. return Ok(JsonView(false, groupData.Msg));
  12781. }
  12782. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12783. }
  12784. catch (Exception ex)
  12785. {
  12786. return Ok(JsonView(false, ex.Message));
  12787. }
  12788. }
  12789. /// <summary>
  12790. /// 保险费用操作(Status:1.新增,2.修改)
  12791. /// </summary>
  12792. /// <param name="dto"></param>
  12793. /// <returns></returns>
  12794. [HttpPost]
  12795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12796. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  12797. {
  12798. Result groupData = await _customersRep.OpCustomers(dto);
  12799. if (groupData.Code != 0)
  12800. {
  12801. return Ok(JsonView(false, groupData.Msg));
  12802. }
  12803. #region 应用推送
  12804. try
  12805. {
  12806. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12807. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12808. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  12809. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12810. //自动审核
  12811. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  12812. //2024-10-21 新增LZ UID
  12813. var userIds = new List<int>() { 21 };
  12814. string title = $"系统通知";
  12815. var diId = dto.DiId;
  12816. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12817. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12818. string content = "";
  12819. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12820. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12821. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12822. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12823. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12824. }
  12825. catch (Exception ex)
  12826. {
  12827. }
  12828. #endregion
  12829. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12830. }
  12831. /// <summary>
  12832. /// 保险文件上传
  12833. /// </summary>
  12834. /// <param name="file"></param>
  12835. /// <returns></returns>
  12836. [HttpPost]
  12837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12838. public async Task<IActionResult> UploadCus(IFormFile file)
  12839. {
  12840. try
  12841. {
  12842. if (file != null)
  12843. {
  12844. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12845. //文件名称
  12846. string projectFileName = file.FileName;
  12847. //上传的文件的路径
  12848. string filePath = "";
  12849. if (!Directory.Exists(fileDir))
  12850. {
  12851. Directory.CreateDirectory(fileDir);
  12852. }
  12853. //上传的文件的路径
  12854. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  12855. using (FileStream fs = System.IO.File.Create(filePath))
  12856. {
  12857. file.CopyTo(fs);
  12858. fs.Flush();
  12859. }
  12860. return Ok(JsonView(true, "上传成功!", projectFileName));
  12861. }
  12862. else
  12863. {
  12864. return Ok(JsonView(false, "上传失败!"));
  12865. }
  12866. }
  12867. catch (Exception ex)
  12868. {
  12869. return Ok(JsonView(false, "程序错误!"));
  12870. throw;
  12871. }
  12872. }
  12873. /// <summary>
  12874. /// 保险删除指定文件
  12875. /// </summary>
  12876. /// <param name="dto"></param>
  12877. /// <returns></returns>
  12878. [HttpPost]
  12879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12880. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  12881. {
  12882. try
  12883. {
  12884. string filePath = "";
  12885. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12886. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  12887. //int id = 0;
  12888. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  12889. // 删除该文件
  12890. try
  12891. {
  12892. System.IO.File.Delete(filePath);
  12893. 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()
  12894. {
  12895. Attachment = "",
  12896. }).ExecuteCommandAsync();
  12897. if (result != 0)
  12898. {
  12899. return Ok(JsonView(true, "成功!"));
  12900. }
  12901. else
  12902. {
  12903. return Ok(JsonView(false, "失败!"));
  12904. }
  12905. }
  12906. catch (Exception)
  12907. {
  12908. 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()
  12909. {
  12910. Attachment = "",
  12911. }).ExecuteCommandAsync();
  12912. if (result != 0)
  12913. {
  12914. return Ok(JsonView(true, "成功!"));
  12915. }
  12916. else
  12917. {
  12918. return Ok(JsonView(false, "失败!"));
  12919. }
  12920. }
  12921. }
  12922. catch (Exception ex)
  12923. {
  12924. return Ok(JsonView(false, "程序错误!"));
  12925. throw;
  12926. }
  12927. }
  12928. /// <summary>
  12929. /// 保险费用操作(删除)
  12930. /// </summary>
  12931. /// <param name="dto"></param>
  12932. /// <returns></returns>
  12933. [HttpPost]
  12934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12935. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  12936. {
  12937. try
  12938. {
  12939. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  12940. if (!res)
  12941. {
  12942. return Ok(JsonView(false, "删除失败"));
  12943. }
  12944. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  12945. {
  12946. IsDel = 1,
  12947. DeleteUserId = dto.DeleteUserId,
  12948. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12949. }).ExecuteCommandAsync();
  12950. return Ok(JsonView(true, "删除成功!"));
  12951. }
  12952. catch (Exception ex)
  12953. {
  12954. return Ok(JsonView(false, "程序错误!"));
  12955. throw;
  12956. }
  12957. }
  12958. #endregion
  12959. #region 接团客户名单 PageId 104
  12960. /// <summary>
  12961. /// 接团客户名单
  12962. /// 迁移数据(慎用!)
  12963. /// </summary>
  12964. /// <param name="dto"></param>
  12965. /// <returns></returns>
  12966. [HttpPost]
  12967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12968. public async Task<IActionResult> PostTourClientListChange()
  12969. {
  12970. try
  12971. {
  12972. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  12973. //var groupClinetData1
  12974. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  12975. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  12976. int updateCount = 0;
  12977. if (oldOAClientList.Count > 0)
  12978. {
  12979. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  12980. _sqlSugar.BeginTran();
  12981. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  12982. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  12983. foreach (var item in oldOAClientList)
  12984. {
  12985. int comId = 0;
  12986. string format = "yyyy-MM-dd HH:mm:ss";
  12987. string data11 = "1990-01-01 00:00";
  12988. var data1 = IsValidDate(item.OPdate, format);
  12989. if (data1) data11 = item.OPdate;
  12990. //客户公司验证
  12991. if (!string.IsNullOrEmpty(item.Company))
  12992. {
  12993. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  12994. if (clientComInfo == null) // add
  12995. {
  12996. var addInfo = new Crm_CustomerCompany()
  12997. {
  12998. CompanyAbbreviation = "",
  12999. CompanyFullName = item.Company,
  13000. Address = "",
  13001. PostCodes = "",
  13002. LastedOpUserId = item.OPer,
  13003. LastedOpDt = Convert.ToDateTime(data11),
  13004. CreateUserId = item.OPer,
  13005. CreateTime = Convert.ToDateTime(data11),
  13006. IsDel = 0
  13007. };
  13008. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  13009. if (comId1 > 0) comId = comId1;
  13010. }
  13011. else comId = clientComInfo.Id;
  13012. }
  13013. //客户人员验证
  13014. int clientId = 0;
  13015. string name = item.LastName + item.Name;
  13016. if (!string.IsNullOrEmpty(name))
  13017. {
  13018. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  13019. if (clientInfo == null)
  13020. {
  13021. DateTime? dateTime = null;
  13022. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  13023. if (isDt) dateTime = birthDayDt;
  13024. var addInfo1 = new Crm_DeleClient()
  13025. {
  13026. CrmCompanyId = comId,
  13027. DiId = -1,
  13028. LastName = item.LastName,
  13029. FirstName = item.Name,
  13030. OldName = "",
  13031. Pinyin = item.Pinyin,
  13032. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  13033. Marriage = 0,
  13034. Phone = item.Phone,
  13035. Job = item.Job,
  13036. BirthDay = dateTime
  13037. };
  13038. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  13039. if (clientId1 > 0) clientId = clientId1;
  13040. }
  13041. else clientId = clientInfo.Id;
  13042. }
  13043. if (clientId < 1)
  13044. {
  13045. continue;
  13046. }
  13047. int airType = 0;
  13048. if (item.AirType == "超经舱") airType = 459;
  13049. else if (item.AirType == "公务舱") airType = 458;
  13050. else if (item.AirType == "经济舱") airType = 460;
  13051. else if (item.AirType == "其他") airType = 565;
  13052. else if (item.AirType == "头等舱") airType = 457;
  13053. var _TourClientListEntity = new Grp_TourClientList()
  13054. {
  13055. DiId = item.Diid,
  13056. ClientId = clientId,
  13057. CreateUserId = item.OPer,
  13058. CreateTime = Convert.ToDateTime(data11),
  13059. Remark = item.Remark,
  13060. IsDel = item.Isdel,
  13061. ShippingSpaceTypeId = airType,
  13062. ShippingSpaceSpecialNeeds = item.AirRemark,
  13063. HotelSpecialNeeds = item.RoomType
  13064. };
  13065. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  13066. if (_TourClientList > 0)
  13067. {
  13068. updateCount++;
  13069. }
  13070. }
  13071. _sqlSugar.CommitTran();
  13072. }
  13073. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  13074. }
  13075. catch (Exception ex)
  13076. {
  13077. _sqlSugar.RollbackTran();
  13078. return Ok(JsonView(false, ex.Message));
  13079. }
  13080. return Ok(JsonView(true));
  13081. }
  13082. private bool IsValidDate(string dateString, string format)
  13083. {
  13084. DateTime dateValue;
  13085. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  13086. return valid;
  13087. }
  13088. /// <summary>
  13089. /// 接团客户名单
  13090. /// 根据团组Id查询List
  13091. /// </summary>
  13092. /// <param name="dto"></param>
  13093. /// <returns></returns>
  13094. [HttpPost]
  13095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13096. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  13097. {
  13098. #region 参数验证
  13099. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  13100. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  13101. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  13102. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13103. #region 页面操作权限验证
  13104. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13105. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13106. #endregion
  13107. #endregion
  13108. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  13109. if (viewData.Code != 0)
  13110. {
  13111. return Ok(JsonView(false, viewData.Msg));
  13112. }
  13113. return Ok(JsonView(viewData.Data));
  13114. }
  13115. /// <summary>
  13116. /// 接团客户名单
  13117. /// 基础数据 Init
  13118. /// </summary>
  13119. /// <param name="_dto"></param>
  13120. /// <returns></returns>
  13121. [HttpPost]
  13122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13123. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  13124. {
  13125. #region 参数验证
  13126. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13127. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13128. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13129. #region 页面操作权限验证
  13130. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13131. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13132. #endregion
  13133. #endregion
  13134. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  13135. }
  13136. /// <summary>
  13137. /// 接团客户名单
  13138. /// 根据 Id查询 Details
  13139. /// </summary>
  13140. /// <param name="_dto"></param>
  13141. /// <returns></returns>
  13142. [HttpPost]
  13143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13144. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  13145. {
  13146. #region 参数验证
  13147. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13148. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13149. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13151. #region 页面操作权限验证
  13152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13153. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13154. #endregion
  13155. #endregion
  13156. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  13157. if (viewData.Code != 0)
  13158. {
  13159. return Ok(JsonView(false, viewData.Msg));
  13160. }
  13161. return Ok(JsonView(viewData.Data));
  13162. }
  13163. /// <summary>
  13164. /// 接团客户名单
  13165. /// Add Or Edit
  13166. /// </summary>
  13167. /// <param name="_dto"></param>
  13168. /// <returns></returns>
  13169. [HttpPost]
  13170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13171. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  13172. {
  13173. #region 参数验证
  13174. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13175. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13176. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13177. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13178. #region 页面操作权限验证
  13179. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13180. if (_dto.Id == 0) //添加
  13181. {
  13182. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13183. }
  13184. else if (_dto.Id >= 0) //修改
  13185. {
  13186. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13187. }
  13188. #endregion
  13189. #endregion
  13190. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  13191. if (viewData.Code != 0)
  13192. {
  13193. return Ok(JsonView(false, viewData.Msg));
  13194. }
  13195. return Ok(JsonView(true));
  13196. }
  13197. /// <summary>
  13198. /// 接团客户名单
  13199. /// AddMultiple(添加多个)
  13200. /// </summary>
  13201. /// <param name="_dto"></param>
  13202. /// <returns></returns>
  13203. [HttpPost]
  13204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13205. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  13206. {
  13207. #region 参数验证
  13208. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13209. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13210. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13211. #region 页面操作权限验证
  13212. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13213. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13214. #endregion
  13215. #endregion
  13216. var viewData = await _tourClientListRep._AddMultiple(_dto);
  13217. if (viewData.Code != 0)
  13218. {
  13219. return Ok(JsonView(false, viewData.Msg));
  13220. }
  13221. return Ok(JsonView(true));
  13222. }
  13223. /// <summary>
  13224. /// 接团客户名单
  13225. /// Del
  13226. /// </summary>
  13227. /// <param name="_dto"></param>
  13228. /// <returns></returns>
  13229. [HttpPost]
  13230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13231. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  13232. {
  13233. #region 参数验证
  13234. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13235. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13236. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13237. #region 页面操作权限验证
  13238. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13239. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13240. #endregion
  13241. #endregion
  13242. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  13243. if (viewData.Code != 0)
  13244. {
  13245. return Ok(JsonView(false, viewData.Msg));
  13246. }
  13247. return Ok(JsonView(true));
  13248. }
  13249. /// <summary>
  13250. /// 接团客户名单
  13251. /// 文件下载 客户名单
  13252. /// </summary>
  13253. /// <param name="_dto"></param>
  13254. /// <returns></returns>
  13255. [HttpPost]
  13256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13257. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  13258. {
  13259. #region 参数验证
  13260. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13261. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13262. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  13263. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13264. #region 页面操作权限验证
  13265. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13266. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13267. #endregion
  13268. #endregion
  13269. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  13270. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  13271. From Grp_TourClientList tcl
  13272. Left Join
  13273. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  13274. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  13275. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  13276. From Crm_DeleClient dc
  13277. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  13278. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  13279. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  13280. Where dc.IsDel = 0) temp
  13281. On temp.DcId =tcl.ClientId
  13282. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  13283. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  13284. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  13285. //载入模板
  13286. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  13287. if (_dto.Language == 1)
  13288. {
  13289. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  13290. }
  13291. //载入模板
  13292. var doc = new Document(tempPath);
  13293. DocumentBuilder builder = new DocumentBuilder(doc);
  13294. //获取word里所有表格
  13295. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13296. //获取所填表格的序数
  13297. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13298. var rowStart = tableOne.Rows[0]; //获取第1行
  13299. if (_dto.Language == 0)
  13300. {
  13301. //循环赋值
  13302. for (int i = 0; i < DcList.Count; i++)
  13303. {
  13304. EncryptionProcessor.DecryptProperties(DcList[i]);
  13305. builder.MoveToCell(0, i + 1, 0, 0);
  13306. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  13307. builder.MoveToCell(0, i + 1, 1, 0);
  13308. int sex = DcList[i].Sex;
  13309. string sexStr = string.Empty;
  13310. if (sex == 0) sexStr = "男";
  13311. else if (sex == 1) sexStr = "女";
  13312. else sexStr = "未设置";
  13313. builder.Write(sexStr);
  13314. builder.MoveToCell(0, i + 1, 2, 0);
  13315. string birthDay = DcList[i].BirthDay;
  13316. string birthDayStr = string.Empty;
  13317. if (!string.IsNullOrEmpty(birthDay))
  13318. {
  13319. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  13320. }
  13321. builder.Write(birthDayStr);
  13322. builder.MoveToCell(0, i + 1, 3, 0);
  13323. string company = "";
  13324. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13325. {
  13326. company = DcList[i].CompanyFullName.ToString();
  13327. }
  13328. builder.Write(company);
  13329. builder.MoveToCell(0, i + 1, 4, 0);
  13330. builder.Write(DcList[i].Job);
  13331. }
  13332. }
  13333. else if (_dto.Language == 1)
  13334. {
  13335. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  13336. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  13337. List<string> transArrayStr = new List<string>();
  13338. string transStrRes1 = "";
  13339. for (int i = 0; i < DcList.Count; i++)
  13340. {
  13341. var dc = DcList[i];
  13342. EncryptionProcessor.DecryptProperties(dc);
  13343. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  13344. if (dc.Job.Equals("暂无")) dc.Job = "-";
  13345. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  13346. if (DcList.Count - 1 == i) transStrRes1 += str1;
  13347. else transStrRes1 += $"{str1}|";
  13348. }
  13349. //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  13350. string transStrRes = "";
  13351. if (transStrRes1.Length > 0)
  13352. {
  13353. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  13354. }
  13355. //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  13356. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  13357. //List<string> transArray = new List<string> { };
  13358. List<TranslateInfo> transArray = new List<TranslateInfo>();
  13359. if (transStrRes.Contains("|"))
  13360. {
  13361. string[] transArray1 = transStrRes.Split('|');
  13362. if (transArray1.Length > 0)
  13363. {
  13364. foreach (var item in transArray1)
  13365. {
  13366. if (item.Contains("&"))
  13367. {
  13368. string[] transArray2 = item.Split('&');
  13369. int index = 0;
  13370. string companyName = "", job = "";
  13371. if (transArray2.Length > 0)
  13372. {
  13373. bool success = int.TryParse(transArray2[0].Trim(), out index);
  13374. if (1 < transArray2.Length) companyName = transArray2[1];
  13375. if (2 < transArray2.Length) job = transArray2[2];
  13376. }
  13377. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  13378. }
  13379. }
  13380. }
  13381. }
  13382. //循环赋值
  13383. for (int i = 0; i < DcList.Count; i++)
  13384. {
  13385. string PYName = "";
  13386. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  13387. {
  13388. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  13389. string PY_First = DcList[i].Pinyin.Split('/')[1];
  13390. PYName = PY_First + " " + PY_Last;
  13391. }
  13392. else
  13393. {
  13394. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  13395. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  13396. PYName = PY_First + " " + PY_Last;
  13397. }
  13398. builder.MoveToCell(0, i + 1, 0, 0);
  13399. builder.Write(PYName);
  13400. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  13401. builder.MoveToCell(0, i + 1, 1, 0);
  13402. builder.Write(sex);
  13403. DateTime birthDt;
  13404. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  13405. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  13406. builder.MoveToCell(0, i + 1, 2, 0);
  13407. builder.Write(birthday);
  13408. string company = string.Empty, job = string.Empty;
  13409. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  13410. if (dcTransInfo != null)
  13411. {
  13412. company = dcTransInfo.CompanyName;
  13413. job = dcTransInfo.Job;
  13414. }
  13415. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13416. {
  13417. //查询对照表
  13418. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  13419. if (tempCec != null)
  13420. {
  13421. company = tempCec.enName;
  13422. }
  13423. //翻译
  13424. else
  13425. {
  13426. }
  13427. }
  13428. builder.MoveToCell(0, i + 1, 3, 0);
  13429. builder.Write(company);
  13430. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  13431. {
  13432. //查询对照表
  13433. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  13434. if (tempPec != null)
  13435. {
  13436. job = tempPec.enName;
  13437. }
  13438. //翻译
  13439. else
  13440. {
  13441. }
  13442. }
  13443. builder.MoveToCell(0, i + 1, 4, 0);
  13444. builder.Write(job);
  13445. }
  13446. }
  13447. //删除多余行
  13448. while (tableOne.Rows.Count > DcList.Count + 1)
  13449. {
  13450. tableOne.Rows.RemoveAt(DcList.Count + 1);
  13451. }
  13452. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  13453. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  13454. doc.Save(fileDir);
  13455. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  13456. return Ok(JsonView(true, "操作成功!", Url));
  13457. }
  13458. private class TranslateInfo
  13459. {
  13460. public int Index { get; set; }
  13461. public string CompanyName { get; set; }
  13462. public string Job { get; set; }
  13463. }
  13464. #endregion
  13465. #region 团组倒推表
  13466. /// <summary>
  13467. /// 倒推表基础数据
  13468. /// Init
  13469. /// </summary>
  13470. /// <param name="dto"></param>
  13471. /// <returns></returns>
  13472. [HttpPost]
  13473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13474. public async Task<IActionResult> PostInvertedListInit()
  13475. {
  13476. var viewData = await _invertedListRep._Init();
  13477. if (viewData.Code != 0)
  13478. {
  13479. return Ok(JsonView(false, viewData.Msg));
  13480. }
  13481. return Ok(JsonView(viewData.Data));
  13482. }
  13483. /// <summary>
  13484. /// 倒推表
  13485. /// Info
  13486. /// </summary>
  13487. /// <param name="dto"></param>
  13488. /// <returns></returns>
  13489. [HttpPost]
  13490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13491. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  13492. {
  13493. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  13494. if (viewData.Code != 0)
  13495. {
  13496. return Ok(JsonView(false, viewData.Msg));
  13497. }
  13498. return Ok(JsonView(viewData.Data));
  13499. }
  13500. /// <summary>
  13501. /// 倒推表
  13502. /// Create
  13503. /// </summary>
  13504. /// <param name="dto"></param>
  13505. /// <returns></returns>
  13506. [HttpPost]
  13507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13508. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  13509. {
  13510. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  13511. if (viewData.Code != 0)
  13512. {
  13513. return Ok(JsonView(false, viewData.Msg));
  13514. }
  13515. return Ok(JsonView(viewData.Data));
  13516. }
  13517. /// <summary>
  13518. /// 倒推表
  13519. /// Update
  13520. /// </summary>
  13521. /// <param name="dto"></param>
  13522. /// <returns></returns>
  13523. [HttpPost]
  13524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13525. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  13526. {
  13527. var viewData = await _invertedListRep._Update(dto);
  13528. if (viewData.Code != 0)
  13529. {
  13530. return Ok(JsonView(false, viewData.Msg));
  13531. }
  13532. return Ok(JsonView(viewData.Data));
  13533. }
  13534. /// <summary>
  13535. /// 倒推表
  13536. /// File Download
  13537. /// </summary>
  13538. /// <param name="dto"></param>
  13539. /// <returns></returns>
  13540. [HttpPost]
  13541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13542. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  13543. {
  13544. var info2 = await _invertedListRep._Info(1, dto.DiId);
  13545. if (info2.Code != 0)
  13546. {
  13547. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  13548. }
  13549. var info1 = info2.Data as InvertedListInfoView;
  13550. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  13551. string teamName = "";
  13552. if (info != null) teamName = info.TeamName;
  13553. //载入模板
  13554. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  13555. DocumentBuilder builder = new DocumentBuilder(doc);
  13556. //利用键值对存放数据
  13557. Dictionary<string, string> dic = new Dictionary<string, string>();
  13558. dic.Add("TeamName", teamName);
  13559. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  13560. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  13561. dic.Add("BPRemark", info1.ApprovalDataRemark);
  13562. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  13563. dic.Add("SQRemark", info1.ApprovalRemark);
  13564. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  13565. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  13566. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  13567. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  13568. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  13569. dic.Add("QZRemark", info1.VisaInformationRemark);
  13570. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  13571. dic.Add("SQQZRemark", info1.SendVisaRemark);
  13572. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  13573. dic.Add("CQRemark", info1.IssueVisaRemark);
  13574. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  13575. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  13576. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  13577. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  13578. #region 填充word模板书签内容
  13579. foreach (var key in dic.Keys)
  13580. {
  13581. builder.MoveToBookmark(key);
  13582. builder.Write(dic[key]);
  13583. }
  13584. #endregion
  13585. var fileDir = AppSettingsHelper.Get("WordBasePath");
  13586. string fileName = $"{teamName}团出行准备流程表.doc";
  13587. string filePath = fileDir + $@"InvertedList/{fileName}";
  13588. doc.Save(filePath);
  13589. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  13590. return Ok(JsonView(true, "操作成功!", Url));
  13591. }
  13592. #endregion
  13593. #region 三公签证费用(签证费、代办费)
  13594. /// <summary>
  13595. /// 三公签证费用(签证费、代办费)
  13596. /// List
  13597. /// </summary>
  13598. /// <returns></returns>
  13599. [HttpPost]
  13600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13601. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  13602. {
  13603. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  13604. if (_view.Code != 0)
  13605. {
  13606. return Ok(JsonView(false, _view.Msg));
  13607. }
  13608. return Ok(JsonView(true, "操作成功!", _view.Data));
  13609. }
  13610. /// <summary>
  13611. /// 三公签证费用(签证费、代办费)
  13612. /// Add Or Update
  13613. /// </summary>
  13614. /// <returns></returns>
  13615. [HttpPost]
  13616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13617. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  13618. {
  13619. var _view = await _visaFeeInfoRep._Update(_dto);
  13620. if (_view.Code != 0)
  13621. {
  13622. return Ok(JsonView(false, _view.Msg));
  13623. }
  13624. return Ok(JsonView(true, _view.Msg));
  13625. }
  13626. #endregion
  13627. #region 酒店询价
  13628. /// <summary>
  13629. /// 酒店询价
  13630. /// Init
  13631. /// </summary>
  13632. /// <param name="dto"></param>
  13633. /// <returns></returns>
  13634. [HttpPost]
  13635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13636. public async Task<IActionResult> PostHotelInquiryInit()
  13637. {
  13638. var res = await _hotelInquiryRep._Init();
  13639. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13640. return Ok(JsonView(true, res.Msg, res.Data));
  13641. }
  13642. /// <summary>
  13643. /// 酒店询价
  13644. /// page Item
  13645. /// </summary>
  13646. /// <param name="_dto"></param>
  13647. /// <returns></returns>
  13648. [HttpPost]
  13649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13650. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  13651. {
  13652. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  13653. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13654. var view = res.Data as PageDataViewBase;
  13655. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  13656. }
  13657. /// <summary>
  13658. /// 酒店询价
  13659. /// info
  13660. /// </summary>
  13661. /// <param name="_dto"></param>
  13662. /// <returns></returns>
  13663. [HttpPost]
  13664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13665. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  13666. {
  13667. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  13668. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13669. return Ok(JsonView(true, res.Msg, res.Data));
  13670. }
  13671. /// <summary>
  13672. /// 酒店询价
  13673. /// Add Or Edit
  13674. /// </summary>
  13675. /// <param name="_dto"></param>
  13676. /// <returns></returns>
  13677. [HttpPost]
  13678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13679. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  13680. {
  13681. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  13682. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13683. return Ok(JsonView(true, res.Msg, res.Data));
  13684. }
  13685. /// <summary>
  13686. /// 酒店询价
  13687. /// Del
  13688. /// </summary>
  13689. /// <param name="_dto"></param>
  13690. /// <returns></returns>
  13691. [HttpPost]
  13692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13693. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  13694. {
  13695. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  13696. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13697. return Ok(JsonView(true, res.Msg, res.Data));
  13698. }
  13699. #endregion
  13700. #region 下载匹配op行程单
  13701. /// <summary>
  13702. /// 匹配op行程单
  13703. /// Init
  13704. /// </summary>
  13705. /// <param name="dto">团组列表请求dto</param>
  13706. /// <returns></returns>
  13707. [HttpPost]
  13708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13709. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  13710. {
  13711. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13712. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13713. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  13714. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  13715. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  13716. .Where(it => it.IsDel == 0)
  13717. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  13718. .OrderByDescending(it => it.CreateUserId)
  13719. .ToList();
  13720. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  13721. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13722. var diids = groupInfos.Select(it => it.Id).ToList();
  13723. List<string> countrys = new List<string>();
  13724. foreach (var item in country)
  13725. {
  13726. var data = _groupRepository.FormartTeamName(item);
  13727. var dataArray = _groupRepository.GroupSplitCountry(data);
  13728. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13729. }
  13730. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  13731. List<string> areaArray = new List<string>(); //GetGroupCityLine
  13732. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  13733. foreach (var item in areaItem)
  13734. {
  13735. string areaStr = item.Value;
  13736. if (!string.IsNullOrEmpty(areaStr))
  13737. {
  13738. string[] str1 = areaStr.Split("-");
  13739. if (str1.Length > 0)
  13740. {
  13741. areaArray.AddRange(str1);
  13742. }
  13743. }
  13744. }
  13745. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  13746. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  13747. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  13748. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  13749. .ToList();
  13750. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  13751. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  13752. .Where(it => countriesIds.Contains(it.Id))
  13753. .Select(it => new { it.Id, Name = it.Name_CN })
  13754. .ToList();
  13755. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  13756. .Select(it => it.TeamName).ToList();
  13757. stopwatch.Stop();
  13758. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  13759. }
  13760. ///// <summary>
  13761. ///// 匹配op行程单
  13762. ///// Init 查询区域数据
  13763. ///// </summary>
  13764. ///// <param name="dto">团组列表请求dto</param>
  13765. ///// <returns></returns>
  13766. //[HttpPost]
  13767. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13768. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  13769. //{
  13770. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13771. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  13772. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  13773. // if (string.IsNullOrEmpty(countriesDataStr))
  13774. // {
  13775. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  13776. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  13777. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  13778. // }
  13779. // else
  13780. // {
  13781. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  13782. // }
  13783. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  13784. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  13785. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  13786. // List<dynamic> childList = new List<dynamic>();
  13787. // int parentId = dto.CountriesId;
  13788. // if (provinceData.Count > 1)
  13789. // {
  13790. // foreach (var item1 in provinceData)
  13791. // {
  13792. // List<dynamic> childList1 = new List<dynamic>();
  13793. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  13794. // foreach (var item2 in citiesData1)
  13795. // {
  13796. // List<dynamic> childList2 = new List<dynamic>();
  13797. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13798. // foreach (var item3 in countiesData1)
  13799. // {
  13800. // childList2.Add(new
  13801. // {
  13802. // id = item3.Id,
  13803. // parentId = item2.Id,
  13804. // level = "district",
  13805. // name = item3.Name_CN,
  13806. // });
  13807. // }
  13808. // childList1.Add(new
  13809. // {
  13810. // id = item2.Id,
  13811. // parentId = item1.Id,
  13812. // level = "city",
  13813. // name = item2.Name_CN,
  13814. // childList = childList2
  13815. // });
  13816. // }
  13817. // childList.Add(new
  13818. // {
  13819. // id = item1.Id,
  13820. // parentId = parentId,
  13821. // level = "province",
  13822. // name = item1.Name_CN,
  13823. // childList = childList1
  13824. // });
  13825. // }
  13826. // //城市
  13827. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  13828. // foreach (var item2 in citiesData2)
  13829. // {
  13830. // List<dynamic> childList22 = new List<dynamic>();
  13831. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13832. // foreach (var item3 in countiesData1)
  13833. // {
  13834. // childList22.Add(new
  13835. // {
  13836. // id = item3.Id,
  13837. // parentId = item2.Id,
  13838. // level = "district",
  13839. // name = item3.Name_CN,
  13840. // });
  13841. // }
  13842. // childList.Add(new
  13843. // {
  13844. // id = item2.Id,
  13845. // parentId = parentId,
  13846. // level = "city",
  13847. // name = item2.Name_CN,
  13848. // childList = childList22
  13849. // });
  13850. // }
  13851. // }
  13852. // else
  13853. // {
  13854. // foreach (var item2 in citiesData)
  13855. // {
  13856. // string cname = item2.Name_CN;
  13857. // List<dynamic> childList1 = new List<dynamic>();
  13858. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13859. // foreach (var item3 in countiesData1)
  13860. // {
  13861. // childList1.Add(new
  13862. // {
  13863. // Id = item3.Id,
  13864. // parentId = item2.Id,
  13865. // level = "district",
  13866. // name = item3.Name_CN
  13867. // });
  13868. // }
  13869. // childList.Add(new
  13870. // {
  13871. // id = item2.Id,
  13872. // parentId = parentId,
  13873. // level = "city",
  13874. // name = item2.Name_CN,
  13875. // childList = childList1
  13876. // });
  13877. // }
  13878. // }
  13879. // stopwatch.Stop();
  13880. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  13881. //}
  13882. /// <summary>
  13883. /// 匹配op行程单
  13884. /// 接团信息列表 Page
  13885. /// </summary>
  13886. /// <param name="dto">团组列表请求dto</param>
  13887. /// <returns></returns>
  13888. [HttpPost]
  13889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13890. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  13891. {
  13892. var swatch = new Stopwatch();
  13893. swatch.Start();
  13894. #region 参数验证
  13895. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13896. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13897. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13898. #region 页面操作权限验证
  13899. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13900. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  13901. #endregion
  13902. #endregion
  13903. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13904. {
  13905. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  13906. string sqlWhere = "";
  13907. if (!string.IsNullOrEmpty(dto.Country))
  13908. {
  13909. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  13910. }
  13911. if (!string.IsNullOrEmpty(dto.Area))
  13912. {
  13913. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  13914. }
  13915. if (!string.IsNullOrEmpty(dto.TeamName))
  13916. {
  13917. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  13918. }
  13919. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  13920. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  13921. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  13922. swatch.Stop();
  13923. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  13924. }
  13925. else
  13926. {
  13927. return Ok(JsonView(false, "查询失败"));
  13928. }
  13929. }
  13930. /// <summary>
  13931. /// 匹配op行程单
  13932. /// 行程单下载
  13933. /// </summary>
  13934. /// <param name="dto">团组列表请求dto</param>
  13935. /// <returns></returns>
  13936. [HttpPost]
  13937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13938. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  13939. {
  13940. #region 参数验证
  13941. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13942. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13943. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13944. #region 页面操作权限验证
  13945. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13946. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  13947. #endregion
  13948. #endregion
  13949. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13950. {
  13951. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  13952. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  13953. }
  13954. else
  13955. {
  13956. return Ok(JsonView(false, "下载失败!"));
  13957. }
  13958. }
  13959. #endregion
  13960. #region 国家信息 数据 注释
  13961. //[HttpPost]
  13962. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  13963. //{
  13964. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  13965. // foreach (var item in dto)
  13966. // {
  13967. // infos.Add(new Grp_GroupsTaskAssignment()
  13968. // {
  13969. // DIId = item,
  13970. // CTId = 82,
  13971. // UId = 248,
  13972. // IsEnable = 1,
  13973. // CreateUserId = 233,
  13974. // CreateTime = DateTime.Now,
  13975. // IsDel = 0
  13976. // });
  13977. // infos.Add(new Grp_GroupsTaskAssignment()
  13978. // {
  13979. // DIId = item,
  13980. // CTId = 82,
  13981. // UId = 286,
  13982. // IsEnable = 1,
  13983. // CreateUserId = 233,
  13984. // CreateTime = DateTime.Now,
  13985. // IsDel = 0
  13986. // });
  13987. // }
  13988. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  13989. // return Ok("操作成功");
  13990. //}
  13991. //public class paramJsonDto
  13992. //{
  13993. // public List<CountriesInfo> str { get; set; }
  13994. //}
  13995. //[HttpPost]
  13996. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  13997. //{
  13998. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  13999. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  14000. // List<Sys_Cities> cities = new List<Sys_Cities>();
  14001. // List<Sys_Cities> districts = new List<Sys_Cities>();
  14002. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  14003. // _sqlSugar.BeginTran();
  14004. // int countitiesIndex = 0;
  14005. // foreach (var item in dto.str)
  14006. // {
  14007. // dynamic data = item.c;
  14008. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  14009. // if (data != null)
  14010. // {
  14011. // countitiesIndex++;
  14012. // foreach (var item1 in data)
  14013. // {
  14014. // string cnname = item1.cn;
  14015. // string enname = item1.en;
  14016. // Sys_Cities provinceInfo = new Sys_Cities()
  14017. // {
  14018. // CountriesId = countriesId,
  14019. // Name_CN = cnname,
  14020. // Name_EN = enname,
  14021. // ParentId = 0,
  14022. // IsCapital = 1,
  14023. // CreateUserId = 208,
  14024. // CreateTime = DateTime.Now,
  14025. // IsDel = 0
  14026. // };
  14027. // if (item1.lv == "province") //省份
  14028. // {
  14029. // provinceInfo.Level = 1;
  14030. // int provinceId = 0;
  14031. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  14032. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  14033. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14034. // var data1 = item1.c;
  14035. // foreach (var item2 in data1)
  14036. // {
  14037. // if (item2.lv == "city")
  14038. // {
  14039. // string citycnname = item2.cn;
  14040. // string cityenname = item2.en;
  14041. // Sys_Cities cityInfo = new Sys_Cities()
  14042. // {
  14043. // CountriesId = countriesId,
  14044. // ParentId = provinceId,
  14045. // Level = 2,
  14046. // Name_CN = citycnname,
  14047. // Name_EN = cityenname,
  14048. // IsCapital = 1,
  14049. // CreateUserId = 208,
  14050. // CreateTime = DateTime.Now,
  14051. // IsDel = 0
  14052. // };
  14053. // if (item2.c != null)
  14054. // {
  14055. // int cityId = 0;
  14056. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  14057. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14058. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  14059. // foreach (var item3 in item2.c)
  14060. // {
  14061. // if (item3.lv == "district")
  14062. // {
  14063. // var districtInfo = new Sys_Cities()
  14064. // {
  14065. // CountriesId = countriesId,
  14066. // Name_CN = item3.cn,
  14067. // Name_EN = item3.en,
  14068. // Level = 3,
  14069. // ParentId = cityId,
  14070. // IsCapital = 1,
  14071. // CreateUserId = 208,
  14072. // CreateTime = DateTime.Now,
  14073. // IsDel = 0
  14074. // };
  14075. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14076. // //{
  14077. // districts.Add(districtInfo);
  14078. // //}
  14079. // }
  14080. // }
  14081. // }
  14082. // else
  14083. // {
  14084. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  14085. // //{
  14086. // cities.Add(cityInfo);
  14087. // //}
  14088. // }
  14089. // }
  14090. // }
  14091. // }
  14092. // else if (item1.lv == "city")//城市
  14093. // {
  14094. // provinceInfo.Level = 2;
  14095. // if (item1.c != null)
  14096. // {
  14097. // int cityId = 0;
  14098. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  14099. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14100. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14101. // foreach (var item3 in item1.c)
  14102. // {
  14103. // if (item3.lv == "district")
  14104. // {
  14105. // var districtInfo = new Sys_Cities()
  14106. // {
  14107. // CountriesId = countriesId,
  14108. // Name_CN = item3.cn,
  14109. // Name_EN = item3.en,
  14110. // Level = 3,
  14111. // ParentId = cityId,
  14112. // IsCapital = 1,
  14113. // CreateUserId = 208,
  14114. // CreateTime = DateTime.Now,
  14115. // IsDel = 0
  14116. // };
  14117. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14118. // //{
  14119. // districts.Add(districtInfo);
  14120. // //}
  14121. // }
  14122. // }
  14123. // }
  14124. // else
  14125. // {
  14126. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  14127. // //{
  14128. // cities.Add(provinceInfo);
  14129. // //}
  14130. // }
  14131. // }
  14132. // }
  14133. // }
  14134. // }
  14135. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  14136. // cities = cities.Distinct().ToList();
  14137. // districts = districts.Distinct().ToList();
  14138. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  14139. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  14140. // cities.AddRange(districts);
  14141. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  14142. // //_sqlSugar.RollbackTran();
  14143. // _sqlSugar.CommitTran();
  14144. // return Ok(JsonView(false, "操作成功!"));
  14145. //}
  14146. //[HttpPost]
  14147. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  14148. //{
  14149. // List<CountitiesInfo> infos = dto.MyProperty;
  14150. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  14151. // _sqlSugar.BeginTran();
  14152. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  14153. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  14154. // foreach (var item in infos)
  14155. // {
  14156. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  14157. // if (countryInfo != null)
  14158. // {
  14159. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  14160. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  14161. // if (cityInfo1 != null)
  14162. // {
  14163. // cityInfo1.IsCapital = 0;
  14164. // cityInfos.Add(cityInfo1);
  14165. // }
  14166. // }
  14167. // }
  14168. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  14169. // .UpdateColumns(it => it.IsCapital)
  14170. // .WhereColumns(it => it.Id)
  14171. // .ExecuteCommand();
  14172. // //_sqlSugar.RollbackTran();
  14173. // _sqlSugar.CommitTran();
  14174. // return Ok(JsonView(false, "操作成功!"));
  14175. //}
  14176. //public class CounrtiesDto
  14177. //{
  14178. // public List<CountitiesInfo> MyProperty { get; set; }
  14179. //}
  14180. //public class CountitiesInfo
  14181. //{
  14182. // /// <summary>
  14183. // /// 圣约翰
  14184. // /// </summary>
  14185. // public string capital_name_chinese { get; set; }
  14186. // /// <summary>
  14187. // ///
  14188. // /// </summary>
  14189. // public string capital_name { get; set; }
  14190. // /// <summary>
  14191. // ///
  14192. // /// </summary>
  14193. // public string country_type { get; set; }
  14194. // /// <summary>
  14195. // /// 安提瓜和巴布达
  14196. // /// </summary>
  14197. // public string country_name_chinese { get; set; }
  14198. // /// <summary>
  14199. // /// 安提瓜和巴布达
  14200. // /// </summary>
  14201. // public string country_name_chinese_short { get; set; }
  14202. // /// <summary>
  14203. // /// 安提瓜和巴布达
  14204. // /// </summary>
  14205. // public string country_name_chinese_UN { get; set; }
  14206. // /// <summary>
  14207. // ///
  14208. // /// </summary>
  14209. // public string country_name_english_abbreviation { get; set; }
  14210. // /// <summary>
  14211. // ///
  14212. // /// </summary>
  14213. // public string country_name_english_formal { get; set; }
  14214. // /// <summary>
  14215. // ///
  14216. // /// </summary>
  14217. // public string country_name_english_UN { get; set; }
  14218. // /// <summary>
  14219. // ///
  14220. // /// </summary>
  14221. // public string continent_name { get; set; }
  14222. // /// <summary>
  14223. // ///
  14224. // /// </summary>
  14225. // public string subregion_name { get; set; }
  14226. // /// <summary>
  14227. // ///
  14228. // /// </summary>
  14229. // public string country_code2 { get; set; }
  14230. // /// <summary>
  14231. // ///
  14232. // /// </summary>
  14233. // public string country_code3 { get; set; }
  14234. // /// <summary>
  14235. // ///
  14236. // /// </summary>
  14237. // public string phone_code { get; set; }
  14238. //}
  14239. //public class CountriesInfo : BasicInfo
  14240. //{
  14241. // public List<CitiesInfo> c { get; set; }
  14242. //}
  14243. //public class CitiesInfo : BasicInfo
  14244. //{
  14245. // public List<AreaInfo> c { get; set; }
  14246. //}
  14247. //public class AreaInfo : BasicInfo
  14248. //{
  14249. // public List<AreaInfo> c { get; set; }
  14250. //}
  14251. //public class BasicInfo
  14252. //{
  14253. // public string code { get; set; }
  14254. // public string cn { get; set; }
  14255. // public string lv { get; set; }
  14256. // public string en { get; set; }
  14257. //}
  14258. #endregion
  14259. #region 查看邀请方
  14260. /// <summary>
  14261. /// 查看邀请方
  14262. /// 邀请方信息 Init
  14263. /// </summary>
  14264. /// <param name="dto"></param>
  14265. /// <returns></returns>
  14266. [HttpPost]
  14267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14268. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  14269. {
  14270. string sqlWhere = string.Empty;
  14271. if (!string.IsNullOrEmpty(dto.Search))
  14272. {
  14273. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  14274. }
  14275. string sql = string.Format($@"Select
  14276. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  14277. Id,
  14278. UnitName
  14279. From Res_InvitationOfficialActivityData
  14280. Where IsDel = 0
  14281. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  14282. RefAsync<int> total = 0;
  14283. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14284. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  14285. }
  14286. /// <summary>
  14287. /// 查看邀请方
  14288. /// 国家信息 Init
  14289. /// </summary>
  14290. /// <param name="dto"></param>
  14291. /// <returns></returns>
  14292. [HttpPost]
  14293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14294. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  14295. {
  14296. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  14297. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  14298. var diids = groupInfos.Select(it => it.Id).ToList();
  14299. List<string> countrys = new List<string>();
  14300. foreach (var item in country)
  14301. {
  14302. var data = _groupRepository.FormartTeamName(item);
  14303. var dataArray = _groupRepository.GroupSplitCountry(data);
  14304. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  14305. }
  14306. countrys = countrys.Distinct().ToList();
  14307. for (int i = 0; i < countrys.Count; i++)
  14308. {
  14309. string item = countrys[i];
  14310. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  14311. {
  14312. countrys.Remove(item);
  14313. i--;
  14314. }
  14315. }
  14316. RefAsync<int> total = 0;
  14317. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  14318. .Where(it => countrys.Contains(it.Name_CN))
  14319. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14320. .Select(it => new { id = it.Id, name = it.Name_CN })
  14321. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14322. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14323. }
  14324. /// <summary>
  14325. /// 查看邀请方
  14326. /// 城市信息 Init
  14327. /// </summary>
  14328. /// <param name="dto"></param>
  14329. /// <returns></returns>
  14330. [HttpPost]
  14331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14332. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  14333. {
  14334. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  14335. RefAsync<int> total = 0;
  14336. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  14337. .Where(it => it.CountriesId == dto.CountiesId)
  14338. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14339. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  14340. .Select(it => new { id = it.Id, name = it.Name_CN })
  14341. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14342. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14343. }
  14344. /// <summary>
  14345. /// 查看邀请方
  14346. /// 团组名称 Init
  14347. /// </summary>
  14348. /// <param name="dto"></param>
  14349. /// <returns></returns>
  14350. [HttpPost]
  14351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14352. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  14353. {
  14354. var watch = new Stopwatch();
  14355. watch.Start();
  14356. RefAsync<int> total = 0;
  14357. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  14358. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  14359. .Where((oa, di) => oa.IsDel == 0)
  14360. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  14361. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  14362. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  14363. .Distinct()
  14364. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14365. watch.Stop();
  14366. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  14367. }
  14368. /// <summary>
  14369. /// 查看邀请方
  14370. /// 团组 & 邀请方信息
  14371. /// </summary>
  14372. /// <param name="dto"></param>
  14373. /// <returns></returns>
  14374. [HttpPost]
  14375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14376. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  14377. {
  14378. var watch = new Stopwatch();
  14379. watch.Start();
  14380. RefAsync<int> total = 0;
  14381. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  14382. .AS("Grp_DelegationInfo")
  14383. .Includes(x => x.InvitingInfos)
  14384. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  14385. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  14386. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  14387. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  14388. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  14389. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  14390. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14391. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  14392. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  14393. infos.ForEach(x =>
  14394. {
  14395. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  14396. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  14397. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  14398. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  14399. });
  14400. watch.Stop();
  14401. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  14402. }
  14403. #endregion
  14404. #region 报批行程
  14405. /// <summary>
  14406. /// 报批行程初始化
  14407. /// </summary>
  14408. /// <param name="dto"></param>
  14409. /// <returns></returns>
  14410. [HttpPost]
  14411. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  14412. {
  14413. const int chiNumber = 5;
  14414. var jw = JsonView(false);
  14415. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  14416. var group = groupList.First();
  14417. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14418. group = groupList.First(x => x.Id == diid);
  14419. if (group == null)
  14420. {
  14421. jw.Msg = "暂无团组!";
  14422. return Ok(jw);
  14423. }
  14424. var data = new
  14425. {
  14426. groupList = groupList.Select(x => new
  14427. {
  14428. x.TeamName,
  14429. x.Id
  14430. }),
  14431. content = new ArrayList(),
  14432. groupInfo = new
  14433. {
  14434. group.VisitDays,
  14435. group.TourCode,
  14436. group.VisitPNumber,
  14437. group.TeamName,
  14438. group.Id,
  14439. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  14440. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  14441. },
  14442. };
  14443. var resultArr = new ArrayList();
  14444. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  14445. if (content.Count == 0)
  14446. {
  14447. var stay = "-";
  14448. var cityPath = "-";
  14449. //添加城市路径以及住宿地
  14450. //黑屏代码数据
  14451. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14452. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14453. {
  14454. jw = JsonView(true, "黑屏代码有误!", data);
  14455. return Ok(jw);
  14456. }
  14457. foreach (DataRow row in dtBlack.Rows)
  14458. {
  14459. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14460. {
  14461. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  14462. return Ok(jw);
  14463. }
  14464. }
  14465. //黑屏代码获取时间区间
  14466. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14467. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14468. _sqlSugar.BeginTran();
  14469. for (int i = 0; i < timeArr.Count; i++)
  14470. {
  14471. stay = "-";
  14472. cityPath = "-";
  14473. DateTime NewData = DateTime.Parse(timeArr[i]);
  14474. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14475. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14476. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14477. if (tbSelect.Length > 0)
  14478. {
  14479. List<string> threeCodeStr = new List<string>();
  14480. foreach (var item in tbSelect)
  14481. {
  14482. var threeCode = item["Three"].ToString() ?? "";
  14483. if (threeCode.Length == 6)
  14484. {
  14485. var start = threeCode.Substring(0, 3);
  14486. var end = threeCode.Substring(3, 3);
  14487. if (threeCodeStr.Count == 0)
  14488. {
  14489. threeCodeStr.Add(start);
  14490. threeCodeStr.Add(end);
  14491. }
  14492. else
  14493. {
  14494. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14495. {
  14496. threeCodeStr.Add(end);
  14497. }
  14498. else
  14499. {
  14500. threeCodeStr.Add(start);
  14501. threeCodeStr.Add(end);
  14502. }
  14503. }
  14504. }
  14505. }
  14506. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14507. var last = threeCodeStr.Last();
  14508. foreach (var item in threeCodeStr)
  14509. {
  14510. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14511. if (item.Equals(last))
  14512. {
  14513. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14514. }
  14515. }
  14516. cityPath = cityPath.Trim('-');
  14517. }
  14518. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14519. appro.Diid = diid ?? -1;
  14520. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14521. appro.Id = thisId;
  14522. appro.CreateUserId = dto.UserId;
  14523. appro.CreateTime = DateTime.Now;
  14524. content.Add(appro);
  14525. }
  14526. _sqlSugar.CommitTran();
  14527. }
  14528. foreach (var x in content)
  14529. {
  14530. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  14531. if (chiList.Count < chiNumber)
  14532. {
  14533. for (int i = chiList.Count; i < chiNumber; i++)
  14534. {
  14535. chiList.Add(new Grp_ApprovalTravelDetails());
  14536. }
  14537. }
  14538. resultArr.Add(new
  14539. {
  14540. x.Id,
  14541. x.Date,
  14542. x.Diid,
  14543. chiList = chiList.Select(x1 => new
  14544. {
  14545. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14546. x1.Details,
  14547. x1.ParentId,
  14548. x1.Id
  14549. })
  14550. });
  14551. }
  14552. data = data with
  14553. {
  14554. content = resultArr,
  14555. };
  14556. jw = JsonView(true, "获取成功!", data);
  14557. return Ok(jw);
  14558. }
  14559. /// <summary>
  14560. /// 报批行程删除
  14561. /// </summary>
  14562. /// <param name="dto"></param>
  14563. /// <returns></returns>
  14564. [HttpPost]
  14565. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  14566. {
  14567. var jw = JsonView(false);
  14568. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14569. if (group == null)
  14570. {
  14571. jw.Msg = "团组参数有误!";
  14572. return Ok(jw);
  14573. }
  14574. try
  14575. {
  14576. _sqlSugar.BeginTran();
  14577. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  14578. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  14579. {
  14580. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14581. DeleteUserId = dto.uesrId,
  14582. IsDel = 1
  14583. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  14584. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  14585. {
  14586. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14587. DeleteUserId = dto.uesrId,
  14588. IsDel = 1
  14589. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  14590. _sqlSugar.CommitTran();
  14591. jw = JsonView(true, "删除成功");
  14592. }
  14593. catch (Exception ex)
  14594. {
  14595. jw = JsonView(false, ex.Message);
  14596. }
  14597. return Ok(jw);
  14598. }
  14599. /// <summary>
  14600. /// 报批行程保存
  14601. /// </summary>
  14602. /// <param name="dto"></param>
  14603. /// <returns></returns>
  14604. [HttpPost]
  14605. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  14606. {
  14607. var jw = JsonView(false);
  14608. var Find = dto.Arr.Find(x => x.id == 0);
  14609. if (Find != null)
  14610. {
  14611. jw.Msg = "生成的ID为0!";
  14612. return Ok(jw);
  14613. }
  14614. foreach (var item in dto.Arr)
  14615. {
  14616. foreach (var chi in item.chiList)
  14617. {
  14618. if (chi.parentId == 0)
  14619. {
  14620. chi.parentId = item.id;
  14621. }
  14622. }
  14623. }
  14624. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  14625. _sqlSugar.BeginTran();
  14626. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  14627. {
  14628. var parentIds = dto.Arr.Select(x => x.id).ToList();
  14629. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  14630. {
  14631. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14632. DeleteUserId = dto.UserId,
  14633. IsDel = 1
  14634. }).ExecuteCommand();
  14635. }
  14636. try
  14637. {
  14638. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  14639. {
  14640. CreateTime = DateTime.Now,
  14641. CreateUserId = dto.UserId,
  14642. Details = x.details,
  14643. ParentId = x.parentId,
  14644. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14645. Remark = "",
  14646. IsDel = 0
  14647. }).ToList()).ExecuteCommand();
  14648. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  14649. {
  14650. Id = x.id,
  14651. Details = x.details,
  14652. ParentId = x.parentId,
  14653. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14654. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  14655. {
  14656. Details = x.Details,
  14657. ParentId = x.ParentId,
  14658. Time = x.Time
  14659. }).ExecuteCommand();
  14660. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  14661. {
  14662. Id = x.id,
  14663. Date = x.date,
  14664. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  14665. {
  14666. Date = x.Date
  14667. }).ExecuteCommand();
  14668. _sqlSugar.CommitTran();
  14669. jw = JsonView(true, "保存成功!");
  14670. }
  14671. catch (Exception ex)
  14672. {
  14673. _sqlSugar.RollbackTran();
  14674. jw = JsonView(false, "保存失败!" + ex.Message);
  14675. }
  14676. return Ok(jw);
  14677. }
  14678. /// <summary>
  14679. /// 报批行程生成
  14680. /// </summary>
  14681. /// <param name="dto"></param>
  14682. /// <returns></returns>
  14683. [HttpPost]
  14684. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  14685. {
  14686. var jw = JsonView(false);
  14687. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14688. if (group == null)
  14689. {
  14690. jw.Msg = "暂无该团组!";
  14691. return Ok(jw);
  14692. }
  14693. //黑屏代码数据
  14694. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14695. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14696. {
  14697. jw.Msg = "黑屏代码有误!";
  14698. return Ok(jw);
  14699. }
  14700. foreach (DataRow row in dtBlack.Rows)
  14701. {
  14702. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14703. {
  14704. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  14705. return Ok(jw);
  14706. }
  14707. }
  14708. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14709. var resultArr = new ArrayList();
  14710. if (officialActivitiesArr.Count == 0)
  14711. {
  14712. jw.Msg = "暂无公务出访信息!";
  14713. return Ok(jw);
  14714. }
  14715. try
  14716. {
  14717. _sqlSugar.BeginTran();
  14718. DeleteApprovalJourney(new
  14719. Domain.Dtos.Groups.DeleteApprovalJourney
  14720. {
  14721. Diid = dto.Diid,
  14722. uesrId = dto.Userid
  14723. });
  14724. var stay = "-";
  14725. var cityPath = "-";
  14726. //添加城市路径以及住宿地
  14727. //黑屏代码获取时间区间
  14728. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14729. var empty = "【未收入该三字码!请机票同事录入】";
  14730. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14731. for (int i = 0; i < timeArr.Count; i++)
  14732. {
  14733. stay = "-";
  14734. cityPath = "-";
  14735. var chiarr = new List<Grp_ApprovalTravelDetails>();
  14736. DateTime NewData = DateTime.Parse(timeArr[i]);
  14737. var gwinfo = officialActivitiesArr.Where(x => DateTime.TryParse(x.Date, out DateTime gwData) && gwData.ToString("yyyy-MM-dd") == NewData.ToString("yyyy-MM-dd")).OrderBy(x => x.Time).ToList();
  14738. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14739. if (tbSelect.Length > 0)
  14740. {
  14741. List<string> threeCodeStr = new List<string>();
  14742. bool isTrade = false;
  14743. string trip = string.Empty;
  14744. var rowLast = tbSelect.Last();
  14745. var rowFirst = tbSelect.First();
  14746. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  14747. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  14748. var takeOffTime = DateTime.Parse(timeArr[i]);
  14749. var fallToTime = DateTime.Parse(timeArr[i]);
  14750. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  14751. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  14752. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  14753. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  14754. foreach (var item in tbSelect)
  14755. {
  14756. var start = string.Empty;
  14757. var end = string.Empty;
  14758. var threeCode = item["Three"].ToString() ?? "";
  14759. if (threeCode.Length == 6)
  14760. {
  14761. start = threeCode.Substring(0, 3);
  14762. end = threeCode.Substring(3, 3);
  14763. if (threeCodeStr.Count == 0)
  14764. {
  14765. threeCodeStr.Add(start);
  14766. threeCodeStr.Add(end);
  14767. }
  14768. else
  14769. {
  14770. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14771. {
  14772. threeCodeStr.Add(end);
  14773. }
  14774. else
  14775. {
  14776. threeCodeStr.Add(start);
  14777. threeCodeStr.Add(end);
  14778. }
  14779. }
  14780. }
  14781. //处理机票信息
  14782. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  14783. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  14784. if (start_Object == null)
  14785. {
  14786. start_Object = new Res_ThreeCode()
  14787. {
  14788. AirPort = empty,
  14789. AirPort_En = empty,
  14790. City = empty,
  14791. Country = empty,
  14792. Four = empty,
  14793. Three = empty,
  14794. };
  14795. }
  14796. if (end_Object == null)
  14797. {
  14798. end_Object = new Res_ThreeCode()
  14799. {
  14800. AirPort = empty,
  14801. AirPort_En = empty,
  14802. City = empty,
  14803. Country = empty,
  14804. Four = empty,
  14805. Three = empty,
  14806. };
  14807. }
  14808. //机型判断
  14809. string airModel = item["AirModel"].ToString();
  14810. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  14811. string flightTime = item["FlightTime"].ToString();
  14812. if (flightTime!.Contains(":"))
  14813. {
  14814. flightTime = flightTime.Replace(":", "小时");
  14815. flightTime += "分钟";
  14816. }
  14817. if (flightTime.Contains("H"))
  14818. {
  14819. flightTime = flightTime.Replace("H", "小时");
  14820. }
  14821. if (flightTime.Contains("M"))
  14822. {
  14823. flightTime = flightTime.Replace("M", "分钟");
  14824. }
  14825. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  14826. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  14827. {
  14828. flightTime = flightDataTime.Hour > 0
  14829. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  14830. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  14831. ? flightDataTime.Minute.ToString() + "分钟" : "";
  14832. }
  14833. //航班号
  14834. string flightcode = item["Fliagtcode"].ToString();
  14835. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  14836. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  14837. if (aircompany == null)
  14838. {
  14839. aircompany = new Res_AirCompany
  14840. {
  14841. CnName = hsEmpty,
  14842. EnName = hsEmpty,
  14843. ShortCode = hsEmpty,
  14844. };
  14845. }
  14846. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  14847. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  14848. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  14849. if (isTrade)
  14850. {
  14851. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  14852. }
  14853. else
  14854. {
  14855. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  14856. }
  14857. }
  14858. chiarr.Add(new Grp_ApprovalTravelDetails
  14859. {
  14860. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  14861. CreateTime = DateTime.Now,
  14862. CreateUserId = dto.Userid,
  14863. ParentId = 0,
  14864. Details = trip
  14865. });
  14866. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14867. var last = threeCodeStr.Last();
  14868. foreach (var item in threeCodeStr)
  14869. {
  14870. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14871. if (item.Equals(last))
  14872. {
  14873. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14874. }
  14875. }
  14876. cityPath = cityPath.Trim('-');
  14877. }
  14878. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14879. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14880. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14881. appro.Diid = dto.Diid;
  14882. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14883. appro.Id = thisId;
  14884. appro.CreateUserId = dto.Userid;
  14885. appro.CreateTime = DateTime.Now;
  14886. foreach (var item in gwinfo)
  14887. {
  14888. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  14889. chi.Details = "拜访" + item.Client;
  14890. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  14891. {
  14892. chi.Details += "," + item.ReqSample;
  14893. }
  14894. chi.ParentId = thisId;
  14895. chi.Time = item.Time;
  14896. chiarr.Add(chi);
  14897. }
  14898. if (chiarr.Count < 5)
  14899. {
  14900. for (int j = chiarr.Count; j < 5; j++)
  14901. {
  14902. chiarr.Add(new
  14903. Grp_ApprovalTravelDetails());
  14904. }
  14905. }
  14906. resultArr.Add(new
  14907. {
  14908. appro.Id,
  14909. appro.Date,
  14910. appro.Diid,
  14911. chiList = chiarr.Select(x1 => new
  14912. {
  14913. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14914. x1.Details,
  14915. x1.ParentId,
  14916. x1.Id
  14917. })
  14918. });
  14919. }
  14920. _sqlSugar.CommitTran();
  14921. jw = JsonView(true, "生成成功!", resultArr);
  14922. }
  14923. catch (Exception ex)
  14924. {
  14925. jw.Code = 400;
  14926. jw.Msg = "生成失败!" + ex.Message;
  14927. }
  14928. return Ok(jw);
  14929. }
  14930. /// <summary>
  14931. /// 报批行程word导出
  14932. /// </summary>
  14933. /// <param name="dto"></param>
  14934. /// <returns></returns>
  14935. [HttpPost]
  14936. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  14937. {
  14938. var jw = JsonView(false);
  14939. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14940. if (group == null)
  14941. {
  14942. jw.Msg = "暂无该团组!";
  14943. return Ok(jw);
  14944. }
  14945. //模板路径
  14946. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  14947. //载入模板
  14948. Document doc = new Document(tempPath);
  14949. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14950. //获取所填表格的序数
  14951. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14952. Aspose.Words.Tables.Row titleRowClone = null;
  14953. Aspose.Words.Tables.Row CenterRowClone = null;
  14954. int index = 0;
  14955. int indexChi = 0;
  14956. int SetIndex = 0;
  14957. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  14958. //获取数据,放到datatable
  14959. foreach (var item in ApprovalTravelArr)
  14960. {
  14961. if (index > 0)
  14962. {
  14963. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  14964. tableOne.AppendChild(titleRowClone);
  14965. }
  14966. var textTime = item.Date;
  14967. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  14968. SetCells(tableOne, doc, SetIndex, 0, textTime);
  14969. SetIndex++;
  14970. if (ChiRep.Count > 0)
  14971. {
  14972. foreach (var itemChi in ChiRep)
  14973. {
  14974. var txtTime = itemChi.Time;
  14975. var txtDetail = itemChi.Details;
  14976. if (indexChi > 0)
  14977. {
  14978. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14979. tableOne.AppendChild(CenterRowClone);
  14980. }
  14981. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  14982. {
  14983. SetCells(tableOne, doc, SetIndex, 0, "");
  14984. SetCells(tableOne, doc, SetIndex, 1, "");
  14985. indexChi++;
  14986. SetIndex++;
  14987. break;
  14988. }
  14989. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  14990. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  14991. indexChi++;
  14992. SetIndex++;
  14993. }
  14994. }
  14995. else
  14996. {
  14997. if (indexChi > 0)
  14998. {
  14999. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  15000. tableOne.AppendChild(CenterRowClone);
  15001. }
  15002. SetCells(tableOne, doc, SetIndex, 0, "");
  15003. SetCells(tableOne, doc, SetIndex, 1, "");
  15004. indexChi++;
  15005. SetIndex++;
  15006. }
  15007. index++;
  15008. }
  15009. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  15010. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  15011. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  15012. jw.Code = 200;
  15013. jw.Msg = "";
  15014. return Ok(jw);
  15015. }
  15016. private string intToString(int numberVal)
  15017. {
  15018. string numberval = numberVal.ToString();
  15019. Dictionary<char, string> Number = new Dictionary<char, string>();
  15020. Number.Add('1', "一");
  15021. Number.Add('2', "二");
  15022. Number.Add('3', "三");
  15023. Number.Add('4', "四");
  15024. Number.Add('5', "五");
  15025. Number.Add('6', "六");
  15026. Number.Add('7', "七");
  15027. Number.Add('8', "八");
  15028. Number.Add('9', "九");
  15029. string stringNumberVal = string.Empty;
  15030. for (int i = 0; i < numberval.Length; i++)
  15031. {
  15032. if (i == 0)
  15033. {
  15034. stringNumberVal += Number[numberval[i]];
  15035. }
  15036. else if (i >= 1)
  15037. {
  15038. if (numberval[i] == '0')
  15039. {
  15040. stringNumberVal = "十";
  15041. }
  15042. else
  15043. {
  15044. stringNumberVal += "十" + Number[numberval[i]];
  15045. }
  15046. }
  15047. }
  15048. return stringNumberVal;
  15049. }
  15050. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  15051. {
  15052. //获取table中的某个单元格,从0开始
  15053. Cell lshCell = table.Rows[rows].Cells[cells];
  15054. //将单元格中段落移除
  15055. foreach (Node item in lshCell.Paragraphs)
  15056. {
  15057. lshCell.Paragraphs.Remove(item);
  15058. }
  15059. if (val.Contains("\r\n"))
  15060. {
  15061. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  15062. foreach (var item in spArr)
  15063. {
  15064. //新建一个段落
  15065. Paragraph p = new Paragraph(doc);
  15066. var r = new Run(doc, item);
  15067. //把设置的值赋给之前新建的段落
  15068. p.AppendChild(r);
  15069. //将此段落加到单元格内
  15070. lshCell.AppendChild(p);
  15071. }
  15072. }
  15073. else
  15074. {
  15075. //新建一个段落
  15076. Paragraph p = new Paragraph(doc);
  15077. var r = new Run(doc, val);
  15078. //把设置的值赋给之前新建的段落
  15079. p.AppendChild(r);
  15080. //将此段落加到单元格内
  15081. lshCell.AppendChild(p);
  15082. }
  15083. }
  15084. [HttpPost]
  15085. public async Task<IActionResult> ServerHttp(string paramStr)
  15086. {
  15087. paramStr = paramStr.TrimEnd('\'');
  15088. paramStr = paramStr.TrimStart('\'');
  15089. JsonView jw = JsonView(false);
  15090. JObject param = JObject.Parse(paramStr);
  15091. if (!param.ContainsKey("url"))
  15092. {
  15093. jw.Msg = "url null";
  15094. return Ok(jw);
  15095. }
  15096. string url = param["url"]!.ToString();
  15097. var methon = "get";
  15098. Dictionary<string, string> headValues = null;
  15099. string bodyStr = string.Empty;
  15100. if (param.ContainsKey("methon"))
  15101. {
  15102. methon = param["methon"]!.ToString().ToLower();
  15103. }
  15104. if (param.ContainsKey("header"))
  15105. {
  15106. var header = param["header"]!.ToString();
  15107. JObject headerJobject = JObject.Parse(header);
  15108. headValues = new Dictionary<string, string>();
  15109. foreach (JProperty item in headerJobject.Properties())
  15110. {
  15111. var value = item.Value.ToString();
  15112. var head = item.Path;
  15113. headValues.Add(head, value);
  15114. }
  15115. }
  15116. HttpClient client = new HttpClient();
  15117. string responseString = string.Empty;
  15118. StringContent content = null;
  15119. if (headValues != null)
  15120. {
  15121. foreach (var item in headValues.Keys)
  15122. {
  15123. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  15124. {
  15125. if (param.ContainsKey("body"))
  15126. {
  15127. bodyStr = param["body"]!.ToString();
  15128. }
  15129. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  15130. }
  15131. else
  15132. {
  15133. client.DefaultRequestHeaders.Add(item, headValues[item]);
  15134. }
  15135. }
  15136. }
  15137. try
  15138. {
  15139. if (methon == "get")
  15140. {
  15141. responseString = await client.GetStringAsync(url);
  15142. }
  15143. else if (methon == "post")
  15144. {
  15145. var request = new HttpRequestMessage(HttpMethod.Post, url)
  15146. {
  15147. Content = content
  15148. };
  15149. var response = await client.SendAsync(request);
  15150. try
  15151. {
  15152. Stream responseStream = await response.Content.ReadAsStreamAsync();
  15153. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  15154. {
  15155. using (StreamReader reader = new StreamReader(gzipStream))
  15156. {
  15157. responseString = await reader.ReadToEndAsync();
  15158. }
  15159. }
  15160. }
  15161. catch (Exception)
  15162. {
  15163. responseString = await response.Content.ReadAsStringAsync();
  15164. }
  15165. }
  15166. else
  15167. {
  15168. responseString = "methon error";
  15169. }
  15170. jw = JsonView(true, "success", responseString);
  15171. }
  15172. catch (Exception ex)
  15173. {
  15174. jw.Msg = "error " + ex.Message;
  15175. jw.Data = ex.StackTrace;
  15176. }
  15177. finally
  15178. {
  15179. client.Dispose();
  15180. }
  15181. return Ok(jw);
  15182. }
  15183. #endregion
  15184. #region 团组接待意见调查
  15185. /// <summary>
  15186. /// 团组接待意见调查 - 信息管理
  15187. /// 基础数据(团组)
  15188. /// </summary>
  15189. /// <param name="dto"></param>
  15190. /// <returns></returns>
  15191. [HttpGet]
  15192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15193. public async Task<IActionResult> OpinionaireInit()
  15194. {
  15195. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  15196. .Select(x => new
  15197. {
  15198. x.Id,
  15199. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  15200. })
  15201. .OrderByDescending(x => x.Id)
  15202. .ToListAsync();
  15203. return Ok(JsonView(groupData, groupData.Count));
  15204. }
  15205. /// <summary>
  15206. /// 团组接待意见调查 - 信息管理
  15207. /// 列表
  15208. /// </summary>
  15209. /// <param name="groupId"></param>
  15210. /// <returns></returns>
  15211. [HttpGet("{groupId}")]
  15212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15213. public async Task<IActionResult> OpinionaireManageList(int groupId)
  15214. {
  15215. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15216. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  15217. .Select(x => new
  15218. {
  15219. x.Id,
  15220. x.TourGuideName,
  15221. x.CityName,
  15222. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  15223. x.CreateTime
  15224. })
  15225. .OrderBy(x => x.Id)
  15226. .ToListAsync();
  15227. return Ok(JsonView(data));
  15228. }
  15229. /// <summary>
  15230. /// 团组接待意见调查 - 信息管理
  15231. /// 保存
  15232. /// </summary>
  15233. /// <param name="dto"></param>
  15234. /// <returns></returns>
  15235. [HttpPost]
  15236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15237. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  15238. {
  15239. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15240. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15241. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15242. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  15243. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  15244. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  15245. _opinionaireRep.BeginTran();
  15246. if (addData != null && addData.Count > 0)
  15247. {
  15248. foreach (var item in addData)
  15249. {
  15250. item.CreateUserId = currUserInfo.UserId;
  15251. item.DiId = dto.DiId;
  15252. }
  15253. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  15254. }
  15255. if (updData != null && updData.Count > 0)
  15256. {
  15257. var upd = await _opinionaireRep._sqlSugar
  15258. .Updateable(updData)
  15259. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  15260. .WhereColumns(x => new { x.Id })
  15261. .ExecuteCommandAsync();
  15262. }
  15263. _opinionaireRep.CommitTran();
  15264. return Ok(JsonView("操作成功!"));
  15265. }
  15266. /// <summary>
  15267. /// 团组接待意见调查 - 信息管理
  15268. /// 删除
  15269. /// </summary>
  15270. /// <param name="id"></param>
  15271. /// <returns></returns>
  15272. [HttpDelete("{id}")]
  15273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15274. public async Task<IActionResult> OpinionaireManageDel(int id)
  15275. {
  15276. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15277. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15278. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  15279. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  15280. if (!del) return Ok(JsonView("操作失败!"));
  15281. return Ok(JsonView("操作成功!"));
  15282. }
  15283. /// <summary>
  15284. /// 团组接待意见调查 - 用户
  15285. /// 列表
  15286. /// </summary>
  15287. /// <param name="id"></param>
  15288. /// <returns></returns>
  15289. [HttpGet("{diId}")]
  15290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15291. public async Task<IActionResult> OpinionaireUserList(int diId)
  15292. {
  15293. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15294. var sql = string.Format(@"
  15295. SELECT
  15296. o.Id,
  15297. o.DiId,
  15298. di.TeamName AS 'GroupName',
  15299. di.VisitPNumber AS 'PeopleNumber',
  15300. di.ClientName AS 'LeadGroup',
  15301. di.VisitCountry AS 'Travel',
  15302. di.VisitDays AS 'Days',
  15303. o.CityName,
  15304. o.TourGuideName,
  15305. o.Catering,
  15306. o.CateringReason,
  15307. o.Stay,
  15308. o.StayReason,
  15309. o.[Route],
  15310. o.RouteReason,
  15311. o.OfficialActivity,
  15312. o.OfficialActivityReason,
  15313. o.TourGuide,
  15314. o.TourGuideReason,
  15315. o.[Translate],
  15316. o.TranslateReason,
  15317. o.Trip,
  15318. o.TripReason,
  15319. o.ESFileName,
  15320. o.SignatureDate,
  15321. o.Remark
  15322. FROM
  15323. Grp_Opinionaire o
  15324. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  15325. WHERE
  15326. o.IsDel = 0
  15327. AND o.DiId = {0}
  15328. ORDER BY
  15329. o.Id ASC", diId);
  15330. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  15331. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  15332. return Ok(JsonView(data));
  15333. }
  15334. /// <summary>
  15335. /// 团组接待意见调查 - 用户
  15336. /// 保存
  15337. /// </summary>
  15338. /// <param name="id"></param>
  15339. /// <returns></returns>
  15340. [HttpPost]
  15341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15342. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  15343. {
  15344. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  15345. foreach (var item in dto)
  15346. {
  15347. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  15348. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  15349. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  15350. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  15351. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  15352. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  15353. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  15354. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  15355. }
  15356. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  15357. if (!Directory.Exists(filePathBase))
  15358. {
  15359. Directory.CreateDirectory(filePathBase);
  15360. }
  15361. #region 上传文件
  15362. var filePaths = new List<string>();
  15363. foreach (var item in dto)
  15364. {
  15365. var file = item.File;
  15366. // 将文件保存到指定位置
  15367. var filePath = Path.Combine(filePathBase, file.FileName);
  15368. using (var stream = new FileStream(filePath, FileMode.Create))
  15369. {
  15370. await file.CopyToAsync(stream);
  15371. }
  15372. //验证文件是否上传成功
  15373. if (!System.IO.File.Exists(filePath))
  15374. {
  15375. foreach (var filePathStr in filePaths)
  15376. {
  15377. System.IO.File.Delete(filePathStr);
  15378. }
  15379. return Ok(JsonView(false, "文件上传失败!"));
  15380. }
  15381. item.ESFileName = file.FileName;
  15382. }
  15383. #endregion
  15384. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  15385. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  15386. .UpdateColumns(x => new
  15387. {
  15388. x.Catering,
  15389. x.CateringReason,
  15390. x.Stay,
  15391. x.StayReason,
  15392. x.Route,
  15393. x.RouteReason,
  15394. x.OfficialActivity,
  15395. x.OfficialActivityReason,
  15396. x.TourGuide,
  15397. x.TourGuideReason,
  15398. x.Translate,
  15399. x.TranslateReason,
  15400. x.Trip,
  15401. x.TripReason,
  15402. x.ESFileName,
  15403. x.SignatureDate,
  15404. x.Remark
  15405. })
  15406. .WhereColumns(x => new { x.Id })
  15407. .ExecuteCommandAsync();
  15408. if (upd < 1)
  15409. {
  15410. foreach (var filePathStr in filePaths)
  15411. {
  15412. System.IO.File.Delete(filePathStr);
  15413. }
  15414. return Ok(JsonView(false));
  15415. }
  15416. return Ok(JsonView(true));
  15417. }
  15418. #endregion
  15419. // /// <summary>
  15420. // ///
  15421. // /// </summary>
  15422. // /// <param name="_dto"></param>
  15423. // /// <returns></returns>
  15424. // [HttpPost]
  15425. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15426. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15427. // {
  15428. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15429. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  15430. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  15431. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15432. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  15433. // dic_psg.Add("客人", 974);
  15434. // dic_psg.Add("司机", 975);
  15435. // dic_psg.Add("导游", 976);
  15436. // dic_psg.Add("公司内部人员", 977);
  15437. // dic_psg.Add("司机/导游/公司内部人员", 978);
  15438. // foreach (var item in list_visa)
  15439. // {
  15440. // Grp_VisaInfo temp = new Grp_VisaInfo();
  15441. // temp.Id = item.Id;
  15442. // temp.DIId = item.DIId;
  15443. // temp.VisaClient = item.VisaClient;
  15444. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  15445. // temp.VisaCurrency = item.VisaCurrency;
  15446. // temp.IsThird = item.IsThird;
  15447. // if (dic_psg.ContainsKey(item.PassengerType))
  15448. // {
  15449. // temp.PassengerType = dic_psg[item.PassengerType];
  15450. // }
  15451. // else {
  15452. // temp.PassengerType = -1;
  15453. // }
  15454. // temp.VisaNumber = item.VisaNumber;
  15455. // temp.VisaFreeNumber = item.VisaFreeNumber;
  15456. // temp.CreateUserId = item.Operators;
  15457. // DateTime dt_ct;
  15458. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  15459. // if (b_ct)
  15460. // {
  15461. // temp.CreateTime = dt_ct;
  15462. // }
  15463. // else
  15464. // {
  15465. // temp.CreateTime = DateTime.Now;
  15466. // }
  15467. // temp.DeleteTime = "";
  15468. // temp.DeleteUserId = 0;
  15469. // temp.Remark = item.Remark;
  15470. // if (string.IsNullOrEmpty(temp.Remark)) {
  15471. // temp.Remark = "";
  15472. // }
  15473. // temp.IsDel = item.IsDel;
  15474. // temp.VisaDescription = item.VisaAttachment;
  15475. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  15476. //([Id]
  15477. // ,[DIId]
  15478. // ,[VisaClient]
  15479. // ,[VisaPrice]
  15480. // ,[VisaCurrency]
  15481. // ,[IsThird]
  15482. // ,[PassengerType]
  15483. // ,[VisaNumber]
  15484. // ,[VisaFreeNumber]
  15485. // ,[CreateUserId]
  15486. // ,[CreateTime]
  15487. // ,[DeleteTime]
  15488. // ,[DeleteUserId]
  15489. // ,[Remark]
  15490. // ,[IsDel]
  15491. // ,[visaDescription])
  15492. // VALUES
  15493. // ({0},{1},'{2}',{3},{4}
  15494. //,{5},{6},{7},{8},{9}
  15495. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  15496. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  15497. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  15498. //);
  15499. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  15500. // }
  15501. // return Ok(JsonView(true, "操作成功!"));
  15502. // }
  15503. /// <summary>
  15504. /// 123132123
  15505. /// </summary>
  15506. /// <param name="_dto"></param>
  15507. /// <returns></returns>
  15508. [HttpPost]
  15509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15510. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15511. {
  15512. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15513. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  15514. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  15515. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15516. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  15517. dicDetail.Add(789, 1034);
  15518. dicDetail.Add(790, 1035);
  15519. dicDetail.Add(791, 1036);
  15520. dicDetail.Add(792, 1037);
  15521. dicDetail.Add(793, 1038);
  15522. dicDetail.Add(794, 1039);
  15523. dicDetail.Add(795, 1040);
  15524. dicDetail.Add(796, 1041);
  15525. dicDetail.Add(797, 1042);
  15526. dicDetail.Add(798, 1043);
  15527. dicDetail.Add(801, 1044);
  15528. dicDetail.Add(802, 1045);
  15529. dicDetail.Add(803, 1046);
  15530. Dictionary<int, int> dic = new Dictionary<int, int>();
  15531. dic.Add(806, 1027);
  15532. dic.Add(807, 1028);
  15533. dic.Add(808, 1029);
  15534. dic.Add(809, 1030);
  15535. dic.Add(810, 1031);
  15536. dic.Add(811, 1032);
  15537. dic.Add(812, 1033);
  15538. foreach (var item in list_visa)
  15539. {
  15540. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  15541. temp.Coefficient = item.coefficient;
  15542. DateTime dtCrt;
  15543. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  15544. if (b1)
  15545. {
  15546. temp.CreateTime = dtCrt;
  15547. }
  15548. else
  15549. {
  15550. temp.CreateTime = DateTime.Now;
  15551. }
  15552. temp.CreateUserId = item.Operators;
  15553. temp.DeleteTime = "";
  15554. temp.DeleteUserId = 0;
  15555. temp.DiId = int.Parse(item.DIID);
  15556. temp.FilePath = item.FilePath;
  15557. temp.IsDel = item.IsDel;
  15558. temp.Price = item.Price;
  15559. temp.PriceCount = 1;
  15560. temp.PriceCurrency = item.Currency;
  15561. int detailId = 0;
  15562. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  15563. {
  15564. detailId = dicDetail[item.PriceTypeDetail];
  15565. }
  15566. temp.PriceDetailType = detailId;
  15567. temp.PriceDt = DateTime.Now;
  15568. temp.PriceName = item.PriceName;
  15569. temp.PriceSum = item.Price;
  15570. int tid = 0;
  15571. if (dic.ContainsKey(item.PriceType))
  15572. {
  15573. tid = dic[item.PriceType];
  15574. }
  15575. temp.PriceType = tid;
  15576. temp.Remark = item.Remark;
  15577. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  15578. }
  15579. return Ok(JsonView(true, "操作成功!"));
  15580. }
  15581. [HttpPost]
  15582. public IActionResult TimeTest()
  15583. {
  15584. var jw = JsonView(false, "error");
  15585. _sqlSugar.BeginTran();
  15586. try
  15587. {
  15588. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  15589. .Select(x => new Crm_NewClientData
  15590. {
  15591. Id = x.Id,
  15592. Client = x.Client,
  15593. Contact = x.Contact,
  15594. Location = x.Location,
  15595. })
  15596. .ToList();
  15597. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  15598. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  15599. Stopwatch stopwatch = new Stopwatch();
  15600. // 开始计时
  15601. stopwatch.Start();
  15602. foreach (var item in clientList)
  15603. {
  15604. EncryptionProcessor.DecryptProperties(item);
  15605. }
  15606. stopwatch.Stop();
  15607. jw.Code = 200;
  15608. jw.Data = stopwatch.ElapsedMilliseconds;
  15609. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  15610. }
  15611. catch (Exception ex)
  15612. {
  15613. jw.Code = 400;
  15614. jw.Msg = ex.Message;
  15615. }
  15616. return Ok(jw);
  15617. }
  15618. }
  15619. }