GroupsController.cs 917 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636
  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. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  119. /// <summary>
  120. /// 构造函数
  121. /// </summary>
  122. /// <param name="logger"></param>
  123. /// <param name="mapper"></param>
  124. /// <param name="hubContext"></param>
  125. /// <param name="sqlSugar"></param>
  126. /// <param name="grpScheduleRep"></param>
  127. /// <param name="groupRepository"></param>
  128. /// <param name="taskAssignmentRep"></param>
  129. /// <param name="airTicketResRep"></param>
  130. /// <param name="decreasePaymentsRep"></param>
  131. /// <param name="InvitationOfficialActivitiesRep"></param>
  132. /// <param name="delegationEnDataRep"></param>
  133. /// <param name="enterExitCostRep"></param>
  134. /// <param name="delegationVisaRep"></param>
  135. /// <param name="message"></param>
  136. /// <param name="visaPriceRep"></param>
  137. /// <param name="carTouristGuideGroundRep"></param>
  138. /// <param name="checkBoxs"></param>
  139. /// <param name="GroupCostRepository"></param>
  140. /// <param name="CostTypeHotelNumberRepository"></param>
  141. /// <param name="GroupCostParameterRepository"></param>
  142. /// <param name="hotelPriceRep"></param>
  143. /// <param name="customersRep"></param>
  144. /// <param name="setDataRep"></param>
  145. /// <param name="tourClientListRep"></param>
  146. /// <param name="teamRateRep"></param>
  147. /// <param name="usersRep"></param>
  148. /// <param name="juHeApi"></param>
  149. /// <param name="invertedListRep"></param>
  150. /// <param name="visaFeeInfoRep"></param>
  151. /// <param name="ticketBlackCodeRep"></param>
  152. /// <param name="hotelInquiryRep"></param>
  153. /// <param name="threeCodeRepository"></param>
  154. /// <param name="feeAuditRep"></param>
  155. /// <param name="visaCommissionRep"></param>
  156. /// <param name="ffrRep"></param>
  157. /// <param name="opinionaireRep"></param>
  158. /// <param name="tableorRep"></param>
  159. public GroupsController(
  160. ILogger<GroupsController> logger,
  161. IMapper mapper,
  162. IHubContext<ChatHub, IChatClient> hubContext,
  163. SqlSugarClient sqlSugar,
  164. GrpScheduleRepository grpScheduleRep,
  165. DelegationInfoRepository groupRepository,
  166. TaskAssignmentRepository taskAssignmentRep,
  167. AirTicketResRepository airTicketResRep,
  168. DecreasePaymentsRepository decreasePaymentsRep,
  169. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  170. DelegationEnDataRepository delegationEnDataRep,
  171. EnterExitCostRepository enterExitCostRep,
  172. DelegationVisaRepository delegationVisaRep,
  173. MessageRepository message,
  174. VisaPriceRepository visaPriceRep,
  175. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  176. CheckBoxsRepository checkBoxs,
  177. GroupCostRepository GroupCostRepository,
  178. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  179. GroupCostParameterRepository GroupCostParameterRepository,
  180. HotelPriceRepository hotelPriceRep,
  181. CustomersRepository customersRep,
  182. SetDataRepository setDataRep,
  183. TourClientListRepository tourClientListRep,
  184. TeamRateRepository teamRateRep,
  185. UsersRepository usersRep, IJuHeApiService juHeApi,
  186. InvertedListRepository invertedListRep,
  187. VisaFeeInfoRepository visaFeeInfoRep,
  188. TicketBlackCodeRepository ticketBlackCodeRep,
  189. HotelInquiryRepository hotelInquiryRep,
  190. ThreeCodeRepository threeCodeRepository,
  191. FeeAuditRepository feeAuditRep,
  192. VisaCommissionRepository visaCommissionRep,
  193. ForeignReceivablesRepository ffrRep,
  194. OpinionaireRepository opinionaireRep,
  195. TableOperationRecordRepository tableorRep,
  196. EnterExitCostDraftRepository enterExitCostDraftRep
  197. )
  198. {
  199. _logger = logger;
  200. _mapper = mapper;
  201. _grpScheduleRep = grpScheduleRep;
  202. _groupRepository = groupRepository;
  203. _taskAssignmentRep = taskAssignmentRep;
  204. _airTicketResRep = airTicketResRep;
  205. _sqlSugar = sqlSugar;
  206. url = AppSettingsHelper.Get("ExcelBaseUrl");
  207. path = AppSettingsHelper.Get("ExcelBasePath");
  208. if (!System.IO.Directory.Exists(path))
  209. {
  210. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  211. }
  212. _decreasePaymentsRep = decreasePaymentsRep;
  213. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  214. _delegationEnDataRep = delegationEnDataRep;
  215. _enterExitCostRep = enterExitCostRep;
  216. _delegationVisaRep = delegationVisaRep;
  217. _message = message;
  218. _visaPriceRep = visaPriceRep;
  219. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  220. _checkBoxs = checkBoxs;
  221. _GroupCostRepository = GroupCostRepository;
  222. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  223. _GroupCostParameterRepository = GroupCostParameterRepository;
  224. _hotelPriceRep = hotelPriceRep;
  225. _customersRep = customersRep;
  226. _setDataRep = setDataRep;
  227. _tourClientListRep = tourClientListRep;
  228. _teamRateRep = teamRateRep;
  229. _hubContext = hubContext;
  230. _usersRep = usersRep;
  231. _juHeApi = juHeApi;
  232. _invertedListRep = invertedListRep;
  233. _visaFeeInfoRep = visaFeeInfoRep;
  234. _ticketBlackCodeRep = ticketBlackCodeRep;
  235. _hotelInquiryRep = hotelInquiryRep;
  236. _threeCodeRepository = threeCodeRepository;
  237. _feeAuditRep = feeAuditRep;
  238. _visaCommissionRep = visaCommissionRep;
  239. _ffrRep = ffrRep;
  240. _opinionaireRep = opinionaireRep;
  241. _currencyInit = new List<CurrencyInfo>()
  242. {
  243. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  244. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  245. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  246. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  247. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  248. };
  249. _portTypeData = new List<int>() { 2, 3 };
  250. _tableorRep = tableorRep;
  251. _enterExitCostDraftRep = enterExitCostDraftRep;
  252. }
  253. #region 流程管控
  254. /// <summary>
  255. /// 获取团组流程管控信息
  256. /// </summary>
  257. /// <param name="paras">参数Json字符串</param>
  258. /// <returns></returns>
  259. [HttpPost]
  260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  261. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  262. {
  263. if (string.IsNullOrEmpty(_jsonDto.Paras))
  264. {
  265. return Ok(JsonView(false, "参数为空"));
  266. }
  267. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  268. if (_ScheduleDto != null)
  269. {
  270. if (_ScheduleDto.SearchType == 2)//获取列表
  271. {
  272. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  273. return Ok(JsonView(_grpScheduleViewList));
  274. }
  275. else//获取对象
  276. {
  277. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  278. if (_grpScheduleView != null)
  279. {
  280. return Ok(JsonView(_grpScheduleView));
  281. }
  282. }
  283. }
  284. else
  285. {
  286. return Ok(JsonView(false, "参数反序列化失败"));
  287. }
  288. return Ok(JsonView(false, "暂无数据!"));
  289. }
  290. /// <summary>
  291. /// 修改团组流程管控详细表数据
  292. /// </summary>
  293. /// <param name="paras"></param>
  294. /// <returns></returns>
  295. [HttpPost]
  296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  298. {
  299. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  300. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  301. .SetColumns(it => it.Duty == _detail.Duty)
  302. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  303. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  304. .SetColumns(it => it.JobContent == _detail.JobContent)
  305. .SetColumns(it => it.Remark == _detail.Remark)
  306. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  307. .Where(s => s.Id == dto.Id)
  308. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  309. .ExecuteCommandAsync();
  310. if (result > 0)
  311. {
  312. return Ok(JsonView(true, "保存成功!"));
  313. }
  314. return Ok(JsonView(false, "保存失败!"));
  315. }
  316. /// <summary>
  317. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  318. /// </summary>
  319. /// <param name="dto"></param>
  320. /// <returns></returns>
  321. [HttpPost]
  322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  323. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  324. {
  325. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  326. _detail.IsDel = 1;
  327. _detail.DeleteUserId = dto.Duty;
  328. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  329. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  330. .SetColumns(it => it.IsDel == _detail.IsDel)
  331. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  332. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  333. .Where(it => it.Id == dto.Id)
  334. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  335. //.WhereColumns(s => s.Id == dto.Id)
  336. .ExecuteCommandAsync();
  337. if (result > 0)
  338. {
  339. return Ok(JsonView(true, "删除成功!"));
  340. }
  341. return Ok(JsonView(false, "删除失败!"));
  342. }
  343. /// <summary>
  344. /// 增加团组流程管控详细表数据
  345. /// </summary>
  346. /// <param name="dto"></param>
  347. /// <returns></returns>
  348. [HttpPost]
  349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  350. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  351. {
  352. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  353. if (DateTime.Now < _detail.ExpectBeginDt)
  354. {
  355. _detail.StepStatus = 0;
  356. }
  357. else
  358. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  359. _detail.StepStatus = 1;
  360. }
  361. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  362. if (result > 0)
  363. {
  364. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  365. return Ok(JsonView(true, "添加成功!", _result));
  366. }
  367. return Ok(JsonView(false, "添加失败!"));
  368. }
  369. #endregion
  370. #region 团组基本信息
  371. /// <summary>
  372. /// 接团信息列表
  373. /// </summary>
  374. /// <param name="dto">团组列表请求dto</param>
  375. /// <returns></returns>
  376. [HttpPost]
  377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  378. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  379. {
  380. var groupData = await _groupRepository.GetGroupList(dto);
  381. if (groupData.Code != 0)
  382. {
  383. return Ok(JsonView(false, groupData.Msg));
  384. }
  385. return Ok(JsonView(groupData.Data));
  386. }
  387. /// <summary>
  388. /// 分页查询团组列表
  389. /// </summary>
  390. /// <param name="dto"></param>
  391. /// <returns></returns>
  392. [HttpPost]
  393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  394. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  395. {
  396. var watch = new Stopwatch();
  397. watch.Start();
  398. RefAsync<int> total = 0;
  399. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  400. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  401. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  402. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  403. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  404. .Distinct()
  405. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  406. watch.Stop();
  407. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  408. }
  409. /// <summary>
  410. /// 接团信息列表 Page
  411. /// </summary>
  412. /// <param name="dto">团组列表请求dto</param>
  413. /// <returns></returns>
  414. [HttpPost]
  415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  416. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  417. {
  418. #region 参数验证
  419. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  420. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  421. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  422. #region 页面操作权限验证
  423. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  424. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  425. #endregion
  426. #endregion
  427. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  428. {
  429. string sqlWhere = string.Empty;
  430. if (dto.IsSure == 0) //未完成
  431. {
  432. sqlWhere += string.Format(@" And IsSure = 0");
  433. }
  434. else if (dto.IsSure == 1) //已完成
  435. {
  436. sqlWhere += string.Format(@" And IsSure = 1");
  437. }
  438. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  439. {
  440. string tj = dto.SearchCriteria;
  441. 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}%')",
  442. tj, tj, tj, tj, tj);
  443. }
  444. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  445. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  446. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  447. JietuanOperator,IsSure,CreateTime,IsBid
  448. From (
  449. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  450. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  451. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  452. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  453. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  454. From Grp_DelegationInfo gdi
  455. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  456. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  457. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  458. Where gdi.IsDel = 0 {0}
  459. ) temp", sqlWhere);
  460. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  461. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  462. #region 处理所属部门
  463. /*
  464. * 1.sq 和 gyy 等显示 市场部
  465. * 2.王鸽和主管及张总还有管理员号统一国交部
  466. * 2-1. 4 管理员 ,21 张海麟
  467. */
  468. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  469. List<int> userIds1 = new List<int>() { 4, 21 };
  470. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  471. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  472. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  473. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  474. .ToList();
  475. foreach (var item in _DelegationList)
  476. {
  477. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  478. }
  479. #endregion
  480. var _view = new
  481. {
  482. PageFuncAuth = pageFunAuthView,
  483. Data = _DelegationList
  484. };
  485. return Ok(JsonView(true, "查询成功!", _view, total));
  486. }
  487. else
  488. {
  489. return Ok(JsonView(false, "查询失败"));
  490. }
  491. }
  492. /// <summary>
  493. /// 团组列表
  494. /// </summary>
  495. /// <returns></returns>
  496. [HttpPost]
  497. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  498. {
  499. #region 参数验证
  500. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  501. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  502. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  503. #region 页面操作权限验证
  504. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  505. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  506. #endregion
  507. #endregion
  508. if (dto.PortType != 1 && dto.PortType != 2)
  509. {
  510. return Ok(JsonView(false, "查询失败!"));
  511. }
  512. string orderbyStr = "order by gdi.CreateTime Desc";
  513. string sqlWhere = string.Empty;
  514. if (dto.IsSure == 0) //未完成
  515. {
  516. sqlWhere += string.Format(@" And IsSure = 0");
  517. }
  518. else if (dto.IsSure == 1) //已完成
  519. {
  520. sqlWhere += string.Format(@" And IsSure = 1");
  521. }
  522. //团组类型
  523. if (dto.TeamDid > 0)
  524. {
  525. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  526. }
  527. //团组名称
  528. if (!string.IsNullOrEmpty(dto.TeamName))
  529. {
  530. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  531. }
  532. //客户名称
  533. if (!string.IsNullOrEmpty(dto.ClientName))
  534. {
  535. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  536. }
  537. //客户单位
  538. if (!string.IsNullOrEmpty(dto.ClientUnit))
  539. {
  540. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  541. }
  542. //出访时间
  543. if (!string.IsNullOrEmpty(dto.visitDataTime))
  544. {
  545. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  546. orderbyStr = "order by gdi.VisitDate";
  547. }
  548. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  549. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  550. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  551. JietuanOperator,IsSure,CreateTime
  552. From (
  553. Select row_number() over({0}) as Row_Number,
  554. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  555. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  556. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  557. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  558. From Grp_DelegationInfo gdi
  559. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  560. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  561. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  562. Where gdi.IsDel = 0 {1}
  563. ) temp ", orderbyStr, sqlWhere);
  564. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  565. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  566. #region 处理所属部门
  567. /*
  568. * 1.sq 和 gyy 等显示 市场部
  569. * 2.王鸽和主管及张总还有管理员号统一国交部
  570. * 2-1. 4 管理员 ,21 张海麟
  571. */
  572. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  573. List<int> userIds1 = new List<int>() { 4, 21 };
  574. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  575. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  576. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  577. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  578. .ToList();
  579. foreach (var item in _DelegationList)
  580. {
  581. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  582. }
  583. #endregion
  584. var _view = new
  585. {
  586. PageFuncAuth = pageFunAuthView,
  587. Data = _DelegationList
  588. };
  589. return Ok(JsonView(true, "查询成功!", _view, total));
  590. }
  591. /// <summary>
  592. /// 接团信息详情
  593. /// </summary>
  594. /// <param name="dto">团组info请求dto</param>
  595. /// <returns></returns>
  596. [HttpPost]
  597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  598. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  599. {
  600. var groupData = await _groupRepository.GetGroupInfo(dto);
  601. if (groupData.Code != 0)
  602. {
  603. return Ok(JsonView(false, groupData.Msg));
  604. }
  605. return Ok(JsonView(groupData.Data));
  606. }
  607. /// <summary>
  608. /// 接团信息 编辑添加
  609. /// 基础信息数据源
  610. /// </summary>
  611. /// <param name="dto"></param>
  612. /// <returns></returns>
  613. [HttpPost]
  614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  615. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  616. {
  617. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  618. if (groupData.Code != 0)
  619. {
  620. return Ok(JsonView(false, groupData.Msg));
  621. }
  622. return Ok(JsonView(groupData.Data));
  623. }
  624. /// <summary>
  625. /// 接团信息 操作(增改)
  626. /// </summary>
  627. /// <param name="dto"></param>
  628. /// <returns></returns>
  629. [HttpPost]
  630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  631. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  632. {
  633. // 创建 Stopwatch 实例
  634. Stopwatch stopwatch = Stopwatch.StartNew();
  635. decimal ffrPrice = 0.00M;
  636. DateTime? visitDt = null;
  637. if (dto.Status == 2)
  638. {
  639. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  640. if (groupInfo != null)
  641. {
  642. ffrPrice = groupInfo.PaymentMoney;
  643. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  644. }
  645. }
  646. var groupData = await _groupRepository.GroupOperation(dto);
  647. if (groupData.Code != 0)
  648. {
  649. return Ok(JsonView(false, groupData.Msg));
  650. }
  651. int diId = 0;
  652. try
  653. {
  654. //添加时 默认加入团组汇率
  655. if (dto.Status == 1) //添加
  656. {
  657. diId = groupData.Data;
  658. //添加默认币种
  659. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  660. //默认分配权限
  661. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  662. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  663. var _managerIds = new List<int>() { 22, 32, 21 };
  664. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  665. if (userIds.Count > 0)
  666. {
  667. userIds.Add(208);
  668. //创建团组管控
  669. GroupStepForDelegation.CreateWorkStep(diId);
  670. //发送消息
  671. string groupName = dto.TeamName;
  672. string createGroupUser = string.Empty;
  673. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  674. if (userInfo != null) createGroupUser = userInfo.CnName;
  675. string title = $"系统通知";
  676. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  677. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  678. }
  679. //默认创建倒推表
  680. await _invertedListRep._Create(dto.UserId, diId);
  681. }
  682. else if (dto.Status == 2)
  683. {
  684. diId = dto.Id;
  685. }
  686. #region 签证人员团组时间通知
  687. #region 计算出访起止时间
  688. var startTime = new DateTime();
  689. var endTime = new DateTime();
  690. if (DateTime.TryParse(dto.VisitDate, out startTime))
  691. {
  692. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  693. }
  694. #endregion
  695. #endregion
  696. #region 团组操作默认添加/修改收款账单
  697. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  698. {
  699. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  700. .Where(x => x.IsDel == 0 &&
  701. x.Diid == diId &&
  702. x.Remark.Equals("预付款")
  703. )
  704. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  705. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  706. .FirstAsync();
  707. ffrInfo = new Fin_ForeignReceivables()
  708. {
  709. Diid = diId,
  710. PriceName = dto.ClientUnit,
  711. Price = dto.PaymentMoney,
  712. Count = 1,
  713. Unit = $"元",
  714. ItemSumPrice = dto.PaymentMoney,
  715. Rate = 1.0000M,
  716. Currency = 836,
  717. AddingWay = 0,
  718. CreateUserId = dto.UserId,
  719. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  720. Remark = $"预付款"
  721. };
  722. if (ffrInfo == null) //Add
  723. {
  724. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  725. }
  726. else //修改
  727. {
  728. await _sqlSugar.Updateable(ffrInfo)
  729. .UpdateColumns(x => new
  730. {
  731. x.PriceName,
  732. x.Price,
  733. x.ItemSumPrice,
  734. x.CreateTime,
  735. x.CreateUserId
  736. })
  737. .WhereColumns(x => x.Id)
  738. .ExecuteCommandAsync();
  739. }
  740. }
  741. #endregion
  742. if (diId > 0)
  743. {
  744. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  745. }
  746. // 停止计时
  747. stopwatch.Stop();
  748. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  749. }
  750. catch (Exception ex)
  751. {
  752. // 停止计时
  753. stopwatch.Stop();
  754. Logs("[response]" + JsonConvert.SerializeObject(dto));
  755. Logs(ex.Message);
  756. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  757. }
  758. // 停止计时
  759. stopwatch.Stop();
  760. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  761. }
  762. /// <summary>
  763. /// 接团流程操作(增改)
  764. /// 安卓端使用 建团时添加客户名单
  765. /// </summary>
  766. /// <param name="dto"></param>
  767. /// <returns></returns>
  768. [HttpPost]
  769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  770. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  771. {
  772. #region 参数验证
  773. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  774. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  775. #region 页面操作权限验证
  776. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  777. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  778. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  779. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  780. #endregion
  781. #endregion
  782. try
  783. {
  784. //_sqlSugar.BeginTran();
  785. decimal ffrPrice = 0.00M;
  786. DateTime? visitDt = null;
  787. if (dto.Status == 2)
  788. {
  789. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  790. if (groupInfo != null)
  791. {
  792. ffrPrice = groupInfo.PaymentMoney;
  793. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  794. }
  795. }
  796. var _dto = new GroupOperationDto();
  797. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  798. var groupData = await _groupRepository.GroupOperation(_dto);
  799. if (groupData.Code != 0)
  800. {
  801. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  802. }
  803. int diId = 0;
  804. //添加时 默认加入团组汇率
  805. if (dto.Status == 1) //添加
  806. {
  807. diId = groupData.Data;
  808. //添加默认币种
  809. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  810. //默认分配权限
  811. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  812. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  813. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  814. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  815. if (userIds.Count > 0)
  816. {
  817. userIds.Add(208);
  818. //创建团组管控
  819. GroupStepForDelegation.CreateWorkStep(diId);
  820. //发送消息
  821. string groupName = dto.TeamName;
  822. string createGroupUser = string.Empty;
  823. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  824. if (userInfo != null) createGroupUser = userInfo.CnName;
  825. string title = $"系统通知";
  826. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  827. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  828. }
  829. #region 应用推送
  830. try
  831. {
  832. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  833. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  834. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  835. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  836. {
  837. List<string> userList = new List<string>() { users.QiyeChatUserId };
  838. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  839. }
  840. }
  841. catch (Exception ex)
  842. {
  843. }
  844. #endregion
  845. //默认创建倒推表
  846. await _invertedListRep._Create(dto.UserId, diId);
  847. }
  848. if (dto.Status == 2)
  849. {
  850. diId = dto.Id;
  851. if (diId == 0)
  852. {
  853. //_sqlSugar.RollbackTran();
  854. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  855. }
  856. }
  857. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  858. if (viewData.Code != 0)
  859. {
  860. //_sqlSugar.RollbackTran();
  861. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  862. }
  863. #region 团组操作默认添加/修改收款账单
  864. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  865. {
  866. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  867. .Where(x => x.IsDel == 0 &&
  868. x.Diid == diId &&
  869. x.Remark.Equals("预付款")
  870. )
  871. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  872. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  873. .FirstAsync();
  874. ffrInfo = new Fin_ForeignReceivables()
  875. {
  876. Diid = diId,
  877. PriceName = dto.ClientUnit,
  878. Price = dto.PaymentMoney,
  879. Count = 1,
  880. Unit = $"元",
  881. ItemSumPrice = dto.PaymentMoney,
  882. Rate = 1.0000M,
  883. Currency = 836,
  884. AddingWay = 0,
  885. CreateUserId = dto.UserId,
  886. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  887. Remark = $"预付款"
  888. };
  889. if (ffrInfo == null) //Add
  890. {
  891. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  892. }
  893. else //修改
  894. {
  895. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  896. .UpdateColumns(x => new
  897. {
  898. x.PriceName,
  899. x.Price,
  900. x.ItemSumPrice,
  901. x.CreateTime,
  902. x.CreateUserId
  903. })
  904. .WhereColumns(x => x.Id)
  905. .ExecuteCommandAsync();
  906. }
  907. }
  908. #endregion
  909. #region 签证人员团组时间通知
  910. #region 计算出访起止时间
  911. var startTime = new DateTime();
  912. var endTime = new DateTime();
  913. if (DateTime.TryParse(dto.VisitDate, out startTime))
  914. {
  915. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  916. }
  917. #endregion
  918. if (diId > 0)
  919. {
  920. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  921. }
  922. #endregion
  923. //_sqlSugar.CommitTran();
  924. return Ok(JsonView(true, "添加成功"));
  925. }
  926. catch (Exception ex)
  927. {
  928. _sqlSugar.RollbackTran();
  929. return Ok(JsonView(false, ex.Message));
  930. }
  931. }
  932. /// <summary>
  933. /// 接团流程操作(增改)
  934. /// 安卓端使用 建团时添加客户名单
  935. /// </summary>
  936. /// <param name="dto"></param>
  937. /// <returns></returns>
  938. [HttpPost]
  939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  940. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  941. {
  942. #region 参数验证
  943. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  944. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  945. #region 页面操作权限验证
  946. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  947. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  948. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  949. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  950. #endregion
  951. #endregion
  952. _sqlSugar.BeginTran();
  953. decimal ffrPrice = 0.00M;
  954. DateTime? visitDt = null;
  955. if (dto.Status == 2)
  956. {
  957. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  958. if (groupInfo != null)
  959. {
  960. ffrPrice = groupInfo.PaymentMoney;
  961. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  962. }
  963. }
  964. var _dto = new GroupOperationDto();
  965. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  966. var groupData = await _groupRepository.GroupOperation(_dto);
  967. if (groupData.Code != 0)
  968. {
  969. _sqlSugar.RollbackTran();
  970. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  971. }
  972. try
  973. {
  974. int diId = 0;
  975. //添加时 默认加入团组汇率
  976. if (dto.Status == 1) //添加
  977. {
  978. diId = groupData.Data;
  979. //添加默认币种
  980. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  981. //默认分配权限
  982. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  983. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  984. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  985. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  986. if (userIds.Count > 0)
  987. {
  988. userIds.Add(208);
  989. //创建团组管控
  990. GroupStepForDelegation.CreateWorkStep(diId);
  991. //发送消息
  992. string groupName = dto.TeamName;
  993. string createGroupUser = string.Empty;
  994. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  995. if (userInfo != null) createGroupUser = userInfo.CnName;
  996. string title = $"系统通知";
  997. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  998. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  999. }
  1000. #region 应用推送
  1001. try
  1002. {
  1003. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1004. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1005. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1006. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1007. {
  1008. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1009. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1010. }
  1011. }
  1012. catch (Exception ex)
  1013. {
  1014. _sqlSugar.CommitTran();
  1015. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1016. }
  1017. #endregion
  1018. //默认创建倒推表
  1019. await _invertedListRep._Create(dto.UserId, diId);
  1020. }
  1021. else if (dto.Status == 2)
  1022. {
  1023. diId = dto.Id;
  1024. if (diId == 0)
  1025. {
  1026. _sqlSugar.RollbackTran();
  1027. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1028. }
  1029. }
  1030. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1031. if (viewData.Code != 0)
  1032. {
  1033. _sqlSugar.RollbackTran();
  1034. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1035. }
  1036. #region 团组操作默认添加/修改收款账单
  1037. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1038. {
  1039. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1040. .Where(x => x.IsDel == 0 &&
  1041. x.Diid == diId &&
  1042. x.Remark.Equals("预付款")
  1043. )
  1044. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1045. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1046. .FirstAsync();
  1047. ffrInfo = new Fin_ForeignReceivables()
  1048. {
  1049. Diid = diId,
  1050. PriceName = dto.ClientUnit,
  1051. Price = dto.PaymentMoney,
  1052. Count = 1,
  1053. Unit = $"元",
  1054. ItemSumPrice = dto.PaymentMoney,
  1055. Rate = 1.0000M,
  1056. Currency = 836,
  1057. AddingWay = 0,
  1058. CreateUserId = dto.UserId,
  1059. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1060. Remark = $"预付款"
  1061. };
  1062. if (ffrInfo == null) //Add
  1063. {
  1064. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1065. }
  1066. else //修改
  1067. {
  1068. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1069. .UpdateColumns(x => new
  1070. {
  1071. x.PriceName,
  1072. x.Price,
  1073. x.ItemSumPrice,
  1074. x.CreateTime,
  1075. x.CreateUserId
  1076. })
  1077. .WhereColumns(x => x.Id)
  1078. .ExecuteCommandAsync();
  1079. }
  1080. }
  1081. #endregion
  1082. #region 签证人员团组时间通知
  1083. #region 计算出访起止时间
  1084. var startTime = new DateTime();
  1085. var endTime = new DateTime();
  1086. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1087. {
  1088. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1089. }
  1090. #endregion
  1091. if (diId > 0)
  1092. {
  1093. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1094. }
  1095. #endregion
  1096. _sqlSugar.CommitTran();
  1097. return Ok(JsonView(true));
  1098. }
  1099. catch (Exception ex)
  1100. {
  1101. _sqlSugar.RollbackTran();
  1102. return Ok(JsonView(false, ex.Message));
  1103. }
  1104. }
  1105. /// <summary>
  1106. /// 接团信息 操作(删除)
  1107. /// </summary>
  1108. /// <param name="dto"></param>
  1109. /// <returns></returns>
  1110. [HttpPost]
  1111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1112. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1113. {
  1114. var diId = dto.Id;
  1115. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1116. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1117. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1118. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1119. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1120. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1121. #endregion
  1122. var groupData = await _groupRepository.GroupDel(dto);
  1123. if (groupData.Code != 0)
  1124. {
  1125. return Ok(JsonView(false, groupData.Msg));
  1126. }
  1127. return Ok(JsonView(true));
  1128. }
  1129. /// <summary>
  1130. /// 获取团组销售报价号
  1131. /// 团组添加时 使用
  1132. /// </summary>
  1133. /// <returns></returns>
  1134. [HttpPost]
  1135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1136. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1137. {
  1138. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1139. if (groupData.Code != 0)
  1140. {
  1141. return Ok(JsonView(false, groupData.Msg));
  1142. }
  1143. object salesQuoteNo = new
  1144. {
  1145. SalesQuoteNo = groupData.Data
  1146. };
  1147. return Ok(JsonView(salesQuoteNo));
  1148. }
  1149. /// <summary>
  1150. /// 设置确认出团
  1151. /// </summary>
  1152. /// <param name="dto"></param>
  1153. /// <returns></returns>
  1154. [HttpPost]
  1155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1156. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1157. {
  1158. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1159. if (groupData.Code != 0)
  1160. {
  1161. return Ok(JsonView(false, groupData.Msg));
  1162. }
  1163. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1164. #region OA消息推送
  1165. try
  1166. {
  1167. string groupName = groupInfo.TeamName;
  1168. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1169. string title = $"系统通知";
  1170. string content = $"团组[{groupName}]已确认出团!";
  1171. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1172. }
  1173. catch (Exception ex)
  1174. {
  1175. }
  1176. #endregion
  1177. #region 应用推送
  1178. try
  1179. {
  1180. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1181. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1182. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1183. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1184. {
  1185. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1186. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1187. }
  1188. }
  1189. catch (Exception ex)
  1190. {
  1191. }
  1192. #endregion
  1193. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1194. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1195. }
  1196. /// <summary>
  1197. /// 获取团组名称data And 签证国别Data
  1198. /// </summary>
  1199. /// <param name="dto"></param>
  1200. /// <returns></returns>
  1201. [HttpPost]
  1202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1203. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1204. {
  1205. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1206. if (groupData.Code != 0)
  1207. {
  1208. return Ok(JsonView(false, groupData.Msg));
  1209. }
  1210. return Ok(JsonView(groupData.Data));
  1211. }
  1212. /// <summary>
  1213. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1214. /// </summary>
  1215. /// <returns></returns>
  1216. [HttpPost]
  1217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1218. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1219. {
  1220. try
  1221. {
  1222. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1223. if (groupData.Code != 0)
  1224. {
  1225. return Ok(JsonView(false, groupData.Msg));
  1226. }
  1227. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1228. }
  1229. catch (Exception ex)
  1230. {
  1231. return Ok(JsonView(false, "程序错误!"));
  1232. throw;
  1233. }
  1234. }
  1235. /// <summary>
  1236. /// 团组清单 Excel
  1237. /// </summary>
  1238. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1239. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1240. /// <returns></returns>
  1241. [HttpGet]
  1242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1243. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1244. {
  1245. DateTime _beginDt, _endDt;
  1246. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1247. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1248. if (!beginBool && !endBool)
  1249. {
  1250. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1251. }
  1252. string sql = string.Format(@"
  1253. SELECT
  1254. ROW_NUMBER,
  1255. Id,
  1256. SalesQuoteNo,
  1257. TourCode,
  1258. TeamTypeId,
  1259. TeamType,
  1260. TeamLevId,
  1261. TeamLev,
  1262. TeamName,
  1263. ClientName,
  1264. ClientUnit,
  1265. VisitDate,
  1266. VisitDays,
  1267. VisitPNumber,
  1268. JietuanOperatorId,
  1269. JietuanOperator,
  1270. IsSure,
  1271. CreateUserName,
  1272. IsBid
  1273. FROM
  1274. (
  1275. SELECT
  1276. ROW_NUMBER() OVER(
  1277. ORDER BY
  1278. gdi.CreateTime Desc
  1279. ) AS ROW_NUMBER,
  1280. gdi.Id,
  1281. SalesQuoteNo,
  1282. TourCode,
  1283. ssd.Id TeamTypeId,
  1284. ssd.Name TeamType,
  1285. ssd1.Id TeamLevId,
  1286. ssd1.Name TeamLev,
  1287. TeamName,
  1288. ClientName,
  1289. ClientUnit,
  1290. VisitDate,
  1291. VisitDays,
  1292. VisitPNumber,
  1293. JietuanOperator JietuanOperatorId,
  1294. su.CnName JietuanOperator,
  1295. IsSure,
  1296. gdi.CreateTime,
  1297. su1.CnName As CreateUserName,
  1298. gdi.IsBid
  1299. FROM
  1300. Grp_DelegationInfo gdi
  1301. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1302. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1303. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1304. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1305. WHERE
  1306. gdi.IsDel = 0
  1307. AND gdi.IsBid = 0
  1308. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1309. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1310. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1311. #region 处理所属部门
  1312. /*
  1313. * 1.sq 和 gyy 等显示 市场部
  1314. * 2.王鸽和主管及张总还有管理员号统一国交部
  1315. * 2-1. 4 管理员 ,21 张海麟
  1316. */
  1317. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1318. List<int> userIds1 = new List<int>() { 4, 21 };
  1319. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1320. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1321. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1322. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1323. .ToListAsync();
  1324. var droupIds = groupList.Select(it => it.Id).ToList();
  1325. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1326. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1327. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1328. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1329. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1330. {
  1331. DiId = tcl.DiId,
  1332. LastName = dc.LastName,
  1333. FirstName = dc.FirstName,
  1334. Sex = dc.Sex,
  1335. Birthday = dc.BirthDay,
  1336. Company = cc.CompanyFullName,
  1337. Job = dc.Job,
  1338. CreateTime = tcl.CreateTime,
  1339. })
  1340. .ToList();
  1341. foreach (var item in groupList)
  1342. {
  1343. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1344. string groupFirstName = "";
  1345. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1346. if (currDatas.Any())
  1347. {
  1348. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1349. }
  1350. item.GroupFirst = groupFirstName;
  1351. }
  1352. #endregion
  1353. #region Excel
  1354. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1355. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1356. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1357. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1358. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1359. //载入模板
  1360. WorkbookDesigner designer = new WorkbookDesigner();
  1361. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1362. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1363. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1364. dt.TableName = "GroupList";
  1365. designer.SetDataSource(dt);
  1366. designer.Process();
  1367. if (!Directory.Exists(savePath))
  1368. {
  1369. Directory.CreateDirectory(savePath);
  1370. }
  1371. string serverPath = $"{savePath}{fileName}";
  1372. designer.Workbook.Save(serverPath);
  1373. string rst = $"{servicePath}{ftpPath}{fileName}";
  1374. #endregion
  1375. return Ok(JsonView(true, "操作成功!", rst));
  1376. }
  1377. #endregion
  1378. #region 团组&签证
  1379. /// <summary>
  1380. /// 根据团组Id获取签证客户信息List
  1381. /// </summary>
  1382. /// <param name="dto">请求dto</param>
  1383. /// <returns></returns>
  1384. [HttpPost]
  1385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1386. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1387. {
  1388. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1389. if (groupData.Code != 0)
  1390. {
  1391. return Ok(JsonView(false, groupData.Msg));
  1392. }
  1393. return Ok(JsonView(groupData.Data));
  1394. }
  1395. /// <summary>
  1396. /// IOS获取团组签证拍照上传进度01(团组列表)
  1397. /// </summary>
  1398. /// <param name="dto">请求dto</param>
  1399. /// <returns></returns>
  1400. [HttpPost]
  1401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1402. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1403. {
  1404. if (dto == null)
  1405. {
  1406. return Ok(JsonView(false, "参数为空"));
  1407. }
  1408. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1409. return Ok(JsonView(visaList));
  1410. }
  1411. /// <summary>
  1412. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1413. /// </summary>
  1414. /// <returns></returns>
  1415. [HttpPost]
  1416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1417. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1418. {
  1419. if (dto == null)
  1420. {
  1421. return Ok(JsonView(false, "请求错误:"));
  1422. }
  1423. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1424. return Ok(JsonView(list));
  1425. }
  1426. /// <summary>
  1427. /// IOS获取团组签证拍照上传进度03(相册)
  1428. /// </summary>
  1429. /// <returns></returns>
  1430. [HttpPost]
  1431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1432. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1433. {
  1434. if (dto == null)
  1435. {
  1436. return Ok(JsonView(false, "请求错误:"));
  1437. }
  1438. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1439. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1440. list.ForEach(s => s.url = url);
  1441. return Ok(JsonView(list));
  1442. }
  1443. /// <summary>
  1444. /// IOS获取团组签证拍照上传进度04(图片上传)
  1445. /// </summary>
  1446. /// <param name="dto"></param>
  1447. /// <returns></returns>
  1448. [HttpPost]
  1449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1450. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1451. {
  1452. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1453. //if (!string.IsNullOrEmpty(result))
  1454. //{
  1455. //}
  1456. //else {
  1457. // return Ok(JsonView(false, "上传失败"));
  1458. //}
  1459. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1460. int sucNum = 0;
  1461. try
  1462. {
  1463. foreach (var item in dto.base64DataList)
  1464. {
  1465. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1466. string result = decodeBase64ToImage(item, imageName);
  1467. if (!string.IsNullOrEmpty(result))
  1468. {
  1469. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1470. pic.CreateUserId = dto.CreateUserId;
  1471. pic.PicName = imageName;
  1472. pic.PicPath = result;
  1473. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1474. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1475. if (insertResult > 0)
  1476. {
  1477. sucNum++;
  1478. }
  1479. }
  1480. }
  1481. }
  1482. catch (Exception ex)
  1483. {
  1484. return Ok(JsonView(false, ex.Message));
  1485. }
  1486. string msg = string.Format(@"成功上传{0}张", sucNum);
  1487. return Ok(JsonView(true, msg));
  1488. }
  1489. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1490. {
  1491. string filename = "";//声明一个string类型的相对路径
  1492. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1493. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1494. try//会有异常抛出,try,catch一下
  1495. {
  1496. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1497. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1498. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1499. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1500. //文件名称
  1501. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1502. //上传的文件的路径
  1503. string filePath = "";
  1504. if (!Directory.Exists(fileDir))
  1505. {
  1506. Directory.CreateDirectory(fileDir);
  1507. }
  1508. //上传的文件的路径
  1509. filePath = fileDir + filename;
  1510. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1511. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1512. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1513. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1514. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1515. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1516. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1517. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1518. bitmap.Dispose();
  1519. }
  1520. catch (Exception e)
  1521. {
  1522. string massage = e.Message;
  1523. Logs("IOS图片上传Error:" + massage);
  1524. //filename = e.Message;
  1525. }
  1526. return filename;//返回相对路径
  1527. }
  1528. /// <summary>
  1529. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1530. /// </summary>
  1531. /// <param name="dto"></param>
  1532. /// <returns></returns>
  1533. [HttpPost]
  1534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1535. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1536. {
  1537. if (dto == null)
  1538. {
  1539. return Ok(JsonView(false, "请求错误:"));
  1540. }
  1541. string msg = "参数错误";
  1542. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1543. {
  1544. try
  1545. {
  1546. //_delegationVisaRep.BeginTran();
  1547. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1548. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1549. .Where(s => s.Id == dto.visaProgressCustomerId)
  1550. .ExecuteCommandAsync();
  1551. if (updCount > 0 && dto.publishCode == 1)
  1552. {
  1553. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1554. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1555. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1556. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1557. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1558. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1559. if (groupData == null)
  1560. {
  1561. _delegationVisaRep.RollbackTran();
  1562. }
  1563. string title = string.Format(@"[签证进度更新]");
  1564. string content = string.Format(@"测试文本");
  1565. bool rst = await _message.AddMsg(new MessageDto()
  1566. {
  1567. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1568. IssuerId = dto.publisher,
  1569. Title = title,
  1570. Content = content,
  1571. ReleaseTime = DateTime.Now,
  1572. UIdList = new List<int> {
  1573. 234
  1574. }
  1575. });
  1576. if (rst)
  1577. {
  1578. return Ok(JsonView(true, "发送通知成功"));
  1579. }
  1580. }
  1581. //_delegationVisaRep.CommitTran();
  1582. }
  1583. catch (Exception)
  1584. {
  1585. //_delegationVisaRep.RollbackTran();
  1586. }
  1587. }
  1588. return Ok(JsonView(true, msg));
  1589. }
  1590. #endregion
  1591. #region 团组任务分配
  1592. /// <summary>
  1593. /// 团组任务分配初始化
  1594. /// </summary>
  1595. /// <param name="dto"></param>
  1596. /// <returns></returns>
  1597. [HttpPost]
  1598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1599. public async Task<IActionResult> GetTaskAssignmen()
  1600. {
  1601. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1602. if (groupData.Code != 0)
  1603. {
  1604. return Ok(JsonView(false, groupData.Msg));
  1605. }
  1606. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1607. }
  1608. /// <summary>
  1609. /// 团组任务分配查询
  1610. /// </summary>
  1611. /// <param name="dto"></param>
  1612. /// <returns></returns>
  1613. [HttpPost]
  1614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1615. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1616. {
  1617. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1618. if (groupData.Code != 0)
  1619. {
  1620. return Ok(JsonView(false, groupData.Msg));
  1621. }
  1622. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1623. }
  1624. /// <summary>
  1625. /// 团组任务分配操作
  1626. /// </summary>
  1627. /// <param name="dto"></param>
  1628. /// <returns></returns>
  1629. [HttpPost]
  1630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1631. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1632. {
  1633. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1634. if (groupData.Code != 0)
  1635. {
  1636. return Ok(JsonView(false, groupData.Msg));
  1637. }
  1638. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1639. }
  1640. /// <summary>
  1641. /// 团组任务分配
  1642. /// 批量分配
  1643. /// 查询团组
  1644. /// </summary>
  1645. /// <param name="dto"></param>
  1646. /// <returns></returns>
  1647. [HttpPost]
  1648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1649. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1650. {
  1651. //参数验证
  1652. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1653. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1654. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1655. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1656. }
  1657. /// <summary>
  1658. /// 团组任务分配
  1659. /// 批量分配
  1660. /// </summary>
  1661. /// <param name="dto"></param>
  1662. /// <returns></returns>
  1663. [HttpPost]
  1664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1665. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1666. {
  1667. //参数验证
  1668. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1669. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1670. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1671. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1672. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1673. }
  1674. #endregion
  1675. #region 团组费用审核
  1676. /// <summary>
  1677. /// 费用审核
  1678. /// 团组列表 Page
  1679. /// </summary>
  1680. /// <param name="_dto">团组列表请求dto</param>
  1681. /// <returns></returns>
  1682. [HttpPost]
  1683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1684. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1685. {
  1686. #region 参数验证
  1687. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1688. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1689. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1690. #region 页面操作权限验证
  1691. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1692. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1693. #endregion
  1694. #endregion
  1695. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1696. {
  1697. string sqlWhere = string.Empty;
  1698. if (_dto.IsSure == 0) //未完成
  1699. {
  1700. sqlWhere += string.Format(@" And IsSure = 0");
  1701. }
  1702. else if (_dto.IsSure == 1) //已完成
  1703. {
  1704. sqlWhere += string.Format(@" And IsSure = 1");
  1705. }
  1706. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1707. {
  1708. string tj = _dto.SearchCriteria;
  1709. 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}%')",
  1710. tj, tj, tj, tj, tj);
  1711. }
  1712. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1713. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1714. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1715. From (
  1716. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1717. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1718. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1719. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1720. From Grp_DelegationInfo gdi
  1721. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1722. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1723. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1724. Where gdi.IsDel = 0 {0}
  1725. ) temp ", sqlWhere);
  1726. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1727. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1728. var _view = new
  1729. {
  1730. PageFuncAuth = pageFunAuthView,
  1731. Data = _DelegationList
  1732. };
  1733. return Ok(JsonView(true, "查询成功!", _view, total));
  1734. }
  1735. else
  1736. {
  1737. return Ok(JsonView(false, "查询失败"));
  1738. }
  1739. }
  1740. /// <summary>
  1741. /// 获取团组费用审核
  1742. /// </summary>
  1743. /// <param name="paras">参数Json字符串</param>
  1744. /// <returns></returns>
  1745. [HttpPost]
  1746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1747. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1748. {
  1749. try
  1750. {
  1751. #region 参数验证
  1752. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1753. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1754. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1755. #region 页面操作权限验证
  1756. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1757. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1758. #endregion
  1759. #endregion
  1760. var _view = new Grp_CreditCardPaymentView();
  1761. var clientNameList = getSimplClientList(_dto.DiId);
  1762. #region 费用清单
  1763. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1764. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1765. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1766. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1767. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1768. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1769. /*
  1770. * 76://酒店预订
  1771. */
  1772. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1773. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1774. /*
  1775. * 79://车/导游地接
  1776. */
  1777. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1778. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1779. /*
  1780. * 80: //签证
  1781. */
  1782. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1783. /*
  1784. *81: //邀请/公务活动
  1785. */
  1786. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1787. /*
  1788. * 82: //团组客户保险
  1789. */
  1790. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1791. /*
  1792. * Lable = 85 机票预订
  1793. */
  1794. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1795. /*
  1796. * 85 机票预定
  1797. */
  1798. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1799. /*
  1800. * 98 其他款项
  1801. */
  1802. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1803. /*
  1804. * 285:收款退还
  1805. */
  1806. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1807. /*
  1808. * 1015: //超支费用
  1809. */
  1810. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1811. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1812. /*
  1813. * 币种信息
  1814. */
  1815. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1816. /*
  1817. * 车/导游地接 费用类型
  1818. */
  1819. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1820. /*
  1821. * 车/导游地接 费用类型
  1822. */
  1823. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1824. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1825. /*
  1826. * 用户信息
  1827. */
  1828. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1829. /*
  1830. * 费用模块
  1831. */
  1832. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1833. string priceModule = string.Empty;
  1834. if (sdPriceName != null)
  1835. {
  1836. priceModule = sdPriceName.Name;
  1837. }
  1838. /*
  1839. * 成本信息
  1840. */
  1841. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1842. decimal _groupRate = 0.0000M;
  1843. string _groupCurrencyCode = "-";
  1844. if (groupCost != null)
  1845. {
  1846. _groupRate = groupCost.Rate;
  1847. if (int.TryParse(groupCost.Currency, out int _currency))
  1848. {
  1849. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1850. }
  1851. else _groupCurrencyCode = groupCost.Currency;
  1852. }
  1853. string costContentSql = $"Select * From Grp_GroupCost";
  1854. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1855. //处理日期为空的天数
  1856. for (int i = 0; i < groupCostDetails.Count; i++)
  1857. if (i != 0)
  1858. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1859. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1860. /*
  1861. * 处理详情数据
  1862. */
  1863. foreach (var entity in entityList)
  1864. {
  1865. var _detail = new Grp_CreditCardPaymentDetailView();
  1866. _detail.Id = entity.Id;
  1867. _detail.PriceName = priceModule;
  1868. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1869. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1870. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1871. //处理金额
  1872. if (entity.CTable == 1015)
  1873. {
  1874. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1875. if (czInfo != null)
  1876. {
  1877. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1878. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1879. }
  1880. }
  1881. /*
  1882. * 应付款金额
  1883. */
  1884. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1885. string PaymentCurrency_WaitPay = "Unknown";
  1886. string hotelCurrncyCode = "Unknown";
  1887. string hotelCurrncyName = "Unknown";
  1888. if (sdPaymentCurrency_WaitPay != null)
  1889. {
  1890. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1891. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1892. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1893. if (hotelCurrncyCode.Equals("CNY"))
  1894. {
  1895. entity.DayRate = 1.0000M;
  1896. }
  1897. }
  1898. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1899. /*
  1900. * 此次付款金额
  1901. */
  1902. decimal CurrPayStr = 0.00M,
  1903. OriginalCurrPay = 0.00M;
  1904. if (entity.PayPercentage == 0)
  1905. {
  1906. if (entity.PayThenMoney != 0)
  1907. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1908. }
  1909. else
  1910. {
  1911. if (entity.PayMoney != 0)
  1912. {
  1913. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1914. }
  1915. }
  1916. //if (_dto.Label == 79)
  1917. //{
  1918. // string original = string.Empty;
  1919. // if (hotelCurrncyCode.Equals("CNY"))
  1920. // {
  1921. // OriginalCurrPay = CurrPayStr;
  1922. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1923. // }
  1924. // else
  1925. // {
  1926. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1927. // //760 EUR(7600.00 CNY)
  1928. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1929. // }
  1930. //}
  1931. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1932. string original = string.Empty;
  1933. if (hotelCurrncyCode.Equals("CNY"))
  1934. {
  1935. OriginalCurrPay = CurrPayStr;
  1936. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1937. }
  1938. else
  1939. {
  1940. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1941. //760 EUR(7600.00 CNY)
  1942. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1943. }
  1944. /*
  1945. * 剩余尾款
  1946. */
  1947. decimal BalanceStr = 0;
  1948. if (CurrPayStr != 0)
  1949. {
  1950. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1951. BalanceStr = 0;
  1952. else
  1953. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1954. }
  1955. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1956. /*
  1957. * Bus名称
  1958. */
  1959. _detail.BusName = "待增加";
  1960. /*
  1961. *费用所属
  1962. */
  1963. switch (entity.CTable)
  1964. {
  1965. case 76://酒店预订
  1966. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1967. if (hotelReservations != null)
  1968. {
  1969. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1970. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1971. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1972. string roomFeeStr = "", roomFeestr1 = "";
  1973. //是否比较房型价格
  1974. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1975. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1976. roomFeeStr += $"<br/>";
  1977. var roomTotal = 0.00M;
  1978. if (hotelReservations.SingleRoomPrice > 0)
  1979. {
  1980. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1981. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1982. __isSingle = true;
  1983. roomTotal += fee;
  1984. }
  1985. if (hotelReservations.DoubleRoomPrice > 0)
  1986. {
  1987. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1988. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1989. __isDouble = true;
  1990. roomTotal += fee;
  1991. }
  1992. if (hotelReservations.SuiteRoomPrice > 0)
  1993. {
  1994. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1995. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1996. __isSuite = true;
  1997. roomTotal += fee;
  1998. }
  1999. if (hotelReservations.OtherRoomPrice > 0)
  2000. {
  2001. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2002. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2003. __isOther = true;
  2004. roomTotal += fee;
  2005. }
  2006. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2007. else roomFeeStr += " 0.00 * 0";
  2008. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2009. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2010. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2011. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2012. /*
  2013. * 费用类型
  2014. * 1:房费
  2015. * 2:早餐
  2016. * 3:地税
  2017. * 4:城市税
  2018. * </summary>
  2019. */
  2020. //地税
  2021. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2022. if (governmentRentData != null)
  2023. {
  2024. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2025. governmentRentFee = governmentRentData.Price;
  2026. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2027. if (governmentRentCurrData != null)
  2028. {
  2029. governmentRentCode = governmentRentCurrData.Name;
  2030. governmentRentName = $"({governmentRentCurrData.Remark})";
  2031. }
  2032. }
  2033. //城市税
  2034. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2035. if (cityTaxData != null)
  2036. {
  2037. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2038. cityTaxFee = cityTaxData.Price;
  2039. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2040. if (cityTaxCurrData != null)
  2041. {
  2042. cityTaxCode = cityTaxCurrData.Name;
  2043. cityTaxName = $"({cityTaxCurrData.Remark})";
  2044. }
  2045. }
  2046. //酒店早餐
  2047. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2048. if (breakfastData != null)
  2049. {
  2050. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2051. breakfastFee = breakfastData.Price;
  2052. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2053. if (breakfastCurrData != null)
  2054. {
  2055. breakfastCode = breakfastCurrData.Name;
  2056. breakfastName = $"({breakfastCurrData.Remark})";
  2057. }
  2058. }
  2059. //房间费用
  2060. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2061. if (roomData != null)
  2062. {
  2063. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2064. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2065. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2066. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2067. roomFee = roomData.Price;
  2068. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2069. if (roomCurrData != null)
  2070. {
  2071. roomCode = roomCurrData.Name;
  2072. roomName = $"({roomCurrData.Remark})";
  2073. }
  2074. }
  2075. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2076. string hotelCostStr = "";
  2077. decimal hotelCsotTotal = 0.00M;
  2078. if (groupCost != null)
  2079. {
  2080. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2081. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2082. }
  2083. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2084. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2085. string hotelCost_day = "";
  2086. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2087. foreach (var item in hotelCostDetails1)
  2088. {
  2089. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2090. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2091. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2092. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2093. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2094. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2095. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2096. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2097. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2098. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2099. hotelCost_day += @$"<br/>";
  2100. }
  2101. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2102. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2103. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2104. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2105. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2106. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2107. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2108. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2109. $"房间说明: {hotelReservations.Remark} <br/>" +
  2110. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2111. $"{hotelBreakfastStr}" +
  2112. $"{hotelGovernmentRentStr}" +
  2113. $"{hotelCityTaxStr}";
  2114. _detail.PriceNameContent = hotelReservations.HotelName;
  2115. }
  2116. break;
  2117. case 79://车/导游地接
  2118. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2119. if (touristGuideGroundReservations != null)
  2120. {
  2121. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2122. {
  2123. _detail.BusName = touristGuideGroundReservations.BusName;
  2124. }
  2125. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2126. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2127. //if (isInt)
  2128. //{
  2129. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2130. // if (cityInfo != null)
  2131. // {
  2132. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2133. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2134. // if (carFeeItem != null)
  2135. // {
  2136. // nameContent += $@"({carFeeItem.Name})";
  2137. // }
  2138. // _detail.PriceNameContent = nameContent;
  2139. // }
  2140. //}
  2141. //else
  2142. //{
  2143. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2144. //}
  2145. var touristGuideGroundReservationsContents =
  2146. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2147. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2148. foreach (var item in touristGuideGroundReservationsContents)
  2149. {
  2150. string typeName = "Unknown";
  2151. string carCurrencyCode = "Unknown";
  2152. string carCurrencyName = "Unknown";
  2153. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2154. if (carTypeData != null) typeName = carTypeData.Name;
  2155. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2156. if (currencyData != null)
  2157. {
  2158. carCurrencyCode = currencyData.Name;
  2159. carCurrencyName = currencyData.Remark;
  2160. }
  2161. //op、成本 币种是否一致
  2162. bool IsCurrencyAgreement = false;
  2163. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2164. string opCostStr = string.Empty;
  2165. decimal opCostTypePrice = 0.00M;
  2166. #region 处理成本各项费用
  2167. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2168. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2169. if (opCost.Count > 0)
  2170. {
  2171. switch (item.SId)
  2172. {
  2173. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2174. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2175. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2176. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2177. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2178. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2179. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2180. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2181. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2182. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2183. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2184. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2185. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2186. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2187. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2188. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2189. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2190. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2191. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2192. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2193. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2194. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2195. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2197. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2198. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2199. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2200. }
  2201. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2202. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2203. }
  2204. #endregion
  2205. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2206. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2207. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2208. $"{opTypeStr} {opCostStr}<br/>" +
  2209. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2210. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2211. }
  2212. _detail.PriceMsgContent = priceMsg;
  2213. }
  2214. break;
  2215. case 80: //签证
  2216. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2217. if (visaInfo != null)
  2218. {
  2219. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2220. _detail.PriceNameContent = visaInfo.VisaDescription;
  2221. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2222. }
  2223. break;
  2224. case 81: //邀请/公务活动
  2225. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2226. if (_ioa != null)
  2227. {
  2228. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2229. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2230. sendCurrName = "Unknown", //快递费用币种 Name
  2231. sendCurrCode = "Unknown", //快递费用币种 Code
  2232. eventsCurrName = "Unknown", //公务活动费币种 Name
  2233. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2234. translateCurrName = "Unknown", //公务翻译费 Name
  2235. translateCurrCode = "Unknown"; //公务翻译费 Code
  2236. #region 处理费用币种
  2237. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2238. if (inviteCurrData != null)
  2239. {
  2240. inviteCurrName = inviteCurrData.Remark;
  2241. inviteCurrCode = inviteCurrData.Name;
  2242. }
  2243. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2244. if (sendCurrData != null)
  2245. {
  2246. sendCurrName = sendCurrData.Remark;
  2247. sendCurrCode = sendCurrData.Name;
  2248. }
  2249. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2250. if (eventsCurrData != null)
  2251. {
  2252. eventsCurrName = eventsCurrData.Remark;
  2253. eventsCurrCode = eventsCurrData.Name;
  2254. }
  2255. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2256. if (translateCurrData != null)
  2257. {
  2258. translateCurrName = translateCurrData.Remark;
  2259. translateCurrCode = translateCurrData.Name;
  2260. }
  2261. #endregion
  2262. _detail.PriceNameContent = _ioa.InviterArea;
  2263. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2264. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2265. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2266. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2267. $@"备注:" + _ioa.Remark + "<br/>";
  2268. }
  2269. break;
  2270. case 82: //团组客户保险
  2271. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2272. if (customers != null)
  2273. {
  2274. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2275. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2276. }
  2277. break;
  2278. case 85: //机票预订
  2279. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2280. if (jpRes != null)
  2281. {
  2282. string FlightsDescription = jpRes.FlightsDescription;
  2283. string PriceDescription = jpRes.PriceDescription;
  2284. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2285. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2286. }
  2287. break;
  2288. case 98://其他款项
  2289. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2290. if (gdpRes != null)
  2291. {
  2292. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2293. _detail.PriceNameContent = gdpRes.PriceName;
  2294. }
  2295. break;
  2296. case 285://收款退还
  2297. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2298. if (refundAndOtherMoney != null)
  2299. {
  2300. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2301. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2302. }
  2303. break;
  2304. case 751://酒店早餐
  2305. break;
  2306. case 1015://超支费用
  2307. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2308. if (groupExtraCost != null)
  2309. {
  2310. _detail.PriceNameContent = groupExtraCost.PriceName;
  2311. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2312. }
  2313. break;
  2314. default:
  2315. break;
  2316. }
  2317. /*
  2318. * 申请人
  2319. */
  2320. string operatorName = " - ";
  2321. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2322. if (_opUser != null)
  2323. {
  2324. operatorName = _opUser.CnName;
  2325. }
  2326. _detail.OperatorName = operatorName;
  2327. /*
  2328. * 审核人
  2329. */
  2330. string auditOperatorName = "Unknown";
  2331. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2332. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2333. else
  2334. {
  2335. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2336. if (_adUser != null)
  2337. {
  2338. auditOperatorName = _adUser.CnName;
  2339. }
  2340. }
  2341. _detail.AuditOperatorName = auditOperatorName;
  2342. /*
  2343. * 超预算比例
  2344. */
  2345. string overBudgetStr = "";
  2346. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2347. else if (entity.ExceedBudget == 0)
  2348. {
  2349. if (entity.CTable == 76 || entity.CTable == 79)
  2350. {
  2351. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2352. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2353. }
  2354. else
  2355. {
  2356. overBudgetStr = "未超预算";
  2357. }
  2358. }
  2359. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2360. _detail.OverBudget = overBudgetStr;
  2361. decimal auditFee = 0.00M; //已审核金额 人名币
  2362. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2363. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2364. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2365. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2366. {
  2367. auditedFeeOriginal = entity.PayMoney;
  2368. auditFee = CurrPayStr;
  2369. }
  2370. else if (entity.IsAuditGM == 0)
  2371. {
  2372. unAuditFeeCNY = CurrPayStr;
  2373. unAuditFeeOriginal = OriginalCurrPay;
  2374. OriginalCurrPay = 0.00M;
  2375. }
  2376. /*
  2377. * 费用总计
  2378. */
  2379. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2380. {
  2381. CurrencyId = entity.PaymentCurrency,
  2382. CurrencyName = PaymentCurrency_WaitPay,
  2383. AmountPayable = entity.PayMoney,
  2384. ThisPayment = OriginalCurrPay,
  2385. BalancePayment = BalanceStr,
  2386. AuditedFunds = auditFee,
  2387. AuditedFundsOriginal = auditedFeeOriginal,
  2388. UnAuditFundsCNY = unAuditFeeCNY,
  2389. UnAuditFundsOriginal = unAuditFeeOriginal
  2390. });
  2391. _detail.IsAuditGM = entity.IsAuditGM;
  2392. detailList.Add(_detail);
  2393. }
  2394. #endregion
  2395. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2396. /*
  2397. * 下方描述处理
  2398. */
  2399. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2400. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2401. if (ccpCurrencyPrice != null)
  2402. {
  2403. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2404. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2405. }
  2406. else
  2407. {
  2408. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2409. }
  2410. string amountPayableStr = string.Format(@"应付款总金额: ");
  2411. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2412. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2413. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2414. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2415. foreach (var item in nonDuplicat)
  2416. {
  2417. var currencyName = item.CurrencyName;
  2418. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2419. if (strs.Count > 0)
  2420. {
  2421. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2422. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2423. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2424. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2425. //单独处理此次付款金额
  2426. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2427. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2428. //单独处理已审核费用
  2429. //if (item.CurrencyId == 836) //人民币
  2430. //{
  2431. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2432. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2433. //}
  2434. //else
  2435. //{
  2436. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2437. //}
  2438. if (currencyName.Equals("CNY"))
  2439. {
  2440. //已审核费用
  2441. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2442. //未审核费用
  2443. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2444. }
  2445. else
  2446. {
  2447. //已审核费用
  2448. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2449. //未审核费用
  2450. 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"));
  2451. }
  2452. }
  2453. }
  2454. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2455. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2456. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2457. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2458. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2459. var _view1 = new
  2460. {
  2461. PageFuncAuth = pageFunAuthView,
  2462. Data = _view
  2463. };
  2464. return Ok(JsonView(_view1));
  2465. }
  2466. catch (Exception ex)
  2467. {
  2468. return Ok(JsonView(false, ex.Message));
  2469. }
  2470. }
  2471. /// <summary>
  2472. /// 费用审核
  2473. /// 修改团组费用审核状态
  2474. /// </summary>
  2475. /// <param name="_dto">参数Json字符串</param>
  2476. /// <returns></returns>
  2477. [HttpPost]
  2478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2479. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2480. {
  2481. #region 参数验证
  2482. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2483. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2484. #endregion
  2485. #region 页面操作权限验证
  2486. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2487. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2488. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2489. #endregion
  2490. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2491. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2492. DateTime dtNow = DateTime.Now;
  2493. _groupRepository.BeginTran();
  2494. int rst = 0;
  2495. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2496. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2497. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2498. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2499. List<dynamic> msgDatas = new List<dynamic>();
  2500. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2501. foreach (var item in idList)
  2502. {
  2503. int CreditId = int.Parse(item);
  2504. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2505. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2506. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2507. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2508. .Where(s => s.Id == CreditId)
  2509. .ExecuteCommandAsync();
  2510. if (result < 1)
  2511. {
  2512. rst = -1;
  2513. _groupRepository.RollbackTran();
  2514. return Ok(JsonView(false, "操作失败并回滚!"));
  2515. }
  2516. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2517. if (creditData != null)
  2518. {
  2519. #region 应用通知配置
  2520. try
  2521. {
  2522. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2523. }
  2524. catch (Exception ex)
  2525. {
  2526. }
  2527. #endregion
  2528. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2529. string groupNameStr = string.Empty;
  2530. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2531. if (groupData != null) groupNameStr = groupData.TeamName;
  2532. string creditTypeStr = string.Empty;
  2533. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2534. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2535. string creditCurrency = string.Empty;
  2536. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2537. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2538. if (creditCurrency.Equals("CNY"))
  2539. {
  2540. creditData.DayRate = 1.0000M;
  2541. }
  2542. if (creditData.PayPercentage == 0.00M)
  2543. {
  2544. creditData.PayPercentage = 100M;
  2545. }
  2546. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2547. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2548. string msgContent = "";
  2549. if (creditCurrency.Equals("CNY"))
  2550. {
  2551. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2552. }
  2553. else
  2554. {
  2555. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2556. }
  2557. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2558. }
  2559. }
  2560. if (rst == 0)
  2561. {
  2562. _groupRepository.CommitTran();
  2563. foreach (var item in msgDatas)
  2564. {
  2565. //发送消息
  2566. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2567. }
  2568. #region 应用推送
  2569. try
  2570. {
  2571. foreach (var ccpId in dic_ccp_user.Keys)
  2572. {
  2573. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2574. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2575. }
  2576. }
  2577. catch (Exception)
  2578. {
  2579. }
  2580. #endregion
  2581. return Ok(JsonView(true, "操作成功!"));
  2582. }
  2583. return Ok(JsonView(false, "操作失败!"));
  2584. }
  2585. #endregion
  2586. #region 机票费用录入
  2587. /// <summary>
  2588. /// 机票录入当前登录人可操作团组
  2589. /// </summary>
  2590. /// <param name="dto"></param>
  2591. /// <returns></returns>
  2592. [HttpPost]
  2593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2594. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2595. {
  2596. try
  2597. {
  2598. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2599. if (groupData.Code != 0)
  2600. {
  2601. return Ok(JsonView(false, groupData.Msg));
  2602. }
  2603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2604. }
  2605. catch (Exception ex)
  2606. {
  2607. return Ok(JsonView(false, "程序错误!"));
  2608. throw;
  2609. }
  2610. }
  2611. /// <summary>
  2612. /// 机票费用录入列表
  2613. /// </summary>
  2614. /// <param name="dto"></param>
  2615. /// <returns></returns>
  2616. [HttpPost]
  2617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2618. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2619. {
  2620. try
  2621. {
  2622. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2623. if (groupData.Code != 0)
  2624. {
  2625. return Ok(JsonView(false, groupData.Msg));
  2626. }
  2627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2628. }
  2629. catch (Exception ex)
  2630. {
  2631. return Ok(JsonView(false, ex.Message));
  2632. throw;
  2633. }
  2634. }
  2635. /// <summary>
  2636. /// 根据id查询费用录入信息
  2637. /// </summary>
  2638. /// <param name="dto"></param>
  2639. /// <returns></returns>
  2640. [HttpPost]
  2641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2642. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2643. {
  2644. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2645. if (groupData.Code != 0)
  2646. {
  2647. return Ok(JsonView(false, groupData.Msg));
  2648. }
  2649. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2650. }
  2651. /// <summary>
  2652. /// 机票费用录入操作(Status:1.新增,2.修改)
  2653. /// </summary>
  2654. /// <param name="dto"></param>
  2655. /// <returns></returns>
  2656. [HttpPost]
  2657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2658. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2659. {
  2660. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2661. if (groupData.Code != 0)
  2662. {
  2663. return Ok(JsonView(false, groupData.Msg));
  2664. }
  2665. #region 应用推送
  2666. try
  2667. {
  2668. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2669. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2670. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2671. //2024-10-21 新增LZ UID
  2672. var userIds = new List<int>() { 21 };
  2673. string title = $"系统通知";
  2674. string content = "";
  2675. var diId = dto.AirTicketResOpData.DiId;
  2676. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2677. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2678. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2679. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2680. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2681. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2682. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2683. }
  2684. catch (Exception ex)
  2685. {
  2686. }
  2687. #endregion
  2688. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2689. }
  2690. /// <summary>
  2691. /// 根据舱位类型查询接团客户名单信息
  2692. /// </summary>
  2693. /// <param name="dto"></param>
  2694. /// <returns></returns>
  2695. [HttpPost]
  2696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2697. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2698. {
  2699. try
  2700. {
  2701. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2702. if (crm_Groups.Count != 0)
  2703. {
  2704. List<dynamic> Customer = new List<dynamic>();
  2705. foreach (var item in crm_Groups)
  2706. {
  2707. var data = new
  2708. {
  2709. Id = item.Id,
  2710. Pinyin = item.Pinyin,
  2711. Name = item.LastName + item.FirstName
  2712. };
  2713. Customer.Add(data);
  2714. }
  2715. return Ok(JsonView(true, "查询成功!", Customer));
  2716. }
  2717. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2718. }
  2719. catch (Exception ex)
  2720. {
  2721. return Ok(JsonView(false, "程序错误!"));
  2722. throw;
  2723. }
  2724. }
  2725. /// <summary>
  2726. /// 根据团号获取客户信息
  2727. /// </summary>
  2728. /// <param name="dto"></param>
  2729. /// <returns></returns>
  2730. [HttpPost]
  2731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2732. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2733. {
  2734. var jw = JsonView(false);
  2735. if (dto.DIID < 1)
  2736. {
  2737. jw.Msg += "请输入正确的diid";
  2738. return Ok(jw);
  2739. }
  2740. var arr = getSimplClientList(dto.DIID);
  2741. jw = JsonView(true, "获取成功!", arr);
  2742. return Ok(jw);
  2743. }
  2744. private List<SimplClientInfo> getSimplClientList(int diId)
  2745. {
  2746. 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);
  2747. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2748. foreach (var item in arr)
  2749. {
  2750. EncryptionProcessor.DecryptProperties(item);
  2751. }
  2752. return arr;
  2753. }
  2754. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2755. {
  2756. string result = origin;
  2757. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2758. {
  2759. string[] temparr = origin.Split(',');
  2760. string fistrStr = temparr[0];
  2761. int count = temparr.Count();
  2762. int tempId;
  2763. bool success = int.TryParse(fistrStr, out tempId);
  2764. if (success)
  2765. {
  2766. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2767. if (tempInfo != null)
  2768. {
  2769. if (count > 1)
  2770. {
  2771. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2772. }
  2773. else
  2774. {
  2775. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2776. }
  2777. }
  2778. }
  2779. }
  2780. return result;
  2781. }
  2782. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2783. {
  2784. string result = origin;
  2785. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2786. {
  2787. string[] temparr = origin.Split(',');
  2788. result = "";
  2789. foreach (var item in temparr)
  2790. {
  2791. int tempId;
  2792. bool success = int.TryParse(item, out tempId);
  2793. if (success)
  2794. {
  2795. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2796. if (tempInfo != null)
  2797. {
  2798. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2799. }
  2800. }
  2801. }
  2802. }
  2803. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2804. return result;
  2805. }
  2806. /// <summary>
  2807. /// 机票费用录入,删除
  2808. /// </summary>
  2809. /// <param name="dto"></param>
  2810. /// <returns></returns>
  2811. [HttpPost]
  2812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2813. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2814. {
  2815. try
  2816. {
  2817. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2818. if (res)
  2819. {
  2820. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2821. {
  2822. IsDel = 1,
  2823. DeleteUserId = dto.DeleteUserId,
  2824. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2825. }).ExecuteCommandAsync();
  2826. return Ok(JsonView(true, "删除成功!"));
  2827. }
  2828. return Ok(JsonView(false, "删除失败!"));
  2829. }
  2830. catch (Exception ex)
  2831. {
  2832. return Ok(JsonView(false, "程序错误!"));
  2833. throw;
  2834. }
  2835. }
  2836. /// <summary>
  2837. /// 导出机票录入报表
  2838. /// </summary>
  2839. /// <param name="dto"></param>
  2840. /// <returns></returns>
  2841. [HttpPost]
  2842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2843. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2844. {
  2845. try
  2846. {
  2847. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2848. if (groupData.Code != 0)
  2849. {
  2850. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2851. }
  2852. else
  2853. {
  2854. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2855. if (AirTicketReservations.Count != 0)
  2856. {
  2857. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2858. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2859. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2860. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2861. WorkbookDesigner designer = new WorkbookDesigner();
  2862. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2863. decimal countCost = 0;
  2864. foreach (var item in AirTicketReservations)
  2865. {
  2866. #region 处理客人姓名
  2867. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2868. item.ClientName = clientNames;
  2869. #endregion
  2870. if (item.BankType == "其他")
  2871. {
  2872. item.BankNo = "--";
  2873. }
  2874. else
  2875. {
  2876. if (!string.IsNullOrEmpty(item.BankType))
  2877. {
  2878. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2879. }
  2880. }
  2881. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2882. item.Price = System.Decimal.Round(item.Price, 2);
  2883. countCost += Convert.ToDecimal(item.Price);
  2884. }
  2885. designer.SetDataSource("Export", AirTicketReservations);
  2886. designer.SetDataSource("ExportDiCode", diCode);
  2887. designer.SetDataSource("ExportDiName", diName);
  2888. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2889. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2890. designer.Process();
  2891. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2892. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2893. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2894. return Ok(JsonView(true, "成功", url = rst));
  2895. }
  2896. else
  2897. {
  2898. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2899. }
  2900. }
  2901. }
  2902. catch (Exception ex)
  2903. {
  2904. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2905. throw;
  2906. }
  2907. }
  2908. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2909. /// <summary>
  2910. /// 行程单导出
  2911. /// </summary>
  2912. /// <param name="dto"></param>
  2913. /// <returns></returns>
  2914. [HttpPost]
  2915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2916. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2917. {
  2918. try
  2919. {
  2920. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2921. if (groupData.Code != 0)
  2922. {
  2923. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2924. }
  2925. else
  2926. {
  2927. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2928. if (dto.Language == "CN")
  2929. {
  2930. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2931. DocumentBuilder builder = new DocumentBuilder(doc);
  2932. int tableIndex = 0;//表格索引
  2933. //得到文档中的第一个表格
  2934. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2935. foreach (var item in _AirTicketReservations)
  2936. {
  2937. #region 处理固定数据
  2938. string[] FlightsCode = item.FlightsCode.Split('/');
  2939. if (FlightsCode.Length != 0)
  2940. {
  2941. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2942. if (_AirCompany != null)
  2943. {
  2944. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2945. }
  2946. else
  2947. {
  2948. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2949. }
  2950. }
  2951. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2952. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2953. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2954. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2955. string name = "";
  2956. foreach (string clientName in nameArray)
  2957. {
  2958. if (!name.Contains(clientName))
  2959. {
  2960. name += clientName + ",";
  2961. }
  2962. }
  2963. if (!string.IsNullOrWhiteSpace(name))
  2964. {
  2965. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2966. }
  2967. else
  2968. {
  2969. table.Range.Bookmarks["ClientName"].Text = "--";
  2970. }
  2971. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2972. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2973. table.Range.Bookmarks["JointTicket"].Text = "--";
  2974. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2975. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2976. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2977. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2978. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2979. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2980. #endregion
  2981. #region 循环数据处理
  2982. List<AirInfo> airs = new List<AirInfo>();
  2983. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2984. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2985. for (int i = 0; i < FlightsCode.Length; i++)
  2986. {
  2987. AirInfo air = new AirInfo();
  2988. string[] tempstr = DayArray[i]
  2989. .Replace("\r\n", string.Empty)
  2990. .Replace("\\r\\n", string.Empty)
  2991. .TrimStart().TrimEnd()
  2992. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2993. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2994. string starCity = "";
  2995. if (star_Three != null)
  2996. {
  2997. starCity = star_Three.AirPort;
  2998. }
  2999. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3000. string EndCity = "";
  3001. if (End_Three != null)
  3002. {
  3003. EndCity = End_Three.AirPort;
  3004. }
  3005. air.Destination = starCity + "/" + EndCity;
  3006. air.Flight = FlightsCode[i];
  3007. air.SeatingClass = item.CTypeName;
  3008. string dateTime = tempstr[2];
  3009. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3010. air.FlightDate = DateTemp;
  3011. air.DepartureTime = tempstr[5];
  3012. air.LandingTime = tempstr[6];
  3013. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3014. air.TicketStatus = "--";
  3015. air.Luggage = "--";
  3016. air.DepartureTerminal = "--";
  3017. air.LandingTerminal = "--";
  3018. airs.Add(air);
  3019. }
  3020. int row = 13;
  3021. for (int i = 0; i < airs.Count; i++)
  3022. {
  3023. if (airs.Count > 2)
  3024. {
  3025. for (int j = 0; j < airs.Count - 2; j++)
  3026. {
  3027. var CopyRow = table.Rows[12].Clone(true);
  3028. table.Rows.Add(CopyRow);
  3029. }
  3030. }
  3031. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3032. int index = 0;
  3033. foreach (PropertyInfo property in properties)
  3034. {
  3035. string value = property.GetValue(airs[i]).ToString();
  3036. Cell ishcel0 = table.Rows[row].Cells[index];
  3037. Paragraph p = new Paragraph(doc);
  3038. string s = value;
  3039. p.AppendChild(new Run(doc, s));
  3040. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3041. ishcel0.AppendChild(p);
  3042. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3043. index++;
  3044. }
  3045. row++;
  3046. }
  3047. #endregion
  3048. Paragraph lastParagraph = new Paragraph(doc);
  3049. //第一个表格末尾加段落
  3050. table.ParentNode.InsertAfter(lastParagraph, table);
  3051. //复制第一个表格
  3052. Table cloneTable = (Table)table.Clone(true);
  3053. //在文档末尾段落后面加入复制的表格
  3054. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3055. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3056. {
  3057. int rownewsIndex = 13;
  3058. for (int i = 0; i < 2; i++)
  3059. {
  3060. var CopyRow = table.Rows[12].Clone(true);
  3061. table.Rows.RemoveAt(13);
  3062. table.Rows.Add(CopyRow);
  3063. rownewsIndex++;
  3064. }
  3065. }
  3066. else
  3067. {
  3068. table.Rows.RemoveAt(12);
  3069. }
  3070. cloneTable.Rows.RemoveAt(12);
  3071. }
  3072. if (_AirTicketReservations.Count != 0)
  3073. {
  3074. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3075. if (FlightsCode.Length != 0)
  3076. {
  3077. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3078. if (_AirCompany != null)
  3079. {
  3080. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3081. }
  3082. else
  3083. {
  3084. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3085. }
  3086. }
  3087. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3088. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3089. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3090. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3091. string name = "";
  3092. foreach (string clientName in nameArray)
  3093. {
  3094. if (!name.Contains(clientName))
  3095. {
  3096. name += clientName + ",";
  3097. }
  3098. }
  3099. if (!string.IsNullOrWhiteSpace(name))
  3100. {
  3101. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3102. }
  3103. else
  3104. {
  3105. table.Range.Bookmarks["ClientName"].Text = "--";
  3106. }
  3107. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3108. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3109. table.Range.Bookmarks["JointTicket"].Text = "--";
  3110. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3111. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3112. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3113. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3114. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3115. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3116. }
  3117. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3118. //保存合并后的文档
  3119. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3120. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3121. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3122. return Ok(JsonView(true, "成功!", rst));
  3123. }
  3124. else
  3125. {
  3126. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3127. DocumentBuilder builder = new DocumentBuilder(doc);
  3128. int tableIndex = 0;//表格索引
  3129. //得到文档中的第一个表格
  3130. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3131. List<string> texts = new List<string>();
  3132. foreach (var item in _AirTicketReservations)
  3133. {
  3134. string[] FlightsCode = item.FlightsCode.Split('/');
  3135. if (FlightsCode.Length != 0)
  3136. {
  3137. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3138. if (_AirCompany != null)
  3139. {
  3140. if (!transDic.ContainsKey(_AirCompany.CnName))
  3141. {
  3142. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3143. }
  3144. }
  3145. else
  3146. {
  3147. if (!transDic.ContainsKey("--"))
  3148. {
  3149. transDic.Add("--", "--");
  3150. }
  3151. }
  3152. }
  3153. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3154. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3155. string name = "";
  3156. foreach (string clientName in nameArray)
  3157. {
  3158. name += clientName + ",";
  3159. }
  3160. if (!texts.Contains(name))
  3161. {
  3162. texts.Add(name);
  3163. }
  3164. List<AirInfo> airs = new List<AirInfo>();
  3165. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3166. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3167. for (int i = 0; i < FlightsCode.Length; i++)
  3168. {
  3169. AirInfo air = new AirInfo();
  3170. string[] tempstr = DayArray[i]
  3171. .Replace("\r\n", string.Empty)
  3172. .Replace("\\r\\n", string.Empty)
  3173. .TrimStart().TrimEnd()
  3174. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3175. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3176. if (star_Three != null)
  3177. {
  3178. if (!transDic.ContainsKey(star_Three.AirPort))
  3179. {
  3180. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3181. }
  3182. }
  3183. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3184. if (End_Three != null)
  3185. {
  3186. if (!transDic.ContainsKey(End_Three.AirPort))
  3187. {
  3188. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3189. }
  3190. }
  3191. if (!texts.Contains(item.CTypeName))
  3192. {
  3193. texts.Add(item.CTypeName);
  3194. }
  3195. }
  3196. }
  3197. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3198. if (transData.Count > 0)
  3199. {
  3200. foreach (TranslateResult item in transData)
  3201. {
  3202. if (!transDic.ContainsKey(item.Query))
  3203. {
  3204. transDic.Add(item.Query, item.Translation);
  3205. }
  3206. }
  3207. }
  3208. foreach (var item in _AirTicketReservations)
  3209. {
  3210. #region 处理固定数据
  3211. string[] FlightsCode = item.FlightsCode.Split('/');
  3212. if (FlightsCode.Length != 0)
  3213. {
  3214. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3215. if (_AirCompany != null)
  3216. {
  3217. string str = "--";
  3218. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3219. if (!string.IsNullOrEmpty(translateResult))
  3220. {
  3221. str = translateResult;
  3222. str = _airTicketResRep.Processing(str);
  3223. }
  3224. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3225. }
  3226. else
  3227. {
  3228. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3229. }
  3230. }
  3231. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3232. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3233. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3234. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3235. string names = "";
  3236. foreach (string clientName in nameArray)
  3237. {
  3238. names += clientName + ",";
  3239. }
  3240. if (!string.IsNullOrWhiteSpace(names))
  3241. {
  3242. string str = "--";
  3243. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3244. if (!string.IsNullOrEmpty(translateResult))
  3245. {
  3246. str = translateResult;
  3247. str = _airTicketResRep.Processing(str);
  3248. }
  3249. table.Range.Bookmarks["ClientName"].Text = str;
  3250. }
  3251. else
  3252. {
  3253. table.Range.Bookmarks["ClientName"].Text = "--";
  3254. }
  3255. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3256. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3257. table.Range.Bookmarks["JointTicket"].Text = "--";
  3258. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3259. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3260. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3261. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3262. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3263. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3264. #endregion
  3265. #region 循环数据处理
  3266. List<AirInfo> airs = new List<AirInfo>();
  3267. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3268. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3269. for (int i = 0; i < FlightsCode.Length; i++)
  3270. {
  3271. AirInfo air = new AirInfo();
  3272. string[] tempstr = DayArray[i]
  3273. .Replace("\r\n", string.Empty)
  3274. .Replace("\\r\\n", string.Empty)
  3275. .TrimStart().TrimEnd()
  3276. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3277. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3278. string starCity = "";
  3279. if (star_Three != null)
  3280. {
  3281. string str2 = "--";
  3282. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3283. if (!string.IsNullOrEmpty(translateResult2))
  3284. {
  3285. str2 = translateResult2;
  3286. str2 = _airTicketResRep.Processing(str2);
  3287. }
  3288. starCity = str2;
  3289. }
  3290. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3291. string EndCity = "";
  3292. if (End_Three != null)
  3293. {
  3294. string str1 = "--";
  3295. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3296. if (!string.IsNullOrEmpty(translateResult1))
  3297. {
  3298. str1 = translateResult1;
  3299. str1 = _airTicketResRep.Processing(str1);
  3300. }
  3301. EndCity = str1;
  3302. }
  3303. air.Destination = starCity + "/" + EndCity;
  3304. air.Flight = FlightsCode[i];
  3305. string str = "--";
  3306. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3307. if (!string.IsNullOrEmpty(translateResult))
  3308. {
  3309. str = translateResult;
  3310. str = _airTicketResRep.Processing(str);
  3311. }
  3312. air.SeatingClass = str;
  3313. string dateTime = tempstr[2];
  3314. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3315. air.FlightDate = DateTemp;
  3316. air.DepartureTime = tempstr[5];
  3317. air.LandingTime = tempstr[6];
  3318. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3319. air.TicketStatus = "--";
  3320. air.Luggage = "--";
  3321. air.DepartureTerminal = "--";
  3322. air.LandingTerminal = "--";
  3323. airs.Add(air);
  3324. }
  3325. int row = 13;
  3326. for (int i = 0; i < airs.Count; i++)
  3327. {
  3328. if (airs.Count > 2)
  3329. {
  3330. for (int j = 0; j < airs.Count - 2; j++)
  3331. {
  3332. var CopyRow = table.Rows[12].Clone(true);
  3333. table.Rows.Add(CopyRow);
  3334. }
  3335. }
  3336. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3337. int index = 0;
  3338. foreach (PropertyInfo property in properties)
  3339. {
  3340. string value = property.GetValue(airs[i]).ToString();
  3341. Cell ishcel0 = table.Rows[row].Cells[index];
  3342. Paragraph p = new Paragraph(doc);
  3343. string s = value;
  3344. p.AppendChild(new Run(doc, s));
  3345. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3346. ishcel0.AppendChild(p);
  3347. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3348. //ishcel0.CellFormat.VerticalAlignment=
  3349. index++;
  3350. }
  3351. row++;
  3352. }
  3353. #endregion
  3354. Paragraph lastParagraph = new Paragraph(doc);
  3355. //第一个表格末尾加段落
  3356. table.ParentNode.InsertAfter(lastParagraph, table);
  3357. //复制第一个表格
  3358. Table cloneTable = (Table)table.Clone(true);
  3359. //在文档末尾段落后面加入复制的表格
  3360. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3361. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3362. {
  3363. int rownewsIndex = 13;
  3364. for (int i = 0; i < 2; i++)
  3365. {
  3366. var CopyRow = table.Rows[12].Clone(true);
  3367. table.Rows.RemoveAt(13);
  3368. table.Rows.Add(CopyRow);
  3369. rownewsIndex++;
  3370. }
  3371. }
  3372. else
  3373. {
  3374. table.Rows.RemoveAt(12);
  3375. }
  3376. cloneTable.Rows.RemoveAt(12);
  3377. }
  3378. if (_AirTicketReservations.Count != 0)
  3379. {
  3380. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3381. if (FlightsCode.Length != 0)
  3382. {
  3383. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3384. if (_AirCompany != null)
  3385. {
  3386. string str = "--";
  3387. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3388. if (!string.IsNullOrEmpty(translateResult))
  3389. {
  3390. str = translateResult;
  3391. str = _airTicketResRep.Processing(str);
  3392. }
  3393. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3394. }
  3395. else
  3396. {
  3397. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3398. }
  3399. }
  3400. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3401. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3402. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3403. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3404. string names = "";
  3405. foreach (string clientName in nameArray)
  3406. {
  3407. names += clientName + ",";
  3408. }
  3409. if (!string.IsNullOrWhiteSpace(names))
  3410. {
  3411. string str = "--";
  3412. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3413. if (!string.IsNullOrEmpty(translateResult))
  3414. {
  3415. str = translateResult;
  3416. str = _airTicketResRep.Processing(str);
  3417. }
  3418. table.Range.Bookmarks["ClientName"].Text = str;
  3419. }
  3420. else
  3421. {
  3422. table.Range.Bookmarks["ClientName"].Text = "--";
  3423. }
  3424. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3425. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3426. table.Range.Bookmarks["JointTicket"].Text = "--";
  3427. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3428. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3429. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3430. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3431. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3432. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3433. }
  3434. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3435. //保存合并后的文档
  3436. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3437. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3438. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3439. return Ok(JsonView(true, "成功!", rst));
  3440. }
  3441. }
  3442. }
  3443. catch (Exception ex)
  3444. {
  3445. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3446. throw;
  3447. }
  3448. }
  3449. #endregion
  3450. #region 团组增减款项 --> 其他款项
  3451. /// <summary>
  3452. /// 团组增减款项下拉框绑定
  3453. /// </summary>
  3454. /// <param name="dto"></param>
  3455. /// <returns></returns>
  3456. [HttpPost]
  3457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3458. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3459. {
  3460. #region 参数验证
  3461. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3462. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3463. #endregion
  3464. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3465. }
  3466. /// <summary>
  3467. /// 根据团组Id查询团组增减款项
  3468. /// </summary>
  3469. /// <param name="dto"></param>
  3470. /// <returns></returns>
  3471. [HttpPost]
  3472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3473. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3474. {
  3475. #region 参数验证
  3476. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3477. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3478. #endregion
  3479. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3480. }
  3481. /// <summary>
  3482. /// 团组增减款项操作(Status:1.新增,2.修改)
  3483. /// </summary>
  3484. /// <param name="dto"></param>
  3485. /// <returns></returns>
  3486. [HttpPost]
  3487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3488. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3489. {
  3490. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3491. if (groupData.Code != 200)
  3492. {
  3493. return Ok(JsonView(false, groupData.Msg));
  3494. }
  3495. #region 应用推送
  3496. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3497. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3498. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3499. //自动审核
  3500. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3501. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3502. //2024-10-21 新增LZ UID
  3503. var userIds = new List<int>() { 21 };
  3504. string title = $"系统通知";
  3505. string content = "";
  3506. var diId = dto.DiId;
  3507. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3508. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3509. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3510. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3511. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3512. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3513. #endregion
  3514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3515. }
  3516. /// <summary>
  3517. /// 团组增减款项操作 删除
  3518. /// </summary>
  3519. /// <param name="dto"></param>
  3520. /// <returns></returns>
  3521. [HttpPost]
  3522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3523. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3524. {
  3525. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3526. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3527. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3528. if (res.Code == 0)
  3529. {
  3530. return Ok(JsonView(true, "删除成功!"));
  3531. }
  3532. return Ok(JsonView(false, "删除失败!"));
  3533. }
  3534. /// <summary>
  3535. /// 根据团组增减款项Id查询
  3536. /// </summary>
  3537. /// <param name="dto"></param>
  3538. /// <returns></returns>
  3539. [HttpPost]
  3540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3541. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3542. {
  3543. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3544. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3545. }
  3546. /// <summary>
  3547. /// 查询供应商名称
  3548. /// </summary>
  3549. /// <param name="dto"></param>
  3550. /// <returns></returns>
  3551. [HttpPost]
  3552. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3553. {
  3554. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3555. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3556. ?? new List<Grp_DecreasePayments>();
  3557. dbResult = dbResult.Distinct(new
  3558. ProductComparer()).ToList();
  3559. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3560. {
  3561. x.Id,
  3562. x.SupplierAddress,
  3563. x.SupplierArea,
  3564. x.SupplierContact,
  3565. x.SupplierContactNumber,
  3566. x.SupplierEmail,
  3567. x.SupplierName,
  3568. x.SupplierSocialAccount,
  3569. x.SupplierTypeId,
  3570. }).ToList());
  3571. return Ok(jw);
  3572. }
  3573. /// <summary>
  3574. /// 团组增减款项 OTA匹配
  3575. /// </summary>
  3576. /// <param name="file"></param>
  3577. /// <returns></returns>
  3578. [HttpPost]
  3579. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3580. {
  3581. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3582. string fileName = file.FileName;
  3583. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3584. {
  3585. return Ok(JsonView(false, "请上传Excel文件!"));
  3586. }
  3587. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3588. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3589. if (!Directory.Exists(path))
  3590. {
  3591. Directory.CreateDirectory(path);
  3592. }
  3593. var filePath = @$"{path}/{fileName}";
  3594. //保存文件
  3595. using (FileStream fs = System.IO.File.Create(filePath))
  3596. {
  3597. file.CopyTo(fs);
  3598. fs.Flush();
  3599. }
  3600. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3601. //读取ExcelFile
  3602. DataTable dt = ConvertExcelToDataTable(filePath);
  3603. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3604. dt.TableName = "TB";
  3605. //修改table列名
  3606. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3607. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3608. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3609. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3610. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3611. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3612. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3613. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3614. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3615. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3616. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3617. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3618. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3619. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3620. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3621. var otaOrderNos = new List<string>();
  3622. foreach (DataRow item in dt.Rows)
  3623. {
  3624. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3625. }
  3626. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3627. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3628. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3629. .Select((dp, di) => new
  3630. {
  3631. dp.PriceName,
  3632. dp.OTAOrderNo,
  3633. dp.FeeTotal,
  3634. di.TeamName,
  3635. })
  3636. .ToListAsync();
  3637. foreach (DataRow item in dt.Rows)
  3638. {
  3639. var otaOrderNo = item["OTAOrderNo"].ToString();
  3640. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3641. if (oaData == null) continue;
  3642. item["GroupName"] = oaData.TeamName;
  3643. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3644. }
  3645. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3646. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3647. List<DataTable> datas = new List<DataTable>();
  3648. datas.Add(dt);
  3649. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3650. return Ok(JsonView(true, "操作成功", new { url = url }));
  3651. }
  3652. #region
  3653. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3654. {
  3655. // 创建Workbook对象
  3656. Workbook workbook = new Workbook(excelFilePath);
  3657. // 获取第一个工作表
  3658. Worksheet worksheet = workbook.Worksheets[0];
  3659. // 将工作表转换为DataTable
  3660. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3661. return dataTable;
  3662. }
  3663. #endregion
  3664. #endregion
  3665. #region 文件上传、删除
  3666. /// <summary>
  3667. /// region 文件上传 可以带参数
  3668. /// </summary>
  3669. /// <param name="file"></param>
  3670. /// <returns></returns>
  3671. [HttpPost]
  3672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3673. public async Task<IActionResult> UploadProject(IFormFile file)
  3674. {
  3675. //var TypeName = Request.Headers["TypeName"].ToString();
  3676. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3677. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3678. ////文件名称
  3679. //string projectFileName = file.FileName;
  3680. ////上传的文件的路径
  3681. //string filePath = $"{fileDir}/{projectFileName}";
  3682. //if (TypeName == "A")//A代表团组增减款项
  3683. //{
  3684. // filePath = fileDir + $@"\团组增减款项相关文件";
  3685. // if (!Directory.Exists(filePath))
  3686. // {
  3687. // Directory.CreateDirectory(filePath);
  3688. // }
  3689. // //上传的文件的路径
  3690. // filePath += $@"\{projectFileName}";
  3691. //}
  3692. //else if (TypeName == "B")//B代表商邀相关文件
  3693. //{
  3694. // //上传的文件的路径
  3695. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3696. // if (!Directory.Exists(filePath))
  3697. // {
  3698. // Directory.CreateDirectory(filePath);
  3699. // }
  3700. // //上传的文件的路径
  3701. // filePath = $@"\{projectFileName}";
  3702. //}
  3703. //try
  3704. //{
  3705. // using (FileStream fs = System.IO.File.Create(filePath))
  3706. // {
  3707. // file.CopyTo(fs);
  3708. // fs.Flush();
  3709. // }
  3710. //}
  3711. //catch (Exception ex)
  3712. //{
  3713. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3714. //}
  3715. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3716. try
  3717. {
  3718. var TypeName = Request.Headers["TypeName"].ToString();
  3719. if (file != null)
  3720. {
  3721. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3722. //文件名称
  3723. string projectFileName = file.FileName;
  3724. //上传的文件的路径
  3725. string filePath = $"{fileDir}/{projectFileName}";
  3726. if (TypeName == "A")//A代表团组增减款项
  3727. {
  3728. if (!Directory.Exists(fileDir))
  3729. {
  3730. Directory.CreateDirectory(fileDir);
  3731. }
  3732. //上传的文件的路径
  3733. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3734. }
  3735. else if (TypeName == "B")//B代表商邀相关文件
  3736. {
  3737. if (!Directory.Exists(fileDir))
  3738. {
  3739. Directory.CreateDirectory(fileDir);
  3740. }
  3741. //上传的文件的路径
  3742. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3743. }
  3744. using (FileStream fs = System.IO.File.Create(filePath))
  3745. {
  3746. file.CopyTo(fs);
  3747. fs.Flush();
  3748. }
  3749. return Ok(JsonView(true, "上传成功!", projectFileName));
  3750. }
  3751. else
  3752. {
  3753. return Ok(JsonView(false, "上传失败!"));
  3754. }
  3755. }
  3756. catch (Exception ex)
  3757. {
  3758. return Ok(JsonView(false, "程序错误!"));
  3759. }
  3760. }
  3761. /// <summary>
  3762. /// 删除指定文件
  3763. /// </summary>
  3764. /// <param name="dto"></param>
  3765. /// <returns></returns>
  3766. [HttpPost]
  3767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3768. public async Task<IActionResult> DelFile(DelFileDto dto)
  3769. {
  3770. try
  3771. {
  3772. var TypeName = Request.Headers["TypeName"].ToString();
  3773. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3774. string filePath = "";
  3775. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3776. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3777. int id = 0;
  3778. if (TypeName == "A")
  3779. {
  3780. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3781. // 删除该文件
  3782. System.IO.File.Delete(filePath);
  3783. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3784. .Where(a => a.Id == dto.Id)
  3785. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3786. .ExecuteCommandAsync();
  3787. }
  3788. else if (TypeName == "B")
  3789. {
  3790. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3791. // 删除该文件
  3792. System.IO.File.Delete(filePath);
  3793. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3794. if (info != null)
  3795. {
  3796. string[] files = new string[] { };
  3797. if (!string.IsNullOrEmpty(info.Attachment))
  3798. {
  3799. try
  3800. {
  3801. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3802. }
  3803. catch (Exception)
  3804. {
  3805. files = new List<string>() { info.Attachment }.ToArray();
  3806. }
  3807. }
  3808. if (files.Length > 0)
  3809. {
  3810. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3811. string filePath2 = string.Empty;
  3812. if (files1.Length > 0)
  3813. {
  3814. filePath2 = JsonConvert.SerializeObject(files1);
  3815. }
  3816. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3817. .Where(a => a.Id == dto.Id)
  3818. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3819. .ExecuteCommandAsync();
  3820. }
  3821. }
  3822. }
  3823. if (id != 0)
  3824. {
  3825. return Ok(JsonView(true, "成功!"));
  3826. }
  3827. else
  3828. {
  3829. return Ok(JsonView(false, "失败!"));
  3830. }
  3831. }
  3832. catch (Exception ex)
  3833. {
  3834. return Ok(JsonView(false, "程序错误!"));
  3835. throw;
  3836. }
  3837. }
  3838. /// <summary>
  3839. /// 文件上传多个文件 可以带参数
  3840. /// </summary>
  3841. /// <param name="file"></param>
  3842. /// <returns></returns>
  3843. [HttpPost]
  3844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3845. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3846. {
  3847. try
  3848. {
  3849. var TypeName = Request.Headers["TypeName"].ToString();
  3850. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3851. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3852. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3853. var filePahts = new List<string>();
  3854. foreach (var file in files)
  3855. {
  3856. //文件名称
  3857. string projectFileName = file.FileName;
  3858. //上传的文件的路径
  3859. string filePath = $"{fileDir}/{projectFileName}";
  3860. if (TypeName == "A")//A代表团组增减款项
  3861. {
  3862. if (!Directory.Exists(fileDir))
  3863. {
  3864. Directory.CreateDirectory(fileDir);
  3865. }
  3866. //上传的文件的路径
  3867. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3868. }
  3869. else if (TypeName == "B")//B代表商邀相关文件
  3870. {
  3871. if (!Directory.Exists(fileDir))
  3872. {
  3873. Directory.CreateDirectory(fileDir);
  3874. }
  3875. //上传的文件的路径
  3876. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3877. }
  3878. using (FileStream fs = System.IO.File.Create(filePath))
  3879. {
  3880. file.CopyTo(fs);
  3881. fs.Flush();
  3882. }
  3883. filePahts.Add(projectFileName);
  3884. }
  3885. return Ok(JsonView(true, "上传成功!", filePahts));
  3886. }
  3887. catch (Exception ex)
  3888. {
  3889. return Ok(JsonView(false, "程序错误!"));
  3890. }
  3891. }
  3892. #endregion
  3893. #region 商邀费用录入
  3894. /// <summary>
  3895. /// 根据团组Id查询商邀费用列表
  3896. /// </summary>
  3897. /// <param name="dto"></param>
  3898. /// <returns></returns>
  3899. [HttpPost]
  3900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3901. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3902. {
  3903. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3904. if (groupData.Code != 0)
  3905. {
  3906. return Ok(JsonView(false, groupData.Msg));
  3907. }
  3908. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3909. }
  3910. /// <summary>
  3911. /// 商邀费用列表
  3912. /// 下载文件
  3913. /// </summary>
  3914. /// <param name="dto"></param>
  3915. /// <returns></returns>
  3916. [HttpGet("{id}")]
  3917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3918. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3919. {
  3920. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3921. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3922. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3923. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3924. var filePaths = new List<string>();
  3925. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3926. try
  3927. {
  3928. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3929. }
  3930. catch (Exception ex)
  3931. {
  3932. filePaths.Add(info.Attachment);
  3933. }
  3934. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3935. for (int i = 0; i < filePaths.Count; i++)
  3936. {
  3937. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3938. }
  3939. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3940. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3941. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3942. {
  3943. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3944. {
  3945. foreach (string filePath in filePaths)
  3946. {
  3947. if (System.IO.File.Exists(filePath))
  3948. {
  3949. // 获取文件名
  3950. string fileName = Path.GetFileName(filePath);
  3951. // 将文件添加到ZIP归档中
  3952. zipArchive.CreateEntryFromFile(filePath, fileName);
  3953. }
  3954. }
  3955. }
  3956. }
  3957. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3958. }
  3959. /// <summary>
  3960. /// 商邀费用 Info Page 基础数据源
  3961. /// </summary>
  3962. /// <param name="dto"></param>
  3963. /// <returns></returns>
  3964. [HttpPost]
  3965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3966. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3967. {
  3968. try
  3969. {
  3970. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3971. if (groupData.Code != 0)
  3972. {
  3973. return Ok(JsonView(false, groupData.Msg));
  3974. }
  3975. return Ok(JsonView(true, "操作成功", groupData.Data));
  3976. }
  3977. catch (Exception ex)
  3978. {
  3979. return Ok(JsonView(false, ex.Message));
  3980. throw;
  3981. }
  3982. }
  3983. /// <summary>
  3984. /// 根据商邀费用ID查询C表和商邀费用数据
  3985. /// </summary>
  3986. /// <param name="dto"></param>
  3987. /// <returns></returns>
  3988. [HttpPost]
  3989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3990. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3991. {
  3992. try
  3993. {
  3994. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3995. if (groupData.Code != 0)
  3996. {
  3997. return Ok(JsonView(false, groupData.Msg));
  3998. }
  3999. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4000. }
  4001. catch (Exception ex)
  4002. {
  4003. return Ok(JsonView(false, ex.Message));
  4004. throw;
  4005. }
  4006. }
  4007. /// <summary>
  4008. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4009. /// </summary>
  4010. /// <param name="dto"></param>
  4011. /// <returns></returns>
  4012. [HttpPost]
  4013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4014. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4015. {
  4016. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4017. if (groupData.Code != 0)
  4018. {
  4019. return Ok(JsonView(false, groupData.Msg));
  4020. }
  4021. #region 应用推送
  4022. try
  4023. {
  4024. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4025. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4026. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4027. //2024-10-21 新增LZ UID
  4028. var userIds = new List<int>() { 21 };
  4029. string title = $"系统通知";
  4030. string content = "";
  4031. var diId = dto.DiId;
  4032. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4033. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4034. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4035. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4036. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4037. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4038. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4039. }
  4040. catch (Exception ex)
  4041. {
  4042. }
  4043. #endregion
  4044. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4045. }
  4046. /// <summary>
  4047. /// 商邀删除
  4048. /// </summary>
  4049. /// <param name="dto"></param>
  4050. /// <returns></returns>
  4051. [HttpPost]
  4052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4053. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4054. {
  4055. try
  4056. {
  4057. _sqlSugar.BeginTran();
  4058. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4059. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4060. {
  4061. IsDel = 1,
  4062. DeleteUserId = dto.DeleteUserId,
  4063. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4064. })
  4065. .Where(it => it.Id == dto.Id)
  4066. .ExecuteCommand();
  4067. if (res1 > 0)
  4068. {
  4069. int _diId = 0;
  4070. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4071. if (_ioaInfo != null)
  4072. {
  4073. _diId = _ioaInfo.DiId;
  4074. }
  4075. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4076. .SetColumns(a => new Grp_CreditCardPayment()
  4077. {
  4078. IsDel = 1,
  4079. DeleteUserId = dto.DeleteUserId,
  4080. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4081. })
  4082. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4083. .ExecuteCommand();
  4084. if (res2 > 0)
  4085. {
  4086. _sqlSugar.CommitTran();
  4087. return Ok(JsonView(true, "删除成功!"));
  4088. }
  4089. }
  4090. _sqlSugar.RollbackTran();
  4091. return Ok(JsonView(false, "删除失败"));
  4092. }
  4093. catch (Exception ex)
  4094. {
  4095. _sqlSugar.RollbackTran();
  4096. return Ok(JsonView(false, ex.Message));
  4097. }
  4098. }
  4099. /// <summary>
  4100. /// 团组模块文件上传
  4101. /// </summary>
  4102. /// <param name="dto"></param>
  4103. /// <returns></returns>
  4104. [HttpPost]
  4105. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4106. {
  4107. var jw = JsonView(false);
  4108. long M = 1024 * 1024;
  4109. if (dto.Files == null || dto.Files.Count == 0)
  4110. {
  4111. jw.Msg = "无文件信息!";
  4112. return Ok(jw);
  4113. }
  4114. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4115. {
  4116. jw.Msg = "文件大小超过20M!";
  4117. return Ok(jw);
  4118. }
  4119. //var nameSp = dto.File.FileName.Split(".");
  4120. //if (nameSp.Length < 2)
  4121. //{
  4122. // jw.Msg = "拓展名称有误!";
  4123. // return Ok(jw);
  4124. //}
  4125. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4126. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4127. //{
  4128. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4129. // return Ok(jw);
  4130. //}
  4131. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4132. if (Ctable == null)
  4133. {
  4134. jw.Msg = "Ctable指向有误!";
  4135. return Ok(jw);
  4136. }
  4137. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4138. if (groupInfo == null)
  4139. {
  4140. jw.Msg = "团组信息不存在!";
  4141. return Ok(jw);
  4142. }
  4143. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4144. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4145. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4146. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4147. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4148. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4149. try
  4150. {
  4151. if (!Directory.Exists(fileBase))
  4152. {
  4153. Directory.CreateDirectory(fileBase);
  4154. }
  4155. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4156. foreach (var fileStream in dto.Files)
  4157. {
  4158. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4159. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4160. {
  4161. Cid = dto.Cid,
  4162. CreateTime = DateTime.Now,
  4163. CreateUserId = dto.Userid,
  4164. Ctable = dto.Ctable,
  4165. Diid = dto.Diid,
  4166. IsDel = 0,
  4167. FilePath = saveFilePath,
  4168. FileName = fileStream.FileName
  4169. };
  4170. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4171. {
  4172. fileStream.CopyTo(fs);
  4173. fs.Flush();
  4174. }
  4175. saveArr.Add(file);
  4176. }
  4177. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4178. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4179. jw = JsonView(true, "保存成功!", new
  4180. {
  4181. count = addResult,
  4182. filesName = saveArr.Select(x => x.FileName)
  4183. });
  4184. }
  4185. catch (Exception ex)
  4186. {
  4187. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4188. {
  4189. count = 0,
  4190. filesName = new string[0],
  4191. });
  4192. }
  4193. return Ok(jw);
  4194. }
  4195. /// <summary>
  4196. /// 查询各模块已保存文件
  4197. /// </summary>
  4198. /// <param name="dto"></param>
  4199. /// <returns></returns>
  4200. [HttpPost]
  4201. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4202. {
  4203. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4204. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4205. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4206. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4207. {
  4208. expression = Expressionable.Create<Grp_GroupModelFile>()
  4209. .And(x => visaIds.Contains(x.CreateUserId));
  4210. }
  4211. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4212. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4213. .Where(expression.ToExpression())
  4214. .ToList();
  4215. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4216. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4217. {
  4218. x.FileName,
  4219. x.Id,
  4220. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4221. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4222. })));
  4223. }
  4224. /// <summary>
  4225. /// 下载该团组下的所有文件
  4226. /// </summary>
  4227. /// <param name="dto"></param>
  4228. /// <returns></returns>
  4229. [HttpPost]
  4230. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4231. {
  4232. var jw = JsonView(false);
  4233. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4234. if (groupInfo == null)
  4235. {
  4236. jw.Msg = "团组信息不存在!";
  4237. return Ok(jw);
  4238. }
  4239. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4240. var isModule = Convert.ToBoolean(dto.isModule);
  4241. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4242. IOOperatorHelper io = new IOOperatorHelper();
  4243. if (isModule)
  4244. {
  4245. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4246. foreach (var moduleArr in moduleGroup)
  4247. {
  4248. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4249. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4250. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4251. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4252. foreach (var item in moduleArr)
  4253. {
  4254. if (System.IO.File.Exists(item.FilePath))
  4255. {
  4256. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4257. {
  4258. byte[] bytes = new byte[fileStream.Length];
  4259. fileStream.Read(bytes, 0, bytes.Length);
  4260. fileStream.Close();
  4261. Stream stream = new MemoryStream(bytes);
  4262. chiZips.Add(item.FileName, stream);
  4263. }
  4264. }
  4265. }
  4266. if (chiZips.Count > 0)
  4267. {
  4268. var byts = io.ConvertZipStream(chiZips);
  4269. Stream stream = new MemoryStream(byts);
  4270. Zips.Add(key.Name + "_.zip", stream);
  4271. }
  4272. }
  4273. }
  4274. else
  4275. {
  4276. foreach (var item in dbQuery)
  4277. {
  4278. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4279. {
  4280. byte[] bytes = new byte[fileStream.Length];
  4281. fileStream.Read(bytes, 0, bytes.Length);
  4282. fileStream.Close();
  4283. Stream stream = new MemoryStream(bytes);
  4284. while (Zips.Keys.Contains(item.FileName))
  4285. {
  4286. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4287. }
  4288. Zips.Add(item.FileName, stream);
  4289. }
  4290. }
  4291. }
  4292. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4293. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4294. if (Zips.Count > 0)
  4295. {
  4296. var byts = io.ConvertZipStream(Zips);
  4297. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4298. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4299. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4300. }
  4301. else
  4302. {
  4303. jw.Msg = "暂无生成文件!";
  4304. }
  4305. return Ok(jw);
  4306. }
  4307. /// <summary>
  4308. /// 下载该团组下此模块的所有文件
  4309. /// </summary>
  4310. /// <param name="dto"></param>
  4311. /// <returns></returns>
  4312. [HttpPost]
  4313. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4314. {
  4315. var jw = JsonView(false);
  4316. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4317. if (groupInfo == null)
  4318. {
  4319. jw.Msg = "团组信息不存在!";
  4320. return Ok(jw);
  4321. }
  4322. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4323. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4324. && x.IsDel == 0);
  4325. if (key == null)
  4326. {
  4327. jw.Msg = "Ctable指向错误!";
  4328. return Ok(jw);
  4329. }
  4330. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4331. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4332. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4333. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4334. IOOperatorHelper io = new IOOperatorHelper();
  4335. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4336. foreach (var item in dbQuery)
  4337. {
  4338. if (System.IO.File.Exists(item.FilePath))
  4339. {
  4340. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4341. {
  4342. byte[] bytes = new byte[fileStream.Length];
  4343. fileStream.Read(bytes, 0, bytes.Length);
  4344. fileStream.Close();
  4345. Stream stream = new MemoryStream(bytes);
  4346. while (Zips.Keys.Contains(item.FileName))
  4347. {
  4348. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4349. }
  4350. Zips.Add(item.FileName, stream);
  4351. }
  4352. }
  4353. }
  4354. if (Zips.Count > 0)
  4355. {
  4356. var byts = io.ConvertZipStream(Zips);
  4357. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4358. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4359. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4360. }
  4361. else
  4362. {
  4363. jw.Msg = "暂无生成文件!";
  4364. }
  4365. return Ok(jw);
  4366. }
  4367. /// <summary>
  4368. /// 删除该团组下的指定文件
  4369. /// </summary>
  4370. /// <param name="dto"></param>
  4371. /// <returns></returns>
  4372. [HttpPost]
  4373. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4374. {
  4375. var jw = JsonView(false);
  4376. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4377. if (sing == null)
  4378. {
  4379. jw.Msg = "暂无";
  4380. return Ok(jw);
  4381. }
  4382. if (System.IO.File.Exists(sing.FilePath))
  4383. {
  4384. try
  4385. {
  4386. System.IO.File.Delete(sing.FilePath);
  4387. }
  4388. catch (Exception ex)
  4389. {
  4390. jw.Msg = "删除失败!" + ex.Message;
  4391. return Ok(jw);
  4392. }
  4393. }
  4394. sing.IsDel = 1;
  4395. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4396. sing.DeleteUserId = dto.UserId;
  4397. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4398. jw = JsonView(true, "删除成功!");
  4399. return Ok(jw);
  4400. }
  4401. #endregion
  4402. #region 团组英文资料
  4403. /// <summary>
  4404. /// 查询团组英文所有资料
  4405. /// </summary>
  4406. /// <param name="dto"></param>
  4407. /// <returns></returns>
  4408. [HttpPost]
  4409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4410. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4411. {
  4412. try
  4413. {
  4414. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4415. if (groupData.Code != 0)
  4416. {
  4417. return Ok(JsonView(false, groupData.Msg));
  4418. }
  4419. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4420. }
  4421. catch (Exception ex)
  4422. {
  4423. return Ok(JsonView(false, "程序错误!"));
  4424. throw;
  4425. }
  4426. }
  4427. /// <summary>
  4428. /// 团组英文资料操作(Status:1.新增,2.修改)
  4429. /// </summary>
  4430. /// <param name="dto"></param>
  4431. /// <returns></returns>
  4432. [HttpPost]
  4433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4434. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4435. {
  4436. try
  4437. {
  4438. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4439. if (groupData.Code != 0)
  4440. {
  4441. return Ok(JsonView(false, groupData.Msg));
  4442. }
  4443. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4444. }
  4445. catch (Exception ex)
  4446. {
  4447. return Ok(JsonView(false, "程序错误!"));
  4448. throw;
  4449. }
  4450. }
  4451. /// <summary>
  4452. /// 团组英文资料Id查询数据
  4453. /// </summary>
  4454. /// <param name="dto"></param>
  4455. /// <returns></returns>
  4456. [HttpPost]
  4457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4458. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4459. {
  4460. try
  4461. {
  4462. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4463. if (_DelegationEnData != null)
  4464. {
  4465. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4466. }
  4467. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4468. }
  4469. catch (Exception ex)
  4470. {
  4471. return Ok(JsonView(false, "程序错误!"));
  4472. throw;
  4473. }
  4474. }
  4475. /// <summary>
  4476. /// 团组英文资料删除
  4477. /// </summary>
  4478. /// <param name="dto"></param>
  4479. /// <returns></returns>
  4480. [HttpPost]
  4481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4482. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4483. {
  4484. try
  4485. {
  4486. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4487. if (!res)
  4488. {
  4489. return Ok(JsonView(false, "删除失败"));
  4490. }
  4491. return Ok(JsonView(true, "删除成功!"));
  4492. }
  4493. catch (Exception ex)
  4494. {
  4495. return Ok(JsonView(false, "程序错误!"));
  4496. throw;
  4497. }
  4498. }
  4499. #endregion
  4500. #region 导出邀请函
  4501. /// <summary>
  4502. /// 导出邀请函页面初始化
  4503. /// </summary>
  4504. /// <param name="dto"></param>
  4505. /// <returns></returns>
  4506. [HttpPost]
  4507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4508. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4509. {
  4510. try
  4511. {
  4512. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4513. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4514. if (dto.DiId == 0)
  4515. {
  4516. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4517. }
  4518. else
  4519. {
  4520. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4521. }
  4522. return Ok(JsonView(true, "查询成功!", new
  4523. {
  4524. deleClient = crm_Deles,
  4525. delegations = grp_Delegations
  4526. }));
  4527. }
  4528. catch (Exception ex)
  4529. {
  4530. return Ok(JsonView(false, "程序错误!"));
  4531. throw;
  4532. }
  4533. }
  4534. /// <summary>
  4535. /// 导出邀请函
  4536. /// </summary>
  4537. /// <param name="dto"></param>
  4538. /// <returns></returns>
  4539. [HttpPost]
  4540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4541. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4542. {
  4543. #region 参数验证
  4544. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4545. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4546. #endregion
  4547. try
  4548. {
  4549. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4550. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4551. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4552. From Grp_TourClientList tcl
  4553. Left Join
  4554. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4555. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4556. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4557. From Crm_DeleClient dc
  4558. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4559. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4560. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4561. Where dc.IsDel = 0) temp
  4562. On temp.DcId =tcl.ClientId
  4563. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4564. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4565. List<string> texts = new List<string>();
  4566. if (datas.Count != 0)
  4567. {
  4568. foreach (TourClientListDetailsView item in datas)
  4569. {
  4570. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4571. {
  4572. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4573. }
  4574. else
  4575. {
  4576. string name = item.LastName + item.FirstName;
  4577. texts.Add(name);
  4578. }
  4579. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4580. {
  4581. if (!transDic.ContainsKey(item.Job))
  4582. {
  4583. texts.Add(item.Job);
  4584. }
  4585. }
  4586. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4587. {
  4588. texts.Add(item.CompanyFullName);
  4589. }
  4590. }
  4591. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4592. if (transData.Count > 0)
  4593. {
  4594. foreach (TranslateResult item in transData)
  4595. {
  4596. if (!transDic.ContainsKey(item.Query))
  4597. {
  4598. transDic.Add(item.Query, item.Translation);
  4599. }
  4600. }
  4601. }
  4602. List<GuestList> list = new List<GuestList>();
  4603. foreach (TourClientListDetailsView dele in datas)
  4604. {
  4605. GuestList guestList = new GuestList();
  4606. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4607. {
  4608. guestList.Name = dele.Pinyin;
  4609. }
  4610. else
  4611. {
  4612. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4613. guestList.Name = Name;
  4614. }
  4615. if (dele.Sex == 0)
  4616. {
  4617. guestList.Sex = "Male";
  4618. }
  4619. else if (dele.Sex == 1)
  4620. {
  4621. guestList.Sex = "Female";
  4622. }
  4623. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4624. if (!string.IsNullOrEmpty(dele.Job))
  4625. {
  4626. guestList.Job = dele.Job;
  4627. }
  4628. list.Add(guestList);
  4629. }
  4630. //载入模板
  4631. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4632. DocumentBuilder builder = new DocumentBuilder(doc);
  4633. //获取word里所有表格
  4634. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4635. //获取所填表格的序数
  4636. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4637. var rowStart = tableOne.Rows[0]; //获取第1行
  4638. //循环赋值
  4639. for (int i = 0; i < list.Count; i++)
  4640. {
  4641. builder.MoveToCell(0, i + 1, 0, 0);
  4642. builder.Write(list[i].Name.ToString());
  4643. builder.MoveToCell(0, i + 1, 1, 0);
  4644. builder.Write(list[i].Sex.ToString());
  4645. builder.MoveToCell(0, i + 1, 2, 0);
  4646. builder.Write(list[i].DOB.ToString());
  4647. builder.MoveToCell(0, i + 1, 3, 0);
  4648. builder.Write(list[i].Job.ToString());
  4649. }
  4650. //删除多余行
  4651. while (tableOne.Rows.Count > list.Count + 1)
  4652. {
  4653. tableOne.Rows.RemoveAt(list.Count + 1);
  4654. }
  4655. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4656. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4657. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4658. doc.Save(filePath);
  4659. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4660. return Ok(JsonView(true, "操作成功!", Url));
  4661. }
  4662. else
  4663. {
  4664. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4665. }
  4666. }
  4667. catch (Exception ex)
  4668. {
  4669. return Ok(JsonView(false, ex.Message));
  4670. throw;
  4671. }
  4672. }
  4673. #endregion
  4674. #region 团组经理模块 出入境费用
  4675. /// <summary>
  4676. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4677. /// </summary>
  4678. /// <returns></returns>
  4679. [HttpPost]
  4680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4681. public async Task<IActionResult> SetDayAndCostAreaChange()
  4682. {
  4683. try
  4684. {
  4685. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4686. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4687. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4688. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4689. foreach (var item in unite) //处理交集数据
  4690. {
  4691. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4692. }
  4693. foreach (var item in merge) //处理差集数据
  4694. {
  4695. int nationalTravelFeeId = 0;
  4696. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4697. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4698. else
  4699. {
  4700. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4701. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4702. }
  4703. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4704. }
  4705. //只更新dayAndCost 的 nationalTravelFeeId;
  4706. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4707. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4708. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4709. }
  4710. catch (Exception ex)
  4711. {
  4712. return Ok(JsonView(false, ex.Message));
  4713. throw;
  4714. }
  4715. }
  4716. /// <summary>
  4717. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4718. /// </summary>
  4719. /// <returns></returns>
  4720. [HttpPost]
  4721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4722. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4723. {
  4724. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4725. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4726. //SetDataInfoView
  4727. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4728. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4729. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4730. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4731. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4732. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4733. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4734. //默认币种显示
  4735. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4736. {
  4737. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4738. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4739. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4740. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4741. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4742. };
  4743. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4744. if (_currencyRate.Count > 0)
  4745. {
  4746. foreach (var item in _currencyInfos)
  4747. {
  4748. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4749. if (rateInfo != null)
  4750. {
  4751. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4752. rate1 *= 1.035M;
  4753. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4754. }
  4755. }
  4756. }
  4757. return Ok(JsonView(true, "查询成功!", new
  4758. {
  4759. GroupNameData = groupNameData.Data,
  4760. CurrencyData = _CurrencyData,
  4761. WordTypeData = _WordTypeData,
  4762. ExcelTypeData = _ExcelTypeData,
  4763. CurrencyInit = _currencyInfos
  4764. }));
  4765. }
  4766. /// <summary>
  4767. /// 团组模块 - 出入境费用
  4768. /// 实时汇率 tips
  4769. /// 签证费用 tips
  4770. /// 机票费用 tips
  4771. /// </summary>
  4772. /// <returns></returns>
  4773. [HttpPost]
  4774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4775. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4776. {
  4777. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4778. //默认币种显示
  4779. var _currencyInfos = _currencyInit;
  4780. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4781. List<dynamic> reteInfos = new List<dynamic>();
  4782. if (_currencyRate.Count > 0)
  4783. {
  4784. foreach (var item in _currencyInfos)
  4785. {
  4786. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4787. if (rateInfo != null)
  4788. {
  4789. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4790. decimal rate1 = item.Rate;
  4791. rate1 *= 1.03M;
  4792. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4793. reteInfos.Add(new
  4794. {
  4795. currCode = item.CurrencyCode,
  4796. currName = item.CurrencyName,
  4797. rate = rate2,
  4798. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4799. });
  4800. }
  4801. }
  4802. }
  4803. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4804. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4805. return Ok(JsonView(true, "查询成功!", new
  4806. {
  4807. //GroupNameData = groupNameData.Data,
  4808. visaData = visaData.Data,
  4809. airData = airData.Data,
  4810. reteInfos = reteInfos
  4811. }));
  4812. }
  4813. /// <summary>
  4814. /// 团组模块 - 出入境费用 - Info
  4815. /// </summary>
  4816. /// <returns></returns>
  4817. [HttpPost]
  4818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4819. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4820. {
  4821. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4822. }
  4823. /// <summary>
  4824. /// 团组模块 - 出入境费用 - Add And Update
  4825. /// </summary>
  4826. /// <returns></returns>
  4827. [HttpPost]
  4828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4829. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4830. {
  4831. try
  4832. {
  4833. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4834. if (dto.DayOtherPriceData.Any())
  4835. {
  4836. var inserList = dto.DayOtherPriceData
  4837. .Where(x => x.Id == 0)
  4838. .Select(x => new Grp_DayOtherPrice
  4839. {
  4840. Cost = x.Cost,
  4841. Id = x.Id,
  4842. CreateTime = DateTime.Now,
  4843. CreateUserId = dto.UserId,
  4844. Currency = x.Currency,
  4845. Diid = x.DiId,
  4846. Index = x.Index,
  4847. IsDel = 0,
  4848. SetDataId = x.SetDataId,
  4849. SubTotal = x.SubTotal,
  4850. Remark = x.Remark
  4851. })
  4852. .ToList();
  4853. var updateList = dto.DayOtherPriceData
  4854. .Where(x => x.Id != 0)
  4855. .Select(x => new Grp_DayOtherPrice
  4856. {
  4857. Cost = x.Cost,
  4858. Id = x.Id,
  4859. CreateTime = DateTime.Now,
  4860. CreateUserId = dto.UserId,
  4861. Currency = x.Currency,
  4862. Diid = x.DiId,
  4863. Index = x.Index,
  4864. IsDel = 0,
  4865. SetDataId = x.SetDataId,
  4866. SubTotal = x.SubTotal,
  4867. Remark = x.Remark
  4868. })
  4869. .ToList();
  4870. //添加
  4871. _sqlSugar.BeginTran();
  4872. if (inserList.Any())
  4873. {
  4874. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4875. }
  4876. if (updateList.Any())
  4877. {
  4878. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4879. }
  4880. _sqlSugar.CommitTran();
  4881. }
  4882. if (data.Code != 0)
  4883. {
  4884. return Ok(JsonView(false, data.Msg));
  4885. }
  4886. //生成默认文件pdf并且通知人员
  4887. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4888. {
  4889. DiId = dto.DiId,
  4890. ExportType = 1,
  4891. SubTypeId = 1005
  4892. }, "pdf");
  4893. //发送通知
  4894. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4895. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4896. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4897. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4898. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4899. //汇率信息记录
  4900. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4901. return Ok(JsonView(true, data.Msg, data.Data));
  4902. }
  4903. catch (Exception ex)
  4904. {
  4905. return Ok(JsonView(false, ex.Message));
  4906. }
  4907. }
  4908. /// <summary>
  4909. /// 团组模块 - 出入境费用 - Confirm 费用
  4910. /// </summary>
  4911. /// <returns></returns>
  4912. [HttpPost]
  4913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4914. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4915. {
  4916. //TODO:测试完毕需把对应的用户ID更改
  4917. //1、数据表添加字段
  4918. //2、更改字段接口()
  4919. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4920. //3、确认成功 给财务发送消息
  4921. if (_view.Code == 200)
  4922. {
  4923. if (dto.Type == 1)
  4924. {
  4925. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4926. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4927. }
  4928. }
  4929. return Ok(_view);
  4930. }
  4931. /// <summary>
  4932. /// 团组模块 - 出入境费用 - File downlaod
  4933. /// </summary>
  4934. /// <param name="dto"></param>
  4935. /// <returns></returns>
  4936. [HttpPost]
  4937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4938. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4939. {
  4940. try
  4941. {
  4942. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4943. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4944. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4945. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4946. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4947. 3 团组成员名单 1 团组成员名单", ""));
  4948. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4949. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4950. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4951. //数据源
  4952. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4953. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4954. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4955. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4956. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4957. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4958. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4959. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4960. .Select((x, a, b) => new
  4961. {
  4962. x.Index,
  4963. itemName = a.Name,
  4964. CurrencyStr = b.Name,
  4965. x.Cost,
  4966. x.SubTotal,
  4967. x.Remark
  4968. })
  4969. .OrderBy((x) => x.Index)
  4970. .ToList(); //其他款项费用
  4971. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4972. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4973. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4974. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4975. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4976. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4977. .Select((tcl, dc, cc) => new ClientInfo
  4978. {
  4979. LastName = dc.LastName,
  4980. FirstName = dc.FirstName,
  4981. Sex = dc.Sex,
  4982. Birthday = dc.BirthDay,
  4983. Company = cc.CompanyFullName,
  4984. Job = dc.Job
  4985. })
  4986. .ToList();
  4987. foreach (var item in DeleClientList)
  4988. {
  4989. EncryptionProcessor.DecryptProperties(item);
  4990. }
  4991. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4992. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4993. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4994. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4995. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4996. if (dto.ExportType == 1) //明细表
  4997. {
  4998. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4999. {
  5000. //获取模板
  5001. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5002. //载入模板
  5003. Document doc = new Document(tempPath);
  5004. DocumentBuilder builder = new DocumentBuilder(doc);
  5005. //利用键值对存放数据
  5006. Dictionary<string, string> dic = new Dictionary<string, string>();
  5007. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5008. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5009. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5010. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5011. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5012. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5013. //境内费用(其他费用)
  5014. if (_EnterExitCosts.ChoiceOne == 1)
  5015. {
  5016. string row1_1 = "";
  5017. if (_EnterExitCosts.Visa > 0)
  5018. {
  5019. //insidePayTotal += _EnterExitCosts.Visa;
  5020. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5021. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5022. {
  5023. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5024. }
  5025. }
  5026. string row1_2 = "";
  5027. if (_EnterExitCosts.YiMiao > 0)
  5028. {
  5029. //insidePayTotal += _EnterExitCosts.YiMiao;
  5030. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5031. }
  5032. if (_EnterExitCosts.HeSuan > 0)
  5033. {
  5034. //insidePayTotal += _EnterExitCosts.HeSuan;
  5035. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5036. }
  5037. if (_EnterExitCosts.Service > 0)
  5038. {
  5039. //insidePayTotal += _EnterExitCosts.Service;
  5040. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5041. }
  5042. string row1_3 = "";
  5043. if (_EnterExitCosts.Safe > 0)
  5044. {
  5045. //insidePayTotal += _EnterExitCosts.Safe;
  5046. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5047. }
  5048. if (_EnterExitCosts.Ticket > 0)
  5049. {
  5050. //insidePayTotal += _EnterExitCosts.Ticket;
  5051. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5052. }
  5053. string row1 = "";
  5054. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5055. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5056. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5057. row1 += $"备注:{_EnterExitCosts.Remark}";
  5058. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5059. dic.Add("Row1Str", row1);
  5060. }
  5061. string airTotalStr = string.Empty,
  5062. airPriceStr = string.Empty;
  5063. //经济舱
  5064. if (_EnterExitCosts.SumJJC == 1)
  5065. {
  5066. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5067. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5068. }
  5069. //公务舱
  5070. if (_EnterExitCosts.SumGWC == 1)
  5071. {
  5072. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5073. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5074. }
  5075. //头等舱
  5076. if (_EnterExitCosts.SumTDC == 1)
  5077. {
  5078. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5079. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5080. }
  5081. dic.Add("AirTotalStr", airTotalStr);
  5082. dic.Add("AirPriceStr", airPriceStr);
  5083. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5084. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5085. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5086. int table1Row = 0,
  5087. table2Row = 0,
  5088. table3Row = 0,
  5089. table4Row = 0,
  5090. table5Row = 0;
  5091. //住宿费
  5092. if (_EnterExitCosts.ChoiceThree == 1)
  5093. {
  5094. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5095. table1Row = dac1.Count;
  5096. #region 填充word表格内容
  5097. for (int i = 0; i < dac1.Count; i++)
  5098. {
  5099. Grp_DayAndCost dac = dac1[i];
  5100. if (dac == null) continue;
  5101. builder.MoveToCell(0, i, 0, 0);
  5102. builder.Write("第" + dac.Days.ToString() + "晚:");
  5103. builder.MoveToCell(0, i, 1, 0);
  5104. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5105. //builder.Write(dac.Place == null ? "" : dac.Place);
  5106. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5107. builder.MoveToCell(0, i, 2, 0);
  5108. builder.Write("费用标准:");
  5109. string curr = "";
  5110. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5111. if (currData != null)
  5112. {
  5113. curr = currData.Name;
  5114. }
  5115. builder.MoveToCell(0, i, 3, 0);
  5116. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5117. builder.MoveToCell(0, i, 4, 0);
  5118. builder.Write("费用小计:");
  5119. builder.MoveToCell(0, i, 5, 0);
  5120. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5121. }
  5122. #endregion
  5123. }
  5124. else dic.Add("SubZS", "0.00");
  5125. //删除多余行
  5126. while (table1.Rows.Count > table1Row)
  5127. {
  5128. table1.Rows.RemoveAt(table1Row);
  5129. }
  5130. //伙食费
  5131. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5132. if (_EnterExitCosts.ChoiceFour == 1)
  5133. {
  5134. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5135. table2Row = dac2.Count;
  5136. #region 填充word表格内容
  5137. for (int i = 0; i < dac2.Count; i++)
  5138. {
  5139. Grp_DayAndCost dac = dac2[i];
  5140. if (dac == null) continue;
  5141. builder.MoveToCell(1, i, 0, 0);
  5142. builder.Write("第" + dac.Days.ToString() + "天:");
  5143. builder.MoveToCell(1, i, 1, 0);
  5144. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5145. builder.MoveToCell(1, i, 2, 0);
  5146. builder.Write("费用标准:");
  5147. string curr = "";
  5148. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5149. if (currData != null)
  5150. {
  5151. curr = currData.Name;
  5152. }
  5153. builder.MoveToCell(1, i, 3, 0);
  5154. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5155. builder.MoveToCell(1, i, 4, 0);
  5156. builder.Write("费用小计:");
  5157. builder.MoveToCell(1, i, 5, 0);
  5158. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5159. }
  5160. #endregion
  5161. }
  5162. else dic.Add("SubHS", "0.00");
  5163. //删除多余行
  5164. while (table2.Rows.Count > table2Row)
  5165. {
  5166. table2.Rows.RemoveAt(table2Row);
  5167. }
  5168. //公杂费
  5169. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5170. if (_EnterExitCosts.ChoiceFive == 1)
  5171. {
  5172. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5173. table3Row = dac3.Count;
  5174. #region 填充word表格内容
  5175. for (int i = 0; i < dac3.Count; i++)
  5176. {
  5177. Grp_DayAndCost dac = dac3[i];
  5178. if (dac == null) continue;
  5179. builder.MoveToCell(2, i, 0, 0);
  5180. builder.Write("第" + dac.Days.ToString() + "天:");
  5181. builder.MoveToCell(2, i, 1, 0);
  5182. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5183. builder.MoveToCell(2, i, 2, 0);
  5184. builder.Write("费用标准:");
  5185. string curr = "";
  5186. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5187. if (currData != null)
  5188. {
  5189. curr = currData.Name;
  5190. }
  5191. builder.MoveToCell(2, i, 3, 0);
  5192. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5193. builder.MoveToCell(2, i, 4, 0);
  5194. builder.Write("费用小计:");
  5195. builder.MoveToCell(2, i, 5, 0);
  5196. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5197. }
  5198. //删除多余行
  5199. while (table3.Rows.Count > table3Row)
  5200. {
  5201. table3.Rows.RemoveAt(table3Row);
  5202. }
  5203. #endregion
  5204. }
  5205. else dic.Add("SubGZF", "0.00");
  5206. //删除多余行
  5207. while (table3.Rows.Count > table3Row)
  5208. {
  5209. table3.Rows.RemoveAt(table3Row);
  5210. }
  5211. //培训费
  5212. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5213. if (_EnterExitCosts.ChoiceSix == 1)
  5214. {
  5215. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5216. dic.Add("SubPX", pxStr);
  5217. table4Row = dac4.Count;
  5218. #region 填充word表格内容
  5219. for (int i = 0; i < dac4.Count; i++)
  5220. {
  5221. Grp_DayAndCost dac = dac4[i];
  5222. if (dac == null) continue;
  5223. builder.MoveToCell(3, i, 0, 0);
  5224. builder.Write("第" + dac.Days.ToString() + "天:");
  5225. builder.MoveToCell(3, i, 1, 0);
  5226. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5227. builder.MoveToCell(3, i, 2, 0);
  5228. builder.Write("费用标准:");
  5229. string curr = "";
  5230. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5231. if (currData != null)
  5232. {
  5233. curr = currData.Name;
  5234. }
  5235. builder.MoveToCell(3, i, 3, 0);
  5236. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5237. builder.MoveToCell(3, i, 4, 0);
  5238. builder.Write("费用小计:");
  5239. builder.MoveToCell(3, i, 5, 0);
  5240. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5241. }
  5242. #endregion
  5243. }
  5244. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5245. //删除多余行
  5246. while (table4.Rows.Count > table4Row)
  5247. {
  5248. table4.Rows.RemoveAt(table4Row);
  5249. }
  5250. //其他费用
  5251. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5252. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5253. {
  5254. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5255. dic.Add("titleQi", qtStr);
  5256. table5Row = dac5.Count;
  5257. #region 填充word表格内容
  5258. for (int i = 0; i < dac5.Count; i++)
  5259. {
  5260. var dac = dac5[i];
  5261. if (dac == null) continue;
  5262. builder.MoveToCell(4, i, 0, 0);
  5263. builder.Write("第" + dac.Index.ToString() + "项:");
  5264. builder.MoveToCell(4, i, 1, 0);
  5265. builder.Write(dac.itemName);
  5266. builder.MoveToCell(4, i, 2, 0);
  5267. builder.Write("费用标准:");
  5268. builder.MoveToCell(4, i, 3, 0);
  5269. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5270. builder.MoveToCell(4, i, 4, 0);
  5271. builder.Write("费用小计:");
  5272. builder.MoveToCell(4, i, 5, 0);
  5273. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5274. builder.MoveToCell(4, i, 6, 0);
  5275. builder.Write("备注:");
  5276. builder.MoveToCell(4, i, 7, 0);
  5277. builder.Write(dac.Remark);
  5278. }
  5279. #endregion
  5280. }
  5281. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5282. //删除多余行
  5283. while (table5.Rows.Count > table5Row)
  5284. {
  5285. table5.Rows.RemoveAt(table5Row);
  5286. }
  5287. //加上其他费用
  5288. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5289. decimal subJJC = 0.00M,
  5290. subGWC = 0.00M,
  5291. subTDC = 0.00M;
  5292. //经济舱
  5293. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5294. //公务舱
  5295. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5296. //头等舱
  5297. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5298. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5299. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5300. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5301. #region 填充word模板书签内容
  5302. foreach (var key in dic.Keys)
  5303. {
  5304. Bookmark bookmark = doc.Range.Bookmarks[key];
  5305. if (bookmark != null)
  5306. {
  5307. builder.MoveToBookmark(key);
  5308. builder.Write(dic[key]);
  5309. }
  5310. }
  5311. #endregion
  5312. //文件名
  5313. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5314. AsposeHelper.removewatermark_v2180();
  5315. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5316. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5317. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5318. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5319. }
  5320. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5321. {
  5322. //获取模板
  5323. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5324. //载入模板
  5325. Document doc = new Document(tempPath);
  5326. DocumentBuilder builder = new DocumentBuilder(doc);
  5327. Dictionary<string, string> dic = new Dictionary<string, string>();
  5328. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5329. {
  5330. List<string> list = new List<string>();
  5331. try
  5332. {
  5333. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5334. foreach (var item in spilitArr)
  5335. {
  5336. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5337. var depCode = spDotandEmpty[2].Substring(0, 3);
  5338. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5339. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5340. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5341. list.Add(depName);
  5342. list.Add(arrName);
  5343. }
  5344. list = list.Distinct().ToList();
  5345. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5346. }
  5347. catch (Exception)
  5348. {
  5349. dic.Add("ReturnCode", "行程录入不正确!");
  5350. }
  5351. }
  5352. else
  5353. {
  5354. dic.Add("ReturnCode", "未录入行程!");
  5355. }
  5356. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5357. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5358. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5359. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5360. {
  5361. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5362. dic.Add("Day", sp.Days.ToString());
  5363. }
  5364. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5365. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5366. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5367. //dic.Add("Names", Names);
  5368. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5369. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5370. decimal dac1totalPrice = 0.00M;
  5371. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5372. foreach (var dac in dac1)
  5373. {
  5374. if (dac.SubTotal == 0.00M)
  5375. {
  5376. continue;
  5377. }
  5378. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5379. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5380. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5381. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5382. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5383. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5384. builder.Write(currency);//币种
  5385. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5386. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5387. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5388. builder.Write("");//人数
  5389. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5390. builder.Write("");//天数
  5391. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5392. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5393. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5394. decimal rate = 0.00M;
  5395. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5396. builder.Write(rate.ToString("#0.0000"));//汇率
  5397. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5398. decimal rbmPrice = dac.SubTotal;
  5399. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5400. accommodationStartIndex++;
  5401. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5402. }
  5403. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5404. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5405. {
  5406. table1.Rows.RemoveAt(i - 1);
  5407. foodandotherStartIndex--;
  5408. }
  5409. if (dac2.Count == dac3.Count)//国家 币种 金额
  5410. {
  5411. for (int i = 0; i < dac2.Count; i++)
  5412. {
  5413. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5414. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5415. }
  5416. }
  5417. decimal dac2totalPrice = 0.00M;
  5418. foreach (var dac in dac2)
  5419. {
  5420. if (dac.SubTotal == 0)
  5421. {
  5422. continue;
  5423. }
  5424. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5425. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5426. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5427. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5428. builder.Write(currency);//币种
  5429. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5430. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5431. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5432. builder.Write("");//人数
  5433. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5434. builder.Write("");//天数
  5435. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5436. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5437. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5438. decimal rate = 0.00M;
  5439. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5440. builder.Write(rate.ToString("#0.0000"));//汇率
  5441. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5442. decimal rbmPrice = dac.SubTotal;
  5443. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5444. foodandotherStartIndex++;
  5445. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5446. }
  5447. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5448. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5449. {
  5450. table1.Rows.RemoveAt(i - 1);
  5451. }
  5452. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5453. string otherFeeStr = "";
  5454. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5455. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5456. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5457. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5458. foreach (var otherInfo in dac5)
  5459. {
  5460. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5461. }
  5462. #endregion
  5463. if (otherFeeStr.Length > 0)
  5464. {
  5465. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5466. otherFeeStr = $"({otherFeeStr})";
  5467. dic.Add("OtherFeeStr", otherFeeStr);
  5468. }
  5469. //总计
  5470. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5471. //国际旅费
  5472. string outsideAir = string.Empty;
  5473. string allPriceAir = string.Empty;
  5474. if (_EnterExitCosts.SumJJC == 1)
  5475. {
  5476. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5477. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5478. }
  5479. if (_EnterExitCosts.SumGWC == 1)
  5480. {
  5481. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5482. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5483. }
  5484. if (_EnterExitCosts.SumTDC == 1)
  5485. {
  5486. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5487. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5488. }
  5489. dic.Add("InTravelPrice", $"({outsideAir})");
  5490. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5491. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5492. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5493. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5494. foreach (var key in dic.Keys)
  5495. {
  5496. builder.MoveToBookmark(key);
  5497. builder.Write(dic[key]);
  5498. }
  5499. //模板文件名
  5500. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5501. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5502. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5503. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5504. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5505. }
  5506. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5507. {
  5508. //获取模板
  5509. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5510. //载入模板
  5511. WorkbookDesigner designer = new WorkbookDesigner();
  5512. designer.Workbook = new Workbook(tempPath);
  5513. Dictionary<string, string> dic = new Dictionary<string, string>();
  5514. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5515. {
  5516. List<string> list = new List<string>();
  5517. try
  5518. {
  5519. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5520. foreach (var item in spilitArr)
  5521. {
  5522. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5523. var depCode = spDotandEmpty[2].Substring(0, 3);
  5524. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5525. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5526. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5527. list.Add(depName);
  5528. list.Add(arrName);
  5529. }
  5530. list = list.Distinct().ToList();
  5531. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5532. }
  5533. catch (Exception)
  5534. {
  5535. dic.Add("ReturnCode", "行程录入不正确!");
  5536. }
  5537. }
  5538. else
  5539. {
  5540. dic.Add("ReturnCode", "未录入行程!");
  5541. }
  5542. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5543. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5544. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5545. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5546. {
  5547. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5548. dic.Add("Day", sp.Days.ToString());
  5549. }
  5550. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5551. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5552. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5553. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5554. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5555. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5556. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5557. designer.SetDataSource("Name", Names);
  5558. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5559. designer.SetDataSource("Day", dic["Day"] + "天");
  5560. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5561. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5562. int startIndex = 10;
  5563. const int startIndexcopy = 10;
  5564. if (dac2.Count == dac3.Count)//国家 币种 金额
  5565. {
  5566. for (int i = 0; i < dac2.Count; i++)
  5567. {
  5568. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5569. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5570. }
  5571. }
  5572. DataTable dtdac1 = new DataTable();
  5573. List<string> place = new List<string>();
  5574. dtdac1.Columns.AddRange(new DataColumn[] {
  5575. new DataColumn(){ ColumnName = "city"},
  5576. new DataColumn(){ ColumnName = "curr"},
  5577. new DataColumn(){ ColumnName = "criterion"},
  5578. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5579. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5580. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5581. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5582. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5583. });
  5584. DataTable dtdac2 = new DataTable();
  5585. dtdac2.Columns.AddRange(new DataColumn[] {
  5586. new DataColumn(){ ColumnName = "city"},
  5587. new DataColumn(){ ColumnName = "curr"},
  5588. new DataColumn(){ ColumnName = "criterion"},
  5589. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5590. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5591. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5592. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5593. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5594. });
  5595. dtdac1.TableName = "tb1";
  5596. dtdac2.TableName = "tb2";
  5597. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5598. foreach (var item in dac1)
  5599. {
  5600. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5601. if (place.Contains(item.Place))
  5602. {
  5603. continue;
  5604. }
  5605. DataRow row = dtdac1.NewRow();
  5606. row["city"] = item.Place;
  5607. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5608. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5609. row["curr"] = currency;
  5610. row["rate"] = rate.ToString("#0.0000");
  5611. row["criterion"] = item.Cost.ToString("#0.00");
  5612. row["number"] = 1;
  5613. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5614. //row["costRMB"] = rbmPrice;
  5615. dtdac1.Rows.Add(row);
  5616. place.Add(item.Place);
  5617. }
  5618. place = new List<string>();
  5619. foreach (var item in dac2)
  5620. {
  5621. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5622. if (place.Contains(item.Place))
  5623. {
  5624. continue;
  5625. }
  5626. DataRow row = dtdac2.NewRow();
  5627. row["city"] = item.Place;
  5628. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5629. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5630. row["curr"] = currency;
  5631. row["rate"] = rate.ToString("#0.0000");
  5632. row["criterion"] = item.Cost.ToString("#0.00");
  5633. row["number"] = 1;
  5634. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5635. //row["cost"] = item.SubTotal;
  5636. //row["costRMB"] = rbmPrice;
  5637. dtdac2.Rows.Add(row);
  5638. place.Add(item.Place);
  5639. //dac2totalPrice += rbmPrice;
  5640. }
  5641. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5642. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5643. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5644. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5645. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5646. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5647. string cell4Str1 = string.Empty;
  5648. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5649. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5650. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5651. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5652. string cellStr = $" 5.其他费用(";
  5653. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5654. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5655. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5656. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5657. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5658. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5659. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5660. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5661. foreach (var otherInfo in dac5)
  5662. {
  5663. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5664. }
  5665. #endregion
  5666. if (cellStr.Length > 8)
  5667. {
  5668. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5669. }
  5670. cellStr += ")";
  5671. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5672. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5673. decimal pxFee = dac4.Sum(it => it.Cost);
  5674. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5675. string celllastStr1 = "";
  5676. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5677. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5678. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5679. celllastStr1 += $",国际旅费 元";
  5680. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5681. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5682. designer.SetDataSource("cell4Str", cell4Str);
  5683. designer.SetDataSource("cellStr", cellStr);
  5684. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5685. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5686. designer.SetDataSource("celllastStr", celllastStr);
  5687. Workbook wb = designer.Workbook;
  5688. var sheet = wb.Worksheets[0];
  5689. //绑定datatable数据集
  5690. designer.SetDataSource(dtdac1);
  5691. designer.SetDataSource(dtdac2);
  5692. designer.Process();
  5693. var rowStart = dtdac1.Rows.Count;
  5694. while (rowStart > 0)
  5695. {
  5696. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5697. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5698. startIndex++;
  5699. rowStart--;
  5700. }
  5701. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5702. startIndex += 1; //总计行
  5703. rowStart = dtdac2.Rows.Count;
  5704. while (rowStart > 0)
  5705. {
  5706. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5707. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5708. startIndex++;
  5709. rowStart--;
  5710. }
  5711. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5712. wb.CalculateFormula(true);
  5713. //模板文件名
  5714. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5715. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5716. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5717. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5718. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5719. }
  5720. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5721. {
  5722. //获取模板
  5723. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5724. //载入模板
  5725. Document doc = new Document(tempPath);
  5726. DocumentBuilder builder = new DocumentBuilder(doc);
  5727. Dictionary<string, string> dic = new Dictionary<string, string>();
  5728. dic.Add("GroupName", _DelegationInfo.TeamName);
  5729. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5730. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5731. string missionLeaderJob = "";//负责人job
  5732. int groupNumber = 0; //团人数
  5733. if (DeleClientList.Count > 0)
  5734. {
  5735. missionLeader = DeleClientList[0]?.Name ?? "";
  5736. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5737. }
  5738. dic.Add("MissionLeader", missionLeader); //团负责人
  5739. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5740. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5741. #region MyRegion
  5742. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5743. //{
  5744. // List<string> list = new List<string>();
  5745. // try
  5746. // {
  5747. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5748. // foreach (var item in spilitArr)
  5749. // {
  5750. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5751. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5752. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5753. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5754. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5755. // list.Add(depName);
  5756. // list.Add(arrName);
  5757. // }
  5758. // list = list.Distinct().ToList();
  5759. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5760. // }
  5761. // catch (Exception)
  5762. // {
  5763. // dic.Add("ReturnCode", "行程录入不正确!");
  5764. // }
  5765. //}
  5766. //else
  5767. //{
  5768. // dic.Add("ReturnCode", "未录入行程!");
  5769. //}
  5770. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5771. dic.Add("ReturnCode", string.Join("、", countrys));
  5772. #endregion
  5773. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5774. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5775. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5776. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5777. //{
  5778. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5779. // dic.Add("Day", sp.Days.ToString());
  5780. //}
  5781. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5782. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5783. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5784. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5785. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5786. //培训人员名单
  5787. int cultivateRowIndex = 7;
  5788. foreach (var item in DeleClientList)
  5789. {
  5790. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5791. builder.Write(item.Name);
  5792. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5793. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5794. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5795. string birthDay = "";
  5796. if (item.Birthday != null)
  5797. {
  5798. DateTime dt = Convert.ToDateTime(item.Birthday);
  5799. birthDay = $"{dt.Year}.{dt.Month}";
  5800. }
  5801. builder.Write(birthDay);
  5802. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5803. builder.Write(item.Company);
  5804. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5805. builder.Write(item.Job);
  5806. cultivateRowIndex++;
  5807. }
  5808. //删除多余行
  5809. //cultivateRowIndex -= 2;
  5810. int delRows = 10 + 7 - cultivateRowIndex;
  5811. if (delRows > 0)
  5812. {
  5813. for (int i = 0; i < delRows; i++)
  5814. {
  5815. table1.Rows.RemoveAt(cultivateRowIndex);
  5816. //cultivateRowIndex++;
  5817. }
  5818. }
  5819. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5820. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5821. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5822. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5823. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5824. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5825. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5826. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5827. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5828. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5829. //其他费用
  5830. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5831. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5832. //其他费用合计
  5833. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5834. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5835. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5836. //公务舱合计
  5837. //国际旅费
  5838. string outsideJJ = "";
  5839. string allPriceJJ = "";
  5840. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5841. {
  5842. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5843. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5844. }
  5845. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5846. {
  5847. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5848. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5849. }
  5850. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5851. {
  5852. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5853. dic.Add("AirFeeTotal", airFeeTotalStr);
  5854. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5855. dic.Add("FeeTotal", feeTotalStr);
  5856. }
  5857. foreach (var key in dic.Keys)
  5858. {
  5859. builder.MoveToBookmark(key);
  5860. builder.Write(dic[key]);
  5861. }
  5862. //模板文件名
  5863. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5864. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5865. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5866. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5867. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5868. }
  5869. }
  5870. else if (dto.ExportType == 2) //表格
  5871. {
  5872. //利用键值对存放数据
  5873. Dictionary<string, string> dic = new Dictionary<string, string>();
  5874. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5875. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5876. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5877. dic.Add("Day", sp.Days.ToString());
  5878. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5879. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5880. {
  5881. //获取模板
  5882. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5883. //载入模板
  5884. Document doc = new Document(tempPath);
  5885. DocumentBuilder builder = new DocumentBuilder(doc);
  5886. dic.Add("TeamName", _DelegationInfo.TeamName);
  5887. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5888. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5889. string missionLeaderName = "",
  5890. missionLeaderJob = "";
  5891. if (DeleClientList.Count > 0)
  5892. {
  5893. missionLeaderName = DeleClientList[0].Name;
  5894. missionLeaderJob = DeleClientList[0].Job;
  5895. }
  5896. dic.Add("MissionLeaderName", missionLeaderName);
  5897. dic.Add("MissionLeaderJob", missionLeaderJob);
  5898. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5899. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5900. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5901. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5902. int rowCount = 10;//总人数行
  5903. int startRowIndex = 7; //起始行
  5904. for (int i = 0; i < DeleClientList.Count; i++)
  5905. {
  5906. builder.MoveToCell(0, startRowIndex, 0, 0);
  5907. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5908. builder.MoveToCell(0, startRowIndex, 1, 0);
  5909. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5910. builder.Write(sex);//性别
  5911. builder.MoveToCell(0, startRowIndex, 2, 0);
  5912. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5913. builder.MoveToCell(0, startRowIndex, 3, 0);
  5914. builder.Write(DeleClientList[i].Company);//工作单位
  5915. builder.MoveToCell(0, startRowIndex, 4, 0);
  5916. builder.Write(DeleClientList[i].Job);//职务及级别
  5917. builder.MoveToCell(0, startRowIndex, 5, 0);
  5918. builder.Write("");//人员属性
  5919. builder.MoveToCell(0, startRowIndex, 6, 0);
  5920. builder.Write("");//上次出国时间
  5921. startRowIndex++;
  5922. }
  5923. int nullRow = rowCount - DeleClientList.Count;//空行
  5924. for (int i = 0; i < nullRow; i++)
  5925. {
  5926. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5927. }
  5928. foreach (var key in dic.Keys)
  5929. {
  5930. builder.MoveToBookmark(key);
  5931. builder.Write(dic[key]);
  5932. }
  5933. //模板文件名
  5934. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5935. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5936. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5937. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5938. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5939. }
  5940. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5941. {
  5942. //获取模板
  5943. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5944. //载入模板
  5945. Document doc = new Document(tempPath);
  5946. DocumentBuilder builder = new DocumentBuilder(doc);
  5947. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5948. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5949. dic.Add("Names", Names);
  5950. int accommodationRows = 12, foodandotherRows = 12;
  5951. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5952. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5953. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5954. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5955. int accommodationStartIndex = 6;
  5956. decimal dac1totalPrice = 0.00M;
  5957. foreach (var dac in dac1)
  5958. {
  5959. if (dac.SubTotal == 0)
  5960. {
  5961. continue;
  5962. }
  5963. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5964. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5965. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5966. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5967. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5968. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5969. builder.Write(currency);//币种
  5970. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5971. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5972. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5973. builder.Write("");//人数
  5974. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5975. builder.Write("");//天数
  5976. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5977. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5978. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5979. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5980. builder.Write(rate.ToString("#0.0000"));//汇率
  5981. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5982. decimal rbmPrice = rate * dac.SubTotal;
  5983. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5984. accommodationStartIndex++;
  5985. dac1totalPrice += rbmPrice;
  5986. }
  5987. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5988. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5989. builder.Write("小计");
  5990. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5991. builder.Write(dac1totalPrice.ToString("#0.00"));
  5992. accommodationStartIndex++;
  5993. int nullRow = accommodationRows - dac1.Count;
  5994. //删除空行
  5995. //if (nullRow > 0)
  5996. //{
  5997. // int rowIndex = accommodationStartIndex;
  5998. // for (int i = 0; i < nullRow; i++)
  5999. // {
  6000. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6001. // row.Remove();
  6002. // rowIndex++;
  6003. // }
  6004. //}
  6005. if (dac2.Count == dac3.Count)//国家 币种 金额
  6006. {
  6007. for (int i = 0; i < dac2.Count; i++)
  6008. {
  6009. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6010. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6011. }
  6012. }
  6013. int foodandotherStartIndex = 19;//
  6014. decimal dac2totalPrice = 0.00M;
  6015. foreach (var dac in dac2)
  6016. {
  6017. if (dac.SubTotal == 0)
  6018. {
  6019. continue;
  6020. }
  6021. //foodandotherStartIndex = 12;
  6022. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6023. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6024. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6025. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6026. builder.Write(currency);//币种
  6027. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6028. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6029. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6030. builder.Write("");//人数
  6031. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6032. builder.Write("");//天数
  6033. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6034. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6035. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6036. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6037. builder.Write(rate.ToString("#0.0000"));//汇率
  6038. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6039. decimal rbmPrice = rate * dac.SubTotal;
  6040. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6041. foodandotherStartIndex++;
  6042. dac2totalPrice += rbmPrice;
  6043. }
  6044. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6045. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6046. //删除空行
  6047. //if (dac2.Count < foodandotherRows)
  6048. //{
  6049. // while (table2.Rows.Count > dac2.Count)
  6050. // {
  6051. // table2.Rows.RemoveAt(dac2.Count);
  6052. // }
  6053. //}
  6054. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6055. string otherFeeStr = "";
  6056. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6057. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6058. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6059. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6060. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6061. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6062. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6063. foreach (var otherInfo in dac5)
  6064. {
  6065. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6066. }
  6067. #endregion
  6068. if (otherFeeStr.Length > 0)
  6069. {
  6070. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6071. otherFeeStr = $"({otherFeeStr})";
  6072. dic.Add("OtherFeeStr", otherFeeStr);
  6073. }
  6074. foreach (var key in dic.Keys)
  6075. {
  6076. builder.MoveToBookmark(key);
  6077. builder.Write(dic[key]);
  6078. }
  6079. //模板文件名
  6080. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6081. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6082. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6083. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6084. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6085. }
  6086. }
  6087. else if (dto.ExportType == 3)
  6088. {
  6089. if (dto.SubTypeId == 1) //团组成员名单
  6090. {
  6091. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6092. //获取模板
  6093. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6094. //载入模板
  6095. Document doc = new Document(tempPath);
  6096. DocumentBuilder builder = new DocumentBuilder(doc);
  6097. //获取word里所有表格
  6098. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6099. //获取所填表格的序数
  6100. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6101. var rowStart = tableOne.Rows[0]; //获取第1行
  6102. //循环赋值
  6103. for (int i = 0; i < DeleClientList.Count; i++)
  6104. {
  6105. builder.MoveToCell(0, i + 1, 0, 0);
  6106. builder.Write(DeleClientList[i].Name);
  6107. builder.MoveToCell(0, i + 1, 1, 0);
  6108. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6109. builder.Write(sex);
  6110. builder.MoveToCell(0, i + 1, 2, 0);
  6111. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6112. builder.MoveToCell(0, i + 1, 3, 0);
  6113. builder.Write(DeleClientList[i].Company);
  6114. builder.MoveToCell(0, i + 1, 4, 0);
  6115. builder.Write(DeleClientList[i].Job);
  6116. }
  6117. //删除多余行
  6118. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6119. {
  6120. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6121. }
  6122. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6123. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6124. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6125. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6126. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6127. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6128. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6129. }
  6130. }
  6131. return Ok(JsonView(400, "操作失败!", ""));
  6132. }
  6133. catch (Exception ex)
  6134. {
  6135. return Ok(JsonView(400, ex.Message, ""));
  6136. }
  6137. }
  6138. /// <summary>
  6139. /// 获取三公费用标准city
  6140. /// </summary>
  6141. /// <param name="placeData"></param>
  6142. /// <param name="nationalTravelFeeId"></param>
  6143. /// <returns></returns>
  6144. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6145. {
  6146. string _city = string.Empty;
  6147. if (placeData.Count < 1) return _city;
  6148. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6149. if (data == null) return _city;
  6150. string country = data.Country;
  6151. string city = data.City;
  6152. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6153. else _city = city;
  6154. return _city;
  6155. }
  6156. /// <summary>
  6157. /// 团组模块 - 出入境费用 - 明细表导出
  6158. /// </summary>
  6159. /// <returns></returns>
  6160. [HttpPost]
  6161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6162. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6163. {
  6164. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6165. if (data.Code != 0)
  6166. {
  6167. return Ok(JsonView(false, data.Msg));
  6168. }
  6169. return Ok(JsonView(true, data.Msg, data.Data));
  6170. }
  6171. /// <summary>
  6172. /// 团组模块 - 出入境费用 - 一键清空
  6173. /// </summary>
  6174. /// <returns></returns>
  6175. [HttpPost]
  6176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6177. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6178. {
  6179. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6180. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6181. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6182. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6183. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6184. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6185. .SetColumns(x => new Grp_DayOtherPrice
  6186. {
  6187. IsDel = 1,
  6188. DeleteUserId = dto.UserId,
  6189. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6190. })
  6191. .ExecuteCommandAsync();
  6192. if (_view.Code == 0)
  6193. {
  6194. return Ok(JsonView(true, "操作成功"));
  6195. }
  6196. return Ok(JsonView(false, "操作失败"));
  6197. }
  6198. /// <summary>
  6199. /// 团组模块 - 出入境费用 - 子项删除
  6200. /// </summary>
  6201. /// <returns></returns>
  6202. [HttpPost]
  6203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6204. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6205. {
  6206. try
  6207. {
  6208. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6209. if (data.Code != 0)
  6210. {
  6211. return Ok(JsonView(false, data.Msg));
  6212. }
  6213. return Ok(JsonView(true, "操作成功!", data.Data));
  6214. }
  6215. catch (Exception ex)
  6216. {
  6217. return Ok(JsonView(false, ex.Message));
  6218. }
  6219. }
  6220. /// <summary>
  6221. /// 删除三公其他费用
  6222. /// </summary>
  6223. /// <param name="dto"></param>
  6224. /// <returns></returns>
  6225. [HttpPost]
  6226. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6227. {
  6228. var jw = JsonView(false,"删除失败!");
  6229. var data = new Grp_DayOtherPrice()
  6230. {
  6231. Id = dto.Id,
  6232. IsDel = 1,
  6233. DeleteUserId = dto.DeleteUserId,
  6234. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6235. };
  6236. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6237. if (del > 0)
  6238. {
  6239. jw.Code = 200;
  6240. jw.Msg = "删除成功!";
  6241. }
  6242. return Ok(jw);
  6243. }
  6244. /// <summary>
  6245. /// 团组模块 - 出入境国家费用标准 List
  6246. /// </summary>
  6247. /// <returns></returns>
  6248. [HttpPost]
  6249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6250. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6251. {
  6252. try
  6253. {
  6254. Stopwatch sw = new Stopwatch();
  6255. sw.Start();
  6256. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6257. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6258. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6259. Where gntf.Isdel = 0");
  6260. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6261. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6262. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6263. //foreach (var item in nationalTravel)
  6264. //{
  6265. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6266. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6267. // if (otherData != null)
  6268. // {
  6269. // cityData.Remove(otherData);
  6270. // cityData.Add(otherData);
  6271. // }
  6272. // nationalTravelFeeData1.Add(new
  6273. // {
  6274. // Country = item.Country,
  6275. // CityData = cityData
  6276. // });
  6277. //}
  6278. sw.Stop();
  6279. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6280. }
  6281. catch (Exception ex)
  6282. {
  6283. return Ok(JsonView(false, ex.Message));
  6284. throw;
  6285. }
  6286. }
  6287. /// <summary>
  6288. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6289. /// </summary>
  6290. /// <returns></returns>
  6291. [HttpPost]
  6292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6293. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6294. {
  6295. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6296. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6297. List<string> countryData = new List<string>();
  6298. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6299. countryData = countryData.Distinct().ToList();
  6300. List<dynamic> dataSource = new List<dynamic>();
  6301. foreach (var item in countryData)
  6302. {
  6303. List<string> cityData1 = new List<string>();
  6304. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6305. var countryData2 = new
  6306. {
  6307. CountryName = item,
  6308. CityData = cityData1
  6309. };
  6310. dataSource.Add(countryData2);
  6311. }
  6312. return Ok(JsonView(true, "查询成功!", dataSource));
  6313. }
  6314. /// <summary>
  6315. /// 团组模块 - 出入境国家费用标准 Page List
  6316. /// </summary>
  6317. /// <returns></returns>
  6318. [HttpPost]
  6319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6320. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6321. {
  6322. int portId = dto.PortType;
  6323. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6324. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6325. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6326. string whereSql = string.Empty;
  6327. if (!string.IsNullOrEmpty(dto.Country))
  6328. {
  6329. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6330. }
  6331. if (!string.IsNullOrEmpty(dto.City))
  6332. {
  6333. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6334. }
  6335. string pageSql = string.Format(@"Select * From (
  6336. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6337. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6338. From Grp_NationalTravelFee gntf
  6339. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6340. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6341. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6342. RefAsync<int> total = 0;
  6343. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6344. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6345. }
  6346. /// <summary>
  6347. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6348. /// </summary>
  6349. /// <returns></returns>
  6350. [HttpPost]
  6351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6352. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6353. {
  6354. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6355. int portId = dto.PortType;
  6356. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6357. string whereSql = string.Empty;
  6358. if (!string.IsNullOrEmpty(dto.Country))
  6359. {
  6360. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6361. }
  6362. if (!string.IsNullOrEmpty(dto.City))
  6363. {
  6364. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6365. }
  6366. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6367. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6368. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6369. From Grp_NationalTravelFee gntf
  6370. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6371. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6372. Where gntf.Isdel = 0 {0} ", whereSql);
  6373. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6374. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6375. }
  6376. /// <summary>
  6377. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6378. /// </summary>
  6379. /// <returns></returns>
  6380. [HttpPost]
  6381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6382. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6383. {
  6384. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6385. if (data.Code != 0)
  6386. {
  6387. return Ok(JsonView(false, data.Msg));
  6388. }
  6389. return Ok(JsonView(true, "操作成功!", data.Data));
  6390. }
  6391. /// <summary>
  6392. /// 团组模块 - 出入境国家费用标准 - Del
  6393. /// </summary>
  6394. /// <returns></returns>
  6395. [HttpPost]
  6396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6397. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6398. {
  6399. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6400. {
  6401. Id = dto.Id,
  6402. DeleteUserId = dto.DeleteUserId,
  6403. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6404. IsDel = 1
  6405. };
  6406. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6407. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6408. .WhereColumns(it => new { it.Id })
  6409. .ExecuteCommandAsync();
  6410. if (delStatus <= 0)
  6411. {
  6412. return Ok(JsonView(false, "删除失败!"));
  6413. }
  6414. return Ok(JsonView(true, "操作成功!"));
  6415. }
  6416. /// <summary>
  6417. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6418. /// 注:Get 请求Headers 加 Token
  6419. /// </summary>
  6420. /// <param name="groupId"></param>
  6421. /// <returns></returns>
  6422. [HttpGet("{groupId}")]
  6423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6424. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6425. {
  6426. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6427. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6428. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6429. data.ForEach(x =>
  6430. {
  6431. x.CreateUserId = _currUserInfo.UserId;
  6432. });
  6433. if (data.Any())
  6434. {
  6435. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6436. if (add > 0)
  6437. {
  6438. return Ok(JsonView(true, "操作成功!"));
  6439. }
  6440. }
  6441. return Ok(JsonView(false, "未操作!"));
  6442. }
  6443. #endregion
  6444. #region 团组经理模块 出入境费用-草稿
  6445. /// <summary>
  6446. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6447. /// </summary>
  6448. /// <returns></returns>
  6449. [HttpPost]
  6450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6451. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6452. {
  6453. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6454. .Where(x => x.IsDel == 0)
  6455. .OrderByDescending(x => x.CreateTime)
  6456. .Select(x => new { x.Id, x.DraftName })
  6457. .ToListAsync();
  6458. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6459. //SetDataInfoView
  6460. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6461. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6462. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6463. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6464. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6465. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6466. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6467. //默认币种显示
  6468. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6469. {
  6470. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6471. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6472. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6473. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6474. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6475. };
  6476. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6477. if (_currencyRate.Count > 0)
  6478. {
  6479. foreach (var item in _currencyInfos)
  6480. {
  6481. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6482. if (rateInfo != null)
  6483. {
  6484. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6485. rate1 *= 1.035M;
  6486. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6487. }
  6488. }
  6489. }
  6490. return Ok(JsonView(true, "查询成功!", new
  6491. {
  6492. DraftNameDatas = draftNameDatas,
  6493. CurrencyData = _CurrencyData,
  6494. WordTypeData = _WordTypeData,
  6495. ExcelTypeData = _ExcelTypeData,
  6496. CurrencyInit = _currencyInfos
  6497. }));
  6498. }
  6499. /// <summary>
  6500. /// 团组模块 - 出入境费用-草稿
  6501. /// 实时汇率 tips
  6502. /// 签证费用 tips
  6503. /// 机票费用 tips
  6504. /// </summary>
  6505. /// <returns></returns>
  6506. [HttpPost]
  6507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6508. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6509. {
  6510. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6511. //默认币种显示
  6512. var _currencyInfos = _currencyInit;
  6513. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6514. List<dynamic> reteInfos = new List<dynamic>();
  6515. if (_currencyRate.Count > 0)
  6516. {
  6517. foreach (var item in _currencyInfos)
  6518. {
  6519. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6520. if (rateInfo != null)
  6521. {
  6522. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6523. decimal rate1 = item.Rate;
  6524. rate1 *= 1.03M;
  6525. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6526. reteInfos.Add(new
  6527. {
  6528. currCode = item.CurrencyCode,
  6529. currName = item.CurrencyName,
  6530. rate = rate2,
  6531. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6532. });
  6533. }
  6534. }
  6535. }
  6536. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6537. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6538. return Ok(JsonView(true, "查询成功!", new
  6539. {
  6540. //GroupNameData = groupNameData.Data,
  6541. //visaData = visaData.Data,
  6542. //airData = airData.Data,
  6543. reteInfos = reteInfos
  6544. }));
  6545. }
  6546. /// <summary>
  6547. /// 团组模块 - 出入境费用-草稿 - Info
  6548. /// </summary>
  6549. /// <returns></returns>
  6550. [HttpPost]
  6551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6552. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6553. {
  6554. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6555. }
  6556. /// <summary>
  6557. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6558. /// </summary>
  6559. /// <returns></returns>
  6560. [HttpPost]
  6561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6562. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6563. {
  6564. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6565. if (data.Code != 0)
  6566. {
  6567. return Ok(JsonView(false, data.Msg));
  6568. }
  6569. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6570. //汇率信息记录
  6571. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6572. return Ok(JsonView(true, data.Msg, data.Data));
  6573. }
  6574. /// <summary>
  6575. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6576. /// </summary>
  6577. /// <param name="dto"></param>
  6578. /// <returns></returns>
  6579. [HttpPost]
  6580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6581. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6582. {
  6583. try
  6584. {
  6585. var id = dto.Id;
  6586. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6587. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6588. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6589. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6590. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6591. 3 团组成员名单 1 团组成员名单", ""));
  6592. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6593. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6594. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6595. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6596. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6597. //数据源
  6598. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6599. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6600. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6601. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6602. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6603. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6604. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6605. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6606. .Select((x, a, b) => new
  6607. {
  6608. x.Index,
  6609. itemName = a.Name,
  6610. CurrencyStr = b.Name,
  6611. x.Cost,
  6612. x.SubTotal,
  6613. x.Remark
  6614. })
  6615. .OrderBy((x) => x.Index)
  6616. .ToList(); //其他款项费用
  6617. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6618. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6619. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6620. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6621. if (dto.ExportType == 1) //明细表
  6622. {
  6623. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6624. {
  6625. //获取模板
  6626. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6627. //载入模板
  6628. Document doc = new Document(tempPath);
  6629. DocumentBuilder builder = new DocumentBuilder(doc);
  6630. //利用键值对存放数据
  6631. Dictionary<string, string> dic = new Dictionary<string, string>();
  6632. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6633. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6634. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6635. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6636. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6637. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6638. //境内费用(其他费用)
  6639. if (_EnterExitCosts.ChoiceOne == 1)
  6640. {
  6641. string row1_1 = "";
  6642. if (_EnterExitCosts.Visa > 0)
  6643. {
  6644. //insidePayTotal += _EnterExitCosts.Visa;
  6645. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6646. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6647. {
  6648. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6649. }
  6650. }
  6651. string row1_2 = "";
  6652. if (_EnterExitCosts.YiMiao > 0)
  6653. {
  6654. //insidePayTotal += _EnterExitCosts.YiMiao;
  6655. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6656. }
  6657. if (_EnterExitCosts.HeSuan > 0)
  6658. {
  6659. //insidePayTotal += _EnterExitCosts.HeSuan;
  6660. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6661. }
  6662. if (_EnterExitCosts.Service > 0)
  6663. {
  6664. //insidePayTotal += _EnterExitCosts.Service;
  6665. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6666. }
  6667. string row1_3 = "";
  6668. if (_EnterExitCosts.Safe > 0)
  6669. {
  6670. //insidePayTotal += _EnterExitCosts.Safe;
  6671. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6672. }
  6673. if (_EnterExitCosts.Ticket > 0)
  6674. {
  6675. //insidePayTotal += _EnterExitCosts.Ticket;
  6676. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6677. }
  6678. string row1 = "";
  6679. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6680. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6681. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6682. row1 += $"备注:{_EnterExitCosts.Remark}";
  6683. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6684. dic.Add("Row1Str", row1);
  6685. }
  6686. string airTotalStr = string.Empty,
  6687. airPriceStr = string.Empty;
  6688. //经济舱
  6689. if (_EnterExitCosts.SumJJC == 1)
  6690. {
  6691. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6692. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6693. }
  6694. //公务舱
  6695. if (_EnterExitCosts.SumGWC == 1)
  6696. {
  6697. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6698. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6699. }
  6700. //头等舱
  6701. if (_EnterExitCosts.SumTDC == 1)
  6702. {
  6703. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6704. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6705. }
  6706. dic.Add("AirTotalStr", airTotalStr);
  6707. dic.Add("AirPriceStr", airPriceStr);
  6708. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6709. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6710. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6711. int table1Row = 0,
  6712. table2Row = 0,
  6713. table3Row = 0,
  6714. table4Row = 0,
  6715. table5Row = 0;
  6716. //住宿费
  6717. if (_EnterExitCosts.ChoiceThree == 1)
  6718. {
  6719. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6720. table1Row = dac1.Count;
  6721. #region 填充word表格内容
  6722. for (int i = 0; i < dac1.Count; i++)
  6723. {
  6724. var dac = dac1[i];
  6725. if (dac == null) continue;
  6726. builder.MoveToCell(0, i, 0, 0);
  6727. builder.Write("第" + dac.Days.ToString() + "晚:");
  6728. builder.MoveToCell(0, i, 1, 0);
  6729. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6730. //builder.Write(dac.Place == null ? "" : dac.Place);
  6731. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6732. builder.MoveToCell(0, i, 2, 0);
  6733. builder.Write("费用标准:");
  6734. string curr = "";
  6735. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6736. if (currData != null)
  6737. {
  6738. curr = currData.Name;
  6739. }
  6740. builder.MoveToCell(0, i, 3, 0);
  6741. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6742. builder.MoveToCell(0, i, 4, 0);
  6743. builder.Write("费用小计:");
  6744. builder.MoveToCell(0, i, 5, 0);
  6745. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6746. }
  6747. #endregion
  6748. }
  6749. else dic.Add("SubZS", "0.00");
  6750. //删除多余行
  6751. while (table1.Rows.Count > table1Row)
  6752. {
  6753. table1.Rows.RemoveAt(table1Row);
  6754. }
  6755. //伙食费
  6756. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6757. if (_EnterExitCosts.ChoiceFour == 1)
  6758. {
  6759. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6760. table2Row = dac2.Count;
  6761. #region 填充word表格内容
  6762. for (int i = 0; i < dac2.Count; i++)
  6763. {
  6764. var dac = dac2[i];
  6765. if (dac == null) continue;
  6766. builder.MoveToCell(1, i, 0, 0);
  6767. builder.Write("第" + dac.Days.ToString() + "天:");
  6768. builder.MoveToCell(1, i, 1, 0);
  6769. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6770. builder.MoveToCell(1, i, 2, 0);
  6771. builder.Write("费用标准:");
  6772. string curr = "";
  6773. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6774. if (currData != null)
  6775. {
  6776. curr = currData.Name;
  6777. }
  6778. builder.MoveToCell(1, i, 3, 0);
  6779. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6780. builder.MoveToCell(1, i, 4, 0);
  6781. builder.Write("费用小计:");
  6782. builder.MoveToCell(1, i, 5, 0);
  6783. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6784. }
  6785. #endregion
  6786. }
  6787. else dic.Add("SubHS", "0.00");
  6788. //删除多余行
  6789. while (table2.Rows.Count > table2Row)
  6790. {
  6791. table2.Rows.RemoveAt(table2Row);
  6792. }
  6793. //公杂费
  6794. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6795. if (_EnterExitCosts.ChoiceFive == 1)
  6796. {
  6797. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6798. table3Row = dac3.Count;
  6799. #region 填充word表格内容
  6800. for (int i = 0; i < dac3.Count; i++)
  6801. {
  6802. var dac = dac3[i];
  6803. if (dac == null) continue;
  6804. builder.MoveToCell(2, i, 0, 0);
  6805. builder.Write("第" + dac.Days.ToString() + "天:");
  6806. builder.MoveToCell(2, i, 1, 0);
  6807. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6808. builder.MoveToCell(2, i, 2, 0);
  6809. builder.Write("费用标准:");
  6810. string curr = "";
  6811. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6812. if (currData != null)
  6813. {
  6814. curr = currData.Name;
  6815. }
  6816. builder.MoveToCell(2, i, 3, 0);
  6817. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6818. builder.MoveToCell(2, i, 4, 0);
  6819. builder.Write("费用小计:");
  6820. builder.MoveToCell(2, i, 5, 0);
  6821. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6822. }
  6823. //删除多余行
  6824. while (table3.Rows.Count > table3Row)
  6825. {
  6826. table3.Rows.RemoveAt(table3Row);
  6827. }
  6828. #endregion
  6829. }
  6830. else dic.Add("SubGZF", "0.00");
  6831. //删除多余行
  6832. while (table3.Rows.Count > table3Row)
  6833. {
  6834. table3.Rows.RemoveAt(table3Row);
  6835. }
  6836. //培训费
  6837. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6838. if (_EnterExitCosts.ChoiceSix == 1)
  6839. {
  6840. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6841. dic.Add("SubPX", pxStr);
  6842. table4Row = dac4.Count;
  6843. #region 填充word表格内容
  6844. for (int i = 0; i < dac4.Count; i++)
  6845. {
  6846. var dac = dac4[i];
  6847. if (dac == null) continue;
  6848. builder.MoveToCell(3, i, 0, 0);
  6849. builder.Write("第" + dac.Days.ToString() + "天:");
  6850. builder.MoveToCell(3, i, 1, 0);
  6851. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6852. builder.MoveToCell(3, i, 2, 0);
  6853. builder.Write("费用标准:");
  6854. string curr = "";
  6855. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6856. if (currData != null)
  6857. {
  6858. curr = currData.Name;
  6859. }
  6860. builder.MoveToCell(3, i, 3, 0);
  6861. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6862. builder.MoveToCell(3, i, 4, 0);
  6863. builder.Write("费用小计:");
  6864. builder.MoveToCell(3, i, 5, 0);
  6865. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6866. }
  6867. #endregion
  6868. }
  6869. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6870. //删除多余行
  6871. while (table4.Rows.Count > table4Row)
  6872. {
  6873. table4.Rows.RemoveAt(table4Row);
  6874. }
  6875. //其他费用
  6876. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6877. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6878. {
  6879. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6880. dic.Add("titleQi", qtStr);
  6881. table5Row = dac5.Count;
  6882. #region 填充word表格内容
  6883. for (int i = 0; i < dac5.Count; i++)
  6884. {
  6885. var dac = dac5[i];
  6886. if (dac == null) continue;
  6887. builder.MoveToCell(4, i, 0, 0);
  6888. builder.Write("第" + dac.Index.ToString() + "项:");
  6889. builder.MoveToCell(4, i, 1, 0);
  6890. builder.Write(dac.itemName);
  6891. builder.MoveToCell(4, i, 2, 0);
  6892. builder.Write("费用标准:");
  6893. builder.MoveToCell(4, i, 3, 0);
  6894. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6895. builder.MoveToCell(4, i, 4, 0);
  6896. builder.Write("费用小计:");
  6897. builder.MoveToCell(4, i, 5, 0);
  6898. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6899. builder.MoveToCell(4, i, 6, 0);
  6900. builder.Write("备注:");
  6901. builder.MoveToCell(4, i, 7, 0);
  6902. builder.Write(dac.Remark);
  6903. }
  6904. #endregion
  6905. }
  6906. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6907. //删除多余行
  6908. while (table5.Rows.Count > table5Row)
  6909. {
  6910. table5.Rows.RemoveAt(table5Row);
  6911. }
  6912. //加上其他费用
  6913. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6914. decimal subJJC = 0.00M,
  6915. subGWC = 0.00M,
  6916. subTDC = 0.00M;
  6917. //经济舱
  6918. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6919. //公务舱
  6920. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6921. //头等舱
  6922. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6923. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6924. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6925. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6926. #region 填充word模板书签内容
  6927. foreach (var key in dic.Keys)
  6928. {
  6929. Bookmark bookmark = doc.Range.Bookmarks[key];
  6930. if (bookmark != null)
  6931. {
  6932. builder.MoveToBookmark(key);
  6933. builder.Write(dic[key]);
  6934. }
  6935. }
  6936. #endregion
  6937. //文件名
  6938. string strFileName = $"{_EnterExitCosts.DraftName}出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  6939. AsposeHelper.removewatermark_v2180();
  6940. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6941. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6942. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6943. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6944. }
  6945. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6946. {
  6947. //获取模板
  6948. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6949. //载入模板
  6950. Document doc = new Document(tempPath);
  6951. DocumentBuilder builder = new DocumentBuilder(doc);
  6952. Dictionary<string, string> dic = new Dictionary<string, string>();
  6953. string returnCodeLabel = string.Empty;
  6954. if (nationalTravelFeeData.Any())
  6955. {
  6956. List<string> list = new List<string>();
  6957. foreach (var item in nationalTravelFeeData)
  6958. {
  6959. list.Add($"{item.Country}({item.City})");
  6960. }
  6961. list = list.Distinct().ToList();
  6962. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  6963. }
  6964. var countryLabel = string.Empty;
  6965. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  6966. if (countryData.Any())
  6967. {
  6968. countryLabel = string.Join("、", countryData);
  6969. }
  6970. dic.Add("ReturnCodeAir", returnCodeLabel);
  6971. dic.Add("VisitStartDate", "-");
  6972. dic.Add("VisitEndDate", "-");
  6973. dic.Add("Day", "-");
  6974. dic.Add("VisitCountry", countryLabel);
  6975. dic.Add("ClientUnit", "-");
  6976. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6977. //dic.Add("Names", Names);
  6978. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6979. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6980. decimal dac1totalPrice = 0.00M;
  6981. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6982. foreach (var dac in dac1)
  6983. {
  6984. if (dac.SubTotal == 0.00M)
  6985. {
  6986. continue;
  6987. }
  6988. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6989. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6990. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6991. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6992. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6993. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6994. builder.Write(currency);//币种
  6995. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6996. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6997. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6998. builder.Write("");//人数
  6999. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7000. builder.Write("");//天数
  7001. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7002. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7003. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7004. decimal rate = 0.00M;
  7005. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7006. builder.Write(rate.ToString("#0.0000"));//汇率
  7007. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7008. decimal rbmPrice = dac.SubTotal;
  7009. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7010. accommodationStartIndex++;
  7011. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7012. }
  7013. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7014. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7015. {
  7016. table1.Rows.RemoveAt(i - 1);
  7017. foodandotherStartIndex--;
  7018. }
  7019. if (dac2.Count == dac3.Count)//国家 币种 金额
  7020. {
  7021. for (int i = 0; i < dac2.Count; i++)
  7022. {
  7023. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7024. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7025. }
  7026. }
  7027. decimal dac2totalPrice = 0.00M;
  7028. foreach (var dac in dac2)
  7029. {
  7030. if (dac.SubTotal == 0)
  7031. {
  7032. continue;
  7033. }
  7034. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7035. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7036. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7037. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7038. builder.Write(currency);//币种
  7039. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7040. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7041. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7042. builder.Write("");//人数
  7043. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7044. builder.Write("");//天数
  7045. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7046. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7047. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7048. decimal rate = 0.00M;
  7049. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7050. builder.Write(rate.ToString("#0.0000"));//汇率
  7051. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7052. decimal rbmPrice = dac.SubTotal;
  7053. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7054. foodandotherStartIndex++;
  7055. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7056. }
  7057. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7058. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7059. {
  7060. table1.Rows.RemoveAt(i - 1);
  7061. }
  7062. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7063. string otherFeeStr = "";
  7064. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7065. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7066. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7067. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7068. foreach (var otherInfo in dac5)
  7069. {
  7070. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7071. }
  7072. #endregion
  7073. if (otherFeeStr.Length > 0)
  7074. {
  7075. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7076. otherFeeStr = $"({otherFeeStr})";
  7077. dic.Add("OtherFeeStr", otherFeeStr);
  7078. }
  7079. //总计
  7080. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7081. //国际旅费
  7082. string outsideAir = string.Empty;
  7083. string allPriceAir = string.Empty;
  7084. if (_EnterExitCosts.SumJJC == 1)
  7085. {
  7086. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7087. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7088. }
  7089. if (_EnterExitCosts.SumGWC == 1)
  7090. {
  7091. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7092. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7093. }
  7094. if (_EnterExitCosts.SumTDC == 1)
  7095. {
  7096. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7097. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7098. }
  7099. dic.Add("InTravelPrice", $"({outsideAir})");
  7100. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7101. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7102. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7103. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7104. foreach (var key in dic.Keys)
  7105. {
  7106. builder.MoveToBookmark(key);
  7107. builder.Write(dic[key]);
  7108. }
  7109. //模板文件名
  7110. string strFileName = $"草稿_{_EnterExitCosts.DraftName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7111. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7112. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7113. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7114. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7115. }
  7116. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7117. {
  7118. //获取模板
  7119. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7120. //载入模板
  7121. WorkbookDesigner designer = new WorkbookDesigner();
  7122. designer.Workbook = new Workbook(tempPath);
  7123. Dictionary<string, string> dic = new Dictionary<string, string>();
  7124. string returnCodeLabel = string.Empty;
  7125. if (nationalTravelFeeData.Any())
  7126. {
  7127. List<string> list = new List<string>();
  7128. foreach (var item in nationalTravelFeeData)
  7129. {
  7130. list.Add($"{item.Country}({item.City})");
  7131. }
  7132. list = list.Distinct().ToList();
  7133. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7134. }
  7135. var countryLabel = string.Empty;
  7136. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7137. if (countryData.Any())
  7138. {
  7139. countryLabel = string.Join("、", countryData);
  7140. }
  7141. dic.Add("ReturnCodeAir", returnCodeLabel);
  7142. dic.Add("VisitStartDate", "-");
  7143. dic.Add("VisitEndDate", "-");
  7144. dic.Add("Day", "0");
  7145. dic.Add("VisitCountry", countryLabel);
  7146. dic.Add("ClientUnit", "-");
  7147. designer.SetDataSource("ClientUnit", "-");
  7148. designer.SetDataSource("VisitCountry", countryLabel);
  7149. designer.SetDataSource("Group", "-");
  7150. designer.SetDataSource("ClientUnitTitle", "-");
  7151. designer.SetDataSource("Name", "-");
  7152. designer.SetDataSource("VisitStartDate", "-" );
  7153. designer.SetDataSource("Day", "0");
  7154. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7155. designer.SetDataSource("ReturnCodeAir", "-");
  7156. int startIndex = 10;
  7157. const int startIndexcopy = 10;
  7158. if (dac2.Count == dac3.Count)//国家 币种 金额
  7159. {
  7160. for (int i = 0; i < dac2.Count; i++)
  7161. {
  7162. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7163. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7164. }
  7165. }
  7166. DataTable dtdac1 = new DataTable();
  7167. List<string> place = new List<string>();
  7168. dtdac1.Columns.AddRange(new DataColumn[] {
  7169. new DataColumn(){ ColumnName = "city"},
  7170. new DataColumn(){ ColumnName = "curr"},
  7171. new DataColumn(){ ColumnName = "criterion"},
  7172. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7173. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7174. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7175. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7176. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7177. });
  7178. DataTable dtdac2 = new DataTable();
  7179. dtdac2.Columns.AddRange(new DataColumn[] {
  7180. new DataColumn(){ ColumnName = "city"},
  7181. new DataColumn(){ ColumnName = "curr"},
  7182. new DataColumn(){ ColumnName = "criterion"},
  7183. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7184. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7185. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7186. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7187. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7188. });
  7189. dtdac1.TableName = "tb1";
  7190. dtdac2.TableName = "tb2";
  7191. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7192. foreach (var item in dac1)
  7193. {
  7194. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7195. if (place.Contains(item.Place))
  7196. {
  7197. continue;
  7198. }
  7199. DataRow row = dtdac1.NewRow();
  7200. row["city"] = item.Place;
  7201. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7202. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7203. row["curr"] = currency;
  7204. row["rate"] = rate.ToString("#0.0000");
  7205. row["criterion"] = item.Cost.ToString("#0.00");
  7206. row["number"] = 1;
  7207. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7208. //row["costRMB"] = rbmPrice;
  7209. dtdac1.Rows.Add(row);
  7210. place.Add(item.Place);
  7211. }
  7212. place = new List<string>();
  7213. foreach (var item in dac2)
  7214. {
  7215. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7216. if (place.Contains(item.Place))
  7217. {
  7218. continue;
  7219. }
  7220. DataRow row = dtdac2.NewRow();
  7221. row["city"] = item.Place;
  7222. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7223. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7224. row["curr"] = currency;
  7225. row["rate"] = rate.ToString("#0.0000");
  7226. row["criterion"] = item.Cost.ToString("#0.00");
  7227. row["number"] = 1;
  7228. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7229. //row["cost"] = item.SubTotal;
  7230. //row["costRMB"] = rbmPrice;
  7231. dtdac2.Rows.Add(row);
  7232. place.Add(item.Place);
  7233. //dac2totalPrice += rbmPrice;
  7234. }
  7235. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7236. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7237. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7238. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7239. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7240. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7241. string cell4Str1 = string.Empty;
  7242. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7243. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7244. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7245. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7246. string cellStr = $" 5.其他费用(";
  7247. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7248. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7249. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7250. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7251. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7252. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7253. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7254. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7255. foreach (var otherInfo in dac5)
  7256. {
  7257. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7258. }
  7259. #endregion
  7260. if (cellStr.Length > 8)
  7261. {
  7262. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7263. }
  7264. cellStr += ")";
  7265. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7266. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7267. decimal pxFee = dac4.Sum(it => it.Cost);
  7268. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7269. string celllastStr1 = "";
  7270. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7271. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7272. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7273. celllastStr1 += $",国际旅费 元";
  7274. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7275. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7276. designer.SetDataSource("cell4Str", cell4Str);
  7277. designer.SetDataSource("cellStr", cellStr);
  7278. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7279. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7280. designer.SetDataSource("celllastStr", celllastStr);
  7281. Workbook wb = designer.Workbook;
  7282. var sheet = wb.Worksheets[0];
  7283. //绑定datatable数据集
  7284. designer.SetDataSource(dtdac1);
  7285. designer.SetDataSource(dtdac2);
  7286. designer.Process();
  7287. var rowStart = dtdac1.Rows.Count;
  7288. while (rowStart > 0)
  7289. {
  7290. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7291. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7292. startIndex++;
  7293. rowStart--;
  7294. }
  7295. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7296. startIndex += 1; //总计行
  7297. rowStart = dtdac2.Rows.Count;
  7298. while (rowStart > 0)
  7299. {
  7300. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7301. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7302. startIndex++;
  7303. rowStart--;
  7304. }
  7305. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7306. wb.CalculateFormula(true);
  7307. //模板文件名
  7308. string strFileName = $"草稿_{_EnterExitCosts.DraftName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7309. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7310. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7311. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7312. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7313. }
  7314. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7315. {
  7316. //获取模板
  7317. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7318. //载入模板
  7319. Document doc = new Document(tempPath);
  7320. DocumentBuilder builder = new DocumentBuilder(doc);
  7321. Dictionary<string, string> dic = new Dictionary<string, string>();
  7322. dic.Add("GroupName", "-");
  7323. dic.Add("ClientUnit", "-");
  7324. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7325. string missionLeaderJob = "";//负责人job
  7326. int groupNumber = 0; //团人数
  7327. dic.Add("MissionLeader", "-"); //团负责人
  7328. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7329. dic.Add("GroupNumber", "0"); //团人数
  7330. dic.Add("Day", "0");
  7331. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7332. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7333. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7334. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7335. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7336. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7337. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7338. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7339. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7340. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7341. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7342. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7343. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7344. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7345. //其他费用
  7346. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7347. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7348. //其他费用合计
  7349. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7350. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7351. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7352. //公务舱合计
  7353. //国际旅费
  7354. string outsideJJ = "";
  7355. string allPriceJJ = "";
  7356. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7357. {
  7358. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7359. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7360. }
  7361. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7362. {
  7363. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7364. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7365. }
  7366. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7367. {
  7368. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7369. dic.Add("AirFeeTotal", airFeeTotalStr);
  7370. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7371. dic.Add("FeeTotal", feeTotalStr);
  7372. }
  7373. foreach (var key in dic.Keys)
  7374. {
  7375. builder.MoveToBookmark(key);
  7376. builder.Write(dic[key]);
  7377. }
  7378. //模板文件名
  7379. string strFileName = $"草稿_{_EnterExitCosts.DraftName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7380. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7381. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7382. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7383. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7384. }
  7385. }
  7386. else if (dto.ExportType == 2) //表格
  7387. {
  7388. }
  7389. else if (dto.ExportType == 3)
  7390. {
  7391. }
  7392. return Ok(JsonView(400, "只可导出明细表!", ""));
  7393. }
  7394. catch (Exception ex)
  7395. {
  7396. return Ok(JsonView(400, ex.Message, ""));
  7397. }
  7398. }
  7399. /// <summary>
  7400. /// 获取三公费用标准city
  7401. /// </summary>
  7402. /// <param name="placeData"></param>
  7403. /// <param name="nationalTravelFeeId"></param>
  7404. /// <returns></returns>
  7405. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7406. {
  7407. string _city = string.Empty;
  7408. if (!placeData.Any()) return _city;
  7409. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7410. if (data == null) return _city;
  7411. string country = data.Country;
  7412. string city = data.City;
  7413. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7414. else _city = city;
  7415. return _city;
  7416. }
  7417. /// <summary>
  7418. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7419. /// </summary>
  7420. /// <returns></returns>
  7421. [HttpPost]
  7422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7423. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7424. {
  7425. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7426. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7427. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7428. if (_view.Code == 0)
  7429. {
  7430. return Ok(JsonView(true, "操作成功"));
  7431. }
  7432. return Ok(JsonView(false, "操作失败"));
  7433. }
  7434. /// <summary>
  7435. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7436. /// </summary>
  7437. /// <returns></returns>
  7438. [HttpPost]
  7439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7440. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7441. {
  7442. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7443. if (data.Code != 0)
  7444. {
  7445. return Ok(JsonView(false, data.Msg));
  7446. }
  7447. return Ok(JsonView(true, "操作成功!", data.Data));
  7448. }
  7449. /// <summary>
  7450. /// 三公其他费用草稿 删除
  7451. /// </summary>
  7452. /// <param name="dto"></param>
  7453. /// <returns></returns>
  7454. [HttpPost]
  7455. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7456. {
  7457. var jw = JsonView(false, "删除失败!");
  7458. var data = new Grp_DayOtherPriceDraft()
  7459. {
  7460. Id = dto.Id,
  7461. IsDel = 1,
  7462. DeleteUserId = dto.DeleteUserId,
  7463. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7464. };
  7465. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7466. if (del > 0)
  7467. {
  7468. jw.Code = 200;
  7469. jw.Msg = "删除成功!";
  7470. }
  7471. return Ok(jw);
  7472. }
  7473. /// <summary>
  7474. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7475. /// </summary>
  7476. /// <param name="dto"></param>
  7477. /// <returns></returns>
  7478. [HttpPost]
  7479. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7480. {
  7481. var jw = JsonView(false);
  7482. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7483. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7484. jw.Code = StatusCodes.Status200OK;
  7485. jw.Msg = "操作成功!";
  7486. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7487. return Ok(jw);
  7488. }
  7489. /// <summary>
  7490. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7491. /// </summary>
  7492. /// <param name="dto"></param>
  7493. /// <returns></returns>
  7494. [HttpPost]
  7495. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7496. {
  7497. int userId = dto.UserId,
  7498. portId = dto.PortType,
  7499. groupId = dto.GroupId,
  7500. draftId = dto.DraftId;
  7501. _portTypeData.Add(1);
  7502. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7503. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7504. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7505. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7506. _sqlSugar.BeginTran();
  7507. try
  7508. {
  7509. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7510. if (draftDatas == null)
  7511. {
  7512. _sqlSugar.RollbackTran();
  7513. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7514. }
  7515. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7516. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7517. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7518. newExterData.DiId = groupId;
  7519. newExterData.CreateUserId = userId;
  7520. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7521. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7522. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7523. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7524. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7525. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7526. //数据如果存在执行删除
  7527. if (enterExitCostInfo != null)
  7528. {
  7529. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7530. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7531. .Where(x => x.Id == enterExitCostInfo.Id)
  7532. .ExecuteCommand();
  7533. _sqlSugar.Updateable<Grp_DayAndCost>()
  7534. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7535. .Where(x => x.DiId == groupId)
  7536. .ExecuteCommand();
  7537. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7538. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7539. .Where(x => x.Diid == groupId)
  7540. .ExecuteCommand();
  7541. }
  7542. //执行insert
  7543. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7544. if (insertId < 1)
  7545. {
  7546. _sqlSugar.RollbackTran();
  7547. return Ok(JsonView(false, "草稿数据导入失败!"));
  7548. }
  7549. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7550. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7551. _sqlSugar.CommitTran();
  7552. //执行操作之后
  7553. //生成默认文件pdf并且通知人员
  7554. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7555. {
  7556. DiId = groupId,
  7557. ExportType = 1,
  7558. SubTypeId = 1005
  7559. }, "pdf");
  7560. //发送通知
  7561. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7562. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7563. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7564. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7565. //汇率信息记录
  7566. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7567. return Ok(JsonView(true));
  7568. }
  7569. catch (Exception ex)
  7570. {
  7571. _sqlSugar.RollbackTran();
  7572. return Ok(JsonView(false,ex.Message));
  7573. }
  7574. }
  7575. #endregion
  7576. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7577. /// <summary>
  7578. /// 获取币种基础数据(含逻辑处理)
  7579. /// </summary>
  7580. /// <returns></returns>
  7581. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7582. {
  7583. //默认币种显示
  7584. var _currencyInfos = _currencyInit;
  7585. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7586. if (_currencyRate.Count > 0)
  7587. {
  7588. foreach (var item in _currencyInfos)
  7589. {
  7590. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7591. if (rateInfo != null)
  7592. {
  7593. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7594. rate1 *= 1.035M;
  7595. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7596. }
  7597. }
  7598. }
  7599. return _currencyInfos;
  7600. }
  7601. /// <summary>
  7602. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7603. /// </summary>
  7604. /// <returns></returns>
  7605. [HttpPost]
  7606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7607. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7608. {
  7609. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7610. //SetDataInfoView
  7611. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7612. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7613. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7614. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7615. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7616. //默认币种显示
  7617. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7618. return Ok(JsonView(true, "查询成功!", new
  7619. {
  7620. WordTypeData = _WordTypeData,
  7621. ExcelTypeData = _ExcelTypeData,
  7622. CurrencyInit = _currencyInfos
  7623. }));
  7624. }
  7625. /// <summary>
  7626. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7627. /// </summary>
  7628. /// <returns></returns>
  7629. [HttpPost]
  7630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7631. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7632. {
  7633. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7634. RefAsync<int> total = 0;
  7635. int diId = 0;
  7636. var status = int.TryParse(dto.GroupName, out diId);
  7637. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7638. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7639. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7640. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7641. .Select(x => new
  7642. {
  7643. Id = x.Id,
  7644. GroupName = x.TeamName
  7645. })
  7646. .OrderByDescending(x => x.Id)
  7647. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7648. return Ok(JsonView(true, "查询成功!", data, total));
  7649. }
  7650. /// <summary>
  7651. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7652. /// </summary>
  7653. /// <returns></returns>
  7654. [HttpPost]
  7655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7656. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7657. {
  7658. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7659. RefAsync<int> total = 0;
  7660. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7661. .Where(x => x.IsDel == 0 && x.STid == 66)
  7662. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7663. .Select(x => new
  7664. {
  7665. id = x.Id,
  7666. name = x.Name,
  7667. remark = x.Remark,
  7668. })
  7669. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7670. return Ok(JsonView(true, "查询成功!", data, total));
  7671. }
  7672. /// <summary>
  7673. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7674. /// </summary>
  7675. /// <returns></returns>
  7676. [HttpPost]
  7677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7678. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7679. {
  7680. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7681. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7682. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7683. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7684. var groupOtherRateData = groupRateData.TeamRates;
  7685. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7686. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7687. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7688. groupOtherRateData = groupOtherRateData
  7689. .Select(x => new TeamRateDescAddCurrencyIdView {
  7690. CurrencyId = x.CurrencyId,
  7691. CurrencyName = x.CurrencyName,
  7692. CurrencyCode = x.CurrencyCode,
  7693. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7694. }).ToList();
  7695. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7696. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7697. }
  7698. /// <summary>
  7699. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7700. /// </summary>
  7701. /// <returns></returns>
  7702. [HttpPost]
  7703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7704. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7705. {
  7706. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7707. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7708. var tipsData = new List<int>() {1,2,3 };
  7709. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7710. if (dto.TipsType == 1)
  7711. {
  7712. //默认币种显示
  7713. var _currencyInfos = _currencyInit;
  7714. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7715. List<dynamic> reteInfos = new List<dynamic>();
  7716. if (_currencyRate.Count > 0)
  7717. {
  7718. foreach (var item in _currencyInfos)
  7719. {
  7720. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7721. if (rateInfo != null)
  7722. {
  7723. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7724. decimal rate1 = item.Rate;
  7725. rate1 *= 1.03M;
  7726. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7727. reteInfos.Add(new
  7728. {
  7729. currCode = item.CurrencyCode,
  7730. currName = item.CurrencyName,
  7731. rate = rate2,
  7732. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7733. });
  7734. }
  7735. }
  7736. }
  7737. return Ok(JsonView(true, "查询成功!", reteInfos));
  7738. }
  7739. else if (dto.TipsType == 2)
  7740. {
  7741. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7742. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7743. }
  7744. else if (dto.TipsType == 3)
  7745. {
  7746. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7747. return Ok(JsonView(true, "查询成功!", airData.Data));
  7748. }
  7749. return Ok(JsonView(false));
  7750. }
  7751. /// <summary>
  7752. /// 团组模块 - 出入境国家费用标准-移动端 List
  7753. /// </summary>
  7754. /// <returns></returns>
  7755. [HttpPost]
  7756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7757. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7758. {
  7759. Stopwatch sw = new Stopwatch();
  7760. sw.Start();
  7761. RefAsync<int> total = 0;
  7762. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7763. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7764. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7765. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7766. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7767. .Select((ntf, sd, u) => new
  7768. {
  7769. Id = ntf.Id,
  7770. Area = $"{ntf.Country}-{ntf.City}",
  7771. Currency = ntf.Currency,
  7772. CurrencyCode = sd.Name,
  7773. CurrencyName = sd.Remark,
  7774. RoomCost = ntf.RoomCost,
  7775. FoodCost = ntf.FoodCost,
  7776. PublicCost = ntf.PublicCost,
  7777. LastUpdateUserId = ntf.LastUpdateUserId,
  7778. LastUpdateUserName = u.CnName,
  7779. LastUpdateTime = ntf.LastUpdateTime,
  7780. })
  7781. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7782. sw.Stop();
  7783. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7784. }
  7785. /// <summary>
  7786. /// 团组模块 - 出入境费用-移动端 - Info
  7787. /// </summary>
  7788. /// <returns></returns>
  7789. [HttpPost]
  7790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7791. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7792. {
  7793. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7794. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7795. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7796. return Ok(data);
  7797. }
  7798. /// <summary>
  7799. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7800. /// </summary>
  7801. /// <returns></returns>
  7802. [HttpPost]
  7803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7804. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7805. {
  7806. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7807. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7808. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7809. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7810. mobileInfo.DiId = dto.DiId;
  7811. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  7812. if (eecInfo == null) return Ok(mobileInfo);
  7813. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  7814. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  7815. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7816. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7817. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  7818. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7819. {
  7820. SubId = dac.Id,
  7821. DiId = dac.DiId,
  7822. Type = dac.Type,
  7823. Days = dac.Days,
  7824. NationalTravelFeeId = dac.NationalTravelFeeId,
  7825. Arae = $"{ntf.Country}-{ntf.City}",
  7826. Cost = dac.Cost,
  7827. Currency = dac.Currency,
  7828. CurrencyName = sd.Name,
  7829. SubTotal = dac.SubTotal,
  7830. })
  7831. .ToList();
  7832. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  7833. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  7834. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  7835. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  7836. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  7837. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  7838. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  7839. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  7840. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  7841. //其他款项
  7842. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7843. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  7844. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  7845. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  7846. .OrderBy((dop, sd1, sd2) => dop.Index)
  7847. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  7848. {
  7849. SubId = dop.Id,
  7850. DiId = dop.Diid,
  7851. Index = dop.Index,
  7852. SetDataId = dop.SetDataId,
  7853. SetDataName = sd1.Name,
  7854. Cost = dop.Cost,
  7855. Currency = dop.Currency,
  7856. CurrencyName = sd2.Remark,
  7857. SubTotal = dop.SubTotal,
  7858. Remark = dop.Remark,
  7859. })
  7860. .ToArray();
  7861. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  7862. return Ok(mobileInfo);
  7863. }
  7864. /// <summary>
  7865. /// 团组模块 - 出入境费用-移动端 - SubInfo
  7866. /// </summary>
  7867. /// <returns></returns>
  7868. [HttpPost]
  7869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7870. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  7871. {
  7872. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7873. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7874. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  7875. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  7876. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7877. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  7878. var subType = dto.SubType;
  7879. if (subType == 1) //1:境内费用
  7880. {
  7881. var oneData = new ChoiceOneMobileSubInfoView()
  7882. {
  7883. Id = eecInfo.Id,
  7884. ChoiceOne = eecInfo.ChoiceOne,
  7885. ChoiceOneTotalCost = eecInfo.InsidePay,
  7886. Visa = eecInfo.Visa,
  7887. VisaRemark = eecInfo.VisaRemark,
  7888. YiMiao = eecInfo.YiMiao,
  7889. HeSuan = eecInfo.HeSuan,
  7890. Service = eecInfo.Service,
  7891. Ticket = eecInfo.Ticket,
  7892. Safe = eecInfo.Safe,
  7893. FirstItemRemark = eecInfo.FirstItemRemark
  7894. };
  7895. return Ok(JsonView(oneData));
  7896. }
  7897. else if (subType == 2) //2:国际旅费
  7898. {
  7899. var twoData = new ChoiceTwoMobileSubInfoView() {
  7900. Id = eecInfo.Id,
  7901. ChoiceTwoJJ = eecInfo.SumJJC,
  7902. OutsideJJPay = eecInfo.OutsideJJPay,
  7903. ChoiceTwoGW = eecInfo.SumGWC,
  7904. OutsideGWPay = eecInfo.OutsideGWPay,
  7905. ChoiceTwoTD = eecInfo.SumTDC,
  7906. OutsideTDPay = eecInfo.OutsideTDPay,
  7907. AirJJ = eecInfo.AirJJ,
  7908. AirGW = eecInfo.AirGW,
  7909. AirTD = eecInfo.AirTD,
  7910. CityTranffic = eecInfo.CityTranffic
  7911. };
  7912. return Ok(JsonView(twoData));
  7913. }
  7914. else if (subType == 3) //3:住宿费
  7915. {
  7916. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  7917. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7918. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7919. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  7920. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7921. {
  7922. SubId = dac.Id,
  7923. DiId = dac.DiId,
  7924. Type = dac.Type,
  7925. Days = dac.Days,
  7926. NationalTravelFeeId = dac.NationalTravelFeeId,
  7927. Arae = $"{ntf.Country}-{ntf.City}",
  7928. Cost = dac.Cost,
  7929. Currency = dac.Currency,
  7930. CurrencyName = sd.Name,
  7931. SubTotal = dac.SubTotal,
  7932. })
  7933. .ToArray();
  7934. var data = new ChoiceMobileSubInfo3To6View() {
  7935. ParentId = eecInfo.Id,
  7936. Choice = eecInfo.ChoiceThree,
  7937. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  7938. Details = dayAndCostDatas
  7939. };
  7940. return Ok(JsonView(data));
  7941. }
  7942. else if (subType == 4) //4:伙食费
  7943. {
  7944. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  7945. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7946. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7947. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  7948. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7949. {
  7950. SubId = dac.Id,
  7951. DiId = dac.DiId,
  7952. Type = dac.Type,
  7953. Days = dac.Days,
  7954. NationalTravelFeeId = dac.NationalTravelFeeId,
  7955. Arae = $"{ntf.Country}-{ntf.City}",
  7956. Cost = dac.Cost,
  7957. Currency = dac.Currency,
  7958. CurrencyName = sd.Name,
  7959. SubTotal = dac.SubTotal,
  7960. })
  7961. .ToArray();
  7962. var data = new ChoiceMobileSubInfo3To6View()
  7963. {
  7964. ParentId = eecInfo.Id,
  7965. Choice = eecInfo.ChoiceFour,
  7966. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  7967. Details = dayAndCostDatas
  7968. };
  7969. return Ok(JsonView(data));
  7970. }
  7971. else if (subType == 5) //5:公杂费
  7972. {
  7973. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  7974. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7975. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7976. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  7977. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7978. {
  7979. SubId = dac.Id,
  7980. DiId = dac.DiId,
  7981. Type = dac.Type,
  7982. Days = dac.Days,
  7983. NationalTravelFeeId = dac.NationalTravelFeeId,
  7984. Arae = $"{ntf.Country}-{ntf.City}",
  7985. Cost = dac.Cost,
  7986. Currency = dac.Currency,
  7987. CurrencyName = sd.Name,
  7988. SubTotal = dac.SubTotal,
  7989. })
  7990. .ToArray();
  7991. var data = new ChoiceMobileSubInfo3To6View()
  7992. {
  7993. ParentId = eecInfo.Id,
  7994. Choice = eecInfo.ChoiceFive,
  7995. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  7996. Details = dayAndCostDatas
  7997. };
  7998. return Ok(JsonView(data));
  7999. }
  8000. else if (subType == 6) //6:培训费
  8001. {
  8002. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8003. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8004. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8005. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8006. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8007. {
  8008. SubId = dac.Id,
  8009. DiId = dac.DiId,
  8010. Type = dac.Type,
  8011. Days = dac.Days,
  8012. NationalTravelFeeId = dac.NationalTravelFeeId,
  8013. Arae = $"{ntf.Country}-{ntf.City}",
  8014. Cost = dac.Cost,
  8015. Currency = dac.Currency,
  8016. CurrencyName = sd.Name,
  8017. SubTotal = dac.SubTotal,
  8018. })
  8019. .ToArray();
  8020. var data = new ChoiceMobileSubInfo3To6View()
  8021. {
  8022. ParentId = eecInfo.Id,
  8023. Choice = eecInfo.ChoiceSix,
  8024. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8025. Details = dayAndCostDatas
  8026. };
  8027. return Ok(JsonView(data));
  8028. }
  8029. else if (subType == 7) //7:其他
  8030. {
  8031. //其他款项
  8032. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8033. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8034. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8035. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8036. .OrderBy((dop, sd1, sd2) => dop.Index)
  8037. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8038. {
  8039. SubId = dop.Id,
  8040. DiId = dop.Diid,
  8041. Index = dop.Index,
  8042. SetDataId = dop.SetDataId,
  8043. SetDataName = sd1.Name,
  8044. Cost = dop.Cost,
  8045. Currency = dop.Currency,
  8046. CurrencyName = sd2.Name,
  8047. SubTotal = dop.SubTotal,
  8048. Remark = dop.Remark,
  8049. })
  8050. .ToArray();
  8051. var data = new ChoiceSevenMobileSubInfoView()
  8052. {
  8053. ParentId = eecInfo.Id,
  8054. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8055. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8056. Details = otherData
  8057. };
  8058. return Ok(JsonView(data));
  8059. }
  8060. return Ok(JsonView(false));
  8061. }
  8062. #region op
  8063. /// <summary>
  8064. /// 移动端更新费用消息通知
  8065. /// </summary>
  8066. /// <param name="diid"></param>
  8067. /// <param name="id"></param>
  8068. /// <param name="currUserId"></param>
  8069. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8070. {
  8071. try
  8072. {
  8073. ////生成默认文件pdf并且通知人员
  8074. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8075. //{
  8076. // DiId = diid,
  8077. // ExportType = 1,
  8078. // SubTypeId = 1005
  8079. //}, "pdf");
  8080. ////发送通知
  8081. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8082. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8083. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8084. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8085. ////汇率信息记录
  8086. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8087. }
  8088. catch (Exception ex)
  8089. {
  8090. //记录日志
  8091. throw;
  8092. }
  8093. }
  8094. /// <summary>
  8095. /// 验证出入境费用数据是否存在
  8096. /// 不存在添加
  8097. /// </summary>
  8098. /// <param name="diId"></param>
  8099. /// <param name="currUserId"></param>
  8100. /// <returns></returns>
  8101. /// <exception cref="CustomException"></exception>
  8102. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8103. {
  8104. var parentId = 0;
  8105. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8106. if (info != null) parentId = info.Id;
  8107. else
  8108. {
  8109. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8110. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8111. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8112. parentId = addId;
  8113. }
  8114. return parentId;
  8115. }
  8116. /// <summary>
  8117. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8118. /// </summary>
  8119. /// <returns></returns>
  8120. [HttpPost]
  8121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8122. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8123. {
  8124. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8125. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8126. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8127. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8128. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8129. int id = dto.Id;
  8130. if (id <= 0) //add
  8131. {
  8132. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8133. if (add < 1) return Ok(JsonView(false));
  8134. id = add;
  8135. }
  8136. else //update
  8137. {
  8138. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8139. if (upd < 1) return Ok(JsonView(false));
  8140. }
  8141. #region 汇率变更时更改币种相关费用
  8142. var opDayCosts = new List<Grp_DayAndCost>();
  8143. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8144. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8145. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8146. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8147. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8148. .Select((dac, sd) => new {
  8149. dac.Id,
  8150. dac.DiId,
  8151. CurrencyCode = sd.Name,
  8152. dac.Cost
  8153. })
  8154. .ToList();
  8155. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8156. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8157. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8158. .Select((dop, sd) => new {
  8159. dop.Id,
  8160. dop.Diid,
  8161. CurrencyCode = sd.Name,
  8162. dop.Cost
  8163. })
  8164. .ToList();
  8165. if (dayCosts.Count > 0)
  8166. {
  8167. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8168. foreach (var dc in new_dayCosts)
  8169. {
  8170. var thisCurrency = dc.Key.ToUpper();
  8171. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8172. if (thisRate == 0.00M) continue;
  8173. foreach (var dcSub in dc)
  8174. {
  8175. opDayCosts.Add(new Grp_DayAndCost() {
  8176. Id = dcSub.Id,
  8177. DiId = dcSub.DiId,
  8178. Cost = dcSub.Cost,
  8179. SubTotal = dcSub.Cost * thisRate,
  8180. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8181. });
  8182. }
  8183. }
  8184. if (opDayCosts.Count > 0)
  8185. {
  8186. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8187. }
  8188. }
  8189. if (dayOtherCosts.Count > 0)
  8190. {
  8191. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8192. foreach (var dc in new_dayOtherCosts)
  8193. {
  8194. var thisCurrency = dc.Key.ToUpper();
  8195. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8196. if (thisRate == 0.00M) continue;
  8197. foreach (var dcSub in dc)
  8198. {
  8199. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8200. {
  8201. Id = dcSub.Id,
  8202. Diid = dcSub.Diid,
  8203. Cost = dcSub.Cost,
  8204. SubTotal = dcSub.Cost * thisRate,
  8205. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8206. });
  8207. }
  8208. }
  8209. if (opDayOtherCosts.Count > 0)
  8210. {
  8211. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8212. }
  8213. }
  8214. #endregion
  8215. //消息通知
  8216. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8217. //汇率信息记录
  8218. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8219. return Ok(JsonView(new { parentId = id }));
  8220. }
  8221. /// <summary>
  8222. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8223. /// </summary>
  8224. /// <returns></returns>
  8225. [HttpPost]
  8226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8227. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8228. {
  8229. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8230. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8231. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8232. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8233. int id = dto.Id;
  8234. if (id <= 0) //add
  8235. {
  8236. checkboxInfo.CreateUserId = dto.CurrUserId;
  8237. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8238. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8239. if (add < 1) return Ok(JsonView(false));
  8240. }
  8241. else //update
  8242. {
  8243. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8244. .UpdateColumns(x => new {
  8245. x.ChoiceOne,
  8246. x.ChoiceTwo,
  8247. x.SumJJC,
  8248. x.SumGWC,
  8249. x.SumTDC,
  8250. x.ChoiceThree,
  8251. x.ChoiceFour,
  8252. x.ChoiceFive,
  8253. x.ChoiceSix,
  8254. x.OtherExpenses_Checked
  8255. })
  8256. .Where(x => x.Id == id)
  8257. .ExecuteCommandAsync();
  8258. if (upd < 1) return Ok(JsonView(false));
  8259. }
  8260. return Ok(JsonView(new { parentId = id }));
  8261. }
  8262. /// <summary>
  8263. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8264. /// </summary>
  8265. /// <returns></returns>
  8266. [HttpPost]
  8267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8268. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8269. {
  8270. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8271. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8272. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8273. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8274. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8275. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8276. var checkboxInfo = new Grp_EnterExitCost() {
  8277. Id = id,
  8278. DiId = diId,
  8279. CreateUserId = currUserId
  8280. };
  8281. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8282. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8283. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8284. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8285. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8286. if (id <= 0) //add
  8287. {
  8288. checkboxInfo.CreateUserId = dto.CurrUserId;
  8289. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8290. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8291. if (add < 1) return Ok(JsonView(false));
  8292. }
  8293. else //update
  8294. {
  8295. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8296. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8297. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8298. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8299. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8300. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8301. .Where(x => x.Id == id)
  8302. .ExecuteCommandAsync();
  8303. if (upd < 1) return Ok(JsonView(false));
  8304. }
  8305. return Ok(JsonView(new { parentId = id }));
  8306. }
  8307. /// <summary>
  8308. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8309. /// </summary>
  8310. /// <returns></returns>
  8311. [HttpPost]
  8312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8313. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8314. {
  8315. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8316. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8317. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8318. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8319. info.FirstItemRemark = dto.FirstItemRemark;
  8320. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8321. int id = dto.Id;
  8322. if (id <= 0) //add
  8323. {
  8324. info.CreateUserId = dto.CurrUserId;
  8325. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8326. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8327. if (add < 1) return Ok(JsonView(false));
  8328. id = add;
  8329. }
  8330. else //update
  8331. {
  8332. var upd = await _sqlSugar.Updateable(info)
  8333. .UpdateColumns(x => new {
  8334. x.ChoiceOne,
  8335. x.InsidePay,
  8336. x.VisaRemark,
  8337. x.Visa,
  8338. x.Service,
  8339. x.Safe,
  8340. x.Ticket,
  8341. x.HeSuan,
  8342. x.YiMiao,
  8343. x.FirstItemRemark
  8344. })
  8345. .Where(x => x.Id == id)
  8346. .ExecuteCommandAsync();
  8347. if (upd < 1) return Ok(JsonView(false));
  8348. }
  8349. //消息通知
  8350. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8351. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8352. }
  8353. /// <summary>
  8354. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8355. /// </summary>
  8356. /// <returns></returns>
  8357. [HttpPost]
  8358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8359. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8360. {
  8361. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8362. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8363. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8364. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8365. info.OutsideJJPay = dto.OutsideJJPay;
  8366. info.OutsideGWPay = dto.OutsideGWPay;
  8367. info.OutsideTDPay = dto.OutsideTDPay;
  8368. info.AirJJ = dto.AirJJ;
  8369. info.AirGW = dto.AirGW;
  8370. info.AirTD = dto.AirTD;
  8371. info.CityTranffic = dto.CityTranffic;
  8372. info.SumJJC = dto.ChoiceTwoJJ;
  8373. info.SumGWC = dto.ChoiceTwoGW;
  8374. info.SumTDC = dto.ChoiceTwoTD;
  8375. int id = dto.Id;
  8376. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8377. if (id <= 0) //add
  8378. {
  8379. info.CreateUserId = dto.CurrUserId;
  8380. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8381. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8382. if (addId <= 0) return Ok(JsonView(false));
  8383. id = addId;
  8384. }
  8385. else //update
  8386. {
  8387. var upd = await _sqlSugar.Updateable(info)
  8388. .UpdateColumns(x => new {
  8389. x.SumJJC,
  8390. x.OutsideJJPay,
  8391. x.SumGWC,
  8392. x.OutsideGWPay,
  8393. x.SumTDC,
  8394. x.OutsideTDPay,
  8395. x.AirJJ,
  8396. x.AirGW,
  8397. x.AirTD,
  8398. x.CityTranffic
  8399. })
  8400. .Where(x => x.Id == id)
  8401. .ExecuteCommandAsync();
  8402. if (upd <1) return Ok(JsonView(false));
  8403. }
  8404. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8405. gwcItemTotal = info.AirGW + info.CityTranffic;
  8406. tdcItemTotal = info.AirTD + info.CityTranffic;
  8407. //消息通知
  8408. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8409. return Ok(JsonView(new
  8410. {
  8411. parentId = id,
  8412. choiceTwoJJ = dto.ChoiceTwoJJ,
  8413. jjcItemTotal = jjcItemTotal,
  8414. choiceTwoGW = dto.ChoiceTwoGW,
  8415. gwcItemTotal = gwcItemTotal,
  8416. choiceTwoTD = dto.ChoiceTwoTD,
  8417. tdcItemTotal = tdcItemTotal
  8418. }));
  8419. }
  8420. /// <summary>
  8421. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8422. /// </summary>
  8423. /// <returns></returns>
  8424. [HttpPost]
  8425. [ApiExplorerSettings(IgnoreApi = true)]
  8426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8427. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8428. {
  8429. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8430. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8431. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8432. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8433. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8434. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8435. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8436. var infos = infos1.Select(x => new Grp_DayAndCost
  8437. {
  8438. Id = x.Id,
  8439. DiId = dto.DiId,
  8440. Type = dto.FeeType,
  8441. Days = x.Days,
  8442. NationalTravelFeeId = x.NationalTravelFeeId,
  8443. Cost = x.Cost,
  8444. Currency = x.Currency,
  8445. SubTotal = x.SubTotal,
  8446. CreateUserId = dto.CurrUserId
  8447. })
  8448. .ToList();
  8449. var adds = infos.Where(x => x.Id <= 0).ToList();
  8450. var upds = infos.Where(x => x.Id > 0).ToList();
  8451. if (adds.Count > 0)
  8452. {
  8453. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8454. if (add < 1) return Ok(JsonView(false));
  8455. }
  8456. if (upds.Count > 0)
  8457. {
  8458. var upd = await _sqlSugar.Updateable(adds)
  8459. .UpdateColumns(x => new
  8460. {
  8461. x.Days,
  8462. x.NationalTravelFeeId,
  8463. x.Cost,
  8464. x.Currency,
  8465. x.SubTotal
  8466. })
  8467. .WhereColumns(x => new { x.Id })
  8468. .ExecuteCommandAsync();
  8469. if (upd < 1) return Ok(JsonView(false));
  8470. }
  8471. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8472. //消息通知
  8473. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8474. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8475. return Ok(JsonView(new { itemTotal = itemTotal }));
  8476. }
  8477. /// <summary>
  8478. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8479. /// </summary>
  8480. /// <returns></returns>
  8481. [HttpPost]
  8482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8483. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8484. {
  8485. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8486. int subId = dto.SubId, feeType = dto.FeeType;
  8487. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8488. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8489. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8490. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8491. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8492. subInfo.Id = subId;
  8493. subInfo.DiId = dto.DiId;
  8494. if (feeType == 3) subInfo.Type = 1;
  8495. else if (feeType == 4) subInfo.Type = 2;
  8496. else if (feeType == 5) subInfo.Type = 3;
  8497. else if (feeType == 6) subInfo.Type = 4;
  8498. subInfo.CreateUserId = dto.CurrUserId;
  8499. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8500. if (parentId < 1) return Ok(JsonView(false));
  8501. //子表op
  8502. if (subId < 1)
  8503. {
  8504. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8505. if (subAdd < 1) return Ok(JsonView(false));
  8506. }
  8507. else
  8508. {
  8509. var subUpd = await _sqlSugar.Updateable(subInfo)
  8510. .UpdateColumns(x => new
  8511. {
  8512. x.Days,
  8513. x.NationalTravelFeeId,
  8514. x.Cost,
  8515. x.Currency,
  8516. x.SubTotal
  8517. })
  8518. .WhereColumns(x => new { x.Id })
  8519. .ExecuteCommandAsync();
  8520. if (subUpd < 1) return Ok(JsonView(false));
  8521. }
  8522. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8523. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8524. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8525. }
  8526. /// <summary>
  8527. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8528. /// </summary>
  8529. /// <returns></returns>
  8530. [HttpPost]
  8531. [ApiExplorerSettings(IgnoreApi = true)]
  8532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8533. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8534. {
  8535. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8536. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8537. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8538. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8539. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8540. {
  8541. Id = x.Id,
  8542. Diid = dto.DiId,
  8543. SetDataId = x.SetDataId,
  8544. Index = x.Index,
  8545. Cost = x.Cost,
  8546. Currency = x.Currency,
  8547. SubTotal = x.SubTotal,
  8548. CreateUserId = dto.CurrUserId,
  8549. Remark = x.Remark
  8550. }).ToList();
  8551. var adds = infos.Where(x => x.Id <= 0).ToList();
  8552. var upds = infos.Where(x => x.Id > 0).ToList();
  8553. if (adds.Count > 0)
  8554. {
  8555. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8556. if (add < 1) return Ok(JsonView(false));
  8557. }
  8558. if (upds.Count > 0)
  8559. {
  8560. var upd = await _sqlSugar.Updateable(adds)
  8561. .UpdateColumns(x => new
  8562. {
  8563. x.Index,
  8564. x.SetDataId,
  8565. x.Cost,
  8566. x.Currency,
  8567. x.SubTotal,
  8568. x.Remark
  8569. })
  8570. .WhereColumns(x => new { x.Id })
  8571. .ExecuteCommandAsync();
  8572. if (upd < 1) return Ok(JsonView(false));
  8573. }
  8574. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8575. //消息通知
  8576. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8577. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8578. return Ok(JsonView(new { itemTotal = itemTotal }));
  8579. }
  8580. /// <summary>
  8581. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8582. /// </summary>
  8583. /// <returns></returns>
  8584. [HttpPost]
  8585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8586. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8587. {
  8588. int subId = dto.SubId;
  8589. int diId = dto.Diid;
  8590. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8591. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8592. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8593. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8594. subInfo.Id = subId;
  8595. subInfo.Diid = dto.Diid;
  8596. subInfo.CreateUserId = dto.CurrUserId;
  8597. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8598. if (parentId < 1) return Ok(JsonView(false));
  8599. #region 子表op
  8600. if (subId < 1)//add
  8601. {
  8602. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8603. if (subAdd < 1) return Ok(JsonView(false));
  8604. }
  8605. else //upd
  8606. {
  8607. var subUpd = await _sqlSugar.Updateable(subInfo)
  8608. .UpdateColumns(x => new
  8609. {
  8610. x.Index,
  8611. x.SetDataId,
  8612. x.Cost,
  8613. x.Currency,
  8614. x.SubTotal,
  8615. x.Remark
  8616. })
  8617. .WhereColumns(x => new { x.Id })
  8618. .ExecuteCommandAsync();
  8619. if (subUpd < 1) return Ok(JsonView(false));
  8620. }
  8621. #endregion
  8622. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8623. //消息通知
  8624. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8625. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8626. }
  8627. /// <summary>
  8628. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8629. /// </summary>
  8630. /// <returns></returns>
  8631. [HttpPost]
  8632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8633. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8634. {
  8635. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8636. if (data.Code != 0)
  8637. {
  8638. return Ok(JsonView(false, data.Msg));
  8639. }
  8640. return Ok(JsonView(true, "操作成功!", data.Data));
  8641. }
  8642. /// <summary>
  8643. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8644. /// </summary>
  8645. /// <param name="dto"></param>
  8646. /// <returns></returns>
  8647. [HttpPost]
  8648. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8649. {
  8650. var data = new Grp_DayOtherPrice()
  8651. {
  8652. Id = dto.Id,
  8653. IsDel = 1,
  8654. DeleteUserId = dto.DeleteUserId,
  8655. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8656. };
  8657. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8658. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8659. return Ok(JsonView(false,"删除失败!"));
  8660. }
  8661. #endregion
  8662. #endregion
  8663. #region 签证费用录入
  8664. /// <summary>
  8665. /// 根据diid查询签证费用列表
  8666. /// </summary>
  8667. /// <param name="dto"></param>
  8668. /// <returns></returns>
  8669. [HttpPost]
  8670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8671. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  8672. {
  8673. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  8674. if (groupData.Code != 0)
  8675. {
  8676. return Ok(JsonView(false, groupData.Msg));
  8677. }
  8678. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8679. }
  8680. /// <summary>
  8681. /// 根据签证费用Id查询单条数据及c表数据
  8682. /// </summary>
  8683. /// <param name="dto"></param>
  8684. /// <returns></returns>
  8685. [HttpPost]
  8686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8687. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  8688. {
  8689. Result groupData = await _visaPriceRep.PostVisaById(dto);
  8690. if (groupData.Code != 0)
  8691. {
  8692. return Ok(JsonView(false, groupData.Msg));
  8693. }
  8694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8695. }
  8696. /// <summary>
  8697. /// 签证费用删除
  8698. /// </summary>
  8699. /// <param name="dto"></param>
  8700. /// <returns></returns>
  8701. [HttpPost]
  8702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8703. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  8704. {
  8705. _sqlSugar.BeginTran();
  8706. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  8707. if (!res)
  8708. {
  8709. _sqlSugar.RollbackTran();
  8710. return Ok(JsonView(false, "删除失败"));
  8711. }
  8712. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  8713. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  8714. .SetColumns(a => new Grp_CreditCardPayment()
  8715. {
  8716. IsDel = 1,
  8717. DeleteUserId = dto.DeleteUserId,
  8718. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8719. })
  8720. .ExecuteCommand();
  8721. if (resSub < 1)
  8722. {
  8723. _sqlSugar.RollbackTran();
  8724. return Ok(JsonView(false, "删除失败"));
  8725. }
  8726. _sqlSugar.CommitTran();
  8727. return Ok(JsonView(true, "删除成功!"));
  8728. }
  8729. /// <summary>
  8730. /// 签证费用录入下拉框初始化
  8731. /// </summary>
  8732. /// <returns></returns>
  8733. [HttpPost]
  8734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8735. public async Task<IActionResult> VisaPriceAddSelect()
  8736. {
  8737. //支付方式
  8738. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  8739. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  8740. //币种
  8741. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  8742. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  8743. //乘客类型
  8744. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  8745. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  8746. //卡类型
  8747. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  8748. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  8749. //代办费类型
  8750. var agencyFeeTypeData = new List<dynamic>() {
  8751. new { id = 0 , Text = "未选择" },
  8752. new { id = 1 , Text = "小公务" },
  8753. new { id = 2 , Text = "大公务" },
  8754. };
  8755. //签证费用标准国家Data
  8756. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  8757. var data = new
  8758. {
  8759. Payment = _Payment,
  8760. CurrencyList = _CurrencyList,
  8761. PassengerType = _PassengerType,
  8762. BankCard = _BankCard,
  8763. AgencyFeeType = agencyFeeTypeData,
  8764. CountryFeeData = visaCountryFeeData
  8765. };
  8766. return Ok(JsonView(true, "查询成功!", data));
  8767. }
  8768. /// <summary>
  8769. /// 签证费用录入操作(Status:1.新增,2.修改)
  8770. /// </summary>
  8771. /// <param name="dto"></param>
  8772. /// <returns></returns>
  8773. [HttpPost]
  8774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8775. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  8776. {
  8777. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  8778. if (groupData.Code != 0)
  8779. {
  8780. return Ok(JsonView(false, groupData.Msg));
  8781. }
  8782. #region 应用推送
  8783. try
  8784. {
  8785. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  8786. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  8787. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8788. //2024-10-21 新增LZ UID
  8789. var userIds = new List<int>() { 21 };
  8790. string title = $"系统通知";
  8791. string content = "";
  8792. var diId = dto.DiId;
  8793. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  8794. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  8795. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8796. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8797. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  8798. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  8799. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  8800. }
  8801. catch (Exception ex)
  8802. {
  8803. }
  8804. #endregion
  8805. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8806. }
  8807. #endregion
  8808. #region 签证提成录入
  8809. /// <summary>
  8810. /// 签证提成录入
  8811. /// 基础数据
  8812. /// </summary>
  8813. /// <param name="_dto"></param>
  8814. /// <returns></returns>
  8815. [HttpGet]
  8816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8817. public async Task<IActionResult> VisaCommissionInit()
  8818. {
  8819. return Ok(await _visaCommissionRep.Init());
  8820. }
  8821. /// <summary>
  8822. /// 签证提成录入
  8823. /// Item
  8824. /// </summary>
  8825. /// <param name="_dto"></param>
  8826. /// <returns></returns>
  8827. [HttpPost]
  8828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8829. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  8830. {
  8831. var validator = new VisaCommissionItemDtoValidator();
  8832. var validatorRes = await validator.ValidateAsync(_dto);
  8833. if (!validatorRes.IsValid)
  8834. {
  8835. StringBuilder sb = new StringBuilder();
  8836. foreach (var item in validatorRes.Errors)
  8837. {
  8838. sb.AppendLine(item.ErrorMessage);
  8839. }
  8840. return Ok(JsonView(false, sb.ToString()));
  8841. }
  8842. return Ok(await _visaCommissionRep.Item(_dto));
  8843. }
  8844. /// <summary>
  8845. /// 签证提成录入
  8846. /// Save
  8847. /// </summary>
  8848. /// <param name="_dto"></param>
  8849. /// <returns></returns>
  8850. [HttpPost]
  8851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8852. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  8853. {
  8854. //参数验证
  8855. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  8856. foreach (var item in _dto.Items)
  8857. {
  8858. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  8859. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  8860. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  8861. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  8862. }
  8863. return Ok(await _visaCommissionRep.Save(_dto));
  8864. }
  8865. /// <summary>
  8866. /// 签证提成录入
  8867. /// Create
  8868. /// </summary>
  8869. /// <param name="_dto"></param>
  8870. /// <returns></returns>
  8871. [HttpPost]
  8872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8873. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  8874. {
  8875. var validator = new VisaCommissionCreateDtoValidator();
  8876. var validatorRes = await validator.ValidateAsync(_dto);
  8877. if (!validatorRes.IsValid)
  8878. {
  8879. StringBuilder sb = new StringBuilder();
  8880. foreach (var item in validatorRes.Errors)
  8881. {
  8882. sb.AppendLine(item.ErrorMessage);
  8883. }
  8884. return Ok(JsonView(false, sb.ToString()));
  8885. }
  8886. return Ok(await _visaCommissionRep.Create(_dto));
  8887. }
  8888. /// <summary>
  8889. /// 签证提成录入
  8890. /// Put(编辑)
  8891. /// </summary>
  8892. /// <param name="id"></param>
  8893. /// <param name="_dto"></param>
  8894. /// <returns></returns>
  8895. [HttpPut]
  8896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8897. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  8898. {
  8899. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  8900. var validator = new VisaCommissionCreateDtoValidator();
  8901. var validatorRes = await validator.ValidateAsync(_dto);
  8902. if (!validatorRes.IsValid)
  8903. {
  8904. StringBuilder sb = new StringBuilder();
  8905. foreach (var item in validatorRes.Errors)
  8906. {
  8907. sb.AppendLine(item.ErrorMessage);
  8908. }
  8909. return Ok(JsonView(false, sb.ToString()));
  8910. }
  8911. return Ok(await _visaCommissionRep.Edit(id, _dto));
  8912. }
  8913. /// <summary>
  8914. /// 签证提成录入
  8915. /// Del
  8916. /// </summary>
  8917. /// <param name="id"></param>
  8918. /// <param name="currUserId"></param>
  8919. /// <returns></returns>
  8920. [HttpPost]
  8921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8922. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  8923. {
  8924. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  8925. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  8926. return Ok(await _visaCommissionRep.Del(id, currUserId));
  8927. }
  8928. #endregion
  8929. #region op费用录入
  8930. /// <summary>
  8931. /// 根据diid查询op费用列表
  8932. /// </summary>
  8933. /// <param name="dto"></param>
  8934. /// <returns></returns>
  8935. [HttpPost]
  8936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8937. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  8938. {
  8939. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  8940. if (groupData.Code != 0)
  8941. {
  8942. return Ok(JsonView(false, groupData.Msg));
  8943. }
  8944. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8945. }
  8946. /// <summary>
  8947. /// 根据op费用Id查询单条数据及c表数据
  8948. /// </summary>
  8949. /// <param name="dto"></param>
  8950. /// <returns></returns>
  8951. [HttpPost]
  8952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8953. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  8954. {
  8955. try
  8956. {
  8957. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  8958. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  8959. var data = new
  8960. {
  8961. CarTouristGuideGround = _groupData,
  8962. CreditCardPayment = _creditCardPayment
  8963. };
  8964. return Ok(JsonView(true, "查询成功!", data));
  8965. }
  8966. catch (Exception ex)
  8967. {
  8968. return Ok(JsonView(false, "程序错误!"));
  8969. }
  8970. }
  8971. /// <summary>
  8972. /// op费用删除
  8973. /// </summary>
  8974. /// <param name="dto"></param>
  8975. /// <returns></returns>
  8976. [HttpPost]
  8977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8978. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  8979. {
  8980. try
  8981. {
  8982. _sqlSugar.BeginTran();
  8983. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  8984. if (!res)
  8985. {
  8986. return Ok(JsonView(false, "删除失败"));
  8987. }
  8988. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  8989. {
  8990. IsDel = 1,
  8991. DeleteUserId = dto.DeleteUserId,
  8992. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8993. }).ExecuteCommandAsync();
  8994. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  8995. {
  8996. IsDel = 1,
  8997. DeleteUserId = dto.DeleteUserId,
  8998. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8999. }).ExecuteCommandAsync();
  9000. #region 删除超支相关数据
  9001. //删除导入的超支数据
  9002. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  9003. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  9004. {
  9005. IsDel = 1,
  9006. DeleteUserId = dto.DeleteUserId,
  9007. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9008. }).ExecuteCommand();
  9009. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  9010. {
  9011. IsDel = 1,
  9012. DeleteUserId = dto.DeleteUserId,
  9013. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9014. }).ExecuteCommand();
  9015. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  9016. {
  9017. IsDel = 1,
  9018. DeleteUserId = dto.DeleteUserId,
  9019. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9020. }).ExecuteCommand();
  9021. #endregion
  9022. _sqlSugar.CommitTran();
  9023. return Ok(JsonView(true, "删除成功!"));
  9024. }
  9025. catch (Exception ex)
  9026. {
  9027. _sqlSugar.RollbackTran();
  9028. return Ok(JsonView(false, "程序错误!" + ex.Message));
  9029. }
  9030. }
  9031. /// <summary>
  9032. /// op费用录入操作(Status:1.新增,2.修改)
  9033. /// </summary>
  9034. /// <param name="dto"></param>
  9035. /// <returns></returns>
  9036. [HttpPost]
  9037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9038. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  9039. {
  9040. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  9041. if (groupData.Code != 0)
  9042. {
  9043. return Ok(JsonView(false, groupData.Msg));
  9044. }
  9045. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9046. }
  9047. /// <summary>
  9048. /// 填写费用详细页面初始化绑定
  9049. /// </summary>
  9050. /// <param name="dto"></param>
  9051. /// <returns></returns>
  9052. [HttpPost]
  9053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9054. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  9055. {
  9056. try
  9057. {
  9058. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  9059. if (groupData.Code != 0)
  9060. {
  9061. return Ok(JsonView(false, groupData.Msg));
  9062. }
  9063. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9064. }
  9065. catch (Exception ex)
  9066. {
  9067. return Ok(JsonView(false, ex.Message));
  9068. }
  9069. }
  9070. /// <summary>
  9071. /// 根据op费用Id查询详细数据
  9072. /// </summary>
  9073. /// <param name="dto"></param>
  9074. /// <returns></returns>
  9075. [HttpPost]
  9076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9077. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  9078. {
  9079. try
  9080. {
  9081. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  9082. if (groupData.Code != 0)
  9083. {
  9084. return Ok(JsonView(false, groupData.Msg));
  9085. }
  9086. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9087. }
  9088. catch (Exception ex)
  9089. {
  9090. return Ok(JsonView(false, ex.Message));
  9091. }
  9092. }
  9093. /// <summary>
  9094. /// OP费用录入填写详情
  9095. /// </summary>
  9096. /// <param name="dto"></param>
  9097. /// <returns></returns>
  9098. [HttpPost]
  9099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9100. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  9101. {
  9102. try
  9103. {
  9104. #region 参数校验
  9105. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  9106. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  9107. if (di == null) return Ok(JsonView(false, "团组错误!"));
  9108. #endregion
  9109. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  9110. if (groupData.Code != 0)
  9111. {
  9112. return Ok(JsonView(false, groupData.Msg));
  9113. }
  9114. //自动审核
  9115. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  9116. #region 应用推送
  9117. try
  9118. {
  9119. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9120. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9121. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9122. //2024-10-21 新增LZ UID
  9123. var userIds = new List<int>() { 21 };
  9124. string title = $"系统通知";
  9125. var diId = dto.DiId;
  9126. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9127. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9128. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  9129. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9130. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  9131. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  9132. }
  9133. catch (Exception ex)
  9134. {
  9135. }
  9136. #endregion
  9137. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9138. }
  9139. catch (Exception ex)
  9140. {
  9141. return Ok(JsonView(false, ex.Message));
  9142. }
  9143. }
  9144. /// <summary>
  9145. /// 获取三公详细所有城市
  9146. /// </summary>
  9147. /// <returns></returns>
  9148. [HttpGet]
  9149. public IActionResult OpCarCityResult()
  9150. {
  9151. var jw = JsonView(false);
  9152. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  9153. {
  9154. x.Id,
  9155. x.Country,
  9156. x.City,
  9157. }).ToList();
  9158. if (data.Count > 0)
  9159. {
  9160. jw = JsonView(true, "获取成功!", data);
  9161. }
  9162. else
  9163. {
  9164. jw.Msg = "城市数据为空!";
  9165. jw.Data = new string[0];
  9166. }
  9167. return Ok(jw);
  9168. }
  9169. /// <summary>
  9170. /// 导出地接费用明细
  9171. /// </summary>
  9172. /// <param name="dto"></param>
  9173. /// <returns></returns>
  9174. [HttpPost]
  9175. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  9176. {
  9177. var jw = JsonView(false);
  9178. if (dto.Diid < 1)
  9179. {
  9180. jw.Msg = "请输入正确的diid!";
  9181. return Ok(jw);
  9182. }
  9183. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  9184. if (group == null)
  9185. {
  9186. jw.Msg = "未找到团组信息!";
  9187. return Ok(jw);
  9188. }
  9189. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  9190. if (localGuideArr.Count == 0)
  9191. {
  9192. jw.Msg = "该团组暂无地接信息!";
  9193. return Ok(jw);
  9194. }
  9195. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  9196. var overspendSoure = new Dictionary<int, int>
  9197. {
  9198. { 91, 982 }, //车
  9199. { 92 , 1059} ,//导游
  9200. { 994 , 1073}, //翻译
  9201. { 988 , 1074 }, //早餐
  9202. { 93 , 1075 }, //午餐
  9203. { 989 , 1076 }, //晚餐
  9204. };
  9205. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  9206. foreach (var groupArr in localGroup)
  9207. {
  9208. var keyValue = groupArr.Key;
  9209. if (int.TryParse(keyValue, out int cityid))
  9210. {
  9211. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  9212. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  9213. }
  9214. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  9215. foreach (var item in groupArr)
  9216. {
  9217. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  9218. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  9219. new Grp_CarTouristGuideGroundReservationsContentExtend
  9220. {
  9221. Count = a.Count,
  9222. CreateTime = a.CreateTime,
  9223. CreateUserId = a.CreateUserId,
  9224. CTGGRId = a.CTGGRId,
  9225. Currency = a.Currency,
  9226. DatePrice = a.DatePrice,
  9227. DeleteTime = a.DeleteTime,
  9228. DeleteUserId = a.DeleteUserId,
  9229. DiId = a.DiId,
  9230. Id = a.Id,
  9231. IsDel = a.IsDel,
  9232. Price = a.Price,
  9233. PriceContent = a.PriceContent,
  9234. Remark = a.Remark,
  9235. SId = a.SId,
  9236. SidName = b.Name,
  9237. Units = a.Units,
  9238. }
  9239. ).ToList();
  9240. if (content.Count > 0)
  9241. {
  9242. contentArr.Add(content);
  9243. }
  9244. }
  9245. //open excel
  9246. //set excel
  9247. //save excel
  9248. try
  9249. {
  9250. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  9251. IWorkbook workbook;
  9252. if (Path.GetExtension(filePath).ToLower() == ".xls")
  9253. {
  9254. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9255. }
  9256. else
  9257. {
  9258. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9259. }
  9260. ISheet sheet = workbook.GetSheetAt(0);
  9261. var rowStartIndex = 2;
  9262. var clounmCount = 10;
  9263. var initStyleRow = sheet.GetRow(2);
  9264. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  9265. //var overspendArrDetail =
  9266. var existsId = new List<CarCompare>();
  9267. var lastElem = arr.Last();
  9268. var thisSid = -1;
  9269. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  9270. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  9271. {
  9272. Name = "未知币种!",
  9273. Remark = "未知币种!",
  9274. };
  9275. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  9276. Action cloneRowFn = () =>
  9277. {
  9278. rowStartIndex++;
  9279. var cloneRow = sheet.CreateRow(rowStartIndex);
  9280. // 复制样式
  9281. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  9282. {
  9283. ICell sourceCell = initStyleRow.GetCell(i);
  9284. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  9285. // 确保单元格存在样式
  9286. if (sourceCell.CellStyle != null)
  9287. {
  9288. targetCell.CellStyle = sourceCell.CellStyle;
  9289. }
  9290. }
  9291. };
  9292. var mergeRow = () =>
  9293. {
  9294. for (int i = 2; i < sheet.LastRowNum; i++)
  9295. {
  9296. var row = sheet.GetRow(i);
  9297. var cellFirst = row.GetCell(0);
  9298. var thisIndex = i + 1;
  9299. while (thisIndex < sheet.LastRowNum)
  9300. {
  9301. var nextRow = sheet.GetRow(thisIndex);
  9302. var nextCellFirst = nextRow.GetCell(0);
  9303. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  9304. {
  9305. thisIndex++;
  9306. }
  9307. else
  9308. {
  9309. break;
  9310. }
  9311. }
  9312. thisIndex--;
  9313. if (thisIndex != i)
  9314. {
  9315. //合并row
  9316. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9317. i, // 起始行索引(0-based)
  9318. thisIndex, // 结束行索引(0-based)
  9319. 0, // 起始列索引(0-based)
  9320. 0 // 结束列索引(0-based)
  9321. );
  9322. sheet.AddMergedRegion(cellRangeAddress);
  9323. i = thisIndex;
  9324. }
  9325. }
  9326. };
  9327. var chaoshiNumber = 0;
  9328. var totalNumber = 0.00M;
  9329. string lastStr = "";
  9330. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  9331. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  9332. {
  9333. b.IsAuditGM,
  9334. x.Id,
  9335. x.Area,
  9336. b.PayPercentage,
  9337. b.PayMoney,
  9338. }).ToList();
  9339. string yesPayment = "", noPayment = "";
  9340. foreach (var item in queryCarArrByCityAndDiid)
  9341. {
  9342. if (item.IsAuditGM == 1)
  9343. {
  9344. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9345. }
  9346. else
  9347. {
  9348. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9349. }
  9350. }
  9351. lastStr = yesPayment + noPayment;
  9352. foreach (var item in arr)
  9353. {
  9354. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  9355. {
  9356. if (thisSid != item.SId)
  9357. {
  9358. if (thisSid == -1)
  9359. {
  9360. thisSid = item.SId;
  9361. }
  9362. else
  9363. {
  9364. //合并小计行
  9365. //创建合并区域的实例
  9366. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9367. rowStartIndex, // 起始行索引(0-based)
  9368. rowStartIndex, // 结束行索引(0-based)
  9369. 0, // 起始列索引(0-based)
  9370. 3 // 结束列索引(0-based)
  9371. );
  9372. sheet.AddMergedRegion(cellRangeAddress);
  9373. var CellStyle = workbook.CreateCellStyle();
  9374. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9375. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9376. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9377. for (int i = 0; i <= clounmCount; i++)
  9378. {
  9379. if (i > 6)
  9380. {
  9381. var CellStyle1 = workbook.CreateCellStyle();
  9382. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9383. IFont Font = workbook.CreateFont(); // 创建字体
  9384. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9385. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9386. CellStyle1.SetFont(Font);
  9387. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9388. }
  9389. else
  9390. {
  9391. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9392. }
  9393. }
  9394. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9395. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9396. //超时合计
  9397. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9398. //超时数
  9399. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9400. //超时合计费用
  9401. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9402. thisSid = item.SId;
  9403. cloneRowFn();
  9404. chaoshiNumber = 0;
  9405. totalNumber = 0;
  9406. }
  9407. }
  9408. IRow row = sheet.GetRow(rowStartIndex);
  9409. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9410. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  9411. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  9412. if (isOpenOverspendSoure)
  9413. {
  9414. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9415. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  9416. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  9417. }
  9418. for (int i = 0; i <= clounmCount; i++)
  9419. {
  9420. var cell = row.GetCell(i);
  9421. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  9422. if (cell == null)
  9423. {
  9424. cell = row.CreateCell(i);
  9425. }
  9426. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  9427. fontRed.CloneStyleFrom(cell.CellStyle);
  9428. IFont Font = workbook.CreateFont(); // 创建字体
  9429. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  9430. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9431. fontRed.SetFont(Font);
  9432. byte[] rgb = new byte[3] { 255, 242, 204 };
  9433. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  9434. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  9435. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  9436. if (workbook is XSSFWorkbook)
  9437. {
  9438. BackgroundColor255_242_204.FillForegroundColor = 0;
  9439. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  9440. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  9441. }
  9442. else
  9443. {
  9444. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  9445. }
  9446. if (i == 1 || i > 6)
  9447. {
  9448. if (i > 6)
  9449. {
  9450. fontRed.FillForegroundColor = 0;
  9451. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  9452. fontRed.FillPattern = FillPattern.SolidForeground;
  9453. }
  9454. cell.CellStyle = fontRed;
  9455. }
  9456. if (i > 2 && i < 7)
  9457. {
  9458. cell.CellStyle = BackgroundColor255_242_204;
  9459. }
  9460. cell.SetCellValue(setCellValue); //写入单元格
  9461. }
  9462. if (overspendSoure.ContainsKey(thisSid))
  9463. {
  9464. var overspendId = overspendSoure[thisSid];
  9465. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9466. }
  9467. cloneRowFn();
  9468. existsId.Add(new CarCompare
  9469. {
  9470. DataPrice = item.DatePrice.ObjToDate(),
  9471. Sid = item.SId
  9472. });
  9473. }
  9474. if (item.Equals(lastElem))
  9475. {
  9476. //合并小计行
  9477. //创建合并区域的实例
  9478. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9479. rowStartIndex, // 起始行索引(0-based)
  9480. rowStartIndex, // 结束行索引(0-based)
  9481. 0, // 起始列索引(0-based)
  9482. 3 // 结束列索引(0-based)
  9483. );
  9484. sheet.AddMergedRegion(cellRangeAddress);
  9485. var CellStyle = workbook.CreateCellStyle();
  9486. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9487. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9488. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9489. for (int i = 0; i <= clounmCount; i++)
  9490. {
  9491. if (i > 6)
  9492. {
  9493. var CellStyle1 = workbook.CreateCellStyle();
  9494. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9495. IFont Font = workbook.CreateFont(); // 创建字体
  9496. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9497. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9498. CellStyle1.SetFont(Font);
  9499. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9500. }
  9501. else
  9502. {
  9503. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9504. }
  9505. }
  9506. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9507. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9508. //超时合计
  9509. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9510. //超时数
  9511. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9512. //超时合计费用
  9513. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9514. cloneRowFn();
  9515. // 创建合并区域的实例
  9516. cellRangeAddress = new CellRangeAddress(
  9517. rowStartIndex, // 起始行索引(0-based)
  9518. rowStartIndex, // 结束行索引(0-based)
  9519. 0, // 起始列索引(0-based)
  9520. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  9521. );
  9522. // 添加合并区域
  9523. sheet.AddMergedRegion(cellRangeAddress);
  9524. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  9525. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  9526. }
  9527. }
  9528. mergeRow();
  9529. // 保存修改后的Excel文件到新文件
  9530. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  9531. // new FileStream(newFilePath, FileMode.CreateNew)
  9532. using (var stream = new MemoryStream())
  9533. {
  9534. workbook.Write(stream, true);
  9535. stream.Flush();
  9536. stream.Seek(0, SeekOrigin.Begin);
  9537. MemoryStream memoryStream = new MemoryStream();
  9538. stream.CopyTo(memoryStream);
  9539. memoryStream.Seek(0, SeekOrigin.Begin);
  9540. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  9541. }
  9542. workbook.Close();
  9543. workbook.Dispose();
  9544. }
  9545. catch (Exception ex)
  9546. {
  9547. jw.Msg = "出现异常!" + ex.Message;
  9548. return Ok(jw);
  9549. }
  9550. }
  9551. if (Zips.Count > 0)
  9552. {
  9553. IOOperatorHelper io = new IOOperatorHelper();
  9554. var byts = io.ConvertZipStream(Zips);
  9555. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  9556. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  9557. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  9558. }
  9559. else
  9560. {
  9561. jw.Msg = "暂无生成文件!";
  9562. }
  9563. return Ok(jw);
  9564. }
  9565. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  9566. {
  9567. string outStr = string.Empty;
  9568. switch (i)
  9569. {
  9570. case 0:
  9571. outStr = arr[0].SidName;
  9572. break;
  9573. case 1:
  9574. outStr = arr[0].DataPriceStr;
  9575. break;
  9576. case 2:
  9577. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  9578. break;
  9579. case 4:
  9580. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  9581. break;
  9582. case 7:
  9583. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9584. {
  9585. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  9586. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  9587. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  9588. }
  9589. break;
  9590. case 8:
  9591. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9592. {
  9593. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  9594. }
  9595. break;
  9596. case 9:
  9597. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9598. {
  9599. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  9600. }
  9601. break;
  9602. case 10:
  9603. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9604. {
  9605. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  9606. }
  9607. break;
  9608. }
  9609. return outStr;
  9610. }
  9611. #region OP行程单
  9612. /// <summary>
  9613. /// OP行程单初始化
  9614. /// </summary>
  9615. /// <param name="dto"></param>
  9616. /// <returns></returns>
  9617. [HttpPost]
  9618. public IActionResult InitOpTravel(InitOpTravelDto dto)
  9619. {
  9620. var jw = JsonView(false);
  9621. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  9622. var group = groupList.First();
  9623. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  9624. if (group == null)
  9625. {
  9626. jw.Msg = "暂无团组!";
  9627. return Ok(jw);
  9628. }
  9629. group = groupList.Find(x => x.Id == diid);
  9630. if (group == null)
  9631. {
  9632. jw.Msg = "请输入正确的团组ID!";
  9633. return Ok(jw);
  9634. }
  9635. string city = string.Empty;
  9636. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  9637. if (blackCode.Count > 0)
  9638. {
  9639. var black = blackCode.First();
  9640. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  9641. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  9642. if (blackSp.Length > 0)
  9643. {
  9644. try
  9645. {
  9646. var cityArrCode = new List<string>(20);
  9647. foreach (var item in blackSp)
  9648. {
  9649. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  9650. var IndexSelect = itemSp[2];
  9651. var cityArrCodeLength = cityArrCode.Count - 1;
  9652. var startCity = IndexSelect.Substring(0, 3);
  9653. if (cityArrCodeLength > 0)
  9654. {
  9655. var arrEndCity = cityArrCode[cityArrCodeLength];
  9656. if (arrEndCity != startCity)
  9657. {
  9658. cityArrCode.Add(startCity.ToUpper());
  9659. }
  9660. }
  9661. else
  9662. {
  9663. cityArrCode.Add(startCity.ToUpper());
  9664. }
  9665. var endCity = IndexSelect.Substring(3, 3);
  9666. cityArrCode.Add(endCity.ToUpper());
  9667. }
  9668. var cityThree = string.Empty;
  9669. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  9670. cityThree = cityThree.TrimEnd(',');
  9671. if (string.IsNullOrWhiteSpace(cityThree))
  9672. {
  9673. throw new
  9674. Exception("error");
  9675. }
  9676. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  9677. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  9678. foreach (var item in cityArrCode)
  9679. {
  9680. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  9681. if (find != null)
  9682. {
  9683. city += find.City + "/";
  9684. }
  9685. else
  9686. {
  9687. city += item + "三字码未收入/";
  9688. }
  9689. }
  9690. city = city.TrimEnd('/');
  9691. }
  9692. catch (Exception e)
  9693. {
  9694. city = "黑屏代码格式不正确!";
  9695. }
  9696. }
  9697. }
  9698. else
  9699. {
  9700. city = "未录入黑屏代码";
  9701. }
  9702. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  9703. {
  9704. Date = x.Date,
  9705. Days = x.Days,
  9706. Diffgroup = x.Diffgroup,
  9707. Diid = x.Diid,
  9708. Traffic_First = x.Traffic_First,
  9709. Traffic_Second = x.Traffic_Second,
  9710. Trip = x.Trip,
  9711. WeekDay = x.WeekDay,
  9712. Id = x.Id
  9713. }).ToList();
  9714. jw.Data = new
  9715. {
  9716. groupList = groupList.Select(x => new
  9717. {
  9718. x.Id,
  9719. x.TeamName,
  9720. x.TourCode
  9721. }).ToList(),
  9722. groupInfo = new
  9723. {
  9724. group.VisitDays,
  9725. group.TourCode,
  9726. group.VisitPNumber,
  9727. group.TeamName,
  9728. city
  9729. },
  9730. OpTravelList
  9731. };
  9732. jw.Code = 200;
  9733. jw.Msg = "操作成功!";
  9734. return Ok(jw);
  9735. }
  9736. /// <summary>
  9737. /// 删除团组行程单
  9738. /// </summary>
  9739. /// <returns></returns>
  9740. [HttpPost]
  9741. public IActionResult DelTravel(DelOpTravelDto dto)
  9742. {
  9743. var jw = JsonView(false);
  9744. if (dto.UserId <= 0 || dto.Diid <= 0)
  9745. {
  9746. jw.Msg = "请输入正确的参数!";
  9747. return Ok(jw);
  9748. }
  9749. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  9750. .SetColumns(x => new Grp_TravelList
  9751. {
  9752. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9753. DeleteUserId = dto.UserId,
  9754. IsDel = 1,
  9755. }).ExecuteCommand();
  9756. jw = JsonView(true);
  9757. return Ok(jw);
  9758. }
  9759. /// <summary>
  9760. /// 行程单保存
  9761. /// </summary>
  9762. /// <returns></returns>
  9763. [HttpPost]
  9764. public IActionResult TravelSave(TravelSaveDto dto)
  9765. {
  9766. var jw = JsonView(false);
  9767. if (dto.Arr.Count > 0)
  9768. {
  9769. try
  9770. {
  9771. _sqlSugar.BeginTran();
  9772. foreach (var item in dto.Arr)
  9773. {
  9774. if (item.Id == 0)
  9775. {
  9776. throw new Exception("请传入正确的Id");
  9777. }
  9778. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  9779. .SetColumns(x => new Grp_TravelList
  9780. {
  9781. Trip = item.Trip
  9782. }).ExecuteCommand();
  9783. }
  9784. _sqlSugar.CommitTran();
  9785. jw = JsonView(true);
  9786. }
  9787. catch (Exception ex)
  9788. {
  9789. _sqlSugar.RollbackTran();
  9790. jw.Msg = "程序异常!" + ex.Message;
  9791. }
  9792. }
  9793. else
  9794. {
  9795. jw.Msg = "请传入正确的参数!";
  9796. }
  9797. return Ok(jw);
  9798. }
  9799. /// <summary>
  9800. /// 导出行程单
  9801. /// </summary>
  9802. /// <param name="dto"></param>
  9803. /// <returns></returns>
  9804. [HttpPost]
  9805. public IActionResult ExportTravel(ExportTravelDto dto)
  9806. {
  9807. var jw = JsonView(false);
  9808. jw.Data = "";
  9809. int diid = 0;
  9810. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  9811. if (Find == null)
  9812. {
  9813. jw.Msg = "请选择正确的团组!";
  9814. return Ok(jw);
  9815. }
  9816. else
  9817. {
  9818. diid = Find.Id;
  9819. }
  9820. //数据源
  9821. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  9822. DataTable dtBlack = null;
  9823. try
  9824. {
  9825. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  9826. }
  9827. catch (Exception)
  9828. {
  9829. jw.Msg = "机票黑屏代码有误!";
  9830. return Ok(jw);
  9831. }
  9832. string CityStr = string.Empty;
  9833. if (dtBlack.Rows.Count == 0)
  9834. {
  9835. jw.Msg = "机票黑屏代码有误!";
  9836. return Ok(jw);
  9837. }
  9838. else
  9839. {
  9840. foreach (DataRow row in dtBlack.Rows)
  9841. {
  9842. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  9843. {
  9844. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  9845. return Ok(jw);
  9846. }
  9847. }
  9848. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  9849. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  9850. }
  9851. //创建数据源Table
  9852. DataTable dtSource = new DataTable();
  9853. dtSource.Columns.Add("Days", typeof(string));
  9854. dtSource.Columns.Add("Date", typeof(string));
  9855. dtSource.Columns.Add("Week", typeof(string));
  9856. dtSource.Columns.Add("Traffic", typeof(string));
  9857. dtSource.Columns.Add("Trip", typeof(string));
  9858. //获取数据,放到datatable
  9859. foreach (var item in _travelList)
  9860. {
  9861. DataRow dr = dtSource.NewRow();
  9862. dr["Days"] = item.Days;
  9863. dr["Date"] = item.Date;
  9864. dr["Week"] = item.WeekDay;
  9865. dr["Traffic"] = item.Traffic_First
  9866. + "\r\n"
  9867. + item.Traffic_Second;
  9868. dr["Trip"] = item.Trip;
  9869. dtSource.Rows.Add(dr);
  9870. }
  9871. Dictionary<string, string> dic = new Dictionary<string, string>();
  9872. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  9873. dic.Add("City", CityStr);
  9874. dic.Add("Days", Find.VisitDays.ToString());
  9875. dic.Add("DeleCode", Find.TourCode);
  9876. dic.Add("Pnum", Find.VisitPNumber.ToString());
  9877. //模板路径
  9878. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  9879. //载入模板
  9880. Document doc = null;
  9881. DocumentBuilder builder = null;
  9882. try
  9883. {
  9884. //载入模板
  9885. doc = new Document(tempPath);
  9886. builder = new DocumentBuilder(doc);
  9887. }
  9888. catch (Exception)
  9889. {
  9890. jw.Msg = "模板位置不存在!";
  9891. return Ok(jw);
  9892. }
  9893. foreach (var key in dic.Keys)
  9894. {
  9895. Bookmark bookmark = doc.Range.Bookmarks[key];
  9896. if (bookmark != null)
  9897. {
  9898. builder.MoveToBookmark(key);
  9899. builder.Write(dic[key]);
  9900. }
  9901. }
  9902. //获取word里所有表格
  9903. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9904. //获取所填表格的序数
  9905. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9906. try
  9907. {
  9908. //循环赋值
  9909. for (int i = 0; i < dtSource.Rows.Count; i++)
  9910. {
  9911. builder.MoveToCell(0, i + 1, 0, 0);
  9912. builder.Write(dtSource.Rows[i]["Days"].ToString());
  9913. builder.MoveToCell(0, i + 1, 1, 0);
  9914. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  9915. builder.MoveToCell(0, i + 1, 2, 0);
  9916. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  9917. var trip = dtSource.Rows[i]["Trip"].ToString();
  9918. builder.MoveToCell(0, i + 1, 3, 0);
  9919. builder.Write(trip);
  9920. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  9921. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  9922. // 获取特定索引的段落
  9923. Paragraph paragraph = (Paragraph)paragraphs[0];
  9924. Run run = paragraph.Runs[0];
  9925. Aspose.Words.Font font = run.Font;
  9926. font.Name = "黑体";
  9927. //设置双休红色
  9928. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  9929. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  9930. paragraph = (Paragraph)paragraphs[1];
  9931. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  9932. {
  9933. run = paragraph.Runs[0];
  9934. font = run.Font;
  9935. font.Color = Color.Red;
  9936. }
  9937. }
  9938. }
  9939. catch (Exception ex)
  9940. {
  9941. }
  9942. //删除多余行
  9943. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  9944. {
  9945. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  9946. }
  9947. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  9948. if (!Directory.Exists(savePath))
  9949. {
  9950. try
  9951. {
  9952. Directory.CreateDirectory(savePath);
  9953. }
  9954. catch
  9955. {
  9956. }
  9957. }
  9958. string path = savePath + Find.TeamName + "出访日程";
  9959. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  9960. try
  9961. {
  9962. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  9963. string postfix = ".docx";
  9964. if (dto.IsPDF == 1)
  9965. {
  9966. saveFormat = Aspose.Words.SaveFormat.Pdf;
  9967. postfix = ".pdf";
  9968. }
  9969. doc.Save(path + postfix, saveFormat);
  9970. jw = JsonView(true, "导出成功", ftpPath + postfix);
  9971. }
  9972. catch (Exception)
  9973. {
  9974. jw = JsonView(false);
  9975. }
  9976. return Ok(jw);
  9977. }
  9978. /// <summary>
  9979. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  9980. /// </summary>
  9981. /// <param name="num"></param>
  9982. /// <returns></returns>
  9983. string GetNum(string num)
  9984. {
  9985. string str = "";
  9986. switch (num)
  9987. {
  9988. case "1":
  9989. str = "一";
  9990. break;
  9991. case "2":
  9992. str = "二";
  9993. break;
  9994. case "3":
  9995. str = "三";
  9996. break;
  9997. case "4":
  9998. str = "四";
  9999. break;
  10000. case "5":
  10001. str = "五";
  10002. break;
  10003. case "6":
  10004. str = "六";
  10005. break;
  10006. case "7":
  10007. str = "七";
  10008. break;
  10009. case "8":
  10010. str = "八";
  10011. break;
  10012. case "9":
  10013. str = "九";
  10014. break;
  10015. case "10":
  10016. str = "十";
  10017. break;
  10018. case "11":
  10019. str = "十一";
  10020. break;
  10021. case "12":
  10022. str = "十二";
  10023. break;
  10024. case "一":
  10025. str = "1";
  10026. break;
  10027. case "二":
  10028. str = "2";
  10029. break;
  10030. case "三":
  10031. str = "3";
  10032. break;
  10033. case "四":
  10034. str = "4";
  10035. break;
  10036. case "五":
  10037. str = "5";
  10038. break;
  10039. case "六":
  10040. str = "6";
  10041. break;
  10042. case "七":
  10043. str = "7";
  10044. break;
  10045. case "八":
  10046. str = "8";
  10047. break;
  10048. case "九":
  10049. str = "9";
  10050. break;
  10051. case "十":
  10052. str = "10";
  10053. break;
  10054. case "十一":
  10055. str = "11";
  10056. break;
  10057. case "十二":
  10058. str = "12";
  10059. break;
  10060. }
  10061. return str;
  10062. }
  10063. #endregion
  10064. #endregion
  10065. #region 团组成本
  10066. /// <summary>
  10067. /// 团组成本数据初始化
  10068. /// </summary>
  10069. /// <param name="dto"></param>
  10070. /// <returns></returns>
  10071. [HttpPost]
  10072. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  10073. {
  10074. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  10075. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  10076. WHEN COUNT(*) >= 0 THEN 'True'
  10077. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  10078. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  10079. ").ToList(); //团组列表
  10080. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  10081. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  10082. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  10083. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  10084. if (groupinfoValue != null)
  10085. {
  10086. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  10087. var spArr = new string[1] { countryArr };
  10088. if (countryArr.Contains("|"))
  10089. {
  10090. spArr = countryArr.Split("|");
  10091. }
  10092. else if (countryArr.Contains("、"))
  10093. {
  10094. spArr = countryArr.Split("、");
  10095. }
  10096. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  10097. {
  10098. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  10099. if (dbQueryCountry != null)
  10100. {
  10101. visaCountryInfoArr.Add(dbQueryCountry);
  10102. }
  10103. }
  10104. }
  10105. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  10106. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  10107. var create = _GroupCostRepository.
  10108. CreateGroupCostByBlackCode(dto.Diid);
  10109. if (groupCost.Count == 0 && create.Code == 0)
  10110. {
  10111. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  10112. }
  10113. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  10114. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  10115. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  10116. groupCostMap = groupCostMap.Select(x =>
  10117. {
  10118. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  10119. {
  10120. x.Date = dataForamt.ToString("yyyy-MM-dd");
  10121. }
  10122. return x;
  10123. }).ToList();
  10124. //GroupCostParameter.Add(new
  10125. // Grp_GroupCostParameter());
  10126. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  10127. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  10128. return Ok(JsonView(new
  10129. {
  10130. groupList,
  10131. groupInfo,
  10132. groupChecks,
  10133. groupCost = groupCostMap,
  10134. hotelNumber,
  10135. GroupCostParameter = GroupCostParameterMap,
  10136. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  10137. {
  10138. x.VisaCountry,
  10139. x.VisaPrice,
  10140. x.Id,
  10141. }).ToList(),
  10142. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  10143. blackCodeIsTrue = create.Code == 0 ? true : false,
  10144. hotelIsTrue = hotelIsTrue,
  10145. }));
  10146. }
  10147. /// <summary>
  10148. /// 团组成本信息保存
  10149. /// </summary>
  10150. /// <param name="dto"></param>
  10151. /// <returns></returns>
  10152. [HttpPost]
  10153. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  10154. {
  10155. if (dto.Diid <= 0 || dto.Userid <= 0)
  10156. {
  10157. return Ok(JsonView(false));
  10158. }
  10159. JsonView jw = null;
  10160. bool isTrue = false;
  10161. #region 复制团组成本
  10162. //if (dto.Diid == 2581)
  10163. //{
  10164. // dto.Diid = 2599;
  10165. // dto.CheckBoxs.ForEach(x =>
  10166. // {
  10167. // x.Diid = 2599;
  10168. // });
  10169. // dto.GroupCosts.ForEach(x =>
  10170. // {
  10171. // x.Diid = 2599;
  10172. // });
  10173. // dto.CostTypeHotelNumbers.ForEach(x =>
  10174. // {
  10175. // x.Diid = 2599;
  10176. // });
  10177. // dto.GroupCostParameters.ForEach(x =>
  10178. // {
  10179. // x.DiId = 2599;
  10180. // });
  10181. //}
  10182. #endregion
  10183. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  10184. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  10185. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  10186. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  10187. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  10188. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  10189. try
  10190. {
  10191. _sqlSugar.BeginTran();
  10192. isTrue = await _GroupCostRepository.
  10193. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  10194. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  10195. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  10196. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  10197. _sqlSugar.CommitTran();
  10198. jw = JsonView(true, "保存成功!", isTrue);
  10199. }
  10200. catch (Exception)
  10201. {
  10202. _sqlSugar.RollbackTran();
  10203. jw = JsonView(false);
  10204. }
  10205. return Ok(jw);
  10206. }
  10207. /// <summary>
  10208. /// 司兼导数据
  10209. /// </summary>
  10210. /// <param name="dto"></param>
  10211. /// <returns></returns>
  10212. [HttpPost]
  10213. public IActionResult GetCarGuides(CarGuidesDto dto)
  10214. {
  10215. JsonView jw = null;
  10216. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  10217. jw = JsonView(true, "获取成功!", Data);
  10218. return Ok(jw);
  10219. }
  10220. /// <summary>
  10221. /// 导游数据
  10222. /// </summary>
  10223. /// <param name="dto"></param>
  10224. /// <returns></returns>
  10225. [HttpPost]
  10226. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  10227. {
  10228. JsonView jw = null;
  10229. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  10230. // 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
  10231. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  10232. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  10233. jw = JsonView(true, "获取成功!", Data);
  10234. return Ok(jw);
  10235. }
  10236. /// <summary>
  10237. /// 成本车数据
  10238. /// </summary>
  10239. /// <param name="dto"></param>
  10240. /// <returns></returns>
  10241. [HttpPost]
  10242. public IActionResult GetCarInfo(CarGuidesDto dto)
  10243. {
  10244. JsonView jw = null;
  10245. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  10246. jw = JsonView(true, "获取成功!", Data);
  10247. return Ok(jw);
  10248. }
  10249. /// <summary>
  10250. /// 景点数据
  10251. /// </summary>
  10252. /// <param name="dto"></param>
  10253. /// <returns></returns>
  10254. [HttpPost]
  10255. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  10256. {
  10257. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  10258. return Ok(JsonView(true, "获取成功!", Data));
  10259. }
  10260. /// <summary>
  10261. /// 成本通知
  10262. /// </summary>
  10263. /// <param name="dto"></param>
  10264. /// <returns></returns>
  10265. [HttpPost]
  10266. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  10267. {
  10268. if (dto.Diid < 0)
  10269. {
  10270. return Ok(JsonView(false));
  10271. }
  10272. JsonView jw = null;
  10273. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  10274. if (GroupCostParameter != null)
  10275. {
  10276. int IsShare = 0;
  10277. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  10278. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  10279. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  10280. string msg = string.Empty;
  10281. if (isTrue)
  10282. {
  10283. if (IsShare == 0)
  10284. {
  10285. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  10286. }
  10287. else
  10288. {
  10289. #region 企微通知对应岗位用户
  10290. try
  10291. {
  10292. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  10293. }
  10294. catch (Exception ex)
  10295. {
  10296. }
  10297. #endregion
  10298. msg = "通知成功,其他模块操作人员可见此成本信息!";
  10299. }
  10300. jw = JsonView(isTrue, msg, new { IsShare });
  10301. }
  10302. else
  10303. {
  10304. msg = "修改失败!";
  10305. jw = JsonView(isTrue, msg);
  10306. }
  10307. }
  10308. else
  10309. {
  10310. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  10311. }
  10312. return Ok(jw);
  10313. }
  10314. /// <summary>
  10315. /// 导出报价单
  10316. /// </summary>
  10317. /// <param name="dto"></param>
  10318. /// <returns></returns>
  10319. [HttpPost]
  10320. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  10321. {
  10322. if (dto.Diid == 0)
  10323. {
  10324. return Ok(JsonView(false, "请传递团组id"));
  10325. }
  10326. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10327. if (deleInfo.Code != 0)
  10328. {
  10329. return Ok(JsonView(false, "团组信息查询失败!"));
  10330. }
  10331. var di = deleInfo.Data as DelegationInfoWebView;
  10332. if (di != null)
  10333. {
  10334. di.TeamName = di.TeamName.Replace("|", "、");
  10335. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  10336. //文件名
  10337. string strFileName = di.TeamName + "-收款账单.doc";
  10338. //获取模板
  10339. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  10340. //载入模板
  10341. Document doc = new Document(tmppath);
  10342. decimal TotalPrice = 0.00M;
  10343. string itemStr = string.Empty;
  10344. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  10345. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10346. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10347. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  10348. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  10349. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  10350. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  10351. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  10352. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  10353. foreach (var cost in groupCostType)
  10354. {
  10355. var List = cost.ToList();
  10356. if (cost.Key == "A")
  10357. {
  10358. foreach (var ListItem in List)
  10359. {
  10360. if (ListItem.number > 0)
  10361. {
  10362. if (ListItem.code.Contains("TBR"))
  10363. {
  10364. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10365. }
  10366. else
  10367. {
  10368. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10369. }
  10370. TotalPrice += (ListItem.number * ListItem.price);
  10371. }
  10372. }
  10373. }
  10374. else
  10375. {
  10376. itemStr = itemStr.Insert(0, "A段\r\n");
  10377. itemStr += "B段\r\n";
  10378. foreach (var ListItem in List)
  10379. {
  10380. if (ListItem.number > 0)
  10381. {
  10382. if (ListItem.code.Contains("TBR"))
  10383. {
  10384. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10385. }
  10386. else
  10387. {
  10388. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10389. }
  10390. TotalPrice += (ListItem.number * ListItem.price);
  10391. }
  10392. }
  10393. }
  10394. }
  10395. #region 替换Word模板书签内容
  10396. Dictionary<string, string> marks = new Dictionary<string, string>();
  10397. marks.Add("To", di.ClientUnit);//付款方
  10398. marks.Add("ToTel", di.TellPhone);//付款方电话
  10399. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  10400. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  10401. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  10402. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  10403. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  10404. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  10405. marks.Add("PayItemContent", itemStr);//详细信息
  10406. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  10407. #endregion
  10408. ////注
  10409. //if (doc.Range.Bookmarks["Attention"] != null)
  10410. //{
  10411. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  10412. // mark.Text = frList[0].Attention;
  10413. //}
  10414. foreach (var item in marks.Keys)
  10415. {
  10416. if (doc.Range.Bookmarks[item] != null)
  10417. {
  10418. Bookmark mark = doc.Range.Bookmarks[item];
  10419. mark.Text = marks[item];
  10420. }
  10421. }
  10422. byte[] bytes = null;
  10423. using (MemoryStream stream = new MemoryStream())
  10424. {
  10425. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10426. bytes = stream.ToArray();
  10427. }
  10428. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  10429. return Ok(JsonView(true, "", new
  10430. {
  10431. Data = bytes,
  10432. strFileName,
  10433. }));
  10434. }
  10435. else
  10436. {
  10437. return Ok(JsonView(false, "团组信息不存在!"));
  10438. }
  10439. }
  10440. /// <summary>
  10441. /// 导出团组成本
  10442. /// </summary>
  10443. /// <param name="dto"></param>
  10444. /// <returns></returns>
  10445. [HttpPost]
  10446. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  10447. {
  10448. var jw = JsonView(false);
  10449. if (dto.Diid == 0)
  10450. {
  10451. return Ok(JsonView(false, "请传递团组id"));
  10452. }
  10453. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10454. if (deleInfo.Code != 0)
  10455. {
  10456. return Ok(JsonView(false, "团组信息查询失败!"));
  10457. }
  10458. var di = deleInfo.Data as DelegationInfoWebView;
  10459. if (di == null)
  10460. {
  10461. return Ok(JsonView(false, "团组信息查询失败!"));
  10462. }
  10463. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  10464. WorkbookDesigner designer = new WorkbookDesigner();
  10465. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  10466. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  10467. for (int i = 0; i < List_GC.Count; i++)
  10468. {
  10469. GroupCost_Excel gc = new GroupCost_Excel();
  10470. gc.Id = List_GC[i].Id;
  10471. gc.Diid = List_GC[i].Diid.ToString();
  10472. gc.DAY = List_GC[i].DAY;
  10473. string week = "";
  10474. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  10475. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  10476. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  10477. gc.ITIN = List_GC[i].ITIN;
  10478. gc.CarType = List_GC[i].CarType;
  10479. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  10480. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  10481. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  10482. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  10483. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  10484. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  10485. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  10486. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  10487. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  10488. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  10489. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  10490. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  10491. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10492. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10493. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  10494. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  10495. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  10496. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  10497. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  10498. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  10499. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  10500. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  10501. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  10502. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  10503. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  10504. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  10505. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  10506. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  10507. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  10508. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  10509. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  10510. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  10511. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  10512. List_GC1.Add(gc);
  10513. }
  10514. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  10515. dt.TableName = "TB";
  10516. //报表标题等不用dt的值
  10517. designer.SetDataSource("TeamName", dto.title.TeamName);
  10518. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  10519. designer.SetDataSource("Tax", dto.title.Tax);
  10520. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  10521. designer.SetDataSource("Currency", dto.title.Currency);
  10522. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  10523. designer.SetDataSource("Rate", dto.title.Rate);
  10524. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  10525. var Aparams = hotels.Find(x => x.Type == "Default");
  10526. if (Aparams == null)
  10527. {
  10528. return Ok(jw);
  10529. }
  10530. //酒店数量
  10531. var txtSGRNumber = Aparams.SGR.ToString();
  10532. var txtTBRNumber = Aparams.TBR.ToString();
  10533. var txtJSESNumber = Aparams.JSES.ToString();
  10534. var txtSUITENumbe = Aparams.SUITE.ToString();
  10535. if (dto.costType == "B")
  10536. {
  10537. Aparams = hotels.Find(x => x.Type == "A");
  10538. var Bparams = hotels.Find(x => x.Type == "B");
  10539. if (Aparams == null || Bparams == null)
  10540. {
  10541. return Ok(jw);
  10542. }
  10543. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  10544. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  10545. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  10546. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  10547. }
  10548. designer.SetDataSource("SGRNumber", txtSGRNumber);
  10549. designer.SetDataSource("TBRNumber", txtTBRNumber);
  10550. designer.SetDataSource("JSESNumber", txtJSESNumber);
  10551. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  10552. var ws = designer.Workbook.Worksheets[0];
  10553. int Row = List_GC.Count;
  10554. int startIndex = 11;
  10555. int HideRows = 0;
  10556. List<int> hideRowsList = new List<int>();
  10557. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  10558. #region A段left数据
  10559. var left = dto.leftInfo.Find(x => x.Type == "A");
  10560. if (left == null)
  10561. {
  10562. return Ok(jw);
  10563. }
  10564. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  10565. if (leftBindData != null)
  10566. {
  10567. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  10568. designer.SetDataSource("VisaRS", leftBindData.rs);
  10569. designer.SetDataSource("VisaXS", leftBindData.xs);
  10570. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10571. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10572. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10573. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10574. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10575. }
  10576. else
  10577. {
  10578. hideRowsList.Add(Row + startIndex + HideRows);
  10579. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10580. }
  10581. HideRows += 2;
  10582. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  10583. if (leftBindData != null)
  10584. {
  10585. designer.SetDataSource("BXDRCB", leftBindData.cb);
  10586. designer.SetDataSource("BXRS", leftBindData.rs);
  10587. designer.SetDataSource("BXXS", leftBindData.xs);
  10588. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10589. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10590. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10591. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10592. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10593. }
  10594. else
  10595. {
  10596. hideRowsList.Add(Row + startIndex + HideRows);
  10597. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10598. }
  10599. HideRows += 2;
  10600. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  10601. if (leftBindData != null)
  10602. {
  10603. designer.SetDataSource("HSDRCB", leftBindData.cb);
  10604. designer.SetDataSource("HSRS", leftBindData.rs);
  10605. designer.SetDataSource("HSXS", leftBindData.xs);
  10606. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10607. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10608. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10609. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10610. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10611. }
  10612. else
  10613. {
  10614. hideRowsList.Add(Row + startIndex + HideRows);
  10615. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10616. }
  10617. HideRows += 2;
  10618. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  10619. if (leftBindData != null)
  10620. {
  10621. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  10622. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  10623. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  10624. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10625. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10626. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10627. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10628. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10629. }
  10630. else
  10631. {
  10632. hideRowsList.Add(Row + startIndex + HideRows);
  10633. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10634. }
  10635. HideRows += 2;
  10636. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  10637. if (leftBindData != null)
  10638. {
  10639. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  10640. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  10641. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  10642. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10643. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10644. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10645. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10646. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10647. }
  10648. else
  10649. {
  10650. hideRowsList.Add(Row + startIndex + HideRows);
  10651. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10652. }
  10653. HideRows += 2;
  10654. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  10655. if (leftBindData != null)
  10656. {
  10657. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  10658. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  10659. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  10660. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10661. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10662. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10663. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10664. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10665. }
  10666. else
  10667. {
  10668. hideRowsList.Add(Row + startIndex + HideRows);
  10669. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10670. }
  10671. HideRows += 2;
  10672. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  10673. if (leftBindData != null)
  10674. {
  10675. ////TBR
  10676. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  10677. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  10678. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  10679. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10680. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10681. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10682. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10683. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10684. }
  10685. else
  10686. {
  10687. hideRowsList.Add(Row + startIndex + HideRows);
  10688. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10689. }
  10690. HideRows += 2;
  10691. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  10692. if (leftBindData != null)
  10693. {
  10694. ////SGR
  10695. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  10696. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  10697. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  10698. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10699. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10700. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10701. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10702. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10703. }
  10704. else
  10705. {
  10706. hideRowsList.Add(Row + startIndex + HideRows);
  10707. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10708. }
  10709. HideRows += 2;
  10710. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  10711. if (leftBindData != null)
  10712. {
  10713. ////JS/ES
  10714. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  10715. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  10716. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  10717. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10718. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10719. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10720. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10721. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10722. }
  10723. else
  10724. {
  10725. hideRowsList.Add(Row + startIndex + HideRows);
  10726. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10727. }
  10728. HideRows += 2;
  10729. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  10730. if (leftBindData != null)
  10731. {
  10732. ////SUITE
  10733. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  10734. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  10735. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  10736. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10737. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10738. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10739. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10740. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10741. }
  10742. else
  10743. {
  10744. hideRowsList.Add(Row + startIndex + HideRows);
  10745. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10746. }
  10747. HideRows += 2;
  10748. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  10749. if (leftBindData != null)
  10750. {
  10751. designer.SetDataSource("DJDRCB", leftBindData.cb);
  10752. designer.SetDataSource("DJRS", leftBindData.rs);
  10753. designer.SetDataSource("DJXS", leftBindData.xs);
  10754. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10755. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10756. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10757. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10758. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10759. }
  10760. else
  10761. {
  10762. hideRowsList.Add(Row + startIndex + HideRows);
  10763. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10764. }
  10765. HideRows += 2;
  10766. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  10767. if (leftBindData != null)
  10768. {
  10769. designer.SetDataSource("HCPCB", leftBindData.cb);
  10770. designer.SetDataSource("HCPRS", leftBindData.rs);
  10771. designer.SetDataSource("HCPXS", leftBindData.xs);
  10772. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10773. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10774. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10775. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10776. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10777. }
  10778. else
  10779. {
  10780. hideRowsList.Add(Row + startIndex + HideRows);
  10781. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10782. }
  10783. HideRows += 2;
  10784. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  10785. if (leftBindData != null)
  10786. {
  10787. designer.SetDataSource("CPCB", leftBindData.cb);
  10788. designer.SetDataSource("CPRS", leftBindData.rs);
  10789. designer.SetDataSource("CPXS", leftBindData.xs);
  10790. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10791. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10792. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10793. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10794. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10795. }
  10796. else
  10797. {
  10798. hideRowsList.Add(Row + startIndex + HideRows);
  10799. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10800. }
  10801. HideRows += 2;
  10802. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  10803. if (leftBindData != null)
  10804. {
  10805. designer.SetDataSource("GWDRCD", leftBindData.cb);
  10806. designer.SetDataSource("GWRS", leftBindData.rs);
  10807. designer.SetDataSource("GWXS", leftBindData.xs);
  10808. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10809. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10810. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10811. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10812. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10813. }
  10814. else
  10815. {
  10816. hideRowsList.Add(Row + startIndex + HideRows);
  10817. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10818. }
  10819. HideRows += 2;
  10820. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  10821. if (leftBindData != null)
  10822. {
  10823. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  10824. designer.SetDataSource("LYJRS", leftBindData.rs);
  10825. designer.SetDataSource("LYJXS", leftBindData.xs);
  10826. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10827. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10828. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10829. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10830. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10831. }
  10832. else
  10833. {
  10834. hideRowsList.Add(Row + startIndex + HideRows);
  10835. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10836. }
  10837. #endregion
  10838. #region A段Right信息
  10839. var right = dto.rightInfo.Find(x => x.Type == "A");
  10840. if (right == null)
  10841. {
  10842. return Ok(jw);
  10843. }
  10844. HideRows += 4;
  10845. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  10846. if (rightBindData != null)
  10847. {
  10848. //经济舱 + 双人间 TBR
  10849. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  10850. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  10851. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10852. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  10853. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10854. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10855. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10856. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10857. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10858. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10859. }
  10860. else
  10861. {
  10862. hideRowsList.Add(Row + startIndex + HideRows);
  10863. }
  10864. HideRows += 2;
  10865. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  10866. if (rightBindData != null)
  10867. {
  10868. //经济舱 + 单人间 SGR
  10869. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  10870. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  10871. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10872. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  10873. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10874. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10875. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10876. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10877. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10878. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10879. }
  10880. else
  10881. {
  10882. hideRowsList.Add(Row + startIndex + HideRows);
  10883. }
  10884. HideRows += 2;
  10885. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  10886. if (rightBindData != null)
  10887. {
  10888. //公务舱 + 单人间 SGR
  10889. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  10890. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  10891. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10892. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  10893. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10894. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10895. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10896. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10897. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10898. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10899. }
  10900. else
  10901. {
  10902. hideRowsList.Add(Row + startIndex + HideRows);
  10903. }
  10904. HideRows += 2;
  10905. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  10906. if (rightBindData != null)
  10907. {
  10908. //公务舱 + 小套房 JSES
  10909. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  10910. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  10911. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10912. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  10913. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10914. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10915. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10916. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10917. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10918. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10919. }
  10920. else
  10921. {
  10922. hideRowsList.Add(Row + startIndex + HideRows);
  10923. }
  10924. HideRows += 2;
  10925. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  10926. if (rightBindData != null)
  10927. {
  10928. //公务舱 + 小套房 JSES
  10929. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  10930. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  10931. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10932. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  10933. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10934. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10935. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10936. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10937. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10938. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10939. }
  10940. else
  10941. {
  10942. hideRowsList.Add(Row + startIndex + HideRows);
  10943. }
  10944. HideRows += 2;
  10945. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  10946. if (rightBindData != null)
  10947. {
  10948. //经济舱 + 大套房
  10949. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  10950. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  10951. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10952. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  10953. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10954. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10955. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10956. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10957. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10958. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10959. }
  10960. else
  10961. {
  10962. hideRowsList.Add(Row + startIndex + HideRows);
  10963. }
  10964. HideRows += 2;
  10965. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  10966. if (rightBindData != null)
  10967. {
  10968. //头等舱 + 小套房 JSES
  10969. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  10970. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  10971. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10972. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  10973. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10974. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10975. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10976. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10977. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10978. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10979. }
  10980. else
  10981. {
  10982. hideRowsList.Add(Row + startIndex + HideRows);
  10983. }
  10984. HideRows += 2;
  10985. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  10986. if (rightBindData != null)
  10987. {
  10988. //头等舱 + 大套房
  10989. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  10990. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  10991. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  10992. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  10993. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  10994. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  10995. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  10996. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  10997. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  10998. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10999. }
  11000. else
  11001. {
  11002. hideRowsList.Add(Row + startIndex + HideRows);
  11003. }
  11004. #endregion
  11005. #region B段标题清空
  11006. designer.SetDataSource("CostBDRCB", "");
  11007. designer.SetDataSource("CostBRS", "");
  11008. designer.SetDataSource("CostBXS", "");
  11009. designer.SetDataSource("CostBZCB", "");
  11010. designer.SetDataSource("CostBDRBJ", "");
  11011. designer.SetDataSource("CostBZBJ", "");
  11012. designer.SetDataSource("CostBDRLR", "");
  11013. designer.SetDataSource("CostBZLR", "");
  11014. designer.SetDataSource("CostBDRCBOM", "");
  11015. designer.SetDataSource("CostBRSOM", "");
  11016. designer.SetDataSource("CostBZCBOM", "");
  11017. designer.SetDataSource("CostBDRBJOM", "");
  11018. designer.SetDataSource("CostBZBJOM", "");
  11019. designer.SetDataSource("CostBDRLROM", "");
  11020. designer.SetDataSource("CostBZLROM", "");
  11021. #endregion
  11022. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  11023. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  11024. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  11025. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  11026. designer.SetDataSource("DJName", "地接(CNY)");
  11027. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  11028. designer.SetDataSource("CPName", "地接-船票(CNY)");
  11029. designer.SetDataSource("GWName", "公务(CNY)");
  11030. designer.SetDataSource("YQHName", "邀请函(CNY)");
  11031. designer.SetDataSource("LYJName", "零用金(CNY)");
  11032. designer.SetDataSource("HSName", "核酸检测(CNY)");
  11033. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  11034. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  11035. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  11036. designer.SetDataSource("BXName", "保险(CNY)");
  11037. designer.SetDataSource("VisaName", "签证(CNY)");
  11038. #region B段基本数据
  11039. if (dto.costType == "B")
  11040. {
  11041. left = dto.leftInfo.Find(x => x.Type == "B");
  11042. if (left == null)
  11043. {
  11044. return Ok(jw);
  11045. }
  11046. #region B段left数据
  11047. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  11048. if (leftBindData != null)
  11049. {
  11050. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  11051. designer.SetDataSource("BHSRS", leftBindData.rs);
  11052. designer.SetDataSource("BHSXS", leftBindData.xs);
  11053. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11054. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11055. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11056. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11057. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11058. }
  11059. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  11060. if (leftBindData != null)
  11061. {
  11062. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  11063. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  11064. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  11065. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11066. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11067. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11068. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11069. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11070. }
  11071. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  11072. if (leftBindData != null)
  11073. {
  11074. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  11075. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  11076. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  11077. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11078. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11079. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11080. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11081. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11082. }
  11083. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  11084. if (leftBindData != null)
  11085. {
  11086. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  11087. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  11088. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  11089. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11090. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11091. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11092. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11093. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11094. }
  11095. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  11096. if (leftBindData != null)
  11097. {
  11098. designer.SetDataSource("BHCPCB", leftBindData.cb);
  11099. designer.SetDataSource("BHCPRS", leftBindData.rs);
  11100. designer.SetDataSource("BHCPXS", leftBindData.xs);
  11101. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11102. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11103. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11104. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11105. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11106. }
  11107. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  11108. if (leftBindData != null)
  11109. {
  11110. designer.SetDataSource("BCPCB", leftBindData.cb);
  11111. designer.SetDataSource("BCPRS", leftBindData.rs);
  11112. designer.SetDataSource("BCPXS", leftBindData.xs);
  11113. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11114. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11115. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11116. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11117. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11118. }
  11119. //TBR
  11120. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  11121. if (leftBindData != null)
  11122. {
  11123. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  11124. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  11125. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  11126. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11127. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11128. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11129. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11130. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11131. }
  11132. //SGR
  11133. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  11134. if (leftBindData != null)
  11135. {
  11136. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  11137. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  11138. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  11139. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11140. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11141. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11142. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11143. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11144. }
  11145. //JS/ES
  11146. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  11147. if (leftBindData != null)
  11148. {
  11149. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  11150. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  11151. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  11152. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11153. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11154. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11155. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11156. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11157. }
  11158. //SUITE
  11159. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  11160. if (leftBindData != null)
  11161. {
  11162. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  11163. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  11164. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  11165. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11166. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11167. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11168. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11169. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11170. }
  11171. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  11172. if (leftBindData != null)
  11173. {
  11174. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  11175. designer.SetDataSource("BDJRS", leftBindData.rs);
  11176. designer.SetDataSource("BDJXS", leftBindData.xs);
  11177. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11178. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11179. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11180. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11181. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11182. }
  11183. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  11184. if (leftBindData != null)
  11185. {
  11186. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  11187. designer.SetDataSource("BGWRS", leftBindData.rs);
  11188. designer.SetDataSource("BGWXS", leftBindData.xs);
  11189. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11190. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11191. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11192. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11193. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11194. }
  11195. #region 优化方案
  11196. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  11197. //excelBind.Add("零用金", new {
  11198. //cb="",
  11199. //rs="",
  11200. //xs ="",
  11201. //zcb = "",
  11202. //});
  11203. #endregion
  11204. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  11205. if (leftBindData != null)
  11206. {
  11207. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  11208. designer.SetDataSource("BLYJRS", leftBindData.rs);
  11209. designer.SetDataSource("BLYJXS", leftBindData.xs);
  11210. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11211. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11212. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11213. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11214. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11215. }
  11216. #endregion
  11217. #region B段Right信息
  11218. right = dto.rightInfo.Find(x => x.Type == "B");
  11219. if (right == null)
  11220. {
  11221. return Ok(jw);
  11222. }
  11223. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  11224. if (rightBindData != null)
  11225. {
  11226. //经济舱 + 双人间 TBR
  11227. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  11228. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  11229. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11230. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  11231. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11232. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11233. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11234. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11235. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11236. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11237. }
  11238. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  11239. if (rightBindData != null)
  11240. {
  11241. //经济舱 + 单人间 SGR
  11242. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  11243. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  11244. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11245. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  11246. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11247. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11248. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11249. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11250. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11251. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11252. }
  11253. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  11254. if (rightBindData != null)
  11255. {
  11256. //公务舱 + 单人间 SGR
  11257. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  11258. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  11259. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11260. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  11261. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11262. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11263. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11264. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11265. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11266. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11267. }
  11268. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  11269. if (rightBindData != null)
  11270. {
  11271. //公务舱 + 小套房 JSES
  11272. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  11273. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  11274. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11275. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  11276. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11277. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11278. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11279. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11280. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11281. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11282. }
  11283. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  11284. if (rightBindData != null)
  11285. {
  11286. //公务舱 + 小套房 JSES
  11287. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  11288. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  11289. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11290. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  11291. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11292. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11293. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11294. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11295. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11296. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11297. }
  11298. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11299. if (rightBindData != null)
  11300. {
  11301. //经济舱 + 大套房
  11302. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  11303. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  11304. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11305. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  11306. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11307. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11308. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11309. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11310. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11311. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11312. }
  11313. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11314. if (rightBindData != null)
  11315. {
  11316. //头等舱 + 小套房 JSES
  11317. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  11318. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  11319. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11320. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  11321. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11322. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11323. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11324. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11325. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11326. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11327. }
  11328. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11329. if (rightBindData != null)
  11330. {
  11331. //头等舱 + 大套房
  11332. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  11333. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  11334. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11335. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  11336. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11337. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11338. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11339. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11340. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11341. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11342. }
  11343. #endregion
  11344. #region 标题
  11345. designer.SetDataSource("CostBDRCB", "单人成本");
  11346. designer.SetDataSource("CostBRS", "人数");
  11347. designer.SetDataSource("CostBXS", "系数");
  11348. designer.SetDataSource("CostBZCB", "总成本");
  11349. designer.SetDataSource("CostBDRBJ", "单人报价");
  11350. designer.SetDataSource("CostBZBJ", "总报价");
  11351. designer.SetDataSource("CostBDRLR", "单人利润");
  11352. designer.SetDataSource("CostBZLR", "总利润");
  11353. designer.SetDataSource("CostBDRCBOM", "单人成本");
  11354. designer.SetDataSource("CostBRSOM", "人数");
  11355. designer.SetDataSource("CostBZCBOM", "总成本");
  11356. designer.SetDataSource("CostBDRBJOM", "单人报价");
  11357. designer.SetDataSource("CostBZBJOM", "总报价");
  11358. designer.SetDataSource("CostBDRLROM", "单人利润");
  11359. designer.SetDataSource("CostBZLROM", "总利润");
  11360. #endregion
  11361. }
  11362. #endregion
  11363. designer.SetDataSource("TzZCB2", TzZCB2);
  11364. designer.SetDataSource("TzZBJ2", TzZBJ2);
  11365. designer.SetDataSource("TzZLR2", TzZLR2);
  11366. string[] dataSourceKeys = new string[]
  11367. {
  11368. "VF",
  11369. "TGS",
  11370. "TGOF",
  11371. "TGM",
  11372. "TGA",
  11373. "TGTF",
  11374. "TGEF",
  11375. "CFM",
  11376. "CFOF",
  11377. "B",
  11378. "L",
  11379. "D",
  11380. "TBR",
  11381. "SGR",
  11382. "JSES",
  11383. "Suite",
  11384. "TV",
  11385. "1L",
  11386. "IF",
  11387. "EF",
  11388. "BRF",
  11389. "TE",
  11390. "TGT",
  11391. "DRVT",
  11392. "PC",
  11393. "TLF",
  11394. "ECT"
  11395. };
  11396. foreach (var item in dataSourceKeys)
  11397. {
  11398. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  11399. if (find != null)
  11400. {
  11401. designer.SetDataSource(item, find.text);
  11402. }
  11403. else
  11404. {
  11405. designer.SetDataSource(item, 0);
  11406. }
  11407. }
  11408. designer.SetDataSource(dt);
  11409. //根据数据源处理生成报表内容
  11410. designer.Process();
  11411. designer.Workbook.Worksheets[0].Name = "清单";
  11412. Worksheet sheet = designer.Workbook.Worksheets[0];
  11413. foreach (var Rowindex in hideRowsList)
  11414. {
  11415. ws.Cells.HideRows(Rowindex, 2);
  11416. }
  11417. byte[] bytes = null;
  11418. string strFileName = di.TeamName + "-团组-成本.xls";
  11419. using (MemoryStream stream = new MemoryStream())
  11420. {
  11421. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  11422. bytes = stream.ToArray();
  11423. }
  11424. return Ok(JsonView(true, "", new
  11425. {
  11426. Data = bytes,
  11427. strFileName,
  11428. }));
  11429. }
  11430. /// <summary>
  11431. /// 导出客户报表
  11432. /// </summary>
  11433. /// <returns></returns>
  11434. [HttpPost]
  11435. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  11436. {
  11437. var jw = JsonView(false);
  11438. if (dto.Diid == 0)
  11439. {
  11440. return Ok(JsonView(false, "请传递团组id"));
  11441. }
  11442. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11443. if (deleInfo.Code != 0)
  11444. {
  11445. return Ok(JsonView(false, "团组信息查询失败!"));
  11446. }
  11447. var di = deleInfo.Data as DelegationInfoWebView;
  11448. if (di == null)
  11449. {
  11450. return Ok(JsonView(false, "团组信息查询失败!"));
  11451. }
  11452. //文件名
  11453. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  11454. //获取模板
  11455. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  11456. //载入模板
  11457. Document doc = new Document(tmppath);
  11458. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  11459. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  11460. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  11461. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  11462. var AParameter = ParameterList.Find(x => x.CostType == "A");
  11463. var BParameter = ParameterList.Find(x => x.CostType == "B");
  11464. if (AParameter == null)
  11465. {
  11466. return Ok(JsonView(false, "系数不存在!"));
  11467. }
  11468. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  11469. , TzAirDesc, TzZCost;
  11470. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  11471. = TzAirDesc = TzZCost = string.Empty;
  11472. TzNumber = AParameter.CostTypenumber.ToString();
  11473. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  11474. CarGuides1 = dto.CarGuides1;
  11475. Meal = dto.Meal;
  11476. SubsidizedMeals = dto.SubsidizedMeals;
  11477. NightRepair = dto.NightRepair;
  11478. AttractionsTickets = dto.AttractionsTickets;
  11479. MiscellaneousFees = dto.MiscellaneousFees;
  11480. ATip = dto.ATip;
  11481. TzHotelDesc = "";
  11482. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  11483. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  11484. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  11485. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  11486. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  11487. TzAirDesc = "";
  11488. TzZCost = dto.TzZCost;
  11489. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  11490. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  11491. var index = 1;
  11492. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  11493. foreach (var item in TzHotelDescArr)
  11494. {
  11495. if (AinfoArr != null)
  11496. {
  11497. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11498. if (Ainfo != null)
  11499. {
  11500. if (int.Parse(Ainfo.rs) <= 0)
  11501. {
  11502. continue;
  11503. }
  11504. var hotelText = string.Empty;
  11505. switch (item)
  11506. {
  11507. case "SGR":
  11508. hotelText = "单人间";
  11509. break;
  11510. case "JSES":
  11511. hotelText = "小套房";
  11512. break;
  11513. case "SUITE":
  11514. hotelText = "套房";
  11515. break;
  11516. case "TBR":
  11517. hotelText = "双人间";
  11518. break;
  11519. }
  11520. if (item != "TBR")
  11521. {
  11522. 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";
  11523. }
  11524. else
  11525. {
  11526. 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";
  11527. }
  11528. index++;
  11529. }
  11530. }
  11531. }
  11532. index = 1;
  11533. foreach (var item in TzAirDescArr)
  11534. {
  11535. if (AinfoArr != null)
  11536. {
  11537. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11538. if (Ainfo != null)
  11539. {
  11540. if (int.Parse(Ainfo.rs) <= 0)
  11541. {
  11542. continue;
  11543. }
  11544. 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";
  11545. index++;
  11546. }
  11547. }
  11548. }
  11549. if (dto.costType == "B")
  11550. {
  11551. if (BParameter == null)
  11552. {
  11553. return Ok(JsonView(false, "B段系数不存在!"));
  11554. }
  11555. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  11556. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  11557. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  11558. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  11559. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  11560. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  11561. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  11562. foreach (var item in TzHotelDescArr)
  11563. {
  11564. if (AinfoArr != null)
  11565. {
  11566. TzHotelDesc += "B段信息 \r\n";
  11567. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11568. if (Ainfo != null)
  11569. {
  11570. if (int.Parse(Ainfo.rs) <= 0)
  11571. {
  11572. continue;
  11573. }
  11574. var hotelText = string.Empty;
  11575. switch (item)
  11576. {
  11577. case "SGR":
  11578. hotelText = "单人间";
  11579. break;
  11580. case "JSES":
  11581. hotelText = "小套房";
  11582. break;
  11583. case "SUITE":
  11584. hotelText = "套房";
  11585. break;
  11586. case "TBR":
  11587. hotelText = "双人间";
  11588. break;
  11589. }
  11590. if (item != "TBR")
  11591. {
  11592. 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";
  11593. }
  11594. else
  11595. {
  11596. 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";
  11597. }
  11598. index++;
  11599. }
  11600. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  11601. }
  11602. }
  11603. index = 1;
  11604. foreach (var item in TzAirDescArr)
  11605. {
  11606. if (AinfoArr != null)
  11607. {
  11608. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11609. if (Ainfo != null)
  11610. {
  11611. if (int.Parse(Ainfo.rs) <= 0)
  11612. {
  11613. continue;
  11614. }
  11615. 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";
  11616. index++;
  11617. }
  11618. }
  11619. }
  11620. }
  11621. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  11622. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  11623. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  11624. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  11625. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  11626. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  11627. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  11628. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  11629. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  11630. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  11631. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  11632. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  11633. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  11634. DickeyValue.Add("Visa", Visa); // 签证单人报价
  11635. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  11636. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  11637. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  11638. DickeyValue.Add("TzZCost", TzZCost);
  11639. foreach (var key in DickeyValue.Keys)
  11640. {
  11641. if (doc.Range.Bookmarks[key] != null)
  11642. {
  11643. Bookmark mark = doc.Range.Bookmarks[key];
  11644. mark.Text = DickeyValue[key];
  11645. }
  11646. }
  11647. byte[] bytes = null;
  11648. string strFileName = di.TeamName + "-客户报价.doc";
  11649. using (MemoryStream stream = new MemoryStream())
  11650. {
  11651. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11652. bytes = stream.ToArray();
  11653. }
  11654. return Ok(JsonView(true, "", new
  11655. {
  11656. Data = bytes,
  11657. strFileName,
  11658. }));
  11659. }
  11660. /// <summary>
  11661. /// 团组成本 各模块(酒店,地接,机票)成本提示
  11662. /// </summary>
  11663. /// <param name="dto"></param>
  11664. /// <returns></returns>
  11665. [HttpPost]
  11666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11667. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  11668. {
  11669. try
  11670. {
  11671. #region 参数验证
  11672. if (dto.DiId < 0)
  11673. {
  11674. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  11675. }
  11676. List<int> cTableIds = new List<int>() {
  11677. 76 ,//酒店预订
  11678. 77 ,//行程
  11679. 79 ,//车/导游地接
  11680. 80 ,//签证
  11681. 81 ,//邀请/公务活
  11682. 82 ,//团组客户保险
  11683. 85 ,//机票预订
  11684. 98 ,//其他款项
  11685. 285 ,//收款退还
  11686. 751 ,//酒店早餐
  11687. 1015 // 超支费用
  11688. };
  11689. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  11690. {
  11691. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  11692. }
  11693. #endregion
  11694. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  11695. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  11696. if (_GroupCostParameters.Count <= 0)
  11697. {
  11698. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  11699. }
  11700. if (_GroupCostParameters[0].IsShare == 0)
  11701. {
  11702. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  11703. }
  11704. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  11705. //处理date为空问题
  11706. if (_GroupCosts.Count > 0)
  11707. {
  11708. for (int i = 0; i < _GroupCosts.Count; i++)
  11709. {
  11710. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  11711. {
  11712. if (i > 0)
  11713. {
  11714. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  11715. }
  11716. }
  11717. }
  11718. }
  11719. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  11720. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  11721. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  11722. string currCode = "";
  11723. #region currCode 验证
  11724. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  11725. if (isInt)
  11726. {
  11727. var currData = currDatas.Find(it => it.Id == intCurrency);
  11728. if (currData != null)
  11729. {
  11730. currCode = currData.Name;
  11731. }
  11732. }
  11733. else
  11734. {
  11735. currCode = _GroupCostParameters[0].Currency.Trim();
  11736. }
  11737. #endregion
  11738. //op,酒店单段模式存储
  11739. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  11740. {
  11741. CurrencyCode = currCode,
  11742. Rate = _GroupCostParameters[0].Rate,
  11743. CostType = _GroupCostParameters[0].CostType,
  11744. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  11745. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  11746. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  11747. };
  11748. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  11749. if (_GroupCostParameters.Count == 2)
  11750. {
  11751. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  11752. }
  11753. foreach (var item in _GroupCostParameters)
  11754. {
  11755. decimal _rate = 1;
  11756. decimal _rate1 = item.Rate;
  11757. decimal _scale = 1;
  11758. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  11759. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  11760. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  11761. //if (userInfo != null)
  11762. //{
  11763. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  11764. // {
  11765. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  11766. // {
  11767. // _scale = 1.00M;
  11768. // }
  11769. // }
  11770. //}
  11771. #endregion
  11772. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  11773. {
  11774. CurrencyCode = currCode,
  11775. Rate = _rate1,
  11776. CostType = item.CostType,
  11777. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  11778. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  11779. CostTypeNumber = item.CostTypenumber
  11780. };
  11781. if (_GroupCostParameters.Count > 1)
  11782. {
  11783. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  11784. }
  11785. else
  11786. {
  11787. modulePromptInfo.CostTypeNumber = item.LYJRS;
  11788. }
  11789. if (dto.CTable == 79)//
  11790. {
  11791. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  11792. modulePromptInfo.TotalCost = item.DJCB;
  11793. }
  11794. List<string> costTypes = new List<string>() { "A", "B" };
  11795. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  11796. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  11797. if (_GroupCostsDuplicates.Count() == 1)
  11798. {
  11799. _GroupCostsTypeData = _GroupCosts;
  11800. }
  11801. else
  11802. {
  11803. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  11804. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  11805. }
  11806. /*
  11807. * 76 酒店预订
  11808. * 77 行程
  11809. * 79 车/导游地接
  11810. * 80 签证
  11811. * 81 邀请/公务活动
  11812. * 82 团组客户保险
  11813. * 85 机票预订
  11814. * 98 其他款项
  11815. * 285 收款退还
  11816. * 751 酒店早餐
  11817. * 1015 超支费用
  11818. */
  11819. switch (dto.CTable)
  11820. {
  11821. case 76: // 酒店预订
  11822. _ModuleSubPromptInfo.AddRange(
  11823. _GroupCostsTypeData.Select(it => new
  11824. {
  11825. it.DAY,
  11826. it.Date,
  11827. it.ACCON,
  11828. it.ITIN,
  11829. it.SGR,
  11830. it.TBR,
  11831. it.JS_ES,
  11832. it.Suite
  11833. })
  11834. );
  11835. break;
  11836. case 79: // 车/导游地接
  11837. _ModuleSubPromptInfo.AddRange(
  11838. _GroupCostsTypeData.Select(it => new
  11839. {
  11840. Date = it.Date, //日期
  11841. CarFee = it.CarCost * _rate * _scale, //车费用
  11842. CarType = it.CarType, //车型
  11843. DriverFee = it.CFS * _rate * _scale, //司机工资
  11844. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  11845. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  11846. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  11847. GuideFee = it.TGS * _rate * _scale, //导游费用
  11848. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  11849. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  11850. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  11851. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  11852. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  11853. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  11854. Breakfast = it.B * _rate * _scale, //早餐费
  11855. Lunch = it.L * _rate * _scale, //午餐费
  11856. Dinner = it.D * _rate * _scale, //晚餐费
  11857. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  11858. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  11859. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  11860. TicketFee = it.EF * _rate * _scale, //门票费
  11861. TicketRemark = it.EFR, //门票费描述
  11862. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  11863. TravelSupplies = it.TE * _rate * _scale, //出行物资
  11864. SpentCash = it.PC * _rate * _scale, //零用金
  11865. LeadersFee = it.TLF * _rate * _scale, //领队费
  11866. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  11867. })
  11868. );
  11869. break;
  11870. case 85: // 机票
  11871. List<dynamic> datas = new List<dynamic>();
  11872. datas.Add(
  11873. new
  11874. {
  11875. AirType = "经济舱",
  11876. AirNum = item.JJCRS,
  11877. AirDRCB = item.JJCCB,
  11878. AirZCB = (item.JJCRS * item.JJCCB)
  11879. }
  11880. );
  11881. datas.Add(
  11882. new
  11883. {
  11884. AirType = "公务舱",
  11885. AirNum = item.GWCRS,
  11886. AirDRCB = item.GWCCB,
  11887. AirZCB = (item.GWCRS * item.GWCCB)
  11888. }
  11889. );
  11890. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  11891. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  11892. modulePromptInfo.Data = new
  11893. {
  11894. airFeeData = datas,
  11895. airInitData = initDatas
  11896. };
  11897. _ModulePromptInfos.Add(modulePromptInfo);
  11898. break;
  11899. default:
  11900. break;
  11901. }
  11902. }
  11903. if (dto.CTable != 85)
  11904. {
  11905. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  11906. _ModulePromptInfos.Add(_ModulePromptInfo);
  11907. }
  11908. _view.ModulePromptInfos = _ModulePromptInfos;
  11909. return Ok(JsonView(true, "操作成功!", _view));
  11910. }
  11911. catch (Exception ex)
  11912. {
  11913. return Ok(JsonView(false, ex.Message));
  11914. }
  11915. }
  11916. /// <summary>
  11917. /// 根据黑屏代码重新生成行程
  11918. /// </summary>
  11919. /// <param name="dto"></param>
  11920. /// <returns></returns>
  11921. [HttpPost]
  11922. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  11923. {
  11924. var jw = JsonView(false);
  11925. var Create = _GroupCostRepository.
  11926. CreateGroupCostByBlackCode(dto.Diid);
  11927. jw.Msg = Create.Msg;
  11928. if (Create.Code == 0)
  11929. {
  11930. jw.Code = 200;
  11931. jw.Data = new
  11932. {
  11933. groupCost = Create.Data,
  11934. blackCodeIsTrue = true
  11935. };
  11936. }
  11937. else
  11938. {
  11939. jw.Code = 400;
  11940. jw.Data = new
  11941. {
  11942. groupCost = Create.Data,
  11943. blackCodeIsTrue = false,
  11944. };
  11945. }
  11946. return Ok(jw);
  11947. }
  11948. /// <summary>
  11949. /// 成本获取OP历史车费用
  11950. /// </summary>
  11951. /// <param name="dto"></param>
  11952. /// <returns></returns>
  11953. [HttpPost]
  11954. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  11955. {
  11956. var jw = JsonView(false);
  11957. try
  11958. {
  11959. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  11960. //获取现有所有车的数据
  11961. if (!dto.Param.IsNullOrWhiteSpace())
  11962. {
  11963. string sql = $@"
  11964. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  11965. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  11966. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  11967. 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
  11968. AND gctggr.ServiceEndTime is not NULL
  11969. ORDER by gctggrc.id DESC
  11970. ";
  11971. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  11972. var numeberResult = await Task.Run(() =>
  11973. {
  11974. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  11975. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  11976. return numberArr;
  11977. });
  11978. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  11979. foreach (var item in numeberResult)
  11980. {
  11981. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  11982. {
  11983. Country = "数据异常!",
  11984. City = string.Empty,
  11985. };
  11986. item.Area = find.Country + " " + find.City;
  11987. }
  11988. dbResult.AddRange(numeberResult);
  11989. if (dto.Param.Contains("、"))
  11990. {
  11991. var sp = dto.Param.Split("、");
  11992. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  11993. .Where(x =>
  11994. {
  11995. return System.Array.Exists(sp, e =>
  11996. {
  11997. bool where = false;
  11998. if (x.Area != null)
  11999. {
  12000. where = x.Area.Contains(e);
  12001. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12002. {
  12003. return false;
  12004. }
  12005. }
  12006. if (x.PriceName != null && !where)
  12007. {
  12008. where = x.PriceName.Contains(e);
  12009. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12010. {
  12011. return false;
  12012. }
  12013. }
  12014. return where;
  12015. });
  12016. }).ToList();
  12017. }
  12018. else
  12019. {
  12020. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12021. .Where(x =>
  12022. {
  12023. bool where = false;
  12024. if (x.Area != null)
  12025. {
  12026. where = x.Area.Contains(dto.Param);
  12027. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12028. {
  12029. return false;
  12030. }
  12031. }
  12032. if (x.PriceName != null && !where)
  12033. {
  12034. where = x.PriceName.Contains(dto.Param);
  12035. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12036. {
  12037. return false;
  12038. }
  12039. }
  12040. return where;
  12041. }
  12042. )
  12043. .ToList();
  12044. }
  12045. }
  12046. var view = dbResult.Select(x =>
  12047. {
  12048. decimal dp = 0.00M;
  12049. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  12050. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  12051. if (string.IsNullOrWhiteSpace(x.DatePrice))
  12052. {
  12053. if (startB && endB)
  12054. {
  12055. var timesp = endD.Subtract(startD);
  12056. if ((timesp.Days + 1) != 0)
  12057. {
  12058. dp = x.Price / (timesp.Days + 1);
  12059. }
  12060. }
  12061. }
  12062. else
  12063. {
  12064. dp = x.Price;
  12065. }
  12066. return new
  12067. {
  12068. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  12069. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  12070. x.Area,
  12071. x.id,
  12072. price = x.Price.ToString("F2"),
  12073. x.PriceName,
  12074. x.PriceContent,
  12075. x.TeamName,
  12076. x.DatePrice,
  12077. dayPrice = dp.ToString("F2"),
  12078. };
  12079. }).OrderByDescending(x => x.id).ToList();
  12080. jw = JsonView(true, "获取成功!", view);
  12081. }
  12082. catch (Exception e)
  12083. {
  12084. jw = JsonView(false, e.Message);
  12085. }
  12086. return Ok(jw);
  12087. }
  12088. #endregion
  12089. #region 酒店预订 新 雷怡 2023-12-28 17:45
  12090. /// <summary>
  12091. /// 酒店预订
  12092. /// 酒店费用列表 根据团组Id查询
  12093. /// </summary>
  12094. /// <param name="_dto"></param>
  12095. /// <returns></returns>
  12096. [HttpPost]
  12097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12098. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  12099. {
  12100. #region 参数验证
  12101. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12102. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12103. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12104. #region 团组操作权限验证 76 酒店预定模块
  12105. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12106. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12107. #endregion
  12108. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12109. #region 页面操作权限验证
  12110. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12111. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12112. #endregion
  12113. #endregion
  12114. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  12115. }
  12116. /// <summary>
  12117. /// 酒店预订
  12118. /// 基础数据
  12119. /// </summary>
  12120. /// <param name="_dto"></param>
  12121. /// <returns></returns>
  12122. [HttpPost]
  12123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12124. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  12125. {
  12126. #region 参数验证
  12127. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12128. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12129. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12130. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12131. #region 页面操作权限验证
  12132. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12133. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12134. #endregion
  12135. #region 团组操作权限验证 76 酒店预定模块
  12136. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12137. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12138. #endregion
  12139. #endregion
  12140. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  12141. }
  12142. /// <summary>
  12143. /// 酒店预订
  12144. /// 创建 入住卷号码
  12145. /// </summary>
  12146. /// <param name="_dto"></param>
  12147. /// <returns></returns>
  12148. [HttpPost]
  12149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12150. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  12151. {
  12152. #region 参数验证
  12153. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12154. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12155. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12156. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12157. #region 页面操作权限验证
  12158. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12159. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12160. #endregion
  12161. #region 团组操作权限验证 76 酒店预定模块
  12162. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12163. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12164. #endregion
  12165. #endregion
  12166. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  12167. if (data.Code != 0)
  12168. {
  12169. return Ok(JsonView(false, data.Msg));
  12170. }
  12171. return Ok(JsonView(true, data.Msg, data.Data));
  12172. }
  12173. /// <summary>
  12174. /// 酒店预订
  12175. /// 详情
  12176. /// </summary>
  12177. /// <param name="_dto"></param>
  12178. /// <returns></returns>
  12179. [HttpPost]
  12180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12181. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  12182. {
  12183. #region 参数验证
  12184. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  12185. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12186. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  12187. #region 团组操作权限验证 76 酒店预定模块
  12188. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12189. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12190. #endregion
  12191. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12192. #region 页面操作权限验证
  12193. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12194. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12195. #endregion
  12196. #endregion
  12197. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  12198. }
  12199. /// <summary>
  12200. /// 酒店预订
  12201. /// Add Or Edit
  12202. /// </summary>
  12203. /// <param name="_dto"></param>
  12204. /// <returns></returns>
  12205. [HttpPost]
  12206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12207. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  12208. {
  12209. #region 参数验证
  12210. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12211. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12212. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12213. #region 团组操作权限验证 76 酒店预定模块
  12214. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12215. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12216. #endregion
  12217. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12218. #region 页面操作权限验证
  12219. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12220. if (_dto.Id == 0) // Add
  12221. {
  12222. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12223. }
  12224. else if (_dto.Id > 1) // Edit
  12225. {
  12226. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  12227. }
  12228. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  12229. #endregion
  12230. #endregion
  12231. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  12232. if (_view.Code != 200)
  12233. {
  12234. return Ok(_view);
  12235. }
  12236. #region 成本无酒店价格数据进入超支
  12237. _sqlSugar.BeginTran();
  12238. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  12239. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  12240. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  12241. for (int i = 0; i < groupCost.Count; i++)
  12242. {
  12243. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  12244. {
  12245. groupCost[i].Date = groupCost[i - 1].Date;
  12246. }
  12247. }
  12248. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  12249. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  12250. List<Fin_GroupExtraCostDto_OP>();
  12251. if (start_Bool && end_Bool)
  12252. {
  12253. while (start_Time < end_Time)
  12254. {
  12255. foreach (var item in groupCost_Grp)
  12256. {
  12257. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  12258. {
  12259. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  12260. {
  12261. extraCostList.Add(new
  12262. Fin_GroupExtraCostDto_OP
  12263. {
  12264. Area = _dto.AreaId,
  12265. coefficient = 1.5M,
  12266. createUser = _dto.UserId,
  12267. currency = _dto.CardPriceCurrency,
  12268. diId = _dto.DiId,
  12269. ManagerConfirm = 0,
  12270. SupervisorConfirm = 0,
  12271. SYsupervisorConfirm = 0,
  12272. editType = 1,
  12273. PortType = 1,
  12274. price = _dto.CardPrice,
  12275. PriceCount = 1,
  12276. priceType = 1027,
  12277. priceDetailType = 1044,
  12278. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  12279. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  12280. });
  12281. }
  12282. }
  12283. }
  12284. start_Time = start_Time.AddDays(1);
  12285. }
  12286. }
  12287. if (extraCostList.Any())
  12288. {
  12289. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  12290. }
  12291. _sqlSugar.CommitTran();
  12292. #endregion
  12293. #region 应用推送
  12294. try
  12295. {
  12296. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12297. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12298. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12299. var diId = _dto.DiId;
  12300. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12301. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12302. #region 操作记录
  12303. var opInfo = new Crm_TableOperationRecord() {
  12304. TableName = "Grp_HotelReservations",
  12305. PortType = _dto.PortType,
  12306. DataId = hotelId,
  12307. CreateUserId = _dto.UserId
  12308. };
  12309. var opStatus = OperationEnum.NoOperation;
  12310. if (_dto.Id<1) //添加操作
  12311. {
  12312. opInfo.OperationItem = OperationEnum.Add;
  12313. }
  12314. else if (_dto.Id > 0)
  12315. {
  12316. opInfo.OperationItem = OperationEnum.Edit;
  12317. }
  12318. string opRemark = string.Empty;
  12319. if (ccpInfo != null)
  12320. {
  12321. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  12322. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  12323. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  12324. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  12325. }
  12326. opInfo.Remark = opRemark;
  12327. await _tableorRep.AddAsync(opInfo);
  12328. #endregion
  12329. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  12330. //2024-10-21 新增LZ UID
  12331. var userIds = new List<int>() { 21 };
  12332. string title = $"费用审核";
  12333. string content = "";
  12334. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12335. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12336. try
  12337. {
  12338. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12339. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  12340. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  12341. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  12342. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  12343. }
  12344. catch (Exception ex )
  12345. {
  12346. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  12347. }
  12348. }
  12349. catch (Exception ex)
  12350. {
  12351. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  12352. }
  12353. try
  12354. {
  12355. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12356. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12357. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12358. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12359. //自动审核
  12360. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  12361. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  12362. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  12363. //2024-10-21 新增LZ UID
  12364. var userIds = new List<int>() { 21 };
  12365. string title = $"系统通知";
  12366. var diId = _dto.DiId;
  12367. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12368. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12369. string content = "";
  12370. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12371. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12372. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12373. }
  12374. catch (Exception ex)
  12375. {
  12376. }
  12377. #endregion
  12378. return Ok(_view);
  12379. }
  12380. /// <summary>
  12381. /// 酒店自动审核测试
  12382. /// Add Or Edit
  12383. /// </summary>
  12384. /// <param name="_dto"></param>
  12385. /// <returns></returns>
  12386. [HttpPost]
  12387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12388. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  12389. {
  12390. #region 应用推送
  12391. try
  12392. {
  12393. //自动审核
  12394. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  12395. }
  12396. catch (Exception ex)
  12397. {
  12398. return Ok(JsonView(false, "操作失败"));
  12399. }
  12400. #endregion
  12401. return Ok(JsonView(false, "操作成功"));
  12402. }
  12403. /// <summary>
  12404. /// 酒店预订
  12405. /// Del
  12406. /// </summary>
  12407. /// <param name="_dto"></param>
  12408. /// <returns></returns>
  12409. [HttpPost]
  12410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12411. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  12412. {
  12413. #region 参数验证
  12414. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12415. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12416. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12417. #region 团组操作权限验证 76 酒店预定模块
  12418. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12419. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12420. #endregion
  12421. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12422. #region 页面操作权限验证
  12423. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12424. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12425. #endregion
  12426. #endregion
  12427. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  12428. #region 操作记录
  12429. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  12430. {
  12431. TableName = "Grp_HotelReservations",
  12432. PortType = _dto.PortType,
  12433. OperationItem = OperationEnum.Del,
  12434. DataId = _dto.Id,
  12435. CreateUserId = _dto.UserId
  12436. });
  12437. #endregion
  12438. return Ok(data);
  12439. }
  12440. /// <summary>
  12441. /// 酒店预订
  12442. /// 生成VOUCHER
  12443. /// 2024.05.06 之前版本
  12444. /// </summary>
  12445. /// <param name="_dto"></param>
  12446. /// <returns></returns>
  12447. [HttpPost]
  12448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12449. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  12450. {
  12451. try
  12452. {
  12453. #region 参数验证
  12454. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12455. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12456. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12457. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  12458. #region 团组操作权限验证 76 酒店预定模块
  12459. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12460. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12461. #endregion
  12462. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12463. #region 页面操作权限验证
  12464. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12465. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12466. #endregion
  12467. #endregion
  12468. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  12469. //判断数据是否完整
  12470. if (hr != null)
  12471. {
  12472. if (!string.IsNullOrEmpty(hr.DetermineNo))
  12473. {
  12474. string strFileName = "HotelStatement/";
  12475. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  12476. if (dele != null)
  12477. strFileName += dele.TourCode;
  12478. //载入模板
  12479. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  12480. Document doc = new Document(sss);
  12481. DocumentBuilder builder = new DocumentBuilder(doc);
  12482. #region 替换Word模板书签内容
  12483. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  12484. //入住卷预定号码
  12485. if (doc.Range.Bookmarks["VNO"] != null)
  12486. {
  12487. Bookmark mark = doc.Range.Bookmarks["VNO"];
  12488. mark.Text = hr.CheckNumber;
  12489. }
  12490. //酒店时间
  12491. if (doc.Range.Bookmarks["Date"] != null)
  12492. {
  12493. Bookmark mark = doc.Range.Bookmarks["Date"];
  12494. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12495. }
  12496. //团号
  12497. if (doc.Range.Bookmarks["TNo"] != null)
  12498. {
  12499. Bookmark mark = doc.Range.Bookmarks["TNo"];
  12500. mark.Text = dele.TourCode;
  12501. }
  12502. //预定号码
  12503. if (doc.Range.Bookmarks["BookingId"] != null)
  12504. {
  12505. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  12506. mark.Text = hr.ReservationsNo;
  12507. }
  12508. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  12509. {
  12510. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  12511. mark.Text = hr.DetermineNo;
  12512. }
  12513. //酒店城市
  12514. if (doc.Range.Bookmarks["City"] != null)
  12515. {
  12516. Bookmark mark = doc.Range.Bookmarks["City"];
  12517. mark.Text = hr.City;
  12518. }
  12519. //酒店名称
  12520. if (doc.Range.Bookmarks["HName"] != null)
  12521. {
  12522. Bookmark mark = doc.Range.Bookmarks["HName"];
  12523. mark.Text = hr.HotelName;
  12524. }
  12525. //酒店地址
  12526. if (doc.Range.Bookmarks["Address"] != null)
  12527. {
  12528. Bookmark mark = doc.Range.Bookmarks["Address"];
  12529. mark.Text = hr.HotelAddress;
  12530. }
  12531. //酒店电话
  12532. if (doc.Range.Bookmarks["Tel"] != null)
  12533. {
  12534. Bookmark mark = doc.Range.Bookmarks["Tel"];
  12535. mark.Text = hr.HotelTel;
  12536. }
  12537. //酒店传真
  12538. if (doc.Range.Bookmarks["Fax"] != null)
  12539. {
  12540. Bookmark mark = doc.Range.Bookmarks["Fax"];
  12541. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  12542. {
  12543. mark.Text = hr.HotelFax;
  12544. }
  12545. }
  12546. //入住时间
  12547. if (doc.Range.Bookmarks["CIn"] != null)
  12548. {
  12549. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12550. Bookmark mark = doc.Range.Bookmarks["CIn"];
  12551. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  12552. }
  12553. //退房时间
  12554. if (doc.Range.Bookmarks["COut"] != null)
  12555. {
  12556. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12557. Bookmark mark = doc.Range.Bookmarks["COut"];
  12558. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12559. }
  12560. //客户名称
  12561. if (doc.Range.Bookmarks["GName"] != null)
  12562. {
  12563. string guestName = "";
  12564. string[] clients = new string[] { };
  12565. if (hr.GuestName.Contains(","))
  12566. {
  12567. clients = hr.GuestName.Split(",");
  12568. }
  12569. else
  12570. {
  12571. clients = new string[] { hr.GuestName };
  12572. }
  12573. List<int> clientIds_int = new List<int>();
  12574. if (clients.Length > 0)
  12575. {
  12576. foreach (var item in clients)
  12577. {
  12578. if (item.IsNumeric())
  12579. {
  12580. clientIds_int.Add(int.Parse(item));
  12581. }
  12582. }
  12583. }
  12584. if (clientIds_int.Count > 0)
  12585. {
  12586. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  12587. foreach (var client in _clientDatas)
  12588. {
  12589. //男
  12590. if (client.Sex == 0) guestName += $"Mr.";
  12591. //女
  12592. else if (client.Sex == 1) guestName += $"Ms.";
  12593. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  12594. {
  12595. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  12596. }
  12597. //guestName += $"{client.Pinyin},";
  12598. }
  12599. if (guestName.Length > 0)
  12600. {
  12601. guestName = guestName.Substring(0, guestName.Length - 1);
  12602. }
  12603. }
  12604. else
  12605. {
  12606. guestName = hr.GuestName;
  12607. }
  12608. Bookmark mark = doc.Range.Bookmarks["GName"];
  12609. mark.Text = guestName;
  12610. }
  12611. //房间介绍
  12612. if (doc.Range.Bookmarks["ROOM"] != null)
  12613. {
  12614. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  12615. mark.Text = hr.RoomExplanation;
  12616. }
  12617. //报价描述
  12618. if (doc.Range.Bookmarks["NOTE"] != null)
  12619. {
  12620. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  12621. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  12622. if (ss != null)
  12623. mark.Text = ss.Name;
  12624. }
  12625. //入住时间
  12626. if (doc.Range.Bookmarks["CheckIn"] != null)
  12627. {
  12628. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12629. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  12630. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  12631. }
  12632. //退房时间
  12633. if (doc.Range.Bookmarks["CheckOut"] != null)
  12634. {
  12635. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12636. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  12637. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12638. }
  12639. //日期
  12640. if (doc.Range.Bookmarks["DT"] != null)
  12641. {
  12642. Bookmark mark = doc.Range.Bookmarks["DT"];
  12643. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12644. }
  12645. //名称
  12646. if (doc.Range.Bookmarks["VName"] != null)
  12647. {
  12648. Bookmark mark = doc.Range.Bookmarks["VName"];
  12649. mark.Text = hr.HotelName;
  12650. }
  12651. //号码
  12652. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  12653. {
  12654. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  12655. mark.Text = hr.CheckNumber;
  12656. }
  12657. #endregion
  12658. strFileName += "VOUCHER.doc";
  12659. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12660. doc.Save(fileDir);
  12661. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12662. return Ok(JsonView(true, "操作成功!", Url));
  12663. }
  12664. else
  12665. {
  12666. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  12667. }
  12668. }
  12669. else
  12670. {
  12671. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  12672. }
  12673. }
  12674. catch (Exception ex)
  12675. {
  12676. return Ok(JsonView(false, ex.Message));
  12677. }
  12678. }
  12679. /// <summary>
  12680. /// 酒店预订
  12681. /// 生成VOUCHER
  12682. /// 2024.05.06 之后版本
  12683. /// </summary>
  12684. /// <param name="_dto"></param>
  12685. /// <returns></returns>
  12686. [HttpPost]
  12687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12688. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  12689. {
  12690. #region 参数验证
  12691. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12692. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12693. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12694. #region 团组操作权限验证 76 酒店预定模块
  12695. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12696. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12697. #endregion
  12698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12699. #region 页面操作权限验证
  12700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12701. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12702. #endregion
  12703. #endregion
  12704. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  12705. //判断数据是否完整
  12706. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  12707. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12708. string strFileName = "HotelStatement/";
  12709. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12710. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  12711. #region 数据处理
  12712. List<int> guestIds = new List<int>();
  12713. int index = 0;
  12714. foreach (var item in hrDtas)
  12715. {
  12716. if (item.GuestName.Contains(","))
  12717. {
  12718. string[] guestIdArr = item.GuestName.Split(',');
  12719. foreach (var guestIdStr in guestIdArr)
  12720. {
  12721. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  12722. if (guestBool)
  12723. {
  12724. guestIds.Add(guestId);
  12725. }
  12726. }
  12727. }
  12728. else guestNames += item.GuestName;
  12729. var voucherInfo = new HotelVoucherInfoView()
  12730. {
  12731. HotelName = item.HotelName,
  12732. CheckInDate = item.CheckInDate,
  12733. CheckOutDate = item.CheckOutDate,
  12734. ConfirmationNumber = item.DetermineNo.Trim(),
  12735. RoomType = item.RoomExplanation
  12736. };
  12737. vouchers.Add(voucherInfo);
  12738. }
  12739. if (guestIds.Count > 0)
  12740. {
  12741. guestIds = guestIds.Distinct().ToList();
  12742. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  12743. if (guestDatas.Count > 0)
  12744. {
  12745. guestNames = "";
  12746. foreach (var guest in guestDatas)
  12747. {
  12748. string guestName = "";
  12749. if (guest.Sex == 0) guestName += @"MR.";
  12750. else if (guest.Sex == 1) guestName += @"MS.";
  12751. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  12752. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  12753. guestNames += @$"{guestName.Trim()}、";
  12754. }
  12755. if (guestNames.Length > 0)
  12756. {
  12757. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  12758. }
  12759. }
  12760. }
  12761. #endregion
  12762. //载入模板
  12763. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  12764. Document doc = new Document(sss);
  12765. DocumentBuilder builder = new DocumentBuilder(doc);
  12766. if (doc.Range.Bookmarks["GuestName"] != null)
  12767. {
  12768. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  12769. mark.Text = guestNames;
  12770. }
  12771. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12772. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  12773. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  12774. for (int i = 1; i <= vouchers.Count; i++)
  12775. {
  12776. HotelVoucherInfoView hviv = vouchers[i - 1];
  12777. builder.MoveToCell(0, i, 0, 0);
  12778. builder.Write(hviv.HotelName);
  12779. builder.MoveToCell(0, i, 1, 0);
  12780. builder.Write(hviv.CheckInDate);
  12781. builder.MoveToCell(0, i, 2, 0);
  12782. builder.Write(hviv.CheckOutDate);
  12783. builder.MoveToCell(0, i, 3, 0);
  12784. builder.Write(hviv.RoomType);
  12785. builder.MoveToCell(0, i, 4, 0);
  12786. builder.Write(hviv.ConfirmationNumber);
  12787. }
  12788. //删除多余行
  12789. int currRowIndex = vouchers.Count + 1;
  12790. int delRows = 21 - currRowIndex;
  12791. if (delRows > 0)
  12792. {
  12793. for (int i = 0; i < delRows; i++)
  12794. {
  12795. table.Rows.RemoveAt(currRowIndex);
  12796. //cultivateRowIndex++;
  12797. }
  12798. }
  12799. strFileName += "VOUCHER.docx";
  12800. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12801. doc.Save(fileDir);
  12802. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12803. return Ok(JsonView(true, "操作成功!", Url));
  12804. }
  12805. /// <summary>
  12806. /// 酒店预订
  12807. /// 生成VOUCHER 批量生成
  12808. /// New
  12809. /// </summary>
  12810. /// <param name="_dto"></param>
  12811. /// <returns></returns>
  12812. [HttpPost]
  12813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12814. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  12815. {
  12816. #region 参数验证
  12817. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12818. if (_dto.PageId < 1) _dto.PageId = 28;
  12819. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12820. #region 团组操作权限验证 76 酒店预定模块
  12821. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12822. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12823. #endregion
  12824. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12825. #region 页面操作权限验证
  12826. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12827. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12828. #endregion
  12829. #endregion
  12830. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  12831. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  12832. .OrderBy(x => x.CheckInDate)
  12833. .ToListAsync();
  12834. //判断数据是否完整
  12835. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  12836. string strFileName = "HotelStatement/";
  12837. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  12838. if (dele != null)
  12839. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  12840. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  12841. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  12842. .Where(it => it.IsDel == 0)
  12843. .ToListAsync();
  12844. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  12845. for (int i = 0; i < hrDtas.Count; i++)
  12846. {
  12847. string guestNames = string.Empty;
  12848. List<int> guestIds = new List<int>();
  12849. var item = hrDtas[i];
  12850. //处理客户姓名
  12851. if (item.GuestName.Contains(","))
  12852. {
  12853. string[] guestIdArr = item.GuestName.Split(',');
  12854. foreach (var guestIdStr in guestIdArr)
  12855. if (int.TryParse(guestIdStr, out int guestId))
  12856. guestIds.Add(guestId);
  12857. }
  12858. else
  12859. {
  12860. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  12861. if (guestIdBool)
  12862. {
  12863. guestIds.Add(guestId);
  12864. }
  12865. //NaN
  12866. if (item.GuestName.Contains("NaN"))
  12867. {
  12868. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  12869. }
  12870. }
  12871. if (guestIds.Count > 0)
  12872. {
  12873. guestIds = guestIds.Distinct().ToList();
  12874. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  12875. if (guestDatas1.Count > 0)
  12876. {
  12877. guestNames = "";
  12878. foreach (var guest in guestDatas1)
  12879. {
  12880. string guestName = "";
  12881. if (guest.Sex == 0) guestName += @"MR.";
  12882. else if (guest.Sex == 1) guestName += @"MS.";
  12883. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  12884. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  12885. guestNames += @$"{guestName.Trim()}、";
  12886. }
  12887. if (guestNames.Length > 0)
  12888. {
  12889. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  12890. }
  12891. }
  12892. }
  12893. //if (!string.IsNullOrEmpty(guestNames))
  12894. //{
  12895. hrDtas[i].GuestName = guestNames;
  12896. //}
  12897. }
  12898. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  12899. Document doc = new Document();
  12900. DocumentBuilder builder = new DocumentBuilder(doc);
  12901. try
  12902. {
  12903. builder.MoveToDocumentStart();
  12904. foreach (var item in hrDtas)
  12905. {
  12906. //标题
  12907. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  12908. builder.ParagraphFormat.LineSpacing = 1;
  12909. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12910. builder.ParagraphFormat.Style.Font.Size = 9;
  12911. builder.ParagraphFormat.Style.Font.Bold = true;
  12912. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  12913. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  12914. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  12915. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  12916. builder.ParagraphFormat.LineSpacing = 1;
  12917. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12918. builder.ParagraphFormat.Style.Font.Size = 9;
  12919. builder.ParagraphFormat.Style.Font.Bold = true;
  12920. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  12921. builder.StartTable();
  12922. // 设置边框颜色
  12923. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  12924. //设置边框样式
  12925. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  12926. //表格
  12927. #region 第一行
  12928. builder.InsertCell();
  12929. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  12930. builder.CellFormat.HorizontalMerge = CellMerge.None;
  12931. //builder.CellFormat.AllowAutoFit = false;
  12932. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12933. builder.ParagraphFormat.Style.Font.Size = 7.5;
  12934. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  12935. builder.CellFormat.WrapText = true; //自动换行
  12936. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  12937. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  12938. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  12939. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  12940. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  12941. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  12942. builder.Write("TOUR NO:");
  12943. builder.InsertCell();
  12944. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  12945. builder.CellFormat.HorizontalMerge = CellMerge.None;
  12946. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12947. builder.ParagraphFormat.Style.Font.Size = 7.5;
  12948. builder.ParagraphFormat.Style.Font.Bold = false;
  12949. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  12950. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  12951. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  12952. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  12953. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  12954. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  12955. builder.Write($"{dele?.TourCode ?? "-"}");
  12956. builder.InsertCell();
  12957. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  12958. builder.CellFormat.HorizontalMerge = CellMerge.None;
  12959. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12960. builder.ParagraphFormat.Style.Font.Size = 7.5;
  12961. builder.ParagraphFormat.Style.Font.Bold = false;
  12962. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  12963. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  12964. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  12965. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  12966. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  12967. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  12968. builder.Write($"CITY:");
  12969. builder.InsertCell();
  12970. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  12971. builder.CellFormat.HorizontalMerge = CellMerge.None;
  12972. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12973. builder.ParagraphFormat.Style.Font.Size = 7.5;
  12974. builder.ParagraphFormat.Style.Font.Bold = false;
  12975. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  12976. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  12977. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  12978. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  12979. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  12980. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  12981. builder.Write($"{item.City}");
  12982. builder.EndRow();
  12983. #endregion
  12984. #region 第二行
  12985. builder.InsertCell();
  12986. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  12987. builder.CellFormat.HorizontalMerge = CellMerge.None;
  12988. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  12989. builder.ParagraphFormat.Style.Font.Size = 7.5;
  12990. builder.ParagraphFormat.Style.Font.Bold = false;
  12991. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  12992. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  12993. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  12994. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  12995. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  12996. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  12997. builder.Write("CONFIRMATION NO:");
  12998. builder.InsertCell();
  12999. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13000. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13001. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13002. builder.ParagraphFormat.Style.Font.Bold = false;
  13003. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13004. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13005. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13006. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13007. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13008. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13009. builder.CellFormat.VerticalMerge = CellMerge.None;
  13010. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13011. builder.Write($"{item.DetermineNo}");
  13012. builder.InsertCell();
  13013. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13014. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13015. builder.InsertCell();
  13016. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13017. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13018. builder.EndRow();
  13019. #endregion
  13020. #region 第三行
  13021. builder.InsertCell();
  13022. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13023. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13024. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13025. builder.ParagraphFormat.Style.Font.Bold = false;
  13026. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13027. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13028. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13029. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13030. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13031. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13032. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13033. builder.Write($"HOTEL NAME:");
  13034. builder.InsertCell();
  13035. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13036. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13037. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13038. builder.ParagraphFormat.Style.Font.Bold = false;
  13039. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13040. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13041. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13042. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13043. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13044. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13045. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13046. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13047. builder.Write($"{item.HotelName}");
  13048. builder.InsertCell();
  13049. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13050. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13051. builder.InsertCell();
  13052. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13053. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13054. builder.EndRow();
  13055. #endregion
  13056. #region 第四行
  13057. builder.InsertCell();
  13058. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13059. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13060. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13061. builder.ParagraphFormat.Style.Font.Bold = false;
  13062. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13063. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13064. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13065. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13066. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13067. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13068. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13069. builder.Write($"HOTEL ADDRESS:");
  13070. builder.InsertCell();
  13071. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13072. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13073. builder.ParagraphFormat.Style.Font.Size = 8;
  13074. builder.ParagraphFormat.Style.Font.Bold = false;
  13075. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13076. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13077. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13078. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13079. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13080. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13081. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13082. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13083. builder.Write($"{item.HotelAddress}");
  13084. builder.InsertCell();
  13085. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13086. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13087. builder.InsertCell();
  13088. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13089. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13090. builder.EndRow();
  13091. #endregion
  13092. #region 第五行
  13093. builder.InsertCell();
  13094. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13095. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13096. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13097. builder.ParagraphFormat.Style.Font.Bold = false;
  13098. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13099. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13100. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13101. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13102. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13103. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13104. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13105. builder.Write("TEL:");
  13106. builder.InsertCell();
  13107. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13108. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13109. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13110. builder.ParagraphFormat.Style.Font.Bold = false;
  13111. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13112. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13113. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13114. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13115. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13116. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13117. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13118. builder.Write($"{item.HotelTel}");
  13119. builder.InsertCell();
  13120. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13121. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13122. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13123. builder.ParagraphFormat.Style.Font.Bold = false;
  13124. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13125. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13126. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13127. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13128. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13129. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13130. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13131. builder.Write($"FAX:");
  13132. builder.InsertCell();
  13133. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13134. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13135. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13136. builder.ParagraphFormat.Style.Font.Bold = false;
  13137. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13138. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13139. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13140. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13141. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13142. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13143. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13144. builder.Write($"{item.HotelFax}");
  13145. builder.EndRow();
  13146. #endregion
  13147. #region 第六行
  13148. builder.InsertCell();
  13149. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13150. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13151. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13152. builder.ParagraphFormat.Style.Font.Bold = false;
  13153. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13154. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13155. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13156. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13157. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13158. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13159. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13160. builder.Write("CHECK IN:");
  13161. builder.InsertCell();
  13162. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13163. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13164. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13165. builder.ParagraphFormat.Style.Font.Bold = false;
  13166. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13167. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13168. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13169. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13170. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13171. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13172. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13173. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  13174. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  13175. builder.Write($"{checkInStr}");
  13176. builder.InsertCell();
  13177. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13178. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13179. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13180. builder.ParagraphFormat.Style.Font.Bold = false;
  13181. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13182. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13183. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13184. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13185. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13186. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13187. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13188. builder.Write($"CHECK OUT:");
  13189. builder.InsertCell();
  13190. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13191. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13192. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13193. builder.ParagraphFormat.Style.Font.Bold = false;
  13194. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13195. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13196. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13197. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13198. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13199. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13200. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13201. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  13202. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  13203. builder.Write($"{checkOutStr}");
  13204. builder.EndRow();
  13205. #endregion
  13206. #region 第七行
  13207. builder.InsertCell();
  13208. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13209. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13210. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13211. builder.ParagraphFormat.Style.Font.Bold = false;
  13212. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13213. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13214. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13215. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13216. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13217. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13218. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13219. builder.Write($"GUEST NAME:");
  13220. builder.InsertCell();
  13221. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13222. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13223. builder.ParagraphFormat.Style.Font.Size = 8;
  13224. builder.ParagraphFormat.Style.Font.Bold = false;
  13225. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13226. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13227. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13228. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13229. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13230. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13231. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13232. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13233. builder.Write($"{item.GuestName}");
  13234. builder.InsertCell();
  13235. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13236. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13237. builder.InsertCell();
  13238. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13239. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13240. builder.EndRow();
  13241. #endregion
  13242. #region 第八行
  13243. builder.InsertCell();
  13244. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13245. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13246. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13247. builder.ParagraphFormat.Style.Font.Bold = false;
  13248. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13249. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13250. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13251. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13252. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13253. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13254. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13255. builder.Write($"ROOM TYPE:");
  13256. builder.InsertCell();
  13257. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13258. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13259. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13260. builder.ParagraphFormat.Style.Font.Bold = false;
  13261. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13262. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13263. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13264. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13265. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13266. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13267. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13268. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13269. builder.Write($"{item.RoomExplanation}");
  13270. builder.InsertCell();
  13271. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13272. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13273. builder.InsertCell();
  13274. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13275. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13276. builder.EndRow();
  13277. #endregion
  13278. #region 第九行
  13279. builder.InsertCell();
  13280. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13281. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13282. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13283. builder.ParagraphFormat.Style.Font.Bold = false;
  13284. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13285. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13286. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13287. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13288. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13289. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13290. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13291. builder.Write($"NOTE:");
  13292. builder.InsertCell();
  13293. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13294. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13295. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13296. builder.ParagraphFormat.Style.Font.Bold = false;
  13297. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13298. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13299. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13300. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13301. 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.");
  13302. builder.InsertCell();
  13303. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13304. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13305. builder.InsertCell();
  13306. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13307. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13308. builder.EndRow();
  13309. #endregion
  13310. builder.EndTable();
  13311. //换行
  13312. builder.Writeln("");
  13313. builder.Writeln("");
  13314. }
  13315. #region 获取文档中的所有表格 设置文字自适应
  13316. // 获取文档中的所有表格。
  13317. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13318. {
  13319. // 遍历表格中的所有行。
  13320. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13321. {
  13322. foreach (Cell cell in row.Cells)
  13323. {
  13324. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  13325. cellFormat.Width = 0;
  13326. }
  13327. }
  13328. }
  13329. #endregion
  13330. #region 设置页眉
  13331. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  13332. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  13333. if (System.IO.File.Exists(voucherHeaderPath))
  13334. {
  13335. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  13336. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  13337. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  13338. Shape shape = builder.InsertImage(imageBytes);
  13339. // 调整图片位置
  13340. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  13341. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  13342. shape.Top = 50; // 将图片距离页眉上边缘的距离
  13343. shape.Left = 0; // 将图片距离页面左边缘的距离
  13344. shape.Width = 81; // 设置图片宽度
  13345. shape.Height = 36; // 设置图片高度
  13346. }
  13347. //靠右
  13348. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  13349. //// 设置页脚上下边距
  13350. //builder.PageSetup.HeaderDistance = 42;
  13351. // 添加页眉线
  13352. Aspose.Words.Border borderHeader = null;
  13353. try
  13354. {
  13355. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  13356. }
  13357. catch (Exception e)
  13358. {
  13359. // TODO Auto-generated catch block
  13360. //e.printStackTrace();
  13361. }
  13362. borderHeader.Shadow = true;
  13363. borderHeader.DistanceFromText = 2;
  13364. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  13365. #endregion
  13366. }
  13367. catch (Exception ex)
  13368. {
  13369. }
  13370. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  13371. doc.Save(fileDir);
  13372. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  13373. return Ok(JsonView(true, "操作成功!", Url));
  13374. }
  13375. /// <summary>
  13376. /// 酒店预订
  13377. /// 生成 预定成本 Excel
  13378. /// </summary>
  13379. /// <param name="_dto"></param>
  13380. /// <returns></returns>
  13381. [HttpPost]
  13382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13383. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  13384. {
  13385. #region 参数验证
  13386. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  13387. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  13388. if (!vadalitorRes.IsValid)
  13389. {
  13390. var errors = new StringBuilder();
  13391. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  13392. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  13393. }
  13394. #region 团组操作权限验证 76 酒店预定模块
  13395. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13396. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13397. #endregion
  13398. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13399. #region 页面操作权限验证
  13400. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13401. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13402. #endregion
  13403. #endregion
  13404. decimal _rate = 1.00M;
  13405. string _currency = string.Empty;
  13406. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  13407. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13408. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  13409. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13410. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  13411. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  13412. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  13413. if (_GroupCostParameter == null)
  13414. {
  13415. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  13416. bool isIntType = int.TryParse(_currency, out int currId);
  13417. if (isIntType)
  13418. {
  13419. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13420. }
  13421. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13422. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13423. if (currInfo == null)
  13424. {
  13425. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13426. }
  13427. else _rate = currInfo.Rate;
  13428. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  13429. {
  13430. _rate = _GroupCostParameter.Rate;
  13431. }
  13432. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13433. string strFileName = "HotelStatement/";
  13434. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13435. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13436. var rateDatas = new List<dynamic>();
  13437. #region 数据处理
  13438. foreach (var item in hrDtas)
  13439. {
  13440. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13441. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13442. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13443. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13444. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13445. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  13446. {
  13447. continue;
  13448. }
  13449. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13450. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  13451. string singleRoomFeeStr = string.Empty,
  13452. doubleRoomFeeStr = string.Empty,
  13453. suiteRoomFeeStr = string.Empty,
  13454. otherRoomFeeStr = string.Empty,
  13455. payMoneyStr = string.Empty,
  13456. cardPriceStr = string.Empty;
  13457. if (roomCurr.Equals("CNY"))
  13458. {
  13459. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  13460. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13461. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13462. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13463. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13464. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  13465. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  13466. }
  13467. else
  13468. {
  13469. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13470. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13471. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13472. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13473. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13474. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13475. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13476. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13477. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13478. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13479. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  13480. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  13481. if (ccpPaymentCurrency.Equals("CNY"))
  13482. {
  13483. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  13484. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13485. }
  13486. else
  13487. {
  13488. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  13489. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  13490. }
  13491. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  13492. if (hotelcardPriceCurrency.Equals("CNY"))
  13493. {
  13494. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13495. }
  13496. else
  13497. {
  13498. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  13499. }
  13500. }
  13501. string breakfastPriceStr = string.Empty,
  13502. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13503. governmentRentStr = string.Empty,
  13504. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13505. cityTaxStr = string.Empty,
  13506. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13507. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  13508. if (!string.IsNullOrEmpty(breakfastCurrency1))
  13509. {
  13510. if (breakfastCurrency1.Equals("CNY"))
  13511. {
  13512. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13513. }
  13514. else
  13515. {
  13516. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  13517. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  13518. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  13519. }
  13520. }
  13521. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13522. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  13523. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  13524. {
  13525. if (governmentRentCurrency.Equals("CNY"))
  13526. {
  13527. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13528. }
  13529. else
  13530. {
  13531. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  13532. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  13533. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  13534. }
  13535. }
  13536. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13537. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  13538. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  13539. {
  13540. if (cityTaxStrCurrency1.Equals("CNY"))
  13541. {
  13542. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13543. }
  13544. else
  13545. {
  13546. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  13547. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  13548. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  13549. }
  13550. }
  13551. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13552. int payDId = roomInfo?.PayDId ?? 0;
  13553. pcfds.Add(new HotelReservations_PCFD_View()
  13554. {
  13555. City = item.City,
  13556. HotelName = item.HotelName,
  13557. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13558. // SingleRoomCount = item.SingleRoomCount,
  13559. SingleRoomPrice = singleRoomFeeStr,
  13560. // DoubleRoomCount = item.DoubleRoomCount,
  13561. DoubleRoomPrice = doubleRoomFeeStr,
  13562. //SuiteRoomCount = item.SuiteRoomCount,
  13563. SuiteRoomPrice = suiteRoomFeeStr,
  13564. OtherRoomPrice = otherRoomFeeStr,
  13565. //OtherRoomCount = item.OtherRoomCount,
  13566. BreakfastPrice = breakfastPriceStr,
  13567. GovernmentRent = governmentRentStr,
  13568. CityTax = cityTaxStr,
  13569. RoomExplanation = item.RoomExplanation,
  13570. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13571. PayTime = roomInfo?.ConsumptionDate,
  13572. BankNo = roomInfo?.BankNo,
  13573. PayMoney = payMoneyStr,
  13574. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13575. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13576. CardPrice = cardPriceStr,
  13577. Remark = ccpInfo.Remark
  13578. });
  13579. }
  13580. #endregion
  13581. //载入模板
  13582. WorkbookDesigner designer = new WorkbookDesigner();
  13583. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13584. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13585. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13586. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13587. var rateDatas1 = rateDatas.Distinct();
  13588. var rateStr = string.Empty;
  13589. foreach (var item in rateDatas1)
  13590. {
  13591. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  13592. }
  13593. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  13594. designer.SetDataSource("Opertor", userInfo.CnName);
  13595. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13596. dt.TableName = "ViewMyHotelReservations";
  13597. designer.SetDataSource(dt);
  13598. designer.Process();
  13599. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13600. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13601. designer.Workbook.Save(serverPath);
  13602. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13603. #region 删除指定行
  13604. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13605. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13606. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13607. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13608. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13609. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13610. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13611. cssIndex = dt.Columns["CityTax"].Ordinal,
  13612. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13613. remarkIndex = dt.Columns["Remark"].Ordinal;
  13614. //删除指定列
  13615. foreach (DataRow item in dt.Rows)
  13616. {
  13617. string singleStr = item["SingleRoomPrice"].ToString();
  13618. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13619. if (containsDigitButNotZero1) singleDel = false;
  13620. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13621. string doubleStr = item["DoubleRoomPrice"].ToString();
  13622. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13623. if (containsDigitButNotZero2) doubleDel = false;
  13624. string suiteStr = item["SuiteRoomPrice"].ToString();
  13625. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13626. if (containsDigitButNotZero3) suiteDel = false;
  13627. string otherStr = item["OtherRoomPrice"].ToString();
  13628. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13629. if (containsDigitButNotZero4) otherDel = false;
  13630. string zcStr = item["BreakfastPrice"].ToString();
  13631. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13632. if (containsDigitButNotZero5) zcDel = false;
  13633. string dsStr = item["GovernmentRent"].ToString();
  13634. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13635. if (containsDigitButNotZero6) dsDel = false;
  13636. string cssStr = item["CityTax"].ToString();
  13637. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13638. if (containsDigitButNotZero7) cssDel = false;
  13639. string cpStr = item["ConsumptionPatterns"].ToString();
  13640. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13641. string remarkStr = item["Remark"].ToString();
  13642. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13643. }
  13644. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13645. DeleteColumn(serverPath, cpIndex, cpDel);
  13646. DeleteColumn(serverPath, dsIndex, dsDel);
  13647. DeleteColumn(serverPath, cssIndex, cssDel);
  13648. DeleteColumn(serverPath, zcIndex, zcDel);
  13649. DeleteColumn(serverPath, otherIndex, otherDel);
  13650. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13651. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13652. DeleteColumn(serverPath, singleIndex, singleDel);
  13653. #endregion
  13654. //只保留第一个表格
  13655. DeleteSheet(serverPath);
  13656. return Ok(JsonView(true, "操作成功", url = rst));
  13657. }
  13658. else
  13659. {
  13660. _currency = _GroupCostParameter.Currency;
  13661. bool isIntType = int.TryParse(_currency, out int currId);
  13662. if (isIntType)
  13663. {
  13664. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13665. }
  13666. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13667. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13668. if (currInfo == null)
  13669. {
  13670. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13671. }
  13672. if (!_currency.ToUpper().Equals("CNY"))
  13673. {
  13674. _rate = _GroupCostParameter.Rate;
  13675. }
  13676. _rate = currInfo.Rate;
  13677. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13678. string strFileName = "HotelStatement/";
  13679. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13680. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13681. #region 数据处理
  13682. foreach (var item in hrDtas)
  13683. {
  13684. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13685. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13686. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13687. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13688. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13689. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13690. string singleRoomFeeStr = string.Empty,
  13691. doubleRoomFeeStr = string.Empty,
  13692. suiteRoomFeeStr = string.Empty,
  13693. otherRoomFeeStr = string.Empty,
  13694. payMoneyStr = string.Empty,
  13695. cardPriceStr = string.Empty;
  13696. if (roomCurr.Equals(_currency))
  13697. {
  13698. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  13699. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  13700. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  13701. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  13702. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  13703. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  13704. }
  13705. else
  13706. {
  13707. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13708. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13709. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13710. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13711. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13712. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13713. }
  13714. string breakfastPriceStr = string.Empty,
  13715. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13716. governmentRentStr = string.Empty,
  13717. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13718. cityTaxStrStr = string.Empty,
  13719. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13720. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  13721. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  13722. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  13723. int payDId = roomInfo?.PayDId ?? 0;
  13724. pcfds.Add(new HotelReservations_PCFD_View()
  13725. {
  13726. City = item.City,
  13727. HotelName = item.HotelName,
  13728. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13729. // SingleRoomCount = item.SingleRoomCount,
  13730. SingleRoomPrice = singleRoomFeeStr,
  13731. // DoubleRoomCount = item.DoubleRoomCount,
  13732. DoubleRoomPrice = doubleRoomFeeStr,
  13733. //SuiteRoomCount = item.SuiteRoomCount,
  13734. SuiteRoomPrice = suiteRoomFeeStr,
  13735. OtherRoomPrice = otherRoomFeeStr,
  13736. //OtherRoomCount = item.OtherRoomCount,
  13737. BreakfastPrice = breakfastPriceStr,
  13738. GovernmentRent = governmentRentStr,
  13739. CityTax = cityTaxStrStr,
  13740. RoomExplanation = item.RoomExplanation,
  13741. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13742. PayTime = roomInfo?.ConsumptionDate,
  13743. BankNo = roomInfo?.BankNo,
  13744. PayMoney = payMoneyStr,
  13745. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13746. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13747. CardPrice = cardPriceStr,
  13748. Remark = ccpInfo.Remark
  13749. });
  13750. }
  13751. #endregion
  13752. //载入模板
  13753. WorkbookDesigner designer = new WorkbookDesigner();
  13754. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13755. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13756. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13757. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13758. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  13759. designer.SetDataSource("Opertor", userInfo.CnName);
  13760. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13761. dt.TableName = "ViewMyHotelReservations";
  13762. designer.SetDataSource(dt);
  13763. designer.Process();
  13764. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13765. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13766. designer.Workbook.Save(serverPath);
  13767. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13768. #region 删除指定行
  13769. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13770. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13771. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13772. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13773. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13774. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13775. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13776. cssIndex = dt.Columns["CityTax"].Ordinal,
  13777. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13778. remarkIndex = dt.Columns["Remark"].Ordinal;
  13779. //删除指定列
  13780. foreach (DataRow item in dt.Rows)
  13781. {
  13782. string singleStr = item["SingleRoomPrice"].ToString();
  13783. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13784. if (containsDigitButNotZero1) singleDel = false;
  13785. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13786. string doubleStr = item["DoubleRoomPrice"].ToString();
  13787. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13788. if (containsDigitButNotZero2) doubleDel = false;
  13789. string suiteStr = item["SuiteRoomPrice"].ToString();
  13790. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13791. if (containsDigitButNotZero3) suiteDel = false;
  13792. string otherStr = item["OtherRoomPrice"].ToString();
  13793. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13794. if (containsDigitButNotZero4) otherDel = false;
  13795. string zcStr = item["BreakfastPrice"].ToString();
  13796. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13797. if (containsDigitButNotZero5) zcDel = false;
  13798. string dsStr = item["GovernmentRent"].ToString();
  13799. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13800. if (containsDigitButNotZero6) dsDel = false;
  13801. string cssStr = item["CityTax"].ToString();
  13802. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13803. if (containsDigitButNotZero7) cssDel = false;
  13804. string cpStr = item["ConsumptionPatterns"].ToString();
  13805. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13806. string remarkStr = item["Remark"].ToString();
  13807. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13808. }
  13809. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13810. DeleteColumn(serverPath, cpIndex, cpDel);
  13811. DeleteColumn(serverPath, dsIndex, dsDel);
  13812. DeleteColumn(serverPath, cssIndex, cssDel);
  13813. DeleteColumn(serverPath, zcIndex, zcDel);
  13814. DeleteColumn(serverPath, otherIndex, otherDel);
  13815. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13816. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13817. DeleteColumn(serverPath, singleIndex, singleDel);
  13818. #endregion
  13819. //只保留第一个表格
  13820. DeleteSheet(serverPath);
  13821. return Ok(JsonView(true, "操作成功", url = rst));
  13822. }
  13823. return Ok(JsonView(false));
  13824. }
  13825. /// <summary>
  13826. /// 删除指定列
  13827. /// </summary>
  13828. /// <param name="file"></param>
  13829. /// <param name="columnIndex"></param>
  13830. /// <param name="isDel"></param>
  13831. private void DeleteColumn(string file, int columnIndex, bool isDel)
  13832. {
  13833. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  13834. //wb.Save(file);
  13835. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  13836. if (sheet1 != null)
  13837. {
  13838. if (isDel)
  13839. {
  13840. Cells cells = sheet1.Cells;
  13841. cells.DeleteColumn(columnIndex);
  13842. }
  13843. }
  13844. wb.Save(file);
  13845. }
  13846. /// <summary>
  13847. /// 删除sheet
  13848. /// </summary>
  13849. /// <param name="file"></param>
  13850. /// <param name="sheetName"></param>
  13851. private void DeleteSheet(string file, string sheetName = "")
  13852. {
  13853. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  13854. //wb.Save(file);
  13855. List<string> sheets = new List<string>();
  13856. foreach (var item in wb.Worksheets)
  13857. {
  13858. sheets.Add(item.Name);
  13859. }
  13860. if (sheets.Count > 0)
  13861. {
  13862. sheets.RemoveAt(0);//不删除第一个sheet
  13863. foreach (var item in sheets)
  13864. {
  13865. wb.Worksheets.RemoveAt(item);
  13866. }
  13867. }
  13868. wb.Save(file);
  13869. }
  13870. /// <summary>
  13871. /// 酒店预订
  13872. /// 确认单
  13873. /// </summary>
  13874. /// <param name="_dto"></param>
  13875. /// <returns></returns>
  13876. [HttpPost]
  13877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13878. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  13879. {
  13880. try
  13881. {
  13882. #region 参数验证
  13883. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  13884. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13885. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  13886. #region 团组操作权限验证 76 酒店预定模块
  13887. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13888. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  13889. #endregion
  13890. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13891. #region 页面操作权限验证
  13892. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13893. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13894. #endregion
  13895. #endregion
  13896. //团组信息
  13897. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  13898. //酒店数据
  13899. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  13900. if (listhoteldata.Count < 0)
  13901. {
  13902. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  13903. }
  13904. //利datatable存储
  13905. DataTable dt = new DataTable();
  13906. dt.Columns.Add("CheckInDate", typeof(string));
  13907. dt.Columns.Add("City", typeof(string));
  13908. dt.Columns.Add("Hotel", typeof(string));
  13909. dt.Columns.Add("Room", typeof(string));
  13910. for (int i = 0; i < listhoteldata.Count; i++)
  13911. {
  13912. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  13913. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  13914. while (dayStart < dayEnd)
  13915. {
  13916. string temp = "";
  13917. DataRow row = dt.NewRow();
  13918. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  13919. row["City"] = listhoteldata[i].City;
  13920. row["Hotel"] = listhoteldata[i].HotelName;
  13921. if (listhoteldata[i].SingleRoomCount > 0)
  13922. {
  13923. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  13924. }
  13925. if (listhoteldata[i].DoubleRoomCount > 0)
  13926. {
  13927. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  13928. }
  13929. if (listhoteldata[i].SuiteRoomCount > 0)
  13930. {
  13931. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  13932. }
  13933. if (listhoteldata[i].OtherRoomCount > 0)
  13934. {
  13935. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  13936. }
  13937. row["Room"] = temp;
  13938. dt.Rows.Add(row);
  13939. dayStart = dayStart.AddDays(1);
  13940. }
  13941. }
  13942. Dictionary<string, string> dic = new Dictionary<string, string>();
  13943. dic.Add("Dele", di.TeamName);
  13944. dic.Add("City", di.VisitCountry);
  13945. //模板路径
  13946. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  13947. //载入模板
  13948. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  13949. DocumentBuilder builder = new DocumentBuilder(doc);
  13950. foreach (var key in dic.Keys)
  13951. {
  13952. builder.MoveToBookmark(key);
  13953. builder.Write(dic[key]);
  13954. }
  13955. //获取word里所有表格
  13956. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13957. //获取所填表格的序数
  13958. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13959. var rowStart = tableOne.Rows[0]; //获取第1行
  13960. //循环赋值
  13961. for (int i = 0; i < dt.Rows.Count; i++)
  13962. {
  13963. builder.MoveToCell(0, i + 1, 0, 0);
  13964. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  13965. builder.MoveToCell(0, i + 1, 1, 0);
  13966. builder.Write(dt.Rows[i]["City"].ToString());
  13967. builder.MoveToCell(0, i + 1, 2, 0);
  13968. builder.Write(dt.Rows[i]["Hotel"].ToString());
  13969. builder.MoveToCell(0, i + 1, 3, 0);
  13970. builder.Write(dt.Rows[i]["Room"].ToString());
  13971. }
  13972. //删除多余行
  13973. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  13974. {
  13975. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  13976. }
  13977. string strFileName = di.TeamName + "酒店确认单.doc";
  13978. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  13979. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  13980. return Ok(JsonView(true, "成功", url));
  13981. }
  13982. catch (Exception ex)
  13983. {
  13984. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  13985. }
  13986. }
  13987. #endregion
  13988. #region 团组状态
  13989. /// <summary>
  13990. /// 团组状态列表 Page
  13991. /// </summary>
  13992. /// <param name="dto">团组列表请求dto</param>
  13993. /// <returns></returns>
  13994. [HttpPost]
  13995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13996. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  13997. {
  13998. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  13999. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  14000. {
  14001. string sqlWhere = string.Empty;
  14002. if (dto.IsSure == 0) //未完成
  14003. {
  14004. sqlWhere += string.Format(@" And IsSure = 0");
  14005. }
  14006. else if (dto.IsSure == 1) //已完成
  14007. {
  14008. sqlWhere += string.Format(@" And IsSure = 1");
  14009. }
  14010. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  14011. {
  14012. string tj = dto.SearchCriteria;
  14013. 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}%')",
  14014. tj, tj, tj, tj, tj);
  14015. }
  14016. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  14017. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  14018. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  14019. From (
  14020. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  14021. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  14022. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  14023. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  14024. From Grp_DelegationInfo gdi
  14025. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  14026. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  14027. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  14028. Where gdi.IsDel = 0 {0}
  14029. ) temp ", sqlWhere);
  14030. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  14031. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  14032. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  14033. }
  14034. else
  14035. {
  14036. return Ok(JsonView(false, "查询失败"));
  14037. }
  14038. }
  14039. /// <summary>
  14040. /// 团组状态
  14041. /// 设置操作完成
  14042. /// </summary>
  14043. /// <param name="dto">团组列表请求dto</param>
  14044. /// <returns></returns>
  14045. [HttpPost]
  14046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14047. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  14048. {
  14049. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14050. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  14051. {
  14052. Id = dto.Id,
  14053. IsSure = 1
  14054. };
  14055. var result = await _sqlSugar.Updateable(_DelegationInfo)
  14056. .UpdateColumns(it => new { it.IsSure })
  14057. .WhereColumns(it => new { it.Id })
  14058. .ExecuteCommandAsync();
  14059. if (result > 0)
  14060. {
  14061. return Ok(JsonView(true, "操作完成!"));
  14062. }
  14063. return Ok(JsonView(false, "操作失败!"));
  14064. }
  14065. #endregion
  14066. #region 保险费用录入
  14067. /// <summary>
  14068. /// 根据团组Id查询保险费用列表
  14069. /// </summary>
  14070. /// <param name="dto"></param>
  14071. /// <returns></returns>
  14072. [HttpPost]
  14073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14074. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  14075. {
  14076. Result groupData = await _customersRep.CustomersByDiId(dto);
  14077. if (groupData.Code != 0)
  14078. {
  14079. return Ok(JsonView(false, groupData.Msg));
  14080. }
  14081. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14082. }
  14083. /// <summary>
  14084. /// 根据保险费用Id查询保险费用详细
  14085. /// </summary>
  14086. /// <param name="dto"></param>
  14087. /// <returns></returns>
  14088. [HttpPost]
  14089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14090. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  14091. {
  14092. try
  14093. {
  14094. Result groupData = await _customersRep.CustomersById(dto);
  14095. if (groupData.Code != 0)
  14096. {
  14097. return Ok(JsonView(false, groupData.Msg));
  14098. }
  14099. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14100. }
  14101. catch (Exception ex)
  14102. {
  14103. return Ok(JsonView(false, ex.Message));
  14104. }
  14105. }
  14106. /// <summary>
  14107. /// 保险费用录入页面初始化绑定
  14108. /// </summary>
  14109. /// <param name="dto"></param>
  14110. /// <returns></returns>
  14111. [HttpPost]
  14112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14113. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  14114. {
  14115. try
  14116. {
  14117. Result groupData = await _customersRep.CustomersInitialize(dto);
  14118. if (groupData.Code != 0)
  14119. {
  14120. return Ok(JsonView(false, groupData.Msg));
  14121. }
  14122. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14123. }
  14124. catch (Exception ex)
  14125. {
  14126. return Ok(JsonView(false, ex.Message));
  14127. }
  14128. }
  14129. /// <summary>
  14130. /// 保险费用操作(Status:1.新增,2.修改)
  14131. /// </summary>
  14132. /// <param name="dto"></param>
  14133. /// <returns></returns>
  14134. [HttpPost]
  14135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14136. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  14137. {
  14138. Result groupData = await _customersRep.OpCustomers(dto);
  14139. if (groupData.Code != 0)
  14140. {
  14141. return Ok(JsonView(false, groupData.Msg));
  14142. }
  14143. #region 应用推送
  14144. try
  14145. {
  14146. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14147. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14148. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  14149. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14150. //自动审核
  14151. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  14152. //2024-10-21 新增LZ UID
  14153. var userIds = new List<int>() { 21 };
  14154. string title = $"系统通知";
  14155. var diId = dto.DiId;
  14156. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14157. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14158. string content = "";
  14159. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14160. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14161. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14162. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14163. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14164. }
  14165. catch (Exception ex)
  14166. {
  14167. }
  14168. #endregion
  14169. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14170. }
  14171. /// <summary>
  14172. /// 保险文件上传
  14173. /// </summary>
  14174. /// <param name="file"></param>
  14175. /// <returns></returns>
  14176. [HttpPost]
  14177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14178. public async Task<IActionResult> UploadCus(IFormFile file)
  14179. {
  14180. try
  14181. {
  14182. if (file != null)
  14183. {
  14184. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14185. //文件名称
  14186. string projectFileName = file.FileName;
  14187. //上传的文件的路径
  14188. string filePath = "";
  14189. if (!Directory.Exists(fileDir))
  14190. {
  14191. Directory.CreateDirectory(fileDir);
  14192. }
  14193. //上传的文件的路径
  14194. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  14195. using (FileStream fs = System.IO.File.Create(filePath))
  14196. {
  14197. file.CopyTo(fs);
  14198. fs.Flush();
  14199. }
  14200. return Ok(JsonView(true, "上传成功!", projectFileName));
  14201. }
  14202. else
  14203. {
  14204. return Ok(JsonView(false, "上传失败!"));
  14205. }
  14206. }
  14207. catch (Exception ex)
  14208. {
  14209. return Ok(JsonView(false, "程序错误!"));
  14210. throw;
  14211. }
  14212. }
  14213. /// <summary>
  14214. /// 保险删除指定文件
  14215. /// </summary>
  14216. /// <param name="dto"></param>
  14217. /// <returns></returns>
  14218. [HttpPost]
  14219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14220. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  14221. {
  14222. try
  14223. {
  14224. string filePath = "";
  14225. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14226. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  14227. //int id = 0;
  14228. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  14229. // 删除该文件
  14230. try
  14231. {
  14232. System.IO.File.Delete(filePath);
  14233. 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()
  14234. {
  14235. Attachment = "",
  14236. }).ExecuteCommandAsync();
  14237. if (result != 0)
  14238. {
  14239. return Ok(JsonView(true, "成功!"));
  14240. }
  14241. else
  14242. {
  14243. return Ok(JsonView(false, "失败!"));
  14244. }
  14245. }
  14246. catch (Exception)
  14247. {
  14248. 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()
  14249. {
  14250. Attachment = "",
  14251. }).ExecuteCommandAsync();
  14252. if (result != 0)
  14253. {
  14254. return Ok(JsonView(true, "成功!"));
  14255. }
  14256. else
  14257. {
  14258. return Ok(JsonView(false, "失败!"));
  14259. }
  14260. }
  14261. }
  14262. catch (Exception ex)
  14263. {
  14264. return Ok(JsonView(false, "程序错误!"));
  14265. throw;
  14266. }
  14267. }
  14268. /// <summary>
  14269. /// 保险费用操作(删除)
  14270. /// </summary>
  14271. /// <param name="dto"></param>
  14272. /// <returns></returns>
  14273. [HttpPost]
  14274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14275. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  14276. {
  14277. try
  14278. {
  14279. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  14280. if (!res)
  14281. {
  14282. return Ok(JsonView(false, "删除失败"));
  14283. }
  14284. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  14285. {
  14286. IsDel = 1,
  14287. DeleteUserId = dto.DeleteUserId,
  14288. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14289. }).ExecuteCommandAsync();
  14290. return Ok(JsonView(true, "删除成功!"));
  14291. }
  14292. catch (Exception ex)
  14293. {
  14294. return Ok(JsonView(false, "程序错误!"));
  14295. throw;
  14296. }
  14297. }
  14298. #endregion
  14299. #region 接团客户名单 PageId 104
  14300. /// <summary>
  14301. /// 接团客户名单
  14302. /// 迁移数据(慎用!)
  14303. /// </summary>
  14304. /// <param name="dto"></param>
  14305. /// <returns></returns>
  14306. [HttpPost]
  14307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14308. public async Task<IActionResult> PostTourClientListChange()
  14309. {
  14310. try
  14311. {
  14312. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  14313. //var groupClinetData1
  14314. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  14315. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  14316. int updateCount = 0;
  14317. if (oldOAClientList.Count > 0)
  14318. {
  14319. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  14320. _sqlSugar.BeginTran();
  14321. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  14322. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  14323. foreach (var item in oldOAClientList)
  14324. {
  14325. int comId = 0;
  14326. string format = "yyyy-MM-dd HH:mm:ss";
  14327. string data11 = "1990-01-01 00:00";
  14328. var data1 = IsValidDate(item.OPdate, format);
  14329. if (data1) data11 = item.OPdate;
  14330. //客户公司验证
  14331. if (!string.IsNullOrEmpty(item.Company))
  14332. {
  14333. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  14334. if (clientComInfo == null) // add
  14335. {
  14336. var addInfo = new Crm_CustomerCompany()
  14337. {
  14338. CompanyAbbreviation = "",
  14339. CompanyFullName = item.Company,
  14340. Address = "",
  14341. PostCodes = "",
  14342. LastedOpUserId = item.OPer,
  14343. LastedOpDt = Convert.ToDateTime(data11),
  14344. CreateUserId = item.OPer,
  14345. CreateTime = Convert.ToDateTime(data11),
  14346. IsDel = 0
  14347. };
  14348. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  14349. if (comId1 > 0) comId = comId1;
  14350. }
  14351. else comId = clientComInfo.Id;
  14352. }
  14353. //客户人员验证
  14354. int clientId = 0;
  14355. string name = item.LastName + item.Name;
  14356. if (!string.IsNullOrEmpty(name))
  14357. {
  14358. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  14359. if (clientInfo == null)
  14360. {
  14361. DateTime? dateTime = null;
  14362. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  14363. if (isDt) dateTime = birthDayDt;
  14364. var addInfo1 = new Crm_DeleClient()
  14365. {
  14366. CrmCompanyId = comId,
  14367. DiId = -1,
  14368. LastName = item.LastName,
  14369. FirstName = item.Name,
  14370. OldName = "",
  14371. Pinyin = item.Pinyin,
  14372. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  14373. Marriage = 0,
  14374. Phone = item.Phone,
  14375. Job = item.Job,
  14376. BirthDay = dateTime
  14377. };
  14378. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  14379. if (clientId1 > 0) clientId = clientId1;
  14380. }
  14381. else clientId = clientInfo.Id;
  14382. }
  14383. if (clientId < 1)
  14384. {
  14385. continue;
  14386. }
  14387. int airType = 0;
  14388. if (item.AirType == "超经舱") airType = 459;
  14389. else if (item.AirType == "公务舱") airType = 458;
  14390. else if (item.AirType == "经济舱") airType = 460;
  14391. else if (item.AirType == "其他") airType = 565;
  14392. else if (item.AirType == "头等舱") airType = 457;
  14393. var _TourClientListEntity = new Grp_TourClientList()
  14394. {
  14395. DiId = item.Diid,
  14396. ClientId = clientId,
  14397. CreateUserId = item.OPer,
  14398. CreateTime = Convert.ToDateTime(data11),
  14399. Remark = item.Remark,
  14400. IsDel = item.Isdel,
  14401. ShippingSpaceTypeId = airType,
  14402. ShippingSpaceSpecialNeeds = item.AirRemark,
  14403. HotelSpecialNeeds = item.RoomType
  14404. };
  14405. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  14406. if (_TourClientList > 0)
  14407. {
  14408. updateCount++;
  14409. }
  14410. }
  14411. _sqlSugar.CommitTran();
  14412. }
  14413. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  14414. }
  14415. catch (Exception ex)
  14416. {
  14417. _sqlSugar.RollbackTran();
  14418. return Ok(JsonView(false, ex.Message));
  14419. }
  14420. return Ok(JsonView(true));
  14421. }
  14422. private bool IsValidDate(string dateString, string format)
  14423. {
  14424. DateTime dateValue;
  14425. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  14426. return valid;
  14427. }
  14428. /// <summary>
  14429. /// 接团客户名单
  14430. /// 根据团组Id查询List
  14431. /// </summary>
  14432. /// <param name="dto"></param>
  14433. /// <returns></returns>
  14434. [HttpPost]
  14435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14436. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  14437. {
  14438. #region 参数验证
  14439. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  14440. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  14441. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  14442. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14443. #region 页面操作权限验证
  14444. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14445. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14446. #endregion
  14447. #endregion
  14448. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  14449. if (viewData.Code != 0)
  14450. {
  14451. return Ok(JsonView(false, viewData.Msg));
  14452. }
  14453. return Ok(JsonView(viewData.Data));
  14454. }
  14455. /// <summary>
  14456. /// 接团客户名单
  14457. /// 基础数据 Init
  14458. /// </summary>
  14459. /// <param name="_dto"></param>
  14460. /// <returns></returns>
  14461. [HttpPost]
  14462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14463. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  14464. {
  14465. #region 参数验证
  14466. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14467. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14468. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14469. #region 页面操作权限验证
  14470. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14471. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14472. #endregion
  14473. #endregion
  14474. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  14475. }
  14476. /// <summary>
  14477. /// 接团客户名单
  14478. /// 根据 Id查询 Details
  14479. /// </summary>
  14480. /// <param name="_dto"></param>
  14481. /// <returns></returns>
  14482. [HttpPost]
  14483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14484. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  14485. {
  14486. #region 参数验证
  14487. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14488. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14489. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14490. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14491. #region 页面操作权限验证
  14492. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14493. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14494. #endregion
  14495. #endregion
  14496. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  14497. if (viewData.Code != 0)
  14498. {
  14499. return Ok(JsonView(false, viewData.Msg));
  14500. }
  14501. return Ok(JsonView(viewData.Data));
  14502. }
  14503. /// <summary>
  14504. /// 接团客户名单
  14505. /// Add Or Edit
  14506. /// </summary>
  14507. /// <param name="_dto"></param>
  14508. /// <returns></returns>
  14509. [HttpPost]
  14510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14511. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  14512. {
  14513. #region 参数验证
  14514. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14515. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14516. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14517. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14518. #region 页面操作权限验证
  14519. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14520. if (_dto.Id == 0) //添加
  14521. {
  14522. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14523. }
  14524. else if (_dto.Id >= 0) //修改
  14525. {
  14526. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14527. }
  14528. #endregion
  14529. #endregion
  14530. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  14531. if (viewData.Code != 0)
  14532. {
  14533. return Ok(JsonView(false, viewData.Msg));
  14534. }
  14535. return Ok(JsonView(true));
  14536. }
  14537. /// <summary>
  14538. /// 接团客户名单
  14539. /// AddMultiple(添加多个)
  14540. /// </summary>
  14541. /// <param name="_dto"></param>
  14542. /// <returns></returns>
  14543. [HttpPost]
  14544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14545. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  14546. {
  14547. #region 参数验证
  14548. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14549. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14550. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14551. #region 页面操作权限验证
  14552. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14553. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14554. #endregion
  14555. #endregion
  14556. var viewData = await _tourClientListRep._AddMultiple(_dto);
  14557. if (viewData.Code != 0)
  14558. {
  14559. return Ok(JsonView(false, viewData.Msg));
  14560. }
  14561. return Ok(JsonView(true));
  14562. }
  14563. /// <summary>
  14564. /// 接团客户名单
  14565. /// Del
  14566. /// </summary>
  14567. /// <param name="_dto"></param>
  14568. /// <returns></returns>
  14569. [HttpPost]
  14570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14571. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  14572. {
  14573. #region 参数验证
  14574. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14575. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14576. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14577. #region 页面操作权限验证
  14578. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14579. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14580. #endregion
  14581. #endregion
  14582. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  14583. if (viewData.Code != 0)
  14584. {
  14585. return Ok(JsonView(false, viewData.Msg));
  14586. }
  14587. return Ok(JsonView(true));
  14588. }
  14589. /// <summary>
  14590. /// 接团客户名单
  14591. /// 文件下载 客户名单
  14592. /// </summary>
  14593. /// <param name="_dto"></param>
  14594. /// <returns></returns>
  14595. [HttpPost]
  14596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14597. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  14598. {
  14599. #region 参数验证
  14600. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14601. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14602. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  14603. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14604. #region 页面操作权限验证
  14605. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14606. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14607. #endregion
  14608. #endregion
  14609. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  14610. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  14611. From Grp_TourClientList tcl
  14612. Left Join
  14613. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  14614. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  14615. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  14616. From Crm_DeleClient dc
  14617. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  14618. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  14619. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  14620. Where dc.IsDel = 0) temp
  14621. On temp.DcId =tcl.ClientId
  14622. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  14623. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  14624. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  14625. //载入模板
  14626. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  14627. if (_dto.Language == 1)
  14628. {
  14629. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  14630. }
  14631. //载入模板
  14632. var doc = new Document(tempPath);
  14633. DocumentBuilder builder = new DocumentBuilder(doc);
  14634. //获取word里所有表格
  14635. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14636. //获取所填表格的序数
  14637. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14638. var rowStart = tableOne.Rows[0]; //获取第1行
  14639. if (_dto.Language == 0)
  14640. {
  14641. //循环赋值
  14642. for (int i = 0; i < DcList.Count; i++)
  14643. {
  14644. EncryptionProcessor.DecryptProperties(DcList[i]);
  14645. builder.MoveToCell(0, i + 1, 0, 0);
  14646. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  14647. builder.MoveToCell(0, i + 1, 1, 0);
  14648. int sex = DcList[i].Sex;
  14649. string sexStr = string.Empty;
  14650. if (sex == 0) sexStr = "男";
  14651. else if (sex == 1) sexStr = "女";
  14652. else sexStr = "未设置";
  14653. builder.Write(sexStr);
  14654. builder.MoveToCell(0, i + 1, 2, 0);
  14655. string birthDay = DcList[i].BirthDay;
  14656. string birthDayStr = string.Empty;
  14657. if (!string.IsNullOrEmpty(birthDay))
  14658. {
  14659. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  14660. }
  14661. builder.Write(birthDayStr);
  14662. builder.MoveToCell(0, i + 1, 3, 0);
  14663. string company = "";
  14664. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  14665. {
  14666. company = DcList[i].CompanyFullName.ToString();
  14667. }
  14668. builder.Write(company);
  14669. builder.MoveToCell(0, i + 1, 4, 0);
  14670. builder.Write(DcList[i].Job);
  14671. }
  14672. }
  14673. else if (_dto.Language == 1)
  14674. {
  14675. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  14676. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  14677. List<string> transArrayStr = new List<string>();
  14678. string transStrRes1 = "";
  14679. for (int i = 0; i < DcList.Count; i++)
  14680. {
  14681. var dc = DcList[i];
  14682. EncryptionProcessor.DecryptProperties(dc);
  14683. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  14684. if (dc.Job.Equals("暂无")) dc.Job = "-";
  14685. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  14686. if (DcList.Count - 1 == i) transStrRes1 += str1;
  14687. else transStrRes1 += $"{str1}|";
  14688. }
  14689. //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";
  14690. string transStrRes = "";
  14691. if (transStrRes1.Length > 0)
  14692. {
  14693. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  14694. }
  14695. //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
  14696. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  14697. //List<string> transArray = new List<string> { };
  14698. List<TranslateInfo> transArray = new List<TranslateInfo>();
  14699. if (transStrRes.Contains("|"))
  14700. {
  14701. string[] transArray1 = transStrRes.Split('|');
  14702. if (transArray1.Length > 0)
  14703. {
  14704. foreach (var item in transArray1)
  14705. {
  14706. if (item.Contains("&"))
  14707. {
  14708. string[] transArray2 = item.Split('&');
  14709. int index = 0;
  14710. string companyName = "", job = "";
  14711. if (transArray2.Length > 0)
  14712. {
  14713. bool success = int.TryParse(transArray2[0].Trim(), out index);
  14714. if (1 < transArray2.Length) companyName = transArray2[1];
  14715. if (2 < transArray2.Length) job = transArray2[2];
  14716. }
  14717. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  14718. }
  14719. }
  14720. }
  14721. }
  14722. //循环赋值
  14723. for (int i = 0; i < DcList.Count; i++)
  14724. {
  14725. string PYName = "";
  14726. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  14727. {
  14728. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  14729. string PY_First = DcList[i].Pinyin.Split('/')[1];
  14730. PYName = PY_First + " " + PY_Last;
  14731. }
  14732. else
  14733. {
  14734. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  14735. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  14736. PYName = PY_First + " " + PY_Last;
  14737. }
  14738. builder.MoveToCell(0, i + 1, 0, 0);
  14739. builder.Write(PYName);
  14740. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  14741. builder.MoveToCell(0, i + 1, 1, 0);
  14742. builder.Write(sex);
  14743. DateTime birthDt;
  14744. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  14745. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  14746. builder.MoveToCell(0, i + 1, 2, 0);
  14747. builder.Write(birthday);
  14748. string company = string.Empty, job = string.Empty;
  14749. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  14750. if (dcTransInfo != null)
  14751. {
  14752. company = dcTransInfo.CompanyName;
  14753. job = dcTransInfo.Job;
  14754. }
  14755. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  14756. {
  14757. //查询对照表
  14758. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  14759. if (tempCec != null)
  14760. {
  14761. company = tempCec.enName;
  14762. }
  14763. //翻译
  14764. else
  14765. {
  14766. }
  14767. }
  14768. builder.MoveToCell(0, i + 1, 3, 0);
  14769. builder.Write(company);
  14770. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  14771. {
  14772. //查询对照表
  14773. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  14774. if (tempPec != null)
  14775. {
  14776. job = tempPec.enName;
  14777. }
  14778. //翻译
  14779. else
  14780. {
  14781. }
  14782. }
  14783. builder.MoveToCell(0, i + 1, 4, 0);
  14784. builder.Write(job);
  14785. }
  14786. }
  14787. //删除多余行
  14788. while (tableOne.Rows.Count > DcList.Count + 1)
  14789. {
  14790. tableOne.Rows.RemoveAt(DcList.Count + 1);
  14791. }
  14792. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  14793. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  14794. doc.Save(fileDir);
  14795. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  14796. return Ok(JsonView(true, "操作成功!", Url));
  14797. }
  14798. private class TranslateInfo
  14799. {
  14800. public int Index { get; set; }
  14801. public string CompanyName { get; set; }
  14802. public string Job { get; set; }
  14803. }
  14804. #endregion
  14805. #region 团组倒推表
  14806. /// <summary>
  14807. /// 倒推表基础数据
  14808. /// Init
  14809. /// </summary>
  14810. /// <param name="dto"></param>
  14811. /// <returns></returns>
  14812. [HttpPost]
  14813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14814. public async Task<IActionResult> PostInvertedListInit()
  14815. {
  14816. var viewData = await _invertedListRep._Init();
  14817. if (viewData.Code != 0)
  14818. {
  14819. return Ok(JsonView(false, viewData.Msg));
  14820. }
  14821. return Ok(JsonView(viewData.Data));
  14822. }
  14823. /// <summary>
  14824. /// 倒推表
  14825. /// Info
  14826. /// </summary>
  14827. /// <param name="dto"></param>
  14828. /// <returns></returns>
  14829. [HttpPost]
  14830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14831. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  14832. {
  14833. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  14834. if (viewData.Code != 0)
  14835. {
  14836. return Ok(JsonView(false, viewData.Msg));
  14837. }
  14838. return Ok(JsonView(viewData.Data));
  14839. }
  14840. /// <summary>
  14841. /// 倒推表
  14842. /// Create
  14843. /// </summary>
  14844. /// <param name="dto"></param>
  14845. /// <returns></returns>
  14846. [HttpPost]
  14847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14848. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  14849. {
  14850. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  14851. if (viewData.Code != 0)
  14852. {
  14853. return Ok(JsonView(false, viewData.Msg));
  14854. }
  14855. return Ok(JsonView(viewData.Data));
  14856. }
  14857. /// <summary>
  14858. /// 倒推表
  14859. /// Update
  14860. /// </summary>
  14861. /// <param name="dto"></param>
  14862. /// <returns></returns>
  14863. [HttpPost]
  14864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14865. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  14866. {
  14867. var viewData = await _invertedListRep._Update(dto);
  14868. if (viewData.Code != 0)
  14869. {
  14870. return Ok(JsonView(false, viewData.Msg));
  14871. }
  14872. return Ok(JsonView(viewData.Data));
  14873. }
  14874. /// <summary>
  14875. /// 倒推表
  14876. /// File Download
  14877. /// </summary>
  14878. /// <param name="dto"></param>
  14879. /// <returns></returns>
  14880. [HttpPost]
  14881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14882. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  14883. {
  14884. var info2 = await _invertedListRep._Info(1, dto.DiId);
  14885. if (info2.Code != 0)
  14886. {
  14887. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  14888. }
  14889. var info1 = info2.Data as InvertedListInfoView;
  14890. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  14891. string teamName = "";
  14892. if (info != null) teamName = info.TeamName;
  14893. //载入模板
  14894. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  14895. DocumentBuilder builder = new DocumentBuilder(doc);
  14896. //利用键值对存放数据
  14897. Dictionary<string, string> dic = new Dictionary<string, string>();
  14898. dic.Add("TeamName", teamName);
  14899. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  14900. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  14901. dic.Add("BPRemark", info1.ApprovalDataRemark);
  14902. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  14903. dic.Add("SQRemark", info1.ApprovalRemark);
  14904. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  14905. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  14906. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  14907. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  14908. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  14909. dic.Add("QZRemark", info1.VisaInformationRemark);
  14910. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  14911. dic.Add("SQQZRemark", info1.SendVisaRemark);
  14912. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  14913. dic.Add("CQRemark", info1.IssueVisaRemark);
  14914. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  14915. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  14916. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  14917. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  14918. #region 填充word模板书签内容
  14919. foreach (var key in dic.Keys)
  14920. {
  14921. builder.MoveToBookmark(key);
  14922. builder.Write(dic[key]);
  14923. }
  14924. #endregion
  14925. var fileDir = AppSettingsHelper.Get("WordBasePath");
  14926. string fileName = $"{teamName}团出行准备流程表.doc";
  14927. string filePath = fileDir + $@"InvertedList/{fileName}";
  14928. doc.Save(filePath);
  14929. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  14930. return Ok(JsonView(true, "操作成功!", Url));
  14931. }
  14932. #endregion
  14933. #region 三公签证费用(签证费、代办费)
  14934. /// <summary>
  14935. /// 三公签证费用(签证费、代办费)
  14936. /// List
  14937. /// </summary>
  14938. /// <returns></returns>
  14939. [HttpPost]
  14940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14941. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  14942. {
  14943. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  14944. if (_view.Code != 0)
  14945. {
  14946. return Ok(JsonView(false, _view.Msg));
  14947. }
  14948. return Ok(JsonView(true, "操作成功!", _view.Data));
  14949. }
  14950. /// <summary>
  14951. /// 三公签证费用(签证费、代办费)
  14952. /// Add Or Update
  14953. /// </summary>
  14954. /// <returns></returns>
  14955. [HttpPost]
  14956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14957. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  14958. {
  14959. var _view = await _visaFeeInfoRep._Update(_dto);
  14960. if (_view.Code != 0)
  14961. {
  14962. return Ok(JsonView(false, _view.Msg));
  14963. }
  14964. return Ok(JsonView(true, _view.Msg));
  14965. }
  14966. #endregion
  14967. #region 酒店询价
  14968. /// <summary>
  14969. /// 酒店询价
  14970. /// Init
  14971. /// </summary>
  14972. /// <param name="dto"></param>
  14973. /// <returns></returns>
  14974. [HttpPost]
  14975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14976. public async Task<IActionResult> PostHotelInquiryInit()
  14977. {
  14978. var res = await _hotelInquiryRep._Init();
  14979. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  14980. return Ok(JsonView(true, res.Msg, res.Data));
  14981. }
  14982. /// <summary>
  14983. /// 酒店询价
  14984. /// page Item
  14985. /// </summary>
  14986. /// <param name="_dto"></param>
  14987. /// <returns></returns>
  14988. [HttpPost]
  14989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14990. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  14991. {
  14992. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  14993. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  14994. var view = res.Data as PageDataViewBase;
  14995. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  14996. }
  14997. /// <summary>
  14998. /// 酒店询价
  14999. /// info
  15000. /// </summary>
  15001. /// <param name="_dto"></param>
  15002. /// <returns></returns>
  15003. [HttpPost]
  15004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15005. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  15006. {
  15007. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  15008. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15009. return Ok(JsonView(true, res.Msg, res.Data));
  15010. }
  15011. /// <summary>
  15012. /// 酒店询价
  15013. /// Add Or Edit
  15014. /// </summary>
  15015. /// <param name="_dto"></param>
  15016. /// <returns></returns>
  15017. [HttpPost]
  15018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15019. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  15020. {
  15021. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  15022. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15023. return Ok(JsonView(true, res.Msg, res.Data));
  15024. }
  15025. /// <summary>
  15026. /// 酒店询价
  15027. /// Del
  15028. /// </summary>
  15029. /// <param name="_dto"></param>
  15030. /// <returns></returns>
  15031. [HttpPost]
  15032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15033. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  15034. {
  15035. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  15036. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15037. return Ok(JsonView(true, res.Msg, res.Data));
  15038. }
  15039. #endregion
  15040. #region 下载匹配op行程单
  15041. /// <summary>
  15042. /// 匹配op行程单
  15043. /// Init
  15044. /// </summary>
  15045. /// <param name="dto">团组列表请求dto</param>
  15046. /// <returns></returns>
  15047. [HttpPost]
  15048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15049. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  15050. {
  15051. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15052. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15053. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  15054. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  15055. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  15056. .Where(it => it.IsDel == 0)
  15057. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  15058. .OrderByDescending(it => it.CreateUserId)
  15059. .ToList();
  15060. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  15061. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15062. var diids = groupInfos.Select(it => it.Id).ToList();
  15063. List<string> countrys = new List<string>();
  15064. foreach (var item in country)
  15065. {
  15066. var data = _groupRepository.FormartTeamName(item);
  15067. var dataArray = _groupRepository.GroupSplitCountry(data);
  15068. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15069. }
  15070. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  15071. List<string> areaArray = new List<string>(); //GetGroupCityLine
  15072. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  15073. foreach (var item in areaItem)
  15074. {
  15075. string areaStr = item.Value;
  15076. if (!string.IsNullOrEmpty(areaStr))
  15077. {
  15078. string[] str1 = areaStr.Split("-");
  15079. if (str1.Length > 0)
  15080. {
  15081. areaArray.AddRange(str1);
  15082. }
  15083. }
  15084. }
  15085. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  15086. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  15087. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  15088. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  15089. .ToList();
  15090. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  15091. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  15092. .Where(it => countriesIds.Contains(it.Id))
  15093. .Select(it => new { it.Id, Name = it.Name_CN })
  15094. .ToList();
  15095. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  15096. .Select(it => it.TeamName).ToList();
  15097. stopwatch.Stop();
  15098. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  15099. }
  15100. ///// <summary>
  15101. ///// 匹配op行程单
  15102. ///// Init 查询区域数据
  15103. ///// </summary>
  15104. ///// <param name="dto">团组列表请求dto</param>
  15105. ///// <returns></returns>
  15106. //[HttpPost]
  15107. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15108. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  15109. //{
  15110. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15111. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  15112. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  15113. // if (string.IsNullOrEmpty(countriesDataStr))
  15114. // {
  15115. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  15116. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  15117. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  15118. // }
  15119. // else
  15120. // {
  15121. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  15122. // }
  15123. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  15124. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  15125. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  15126. // List<dynamic> childList = new List<dynamic>();
  15127. // int parentId = dto.CountriesId;
  15128. // if (provinceData.Count > 1)
  15129. // {
  15130. // foreach (var item1 in provinceData)
  15131. // {
  15132. // List<dynamic> childList1 = new List<dynamic>();
  15133. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  15134. // foreach (var item2 in citiesData1)
  15135. // {
  15136. // List<dynamic> childList2 = new List<dynamic>();
  15137. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15138. // foreach (var item3 in countiesData1)
  15139. // {
  15140. // childList2.Add(new
  15141. // {
  15142. // id = item3.Id,
  15143. // parentId = item2.Id,
  15144. // level = "district",
  15145. // name = item3.Name_CN,
  15146. // });
  15147. // }
  15148. // childList1.Add(new
  15149. // {
  15150. // id = item2.Id,
  15151. // parentId = item1.Id,
  15152. // level = "city",
  15153. // name = item2.Name_CN,
  15154. // childList = childList2
  15155. // });
  15156. // }
  15157. // childList.Add(new
  15158. // {
  15159. // id = item1.Id,
  15160. // parentId = parentId,
  15161. // level = "province",
  15162. // name = item1.Name_CN,
  15163. // childList = childList1
  15164. // });
  15165. // }
  15166. // //城市
  15167. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  15168. // foreach (var item2 in citiesData2)
  15169. // {
  15170. // List<dynamic> childList22 = new List<dynamic>();
  15171. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15172. // foreach (var item3 in countiesData1)
  15173. // {
  15174. // childList22.Add(new
  15175. // {
  15176. // id = item3.Id,
  15177. // parentId = item2.Id,
  15178. // level = "district",
  15179. // name = item3.Name_CN,
  15180. // });
  15181. // }
  15182. // childList.Add(new
  15183. // {
  15184. // id = item2.Id,
  15185. // parentId = parentId,
  15186. // level = "city",
  15187. // name = item2.Name_CN,
  15188. // childList = childList22
  15189. // });
  15190. // }
  15191. // }
  15192. // else
  15193. // {
  15194. // foreach (var item2 in citiesData)
  15195. // {
  15196. // string cname = item2.Name_CN;
  15197. // List<dynamic> childList1 = new List<dynamic>();
  15198. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15199. // foreach (var item3 in countiesData1)
  15200. // {
  15201. // childList1.Add(new
  15202. // {
  15203. // Id = item3.Id,
  15204. // parentId = item2.Id,
  15205. // level = "district",
  15206. // name = item3.Name_CN
  15207. // });
  15208. // }
  15209. // childList.Add(new
  15210. // {
  15211. // id = item2.Id,
  15212. // parentId = parentId,
  15213. // level = "city",
  15214. // name = item2.Name_CN,
  15215. // childList = childList1
  15216. // });
  15217. // }
  15218. // }
  15219. // stopwatch.Stop();
  15220. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  15221. //}
  15222. /// <summary>
  15223. /// 匹配op行程单
  15224. /// 接团信息列表 Page
  15225. /// </summary>
  15226. /// <param name="dto">团组列表请求dto</param>
  15227. /// <returns></returns>
  15228. [HttpPost]
  15229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15230. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  15231. {
  15232. var swatch = new Stopwatch();
  15233. swatch.Start();
  15234. #region 参数验证
  15235. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15236. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15237. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15238. #region 页面操作权限验证
  15239. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15240. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  15241. #endregion
  15242. #endregion
  15243. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15244. {
  15245. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  15246. string sqlWhere = "";
  15247. if (!string.IsNullOrEmpty(dto.Country))
  15248. {
  15249. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  15250. }
  15251. if (!string.IsNullOrEmpty(dto.Area))
  15252. {
  15253. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  15254. }
  15255. if (!string.IsNullOrEmpty(dto.TeamName))
  15256. {
  15257. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  15258. }
  15259. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  15260. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  15261. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  15262. swatch.Stop();
  15263. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  15264. }
  15265. else
  15266. {
  15267. return Ok(JsonView(false, "查询失败"));
  15268. }
  15269. }
  15270. /// <summary>
  15271. /// 匹配op行程单
  15272. /// 行程单下载
  15273. /// </summary>
  15274. /// <param name="dto">团组列表请求dto</param>
  15275. /// <returns></returns>
  15276. [HttpPost]
  15277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15278. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  15279. {
  15280. #region 参数验证
  15281. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15282. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15283. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15284. #region 页面操作权限验证
  15285. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15286. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  15287. #endregion
  15288. #endregion
  15289. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15290. {
  15291. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  15292. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  15293. }
  15294. else
  15295. {
  15296. return Ok(JsonView(false, "下载失败!"));
  15297. }
  15298. }
  15299. #endregion
  15300. #region 国家信息 数据 注释
  15301. //[HttpPost]
  15302. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  15303. //{
  15304. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  15305. // foreach (var item in dto)
  15306. // {
  15307. // infos.Add(new Grp_GroupsTaskAssignment()
  15308. // {
  15309. // DIId = item,
  15310. // CTId = 82,
  15311. // UId = 248,
  15312. // IsEnable = 1,
  15313. // CreateUserId = 233,
  15314. // CreateTime = DateTime.Now,
  15315. // IsDel = 0
  15316. // });
  15317. // infos.Add(new Grp_GroupsTaskAssignment()
  15318. // {
  15319. // DIId = item,
  15320. // CTId = 82,
  15321. // UId = 286,
  15322. // IsEnable = 1,
  15323. // CreateUserId = 233,
  15324. // CreateTime = DateTime.Now,
  15325. // IsDel = 0
  15326. // });
  15327. // }
  15328. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  15329. // return Ok("操作成功");
  15330. //}
  15331. //public class paramJsonDto
  15332. //{
  15333. // public List<CountriesInfo> str { get; set; }
  15334. //}
  15335. //[HttpPost]
  15336. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  15337. //{
  15338. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  15339. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  15340. // List<Sys_Cities> cities = new List<Sys_Cities>();
  15341. // List<Sys_Cities> districts = new List<Sys_Cities>();
  15342. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15343. // _sqlSugar.BeginTran();
  15344. // int countitiesIndex = 0;
  15345. // foreach (var item in dto.str)
  15346. // {
  15347. // dynamic data = item.c;
  15348. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  15349. // if (data != null)
  15350. // {
  15351. // countitiesIndex++;
  15352. // foreach (var item1 in data)
  15353. // {
  15354. // string cnname = item1.cn;
  15355. // string enname = item1.en;
  15356. // Sys_Cities provinceInfo = new Sys_Cities()
  15357. // {
  15358. // CountriesId = countriesId,
  15359. // Name_CN = cnname,
  15360. // Name_EN = enname,
  15361. // ParentId = 0,
  15362. // IsCapital = 1,
  15363. // CreateUserId = 208,
  15364. // CreateTime = DateTime.Now,
  15365. // IsDel = 0
  15366. // };
  15367. // if (item1.lv == "province") //省份
  15368. // {
  15369. // provinceInfo.Level = 1;
  15370. // int provinceId = 0;
  15371. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  15372. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  15373. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15374. // var data1 = item1.c;
  15375. // foreach (var item2 in data1)
  15376. // {
  15377. // if (item2.lv == "city")
  15378. // {
  15379. // string citycnname = item2.cn;
  15380. // string cityenname = item2.en;
  15381. // Sys_Cities cityInfo = new Sys_Cities()
  15382. // {
  15383. // CountriesId = countriesId,
  15384. // ParentId = provinceId,
  15385. // Level = 2,
  15386. // Name_CN = citycnname,
  15387. // Name_EN = cityenname,
  15388. // IsCapital = 1,
  15389. // CreateUserId = 208,
  15390. // CreateTime = DateTime.Now,
  15391. // IsDel = 0
  15392. // };
  15393. // if (item2.c != null)
  15394. // {
  15395. // int cityId = 0;
  15396. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  15397. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15398. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  15399. // foreach (var item3 in item2.c)
  15400. // {
  15401. // if (item3.lv == "district")
  15402. // {
  15403. // var districtInfo = new Sys_Cities()
  15404. // {
  15405. // CountriesId = countriesId,
  15406. // Name_CN = item3.cn,
  15407. // Name_EN = item3.en,
  15408. // Level = 3,
  15409. // ParentId = cityId,
  15410. // IsCapital = 1,
  15411. // CreateUserId = 208,
  15412. // CreateTime = DateTime.Now,
  15413. // IsDel = 0
  15414. // };
  15415. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15416. // //{
  15417. // districts.Add(districtInfo);
  15418. // //}
  15419. // }
  15420. // }
  15421. // }
  15422. // else
  15423. // {
  15424. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  15425. // //{
  15426. // cities.Add(cityInfo);
  15427. // //}
  15428. // }
  15429. // }
  15430. // }
  15431. // }
  15432. // else if (item1.lv == "city")//城市
  15433. // {
  15434. // provinceInfo.Level = 2;
  15435. // if (item1.c != null)
  15436. // {
  15437. // int cityId = 0;
  15438. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  15439. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15440. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15441. // foreach (var item3 in item1.c)
  15442. // {
  15443. // if (item3.lv == "district")
  15444. // {
  15445. // var districtInfo = new Sys_Cities()
  15446. // {
  15447. // CountriesId = countriesId,
  15448. // Name_CN = item3.cn,
  15449. // Name_EN = item3.en,
  15450. // Level = 3,
  15451. // ParentId = cityId,
  15452. // IsCapital = 1,
  15453. // CreateUserId = 208,
  15454. // CreateTime = DateTime.Now,
  15455. // IsDel = 0
  15456. // };
  15457. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15458. // //{
  15459. // districts.Add(districtInfo);
  15460. // //}
  15461. // }
  15462. // }
  15463. // }
  15464. // else
  15465. // {
  15466. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  15467. // //{
  15468. // cities.Add(provinceInfo);
  15469. // //}
  15470. // }
  15471. // }
  15472. // }
  15473. // }
  15474. // }
  15475. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  15476. // cities = cities.Distinct().ToList();
  15477. // districts = districts.Distinct().ToList();
  15478. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  15479. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  15480. // cities.AddRange(districts);
  15481. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  15482. // //_sqlSugar.RollbackTran();
  15483. // _sqlSugar.CommitTran();
  15484. // return Ok(JsonView(false, "操作成功!"));
  15485. //}
  15486. //[HttpPost]
  15487. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  15488. //{
  15489. // List<CountitiesInfo> infos = dto.MyProperty;
  15490. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  15491. // _sqlSugar.BeginTran();
  15492. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15493. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  15494. // foreach (var item in infos)
  15495. // {
  15496. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  15497. // if (countryInfo != null)
  15498. // {
  15499. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  15500. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  15501. // if (cityInfo1 != null)
  15502. // {
  15503. // cityInfo1.IsCapital = 0;
  15504. // cityInfos.Add(cityInfo1);
  15505. // }
  15506. // }
  15507. // }
  15508. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  15509. // .UpdateColumns(it => it.IsCapital)
  15510. // .WhereColumns(it => it.Id)
  15511. // .ExecuteCommand();
  15512. // //_sqlSugar.RollbackTran();
  15513. // _sqlSugar.CommitTran();
  15514. // return Ok(JsonView(false, "操作成功!"));
  15515. //}
  15516. //public class CounrtiesDto
  15517. //{
  15518. // public List<CountitiesInfo> MyProperty { get; set; }
  15519. //}
  15520. //public class CountitiesInfo
  15521. //{
  15522. // /// <summary>
  15523. // /// 圣约翰
  15524. // /// </summary>
  15525. // public string capital_name_chinese { get; set; }
  15526. // /// <summary>
  15527. // ///
  15528. // /// </summary>
  15529. // public string capital_name { get; set; }
  15530. // /// <summary>
  15531. // ///
  15532. // /// </summary>
  15533. // public string country_type { get; set; }
  15534. // /// <summary>
  15535. // /// 安提瓜和巴布达
  15536. // /// </summary>
  15537. // public string country_name_chinese { get; set; }
  15538. // /// <summary>
  15539. // /// 安提瓜和巴布达
  15540. // /// </summary>
  15541. // public string country_name_chinese_short { get; set; }
  15542. // /// <summary>
  15543. // /// 安提瓜和巴布达
  15544. // /// </summary>
  15545. // public string country_name_chinese_UN { get; set; }
  15546. // /// <summary>
  15547. // ///
  15548. // /// </summary>
  15549. // public string country_name_english_abbreviation { get; set; }
  15550. // /// <summary>
  15551. // ///
  15552. // /// </summary>
  15553. // public string country_name_english_formal { get; set; }
  15554. // /// <summary>
  15555. // ///
  15556. // /// </summary>
  15557. // public string country_name_english_UN { get; set; }
  15558. // /// <summary>
  15559. // ///
  15560. // /// </summary>
  15561. // public string continent_name { get; set; }
  15562. // /// <summary>
  15563. // ///
  15564. // /// </summary>
  15565. // public string subregion_name { get; set; }
  15566. // /// <summary>
  15567. // ///
  15568. // /// </summary>
  15569. // public string country_code2 { get; set; }
  15570. // /// <summary>
  15571. // ///
  15572. // /// </summary>
  15573. // public string country_code3 { get; set; }
  15574. // /// <summary>
  15575. // ///
  15576. // /// </summary>
  15577. // public string phone_code { get; set; }
  15578. //}
  15579. //public class CountriesInfo : BasicInfo
  15580. //{
  15581. // public List<CitiesInfo> c { get; set; }
  15582. //}
  15583. //public class CitiesInfo : BasicInfo
  15584. //{
  15585. // public List<AreaInfo> c { get; set; }
  15586. //}
  15587. //public class AreaInfo : BasicInfo
  15588. //{
  15589. // public List<AreaInfo> c { get; set; }
  15590. //}
  15591. //public class BasicInfo
  15592. //{
  15593. // public string code { get; set; }
  15594. // public string cn { get; set; }
  15595. // public string lv { get; set; }
  15596. // public string en { get; set; }
  15597. //}
  15598. #endregion
  15599. #region 查看邀请方
  15600. /// <summary>
  15601. /// 查看邀请方
  15602. /// 邀请方信息 Init
  15603. /// </summary>
  15604. /// <param name="dto"></param>
  15605. /// <returns></returns>
  15606. [HttpPost]
  15607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15608. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  15609. {
  15610. string sqlWhere = string.Empty;
  15611. if (!string.IsNullOrEmpty(dto.Search))
  15612. {
  15613. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  15614. }
  15615. string sql = string.Format($@"Select
  15616. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  15617. Id,
  15618. UnitName
  15619. From Res_InvitationOfficialActivityData
  15620. Where IsDel = 0
  15621. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  15622. RefAsync<int> total = 0;
  15623. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15624. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  15625. }
  15626. /// <summary>
  15627. /// 查看邀请方
  15628. /// 国家信息 Init
  15629. /// </summary>
  15630. /// <param name="dto"></param>
  15631. /// <returns></returns>
  15632. [HttpPost]
  15633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15634. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  15635. {
  15636. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  15637. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15638. var diids = groupInfos.Select(it => it.Id).ToList();
  15639. List<string> countrys = new List<string>();
  15640. foreach (var item in country)
  15641. {
  15642. var data = _groupRepository.FormartTeamName(item);
  15643. var dataArray = _groupRepository.GroupSplitCountry(data);
  15644. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15645. }
  15646. countrys = countrys.Distinct().ToList();
  15647. for (int i = 0; i < countrys.Count; i++)
  15648. {
  15649. string item = countrys[i];
  15650. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  15651. {
  15652. countrys.Remove(item);
  15653. i--;
  15654. }
  15655. }
  15656. RefAsync<int> total = 0;
  15657. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  15658. .Where(it => countrys.Contains(it.Name_CN))
  15659. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15660. .Select(it => new { id = it.Id, name = it.Name_CN })
  15661. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15662. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15663. }
  15664. /// <summary>
  15665. /// 查看邀请方
  15666. /// 城市信息 Init
  15667. /// </summary>
  15668. /// <param name="dto"></param>
  15669. /// <returns></returns>
  15670. [HttpPost]
  15671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15672. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  15673. {
  15674. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  15675. RefAsync<int> total = 0;
  15676. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  15677. .Where(it => it.CountriesId == dto.CountiesId)
  15678. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15679. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  15680. .Select(it => new { id = it.Id, name = it.Name_CN })
  15681. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15682. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15683. }
  15684. /// <summary>
  15685. /// 查看邀请方
  15686. /// 团组名称 Init
  15687. /// </summary>
  15688. /// <param name="dto"></param>
  15689. /// <returns></returns>
  15690. [HttpPost]
  15691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15692. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  15693. {
  15694. var watch = new Stopwatch();
  15695. watch.Start();
  15696. RefAsync<int> total = 0;
  15697. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  15698. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  15699. .Where((oa, di) => oa.IsDel == 0)
  15700. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  15701. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  15702. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  15703. .Distinct()
  15704. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15705. watch.Stop();
  15706. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  15707. }
  15708. /// <summary>
  15709. /// 查看邀请方
  15710. /// 团组 & 邀请方信息
  15711. /// </summary>
  15712. /// <param name="dto"></param>
  15713. /// <returns></returns>
  15714. [HttpPost]
  15715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15716. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  15717. {
  15718. var watch = new Stopwatch();
  15719. watch.Start();
  15720. RefAsync<int> total = 0;
  15721. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  15722. .AS("Grp_DelegationInfo")
  15723. .Includes(x => x.InvitingInfos)
  15724. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  15725. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  15726. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  15727. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  15728. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  15729. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  15730. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15731. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  15732. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  15733. infos.ForEach(x =>
  15734. {
  15735. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  15736. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  15737. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  15738. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  15739. });
  15740. watch.Stop();
  15741. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  15742. }
  15743. #endregion
  15744. #region 报批行程
  15745. /// <summary>
  15746. /// 报批行程初始化
  15747. /// </summary>
  15748. /// <param name="dto"></param>
  15749. /// <returns></returns>
  15750. [HttpPost]
  15751. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  15752. {
  15753. const int chiNumber = 5;
  15754. var jw = JsonView(false);
  15755. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  15756. var group = groupList.First();
  15757. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  15758. group = groupList.First(x => x.Id == diid);
  15759. if (group == null)
  15760. {
  15761. jw.Msg = "暂无团组!";
  15762. return Ok(jw);
  15763. }
  15764. var data = new
  15765. {
  15766. groupList = groupList.Select(x => new
  15767. {
  15768. x.TeamName,
  15769. x.Id
  15770. }),
  15771. content = new ArrayList(),
  15772. groupInfo = new
  15773. {
  15774. group.VisitDays,
  15775. group.TourCode,
  15776. group.VisitPNumber,
  15777. group.TeamName,
  15778. group.Id,
  15779. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  15780. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  15781. },
  15782. };
  15783. var resultArr = new ArrayList();
  15784. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  15785. if (content.Count == 0)
  15786. {
  15787. var stay = "-";
  15788. var cityPath = "-";
  15789. //添加城市路径以及住宿地
  15790. //黑屏代码数据
  15791. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  15792. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  15793. {
  15794. jw = JsonView(true, "黑屏代码有误!", data);
  15795. return Ok(jw);
  15796. }
  15797. foreach (DataRow row in dtBlack.Rows)
  15798. {
  15799. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  15800. {
  15801. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  15802. return Ok(jw);
  15803. }
  15804. }
  15805. //黑屏代码获取时间区间
  15806. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  15807. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  15808. _sqlSugar.BeginTran();
  15809. for (int i = 0; i < timeArr.Count; i++)
  15810. {
  15811. stay = "-";
  15812. cityPath = "-";
  15813. DateTime NewData = DateTime.Parse(timeArr[i]);
  15814. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  15815. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  15816. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  15817. if (tbSelect.Length > 0)
  15818. {
  15819. List<string> threeCodeStr = new List<string>();
  15820. foreach (var item in tbSelect)
  15821. {
  15822. var threeCode = item["Three"].ToString() ?? "";
  15823. if (threeCode.Length == 6)
  15824. {
  15825. var start = threeCode.Substring(0, 3);
  15826. var end = threeCode.Substring(3, 3);
  15827. if (threeCodeStr.Count == 0)
  15828. {
  15829. threeCodeStr.Add(start);
  15830. threeCodeStr.Add(end);
  15831. }
  15832. else
  15833. {
  15834. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  15835. {
  15836. threeCodeStr.Add(end);
  15837. }
  15838. else
  15839. {
  15840. threeCodeStr.Add(start);
  15841. threeCodeStr.Add(end);
  15842. }
  15843. }
  15844. }
  15845. }
  15846. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  15847. var last = threeCodeStr.Last();
  15848. foreach (var item in threeCodeStr)
  15849. {
  15850. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  15851. if (item.Equals(last))
  15852. {
  15853. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  15854. }
  15855. }
  15856. cityPath = cityPath.Trim('-');
  15857. }
  15858. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  15859. appro.Diid = diid ?? -1;
  15860. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  15861. appro.Id = thisId;
  15862. appro.CreateUserId = dto.UserId;
  15863. appro.CreateTime = DateTime.Now;
  15864. content.Add(appro);
  15865. }
  15866. _sqlSugar.CommitTran();
  15867. }
  15868. foreach (var x in content)
  15869. {
  15870. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  15871. if (chiList.Count < chiNumber)
  15872. {
  15873. for (int i = chiList.Count; i < chiNumber; i++)
  15874. {
  15875. chiList.Add(new Grp_ApprovalTravelDetails());
  15876. }
  15877. }
  15878. resultArr.Add(new
  15879. {
  15880. x.Id,
  15881. x.Date,
  15882. x.Diid,
  15883. chiList = chiList.Select(x1 => new
  15884. {
  15885. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  15886. x1.Details,
  15887. x1.ParentId,
  15888. x1.Id
  15889. })
  15890. });
  15891. }
  15892. data = data with
  15893. {
  15894. content = resultArr,
  15895. };
  15896. jw = JsonView(true, "获取成功!", data);
  15897. return Ok(jw);
  15898. }
  15899. /// <summary>
  15900. /// 报批行程删除
  15901. /// </summary>
  15902. /// <param name="dto"></param>
  15903. /// <returns></returns>
  15904. [HttpPost]
  15905. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  15906. {
  15907. var jw = JsonView(false);
  15908. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  15909. if (group == null)
  15910. {
  15911. jw.Msg = "团组参数有误!";
  15912. return Ok(jw);
  15913. }
  15914. try
  15915. {
  15916. _sqlSugar.BeginTran();
  15917. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  15918. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  15919. {
  15920. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  15921. DeleteUserId = dto.uesrId,
  15922. IsDel = 1
  15923. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  15924. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  15925. {
  15926. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  15927. DeleteUserId = dto.uesrId,
  15928. IsDel = 1
  15929. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  15930. _sqlSugar.CommitTran();
  15931. jw = JsonView(true, "删除成功");
  15932. }
  15933. catch (Exception ex)
  15934. {
  15935. jw = JsonView(false, ex.Message);
  15936. }
  15937. return Ok(jw);
  15938. }
  15939. /// <summary>
  15940. /// 报批行程保存
  15941. /// </summary>
  15942. /// <param name="dto"></param>
  15943. /// <returns></returns>
  15944. [HttpPost]
  15945. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  15946. {
  15947. var jw = JsonView(false);
  15948. var Find = dto.Arr.Find(x => x.id == 0);
  15949. if (Find != null)
  15950. {
  15951. jw.Msg = "生成的ID为0!";
  15952. return Ok(jw);
  15953. }
  15954. foreach (var item in dto.Arr)
  15955. {
  15956. foreach (var chi in item.chiList)
  15957. {
  15958. if (chi.parentId == 0)
  15959. {
  15960. chi.parentId = item.id;
  15961. }
  15962. }
  15963. }
  15964. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  15965. _sqlSugar.BeginTran();
  15966. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  15967. {
  15968. var parentIds = dto.Arr.Select(x => x.id).ToList();
  15969. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  15970. {
  15971. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  15972. DeleteUserId = dto.UserId,
  15973. IsDel = 1
  15974. }).ExecuteCommand();
  15975. }
  15976. try
  15977. {
  15978. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  15979. {
  15980. CreateTime = DateTime.Now,
  15981. CreateUserId = dto.UserId,
  15982. Details = x.details,
  15983. ParentId = x.parentId,
  15984. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  15985. Remark = "",
  15986. IsDel = 0
  15987. }).ToList()).ExecuteCommand();
  15988. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  15989. {
  15990. Id = x.id,
  15991. Details = x.details,
  15992. ParentId = x.parentId,
  15993. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  15994. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  15995. {
  15996. Details = x.Details,
  15997. ParentId = x.ParentId,
  15998. Time = x.Time
  15999. }).ExecuteCommand();
  16000. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  16001. {
  16002. Id = x.id,
  16003. Date = x.date,
  16004. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  16005. {
  16006. Date = x.Date
  16007. }).ExecuteCommand();
  16008. _sqlSugar.CommitTran();
  16009. jw = JsonView(true, "保存成功!");
  16010. }
  16011. catch (Exception ex)
  16012. {
  16013. _sqlSugar.RollbackTran();
  16014. jw = JsonView(false, "保存失败!" + ex.Message);
  16015. }
  16016. return Ok(jw);
  16017. }
  16018. /// <summary>
  16019. /// 报批行程生成
  16020. /// </summary>
  16021. /// <param name="dto"></param>
  16022. /// <returns></returns>
  16023. [HttpPost]
  16024. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  16025. {
  16026. var jw = JsonView(false);
  16027. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16028. if (group == null)
  16029. {
  16030. jw.Msg = "暂无该团组!";
  16031. return Ok(jw);
  16032. }
  16033. //黑屏代码数据
  16034. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  16035. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  16036. {
  16037. jw.Msg = "黑屏代码有误!";
  16038. return Ok(jw);
  16039. }
  16040. foreach (DataRow row in dtBlack.Rows)
  16041. {
  16042. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  16043. {
  16044. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  16045. return Ok(jw);
  16046. }
  16047. }
  16048. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  16049. var resultArr = new ArrayList();
  16050. if (officialActivitiesArr.Count == 0)
  16051. {
  16052. jw.Msg = "暂无公务出访信息!";
  16053. return Ok(jw);
  16054. }
  16055. try
  16056. {
  16057. _sqlSugar.BeginTran();
  16058. DeleteApprovalJourney(new
  16059. Domain.Dtos.Groups.DeleteApprovalJourney
  16060. {
  16061. Diid = dto.Diid,
  16062. uesrId = dto.Userid
  16063. });
  16064. var stay = "-";
  16065. var cityPath = "-";
  16066. //添加城市路径以及住宿地
  16067. //黑屏代码获取时间区间
  16068. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  16069. var empty = "【未收入该三字码!请机票同事录入】";
  16070. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  16071. for (int i = 0; i < timeArr.Count; i++)
  16072. {
  16073. stay = "-";
  16074. cityPath = "-";
  16075. var chiarr = new List<Grp_ApprovalTravelDetails>();
  16076. DateTime NewData = DateTime.Parse(timeArr[i]);
  16077. 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();
  16078. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  16079. if (tbSelect.Length > 0)
  16080. {
  16081. List<string> threeCodeStr = new List<string>();
  16082. bool isTrade = false;
  16083. string trip = string.Empty;
  16084. var rowLast = tbSelect.Last();
  16085. var rowFirst = tbSelect.First();
  16086. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  16087. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  16088. var takeOffTime = DateTime.Parse(timeArr[i]);
  16089. var fallToTime = DateTime.Parse(timeArr[i]);
  16090. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  16091. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  16092. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  16093. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  16094. foreach (var item in tbSelect)
  16095. {
  16096. var start = string.Empty;
  16097. var end = string.Empty;
  16098. var threeCode = item["Three"].ToString() ?? "";
  16099. if (threeCode.Length == 6)
  16100. {
  16101. start = threeCode.Substring(0, 3);
  16102. end = threeCode.Substring(3, 3);
  16103. if (threeCodeStr.Count == 0)
  16104. {
  16105. threeCodeStr.Add(start);
  16106. threeCodeStr.Add(end);
  16107. }
  16108. else
  16109. {
  16110. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  16111. {
  16112. threeCodeStr.Add(end);
  16113. }
  16114. else
  16115. {
  16116. threeCodeStr.Add(start);
  16117. threeCodeStr.Add(end);
  16118. }
  16119. }
  16120. }
  16121. //处理机票信息
  16122. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  16123. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  16124. if (start_Object == null)
  16125. {
  16126. start_Object = new Res_ThreeCode()
  16127. {
  16128. AirPort = empty,
  16129. AirPort_En = empty,
  16130. City = empty,
  16131. Country = empty,
  16132. Four = empty,
  16133. Three = empty,
  16134. };
  16135. }
  16136. if (end_Object == null)
  16137. {
  16138. end_Object = new Res_ThreeCode()
  16139. {
  16140. AirPort = empty,
  16141. AirPort_En = empty,
  16142. City = empty,
  16143. Country = empty,
  16144. Four = empty,
  16145. Three = empty,
  16146. };
  16147. }
  16148. //机型判断
  16149. string airModel = item["AirModel"].ToString();
  16150. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  16151. string flightTime = item["FlightTime"].ToString();
  16152. if (flightTime!.Contains(":"))
  16153. {
  16154. flightTime = flightTime.Replace(":", "小时");
  16155. flightTime += "分钟";
  16156. }
  16157. if (flightTime.Contains("H"))
  16158. {
  16159. flightTime = flightTime.Replace("H", "小时");
  16160. }
  16161. if (flightTime.Contains("M"))
  16162. {
  16163. flightTime = flightTime.Replace("M", "分钟");
  16164. }
  16165. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  16166. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  16167. {
  16168. flightTime = flightDataTime.Hour > 0
  16169. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  16170. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  16171. ? flightDataTime.Minute.ToString() + "分钟" : "";
  16172. }
  16173. //航班号
  16174. string flightcode = item["Fliagtcode"].ToString();
  16175. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  16176. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  16177. if (aircompany == null)
  16178. {
  16179. aircompany = new Res_AirCompany
  16180. {
  16181. CnName = hsEmpty,
  16182. EnName = hsEmpty,
  16183. ShortCode = hsEmpty,
  16184. };
  16185. }
  16186. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  16187. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  16188. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  16189. if (isTrade)
  16190. {
  16191. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  16192. }
  16193. else
  16194. {
  16195. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  16196. }
  16197. }
  16198. chiarr.Add(new Grp_ApprovalTravelDetails
  16199. {
  16200. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  16201. CreateTime = DateTime.Now,
  16202. CreateUserId = dto.Userid,
  16203. ParentId = 0,
  16204. Details = trip
  16205. });
  16206. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  16207. var last = threeCodeStr.Last();
  16208. foreach (var item in threeCodeStr)
  16209. {
  16210. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  16211. if (item.Equals(last))
  16212. {
  16213. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  16214. }
  16215. }
  16216. cityPath = cityPath.Trim('-');
  16217. }
  16218. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  16219. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  16220. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  16221. appro.Diid = dto.Diid;
  16222. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  16223. appro.Id = thisId;
  16224. appro.CreateUserId = dto.Userid;
  16225. appro.CreateTime = DateTime.Now;
  16226. foreach (var item in gwinfo)
  16227. {
  16228. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  16229. chi.Details = "拜访" + item.Client;
  16230. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  16231. {
  16232. chi.Details += "," + item.ReqSample;
  16233. }
  16234. chi.ParentId = thisId;
  16235. chi.Time = item.Time;
  16236. chiarr.Add(chi);
  16237. }
  16238. if (chiarr.Count < 5)
  16239. {
  16240. for (int j = chiarr.Count; j < 5; j++)
  16241. {
  16242. chiarr.Add(new
  16243. Grp_ApprovalTravelDetails());
  16244. }
  16245. }
  16246. resultArr.Add(new
  16247. {
  16248. appro.Id,
  16249. appro.Date,
  16250. appro.Diid,
  16251. chiList = chiarr.Select(x1 => new
  16252. {
  16253. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  16254. x1.Details,
  16255. x1.ParentId,
  16256. x1.Id
  16257. })
  16258. });
  16259. }
  16260. _sqlSugar.CommitTran();
  16261. jw = JsonView(true, "生成成功!", resultArr);
  16262. }
  16263. catch (Exception ex)
  16264. {
  16265. jw.Code = 400;
  16266. jw.Msg = "生成失败!" + ex.Message;
  16267. }
  16268. return Ok(jw);
  16269. }
  16270. /// <summary>
  16271. /// 报批行程word导出
  16272. /// </summary>
  16273. /// <param name="dto"></param>
  16274. /// <returns></returns>
  16275. [HttpPost]
  16276. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  16277. {
  16278. var jw = JsonView(false);
  16279. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16280. if (group == null)
  16281. {
  16282. jw.Msg = "暂无该团组!";
  16283. return Ok(jw);
  16284. }
  16285. //模板路径
  16286. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  16287. //载入模板
  16288. Document doc = new Document(tempPath);
  16289. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16290. //获取所填表格的序数
  16291. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16292. Aspose.Words.Tables.Row titleRowClone = null;
  16293. Aspose.Words.Tables.Row CenterRowClone = null;
  16294. int index = 0;
  16295. int indexChi = 0;
  16296. int SetIndex = 0;
  16297. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  16298. //获取数据,放到datatable
  16299. foreach (var item in ApprovalTravelArr)
  16300. {
  16301. if (index > 0)
  16302. {
  16303. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  16304. tableOne.AppendChild(titleRowClone);
  16305. }
  16306. var textTime = item.Date;
  16307. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  16308. SetCells(tableOne, doc, SetIndex, 0, textTime);
  16309. SetIndex++;
  16310. if (ChiRep.Count > 0)
  16311. {
  16312. foreach (var itemChi in ChiRep)
  16313. {
  16314. var txtTime = itemChi.Time;
  16315. var txtDetail = itemChi.Details;
  16316. if (indexChi > 0)
  16317. {
  16318. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16319. tableOne.AppendChild(CenterRowClone);
  16320. }
  16321. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  16322. {
  16323. SetCells(tableOne, doc, SetIndex, 0, "");
  16324. SetCells(tableOne, doc, SetIndex, 1, "");
  16325. indexChi++;
  16326. SetIndex++;
  16327. break;
  16328. }
  16329. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  16330. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  16331. indexChi++;
  16332. SetIndex++;
  16333. }
  16334. }
  16335. else
  16336. {
  16337. if (indexChi > 0)
  16338. {
  16339. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16340. tableOne.AppendChild(CenterRowClone);
  16341. }
  16342. SetCells(tableOne, doc, SetIndex, 0, "");
  16343. SetCells(tableOne, doc, SetIndex, 1, "");
  16344. indexChi++;
  16345. SetIndex++;
  16346. }
  16347. index++;
  16348. }
  16349. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  16350. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16351. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16352. jw.Code = 200;
  16353. jw.Msg = "";
  16354. return Ok(jw);
  16355. }
  16356. private string intToString(int numberVal)
  16357. {
  16358. string numberval = numberVal.ToString();
  16359. Dictionary<char, string> Number = new Dictionary<char, string>();
  16360. Number.Add('1', "一");
  16361. Number.Add('2', "二");
  16362. Number.Add('3', "三");
  16363. Number.Add('4', "四");
  16364. Number.Add('5', "五");
  16365. Number.Add('6', "六");
  16366. Number.Add('7', "七");
  16367. Number.Add('8', "八");
  16368. Number.Add('9', "九");
  16369. string stringNumberVal = string.Empty;
  16370. for (int i = 0; i < numberval.Length; i++)
  16371. {
  16372. if (i == 0)
  16373. {
  16374. stringNumberVal += Number[numberval[i]];
  16375. }
  16376. else if (i >= 1)
  16377. {
  16378. if (numberval[i] == '0')
  16379. {
  16380. stringNumberVal = "十";
  16381. }
  16382. else
  16383. {
  16384. stringNumberVal += "十" + Number[numberval[i]];
  16385. }
  16386. }
  16387. }
  16388. return stringNumberVal;
  16389. }
  16390. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  16391. {
  16392. //获取table中的某个单元格,从0开始
  16393. Cell lshCell = table.Rows[rows].Cells[cells];
  16394. //将单元格中段落移除
  16395. foreach (Node item in lshCell.Paragraphs)
  16396. {
  16397. lshCell.Paragraphs.Remove(item);
  16398. }
  16399. if (val.Contains("\r\n"))
  16400. {
  16401. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  16402. foreach (var item in spArr)
  16403. {
  16404. //新建一个段落
  16405. Paragraph p = new Paragraph(doc);
  16406. var r = new Run(doc, item);
  16407. //把设置的值赋给之前新建的段落
  16408. p.AppendChild(r);
  16409. //将此段落加到单元格内
  16410. lshCell.AppendChild(p);
  16411. }
  16412. }
  16413. else
  16414. {
  16415. //新建一个段落
  16416. Paragraph p = new Paragraph(doc);
  16417. var r = new Run(doc, val);
  16418. //把设置的值赋给之前新建的段落
  16419. p.AppendChild(r);
  16420. //将此段落加到单元格内
  16421. lshCell.AppendChild(p);
  16422. }
  16423. }
  16424. [HttpPost]
  16425. public async Task<IActionResult> ServerHttp(string paramStr)
  16426. {
  16427. paramStr = paramStr.TrimEnd('\'');
  16428. paramStr = paramStr.TrimStart('\'');
  16429. JsonView jw = JsonView(false);
  16430. JObject param = JObject.Parse(paramStr);
  16431. if (!param.ContainsKey("url"))
  16432. {
  16433. jw.Msg = "url null";
  16434. return Ok(jw);
  16435. }
  16436. string url = param["url"]!.ToString();
  16437. var methon = "get";
  16438. Dictionary<string, string> headValues = null;
  16439. string bodyStr = string.Empty;
  16440. if (param.ContainsKey("methon"))
  16441. {
  16442. methon = param["methon"]!.ToString().ToLower();
  16443. }
  16444. if (param.ContainsKey("header"))
  16445. {
  16446. var header = param["header"]!.ToString();
  16447. JObject headerJobject = JObject.Parse(header);
  16448. headValues = new Dictionary<string, string>();
  16449. foreach (JProperty item in headerJobject.Properties())
  16450. {
  16451. var value = item.Value.ToString();
  16452. var head = item.Path;
  16453. headValues.Add(head, value);
  16454. }
  16455. }
  16456. HttpClient client = new HttpClient();
  16457. string responseString = string.Empty;
  16458. StringContent content = null;
  16459. if (headValues != null)
  16460. {
  16461. foreach (var item in headValues.Keys)
  16462. {
  16463. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  16464. {
  16465. if (param.ContainsKey("body"))
  16466. {
  16467. bodyStr = param["body"]!.ToString();
  16468. }
  16469. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  16470. }
  16471. else
  16472. {
  16473. client.DefaultRequestHeaders.Add(item, headValues[item]);
  16474. }
  16475. }
  16476. }
  16477. try
  16478. {
  16479. if (methon == "get")
  16480. {
  16481. responseString = await client.GetStringAsync(url);
  16482. }
  16483. else if (methon == "post")
  16484. {
  16485. var request = new HttpRequestMessage(HttpMethod.Post, url)
  16486. {
  16487. Content = content
  16488. };
  16489. var response = await client.SendAsync(request);
  16490. try
  16491. {
  16492. Stream responseStream = await response.Content.ReadAsStreamAsync();
  16493. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  16494. {
  16495. using (StreamReader reader = new StreamReader(gzipStream))
  16496. {
  16497. responseString = await reader.ReadToEndAsync();
  16498. }
  16499. }
  16500. }
  16501. catch (Exception)
  16502. {
  16503. responseString = await response.Content.ReadAsStringAsync();
  16504. }
  16505. }
  16506. else
  16507. {
  16508. responseString = "methon error";
  16509. }
  16510. jw = JsonView(true, "success", responseString);
  16511. }
  16512. catch (Exception ex)
  16513. {
  16514. jw.Msg = "error " + ex.Message;
  16515. jw.Data = ex.StackTrace;
  16516. }
  16517. finally
  16518. {
  16519. client.Dispose();
  16520. }
  16521. return Ok(jw);
  16522. }
  16523. #endregion
  16524. #region 团组接待意见调查
  16525. /// <summary>
  16526. /// 团组接待意见调查 - 信息管理
  16527. /// 基础数据(团组)
  16528. /// </summary>
  16529. /// <param name="dto"></param>
  16530. /// <returns></returns>
  16531. [HttpGet]
  16532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16533. public async Task<IActionResult> OpinionaireInit()
  16534. {
  16535. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  16536. .Select(x => new
  16537. {
  16538. x.Id,
  16539. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  16540. })
  16541. .OrderByDescending(x => x.Id)
  16542. .ToListAsync();
  16543. return Ok(JsonView(groupData, groupData.Count));
  16544. }
  16545. /// <summary>
  16546. /// 团组接待意见调查 - 信息管理
  16547. /// 列表
  16548. /// </summary>
  16549. /// <param name="groupId"></param>
  16550. /// <returns></returns>
  16551. [HttpGet("{groupId}")]
  16552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16553. public async Task<IActionResult> OpinionaireManageList(int groupId)
  16554. {
  16555. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16556. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  16557. .Select(x => new
  16558. {
  16559. x.Id,
  16560. x.TourGuideName,
  16561. x.CityName,
  16562. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  16563. x.CreateTime
  16564. })
  16565. .OrderBy(x => x.Id)
  16566. .ToListAsync();
  16567. return Ok(JsonView(data));
  16568. }
  16569. /// <summary>
  16570. /// 团组接待意见调查 - 信息管理
  16571. /// 保存
  16572. /// </summary>
  16573. /// <param name="dto"></param>
  16574. /// <returns></returns>
  16575. [HttpPost]
  16576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16577. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  16578. {
  16579. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16580. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16581. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16582. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  16583. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  16584. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  16585. _opinionaireRep.BeginTran();
  16586. if (addData != null && addData.Count > 0)
  16587. {
  16588. foreach (var item in addData)
  16589. {
  16590. item.CreateUserId = currUserInfo.UserId;
  16591. item.DiId = dto.DiId;
  16592. }
  16593. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  16594. }
  16595. if (updData != null && updData.Count > 0)
  16596. {
  16597. var upd = await _opinionaireRep._sqlSugar
  16598. .Updateable(updData)
  16599. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  16600. .WhereColumns(x => new { x.Id })
  16601. .ExecuteCommandAsync();
  16602. }
  16603. _opinionaireRep.CommitTran();
  16604. return Ok(JsonView("操作成功!"));
  16605. }
  16606. /// <summary>
  16607. /// 团组接待意见调查 - 信息管理
  16608. /// 删除
  16609. /// </summary>
  16610. /// <param name="id"></param>
  16611. /// <returns></returns>
  16612. [HttpDelete("{id}")]
  16613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16614. public async Task<IActionResult> OpinionaireManageDel(int id)
  16615. {
  16616. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16617. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16618. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  16619. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  16620. if (!del) return Ok(JsonView("操作失败!"));
  16621. return Ok(JsonView("操作成功!"));
  16622. }
  16623. /// <summary>
  16624. /// 团组接待意见调查 - 用户
  16625. /// 列表
  16626. /// </summary>
  16627. /// <param name="id"></param>
  16628. /// <returns></returns>
  16629. [HttpGet("{diId}")]
  16630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16631. public async Task<IActionResult> OpinionaireUserList(int diId)
  16632. {
  16633. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16634. var sql = string.Format(@"
  16635. SELECT
  16636. o.Id,
  16637. o.DiId,
  16638. di.TeamName AS 'GroupName',
  16639. di.VisitPNumber AS 'PeopleNumber',
  16640. di.ClientName AS 'LeadGroup',
  16641. di.VisitCountry AS 'Travel',
  16642. di.VisitDays AS 'Days',
  16643. o.CityName,
  16644. o.TourGuideName,
  16645. o.Catering,
  16646. o.CateringReason,
  16647. o.Stay,
  16648. o.StayReason,
  16649. o.[Route],
  16650. o.RouteReason,
  16651. o.OfficialActivity,
  16652. o.OfficialActivityReason,
  16653. o.TourGuide,
  16654. o.TourGuideReason,
  16655. o.[Translate],
  16656. o.TranslateReason,
  16657. o.Trip,
  16658. o.TripReason,
  16659. o.ESFileName,
  16660. o.SignatureDate,
  16661. o.Remark
  16662. FROM
  16663. Grp_Opinionaire o
  16664. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  16665. WHERE
  16666. o.IsDel = 0
  16667. AND o.DiId = {0}
  16668. ORDER BY
  16669. o.Id ASC", diId);
  16670. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  16671. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  16672. return Ok(JsonView(data));
  16673. }
  16674. /// <summary>
  16675. /// 团组接待意见调查 - 用户
  16676. /// 保存
  16677. /// </summary>
  16678. /// <param name="id"></param>
  16679. /// <returns></returns>
  16680. [HttpPost]
  16681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16682. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  16683. {
  16684. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  16685. foreach (var item in dto)
  16686. {
  16687. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  16688. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  16689. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  16690. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  16691. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  16692. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  16693. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  16694. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  16695. }
  16696. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  16697. if (!Directory.Exists(filePathBase))
  16698. {
  16699. Directory.CreateDirectory(filePathBase);
  16700. }
  16701. #region 上传文件
  16702. var filePaths = new List<string>();
  16703. foreach (var item in dto)
  16704. {
  16705. var file = item.File;
  16706. // 将文件保存到指定位置
  16707. var filePath = Path.Combine(filePathBase, file.FileName);
  16708. using (var stream = new FileStream(filePath, FileMode.Create))
  16709. {
  16710. await file.CopyToAsync(stream);
  16711. }
  16712. //验证文件是否上传成功
  16713. if (!System.IO.File.Exists(filePath))
  16714. {
  16715. foreach (var filePathStr in filePaths)
  16716. {
  16717. System.IO.File.Delete(filePathStr);
  16718. }
  16719. return Ok(JsonView(false, "文件上传失败!"));
  16720. }
  16721. item.ESFileName = file.FileName;
  16722. }
  16723. #endregion
  16724. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  16725. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  16726. .UpdateColumns(x => new
  16727. {
  16728. x.Catering,
  16729. x.CateringReason,
  16730. x.Stay,
  16731. x.StayReason,
  16732. x.Route,
  16733. x.RouteReason,
  16734. x.OfficialActivity,
  16735. x.OfficialActivityReason,
  16736. x.TourGuide,
  16737. x.TourGuideReason,
  16738. x.Translate,
  16739. x.TranslateReason,
  16740. x.Trip,
  16741. x.TripReason,
  16742. x.ESFileName,
  16743. x.SignatureDate,
  16744. x.Remark
  16745. })
  16746. .WhereColumns(x => new { x.Id })
  16747. .ExecuteCommandAsync();
  16748. if (upd < 1)
  16749. {
  16750. foreach (var filePathStr in filePaths)
  16751. {
  16752. System.IO.File.Delete(filePathStr);
  16753. }
  16754. return Ok(JsonView(false));
  16755. }
  16756. return Ok(JsonView(true));
  16757. }
  16758. #endregion
  16759. // /// <summary>
  16760. // ///
  16761. // /// </summary>
  16762. // /// <param name="_dto"></param>
  16763. // /// <returns></returns>
  16764. // [HttpPost]
  16765. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16766. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  16767. // {
  16768. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  16769. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  16770. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  16771. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  16772. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  16773. // dic_psg.Add("客人", 974);
  16774. // dic_psg.Add("司机", 975);
  16775. // dic_psg.Add("导游", 976);
  16776. // dic_psg.Add("公司内部人员", 977);
  16777. // dic_psg.Add("司机/导游/公司内部人员", 978);
  16778. // foreach (var item in list_visa)
  16779. // {
  16780. // Grp_VisaInfo temp = new Grp_VisaInfo();
  16781. // temp.Id = item.Id;
  16782. // temp.DIId = item.DIId;
  16783. // temp.VisaClient = item.VisaClient;
  16784. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  16785. // temp.VisaCurrency = item.VisaCurrency;
  16786. // temp.IsThird = item.IsThird;
  16787. // if (dic_psg.ContainsKey(item.PassengerType))
  16788. // {
  16789. // temp.PassengerType = dic_psg[item.PassengerType];
  16790. // }
  16791. // else {
  16792. // temp.PassengerType = -1;
  16793. // }
  16794. // temp.VisaNumber = item.VisaNumber;
  16795. // temp.VisaFreeNumber = item.VisaFreeNumber;
  16796. // temp.CreateUserId = item.Operators;
  16797. // DateTime dt_ct;
  16798. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  16799. // if (b_ct)
  16800. // {
  16801. // temp.CreateTime = dt_ct;
  16802. // }
  16803. // else
  16804. // {
  16805. // temp.CreateTime = DateTime.Now;
  16806. // }
  16807. // temp.DeleteTime = "";
  16808. // temp.DeleteUserId = 0;
  16809. // temp.Remark = item.Remark;
  16810. // if (string.IsNullOrEmpty(temp.Remark)) {
  16811. // temp.Remark = "";
  16812. // }
  16813. // temp.IsDel = item.IsDel;
  16814. // temp.VisaDescription = item.VisaAttachment;
  16815. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  16816. //([Id]
  16817. // ,[DIId]
  16818. // ,[VisaClient]
  16819. // ,[VisaPrice]
  16820. // ,[VisaCurrency]
  16821. // ,[IsThird]
  16822. // ,[PassengerType]
  16823. // ,[VisaNumber]
  16824. // ,[VisaFreeNumber]
  16825. // ,[CreateUserId]
  16826. // ,[CreateTime]
  16827. // ,[DeleteTime]
  16828. // ,[DeleteUserId]
  16829. // ,[Remark]
  16830. // ,[IsDel]
  16831. // ,[visaDescription])
  16832. // VALUES
  16833. // ({0},{1},'{2}',{3},{4}
  16834. //,{5},{6},{7},{8},{9}
  16835. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  16836. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  16837. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  16838. //);
  16839. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  16840. // }
  16841. // return Ok(JsonView(true, "操作成功!"));
  16842. // }
  16843. /// <summary>
  16844. /// 123132123
  16845. /// </summary>
  16846. /// <param name="_dto"></param>
  16847. /// <returns></returns>
  16848. [HttpPost]
  16849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16850. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  16851. {
  16852. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  16853. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  16854. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  16855. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  16856. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  16857. dicDetail.Add(789, 1034);
  16858. dicDetail.Add(790, 1035);
  16859. dicDetail.Add(791, 1036);
  16860. dicDetail.Add(792, 1037);
  16861. dicDetail.Add(793, 1038);
  16862. dicDetail.Add(794, 1039);
  16863. dicDetail.Add(795, 1040);
  16864. dicDetail.Add(796, 1041);
  16865. dicDetail.Add(797, 1042);
  16866. dicDetail.Add(798, 1043);
  16867. dicDetail.Add(801, 1044);
  16868. dicDetail.Add(802, 1045);
  16869. dicDetail.Add(803, 1046);
  16870. Dictionary<int, int> dic = new Dictionary<int, int>();
  16871. dic.Add(806, 1027);
  16872. dic.Add(807, 1028);
  16873. dic.Add(808, 1029);
  16874. dic.Add(809, 1030);
  16875. dic.Add(810, 1031);
  16876. dic.Add(811, 1032);
  16877. dic.Add(812, 1033);
  16878. foreach (var item in list_visa)
  16879. {
  16880. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  16881. temp.Coefficient = item.coefficient;
  16882. DateTime dtCrt;
  16883. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  16884. if (b1)
  16885. {
  16886. temp.CreateTime = dtCrt;
  16887. }
  16888. else
  16889. {
  16890. temp.CreateTime = DateTime.Now;
  16891. }
  16892. temp.CreateUserId = item.Operators;
  16893. temp.DeleteTime = "";
  16894. temp.DeleteUserId = 0;
  16895. temp.DiId = int.Parse(item.DIID);
  16896. temp.FilePath = item.FilePath;
  16897. temp.IsDel = item.IsDel;
  16898. temp.Price = item.Price;
  16899. temp.PriceCount = 1;
  16900. temp.PriceCurrency = item.Currency;
  16901. int detailId = 0;
  16902. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  16903. {
  16904. detailId = dicDetail[item.PriceTypeDetail];
  16905. }
  16906. temp.PriceDetailType = detailId;
  16907. temp.PriceDt = DateTime.Now;
  16908. temp.PriceName = item.PriceName;
  16909. temp.PriceSum = item.Price;
  16910. int tid = 0;
  16911. if (dic.ContainsKey(item.PriceType))
  16912. {
  16913. tid = dic[item.PriceType];
  16914. }
  16915. temp.PriceType = tid;
  16916. temp.Remark = item.Remark;
  16917. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  16918. }
  16919. return Ok(JsonView(true, "操作成功!"));
  16920. }
  16921. [HttpPost]
  16922. public IActionResult TimeTest()
  16923. {
  16924. var jw = JsonView(false, "error");
  16925. _sqlSugar.BeginTran();
  16926. try
  16927. {
  16928. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  16929. .Select(x => new Crm_NewClientData
  16930. {
  16931. Id = x.Id,
  16932. Client = x.Client,
  16933. Contact = x.Contact,
  16934. Location = x.Location,
  16935. })
  16936. .ToList();
  16937. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  16938. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  16939. Stopwatch stopwatch = new Stopwatch();
  16940. // 开始计时
  16941. stopwatch.Start();
  16942. foreach (var item in clientList)
  16943. {
  16944. EncryptionProcessor.DecryptProperties(item);
  16945. }
  16946. stopwatch.Stop();
  16947. jw.Code = 200;
  16948. jw.Data = stopwatch.ElapsedMilliseconds;
  16949. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  16950. }
  16951. catch (Exception ex)
  16952. {
  16953. jw.Code = 400;
  16954. jw.Msg = ex.Message;
  16955. }
  16956. return Ok(jw);
  16957. }
  16958. }
  16959. }