GroupsController.cs 1.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using Microsoft.VisualBasic;
  8. using MySqlX.XDevAPI.Relational;
  9. using NPOI.HSSF.UserModel;
  10. using NPOI.SS.Formula.Functions;
  11. using NPOI.SS.UserModel;
  12. using NPOI.SS.Util;
  13. using NPOI.XSSF.UserModel;
  14. using OASystem.API.Middlewares;
  15. using OASystem.API.OAMethodLib;
  16. using OASystem.API.OAMethodLib.APNs;
  17. using OASystem.API.OAMethodLib.File;
  18. using OASystem.API.OAMethodLib.Hub.HubClients;
  19. using OASystem.API.OAMethodLib.Hub.Hubs;
  20. using OASystem.API.OAMethodLib.JuHeAPI;
  21. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  22. using OASystem.Domain.AesEncryption;
  23. using OASystem.Domain.Attributes;
  24. using OASystem.Domain.Dtos.CRM;
  25. using OASystem.Domain.Dtos.FileDto;
  26. using OASystem.Domain.Dtos.Financial;
  27. using OASystem.Domain.Dtos.Groups;
  28. using OASystem.Domain.Entities.Customer;
  29. using OASystem.Domain.Entities.Financial;
  30. using OASystem.Domain.Entities.Groups;
  31. using OASystem.Domain.ViewModels.Financial;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.QiYeWeChat;
  34. using OASystem.Infrastructure.Repositories.CRM;
  35. using OASystem.Infrastructure.Repositories.Financial;
  36. using OASystem.Infrastructure.Repositories.Groups;
  37. using OASystem.Infrastructure.Tools;
  38. using Org.BouncyCastle.Crypto;
  39. using Quartz.Util;
  40. using SqlSugar.Extensions;
  41. using System.Collections;
  42. using System.Data;
  43. using System.Diagnostics;
  44. using System.Globalization;
  45. using System.IO.Compression;
  46. using System.Text.Json;
  47. using TencentCloud.Ocr.V20181119.Models;
  48. using static OASystem.API.OAMethodLib.JWTHelper;
  49. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  50. using Bookmark = Aspose.Words.Bookmark;
  51. using Cell = Aspose.Words.Tables.Cell;
  52. using Table = Aspose.Words.Tables.Table;
  53. namespace OASystem.API.Controllers
  54. {
  55. /// <summary>
  56. /// 团组相关
  57. /// </summary>
  58. //[Authorize]
  59. [Route("api/[controller]/[action]")]
  60. public class GroupsController : ControllerBase
  61. {
  62. private readonly ILogger<GroupsController> _logger;
  63. private readonly GrpScheduleRepository _grpScheduleRep;
  64. private readonly IMapper _mapper;
  65. private readonly DelegationInfoRepository _groupRepository;
  66. private readonly TaskAssignmentRepository _taskAssignmentRep;
  67. private readonly AirTicketResRepository _airTicketResRep;
  68. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  69. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  70. private readonly DelegationEnDataRepository _delegationEnDataRep;
  71. private readonly DelegationVisaRepository _delegationVisaRep;
  72. private readonly VisaPriceRepository _visaPriceRep;
  73. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  74. private readonly HotelPriceRepository _hotelPriceRep;
  75. private readonly CustomersRepository _customersRep;
  76. private readonly MessageRepository _message;
  77. private readonly SqlSugarClient _sqlSugar;
  78. private readonly TourClientListRepository _tourClientListRep;
  79. private readonly TeamRateRepository _teamRateRep;
  80. #region 成本相关
  81. private readonly CheckBoxsRepository _checkBoxs;
  82. private readonly GroupCostRepository _GroupCostRepository;
  83. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  84. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  85. #endregion
  86. private readonly SetDataRepository _setDataRep;
  87. private string url;
  88. private string path;
  89. private readonly EnterExitCostRepository _enterExitCostRep;
  90. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  91. private readonly UsersRepository _usersRep;
  92. private readonly IJuHeApiService _juHeApi;
  93. private readonly InvertedListRepository _invertedListRep;
  94. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  95. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  96. private readonly ThreeCodeRepository _threeCodeRepository;
  97. private readonly HotelInquiryRepository _hotelInquiryRep;
  98. private readonly FeeAuditRepository _feeAuditRep;
  99. private readonly VisaCommissionRepository _visaCommissionRep;
  100. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  101. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  102. private readonly List<CurrencyInfo> _currencyInit;
  103. private readonly List<int> _portTypeData;
  104. private readonly TableOperationRecordRepository _tableorRep;
  105. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  106. private readonly RestaurantRepository _restaurantRep;
  107. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  108. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  109. /// <summary>
  110. /// 构造函数
  111. /// </summary>
  112. /// <param name="logger"></param>
  113. /// <param name="mapper"></param>
  114. /// <param name="hubContext"></param>
  115. /// <param name="sqlSugar"></param>
  116. /// <param name="grpScheduleRep"></param>
  117. /// <param name="groupRepository"></param>
  118. /// <param name="taskAssignmentRep"></param>
  119. /// <param name="airTicketResRep"></param>
  120. /// <param name="decreasePaymentsRep"></param>
  121. /// <param name="InvitationOfficialActivitiesRep"></param>
  122. /// <param name="delegationEnDataRep"></param>
  123. /// <param name="enterExitCostRep"></param>
  124. /// <param name="delegationVisaRep"></param>
  125. /// <param name="message"></param>
  126. /// <param name="visaPriceRep"></param>
  127. /// <param name="carTouristGuideGroundRep"></param>
  128. /// <param name="checkBoxs"></param>
  129. /// <param name="GroupCostRepository"></param>
  130. /// <param name="CostTypeHotelNumberRepository"></param>
  131. /// <param name="GroupCostParameterRepository"></param>
  132. /// <param name="hotelPriceRep"></param>
  133. /// <param name="customersRep"></param>
  134. /// <param name="setDataRep"></param>
  135. /// <param name="tourClientListRep"></param>
  136. /// <param name="teamRateRep"></param>
  137. /// <param name="usersRep"></param>
  138. /// <param name="juHeApi"></param>
  139. /// <param name="invertedListRep"></param>
  140. /// <param name="visaFeeInfoRep"></param>
  141. /// <param name="ticketBlackCodeRep"></param>
  142. /// <param name="hotelInquiryRep"></param>
  143. /// <param name="threeCodeRepository"></param>
  144. /// <param name="feeAuditRep"></param>
  145. /// <param name="visaCommissionRep"></param>
  146. /// <param name="ffrRep"></param>
  147. /// <param name="opinionaireRep"></param>
  148. /// <param name="tableorRep"></param>
  149. /// <param name="enterExitCostDraftRep"></param>
  150. /// <param name="restaurantRep"></param>
  151. /// <param name="enterExitCostQuoteRep"></param>
  152. public GroupsController(
  153. ILogger<GroupsController> logger,
  154. IMapper mapper,
  155. IHubContext<ChatHub, IChatClient> hubContext,
  156. SqlSugarClient sqlSugar,
  157. GrpScheduleRepository grpScheduleRep,
  158. DelegationInfoRepository groupRepository,
  159. TaskAssignmentRepository taskAssignmentRep,
  160. AirTicketResRepository airTicketResRep,
  161. DecreasePaymentsRepository decreasePaymentsRep,
  162. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  163. DelegationEnDataRepository delegationEnDataRep,
  164. EnterExitCostRepository enterExitCostRep,
  165. DelegationVisaRepository delegationVisaRep,
  166. MessageRepository message,
  167. VisaPriceRepository visaPriceRep,
  168. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  169. CheckBoxsRepository checkBoxs,
  170. GroupCostRepository GroupCostRepository,
  171. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  172. GroupCostParameterRepository GroupCostParameterRepository,
  173. HotelPriceRepository hotelPriceRep,
  174. CustomersRepository customersRep,
  175. SetDataRepository setDataRep,
  176. TourClientListRepository tourClientListRep,
  177. TeamRateRepository teamRateRep,
  178. UsersRepository usersRep, IJuHeApiService juHeApi,
  179. InvertedListRepository invertedListRep,
  180. VisaFeeInfoRepository visaFeeInfoRep,
  181. TicketBlackCodeRepository ticketBlackCodeRep,
  182. HotelInquiryRepository hotelInquiryRep,
  183. ThreeCodeRepository threeCodeRepository,
  184. FeeAuditRepository feeAuditRep,
  185. VisaCommissionRepository visaCommissionRep,
  186. ForeignReceivablesRepository ffrRep,
  187. OpinionaireRepository opinionaireRep,
  188. TableOperationRecordRepository tableorRep,
  189. EnterExitCostDraftRepository enterExitCostDraftRep,
  190. RestaurantRepository restaurantRep,
  191. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  192. GroupOrderPreInfoRepository grpOrderPreInfoRep
  193. )
  194. {
  195. _logger = logger;
  196. _mapper = mapper;
  197. _grpScheduleRep = grpScheduleRep;
  198. _groupRepository = groupRepository;
  199. _taskAssignmentRep = taskAssignmentRep;
  200. _airTicketResRep = airTicketResRep;
  201. _sqlSugar = sqlSugar;
  202. url = AppSettingsHelper.Get("ExcelBaseUrl");
  203. path = AppSettingsHelper.Get("ExcelBasePath");
  204. if (!System.IO.Directory.Exists(path))
  205. {
  206. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  207. }
  208. _decreasePaymentsRep = decreasePaymentsRep;
  209. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  210. _delegationEnDataRep = delegationEnDataRep;
  211. _enterExitCostRep = enterExitCostRep;
  212. _delegationVisaRep = delegationVisaRep;
  213. _message = message;
  214. _visaPriceRep = visaPriceRep;
  215. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  216. _checkBoxs = checkBoxs;
  217. _GroupCostRepository = GroupCostRepository;
  218. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  219. _GroupCostParameterRepository = GroupCostParameterRepository;
  220. _hotelPriceRep = hotelPriceRep;
  221. _customersRep = customersRep;
  222. _setDataRep = setDataRep;
  223. _tourClientListRep = tourClientListRep;
  224. _teamRateRep = teamRateRep;
  225. _hubContext = hubContext;
  226. _usersRep = usersRep;
  227. _juHeApi = juHeApi;
  228. _invertedListRep = invertedListRep;
  229. _visaFeeInfoRep = visaFeeInfoRep;
  230. _ticketBlackCodeRep = ticketBlackCodeRep;
  231. _hotelInquiryRep = hotelInquiryRep;
  232. _threeCodeRepository = threeCodeRepository;
  233. _feeAuditRep = feeAuditRep;
  234. _visaCommissionRep = visaCommissionRep;
  235. _ffrRep = ffrRep;
  236. _opinionaireRep = opinionaireRep;
  237. _currencyInit = new List<CurrencyInfo>()
  238. {
  239. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  240. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  241. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  242. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  243. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  244. };
  245. _portTypeData = new List<int>() { 2, 3 };
  246. _tableorRep = tableorRep;
  247. _enterExitCostDraftRep = enterExitCostDraftRep;
  248. _restaurantRep = restaurantRep;
  249. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  250. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  251. }
  252. #region 流程管控
  253. /// <summary>
  254. /// 获取团组流程管控信息
  255. /// </summary>
  256. /// <param name="_jsonDto"></param>
  257. /// <returns></returns>
  258. [HttpPost]
  259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  260. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  261. {
  262. if (string.IsNullOrEmpty(_jsonDto.Paras))
  263. {
  264. return Ok(JsonView(false, "参数为空"));
  265. }
  266. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  267. if (_ScheduleDto != null)
  268. {
  269. if (_ScheduleDto.SearchType == 2)//获取列表
  270. {
  271. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  272. return Ok(JsonView(_grpScheduleViewList));
  273. }
  274. else//获取对象
  275. {
  276. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  277. if (_grpScheduleView != null)
  278. {
  279. return Ok(JsonView(_grpScheduleView));
  280. }
  281. }
  282. }
  283. else
  284. {
  285. return Ok(JsonView(false, "参数反序列化失败"));
  286. }
  287. return Ok(JsonView(false, "暂无数据!"));
  288. }
  289. /// <summary>
  290. /// 修改团组流程管控详细表数据
  291. /// </summary>
  292. /// <param name="dto"></param>
  293. /// <returns></returns>
  294. [HttpPost]
  295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  296. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  297. {
  298. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  299. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  300. .SetColumns(it => it.Duty == _detail.Duty)
  301. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  302. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  303. .SetColumns(it => it.JobContent == _detail.JobContent)
  304. .SetColumns(it => it.Remark == _detail.Remark)
  305. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  306. .Where(s => s.Id == dto.Id)
  307. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  308. .ExecuteCommandAsync();
  309. if (result > 0)
  310. {
  311. return Ok(JsonView(true, "保存成功!"));
  312. }
  313. return Ok(JsonView(false, "保存失败!"));
  314. }
  315. /// <summary>
  316. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  317. /// </summary>
  318. /// <param name="dto"></param>
  319. /// <returns></returns>
  320. [HttpPost]
  321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  322. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  323. {
  324. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  325. _detail.IsDel = 1;
  326. _detail.DeleteUserId = dto.Duty;
  327. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  328. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  329. .SetColumns(it => it.IsDel == _detail.IsDel)
  330. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  331. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  332. .Where(it => it.Id == dto.Id)
  333. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  334. //.WhereColumns(s => s.Id == dto.Id)
  335. .ExecuteCommandAsync();
  336. if (result > 0)
  337. {
  338. return Ok(JsonView(true, "删除成功!"));
  339. }
  340. return Ok(JsonView(false, "删除失败!"));
  341. }
  342. /// <summary>
  343. /// 增加团组流程管控详细表数据
  344. /// </summary>
  345. /// <param name="dto"></param>
  346. /// <returns></returns>
  347. [HttpPost]
  348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  349. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  350. {
  351. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  352. if (DateTime.Now < _detail.ExpectBeginDt)
  353. {
  354. _detail.StepStatus = 0;
  355. }
  356. else
  357. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  358. _detail.StepStatus = 1;
  359. }
  360. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  361. if (result > 0)
  362. {
  363. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  364. return Ok(JsonView(true, "添加成功!", _result));
  365. }
  366. return Ok(JsonView(false, "添加失败!"));
  367. }
  368. #endregion
  369. #region 团组前期信息
  370. /// <summary>
  371. /// 团组前期信息 Init
  372. /// </summary>
  373. /// <returns></returns>
  374. [HttpGet]
  375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  376. public async Task<IActionResult> GroupOrderPreInfo()
  377. {
  378. return Ok(await _grpOrderPreInfoRep.DataInit());
  379. }
  380. /// <summary>
  381. /// 国家数据源
  382. /// </summary>
  383. /// <returns></returns>
  384. [HttpGet]
  385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  386. public async Task<IActionResult> CountryInit()
  387. {
  388. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  389. return Ok(JsonView(countrys));
  390. }
  391. /// <summary>
  392. /// 城市数据源
  393. /// </summary>
  394. /// <returns></returns>
  395. [HttpGet("{countryLabel}")]
  396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  397. public async Task<IActionResult> CityByCountry(string countryLabel)
  398. {
  399. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  400. var citys = Array.Empty<string?>();
  401. if (countryList.Any())
  402. {
  403. citys = await _sqlSugar
  404. .Queryable<Grp_NationalTravelFee>()
  405. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City) && !x.City.Contains("城市"))
  406. .Select(x => x.City)
  407. .ToArrayAsync();
  408. }
  409. return Ok(JsonView(citys));
  410. }
  411. /// <summary>
  412. /// 团组前期信息 Info
  413. /// </summary>
  414. /// <param name="id">Id</param>
  415. /// <param name="tempId">Id</param>
  416. /// <returns></returns>
  417. [HttpGet("{id}/{tempId}")]
  418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  419. public async Task<IActionResult> GroupOrderPreInfo(int id,int tempId = 1404)
  420. {
  421. return Ok(await _grpOrderPreInfoRep.InfoAsync(id, tempId));
  422. }
  423. /// <summary>
  424. /// 团组前期信息 Save
  425. /// </summary>
  426. /// <param name="dto">Id</param>
  427. /// <returns></returns>
  428. [HttpPost]
  429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  430. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  431. {
  432. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  433. }
  434. #endregion
  435. #region 团组基本信息
  436. /// <summary>
  437. /// 接团信息列表
  438. /// </summary>
  439. /// <param name="dto">团组列表请求dto</param>
  440. /// <returns></returns>
  441. [HttpPost]
  442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  443. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  444. {
  445. var groupData = await _groupRepository.GetGroupList(dto);
  446. if (groupData.Code != 0)
  447. {
  448. return Ok(JsonView(false, groupData.Msg));
  449. }
  450. return Ok(JsonView(groupData.Data));
  451. }
  452. /// <summary>
  453. /// 分页查询团组列表
  454. /// </summary>
  455. /// <param name="dto"></param>
  456. /// <returns></returns>
  457. [HttpPost]
  458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  459. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  460. {
  461. var watch = new Stopwatch();
  462. watch.Start();
  463. RefAsync<int> total = 0;
  464. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  465. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  466. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  467. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  468. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  469. .Distinct()
  470. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  471. watch.Stop();
  472. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  473. }
  474. /// <summary>
  475. /// 接团信息列表 Page Init
  476. /// </summary>
  477. /// <returns></returns>
  478. [HttpPost]
  479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  480. public async Task<IActionResult> PostGroupPageListInit()
  481. {
  482. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  483. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  484. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  485. var _view = new
  486. {
  487. depData = depDatas,
  488. rankData = rankDatas
  489. };
  490. return Ok(JsonView(true, "查询成功!", _view));
  491. }
  492. /// <summary>
  493. /// 接团信息列表 Page
  494. /// </summary>
  495. /// <param name="dto">团组列表请求dto</param>
  496. /// <returns></returns>
  497. [HttpPost]
  498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  499. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  500. {
  501. #region 参数验证
  502. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  503. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  504. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  505. #region 页面操作权限验证
  506. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  507. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  508. #endregion
  509. #endregion
  510. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  511. {
  512. string sqlWhere = string.Empty;
  513. if (dto.IsSure == 0) //未完成
  514. {
  515. sqlWhere += string.Format(@" And IsSure = 0");
  516. }
  517. else if (dto.IsSure == 1) //已完成
  518. {
  519. sqlWhere += string.Format(@" And IsSure = 1");
  520. }
  521. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  522. {
  523. string tj = dto.SearchCriteria;
  524. 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}%')",
  525. tj, tj, tj, tj, tj);
  526. }
  527. if (int.TryParse(dto.Rank, out int rankId))
  528. {
  529. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  530. }
  531. string sqlWhere1 = string.Empty;
  532. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  533. {
  534. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  535. }
  536. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  537. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  538. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  539. JietuanOperator,IsSure,CreateTime,IsBid
  540. From (
  541. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  542. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  543. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  544. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  545. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  546. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  547. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  548. From Grp_DelegationInfo gdi
  549. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  550. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  551. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  552. Where gdi.IsDel = 0 {0}
  553. ) temp {1}", sqlWhere, sqlWhere1);
  554. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  555. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  556. var _view = new
  557. {
  558. PageFuncAuth = pageFunAuthView,
  559. Data = _DelegationList
  560. };
  561. return Ok(JsonView(true, "查询成功!", _view, total));
  562. }
  563. else
  564. {
  565. return Ok(JsonView(false, "查询失败"));
  566. }
  567. }
  568. /// <summary>
  569. /// 团组列表
  570. /// </summary>
  571. /// <returns></returns>
  572. [HttpPost]
  573. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  574. {
  575. #region 参数验证
  576. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  577. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  578. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  579. #region 页面操作权限验证
  580. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  581. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  582. #endregion
  583. #endregion
  584. if (dto.PortType != 1 && dto.PortType != 2)
  585. {
  586. return Ok(JsonView(false, "查询失败!"));
  587. }
  588. string orderbyStr = "order by gdi.CreateTime Desc";
  589. string sqlWhere = string.Empty;
  590. if (dto.IsSure == 0) //未完成
  591. {
  592. sqlWhere += string.Format(@" And IsSure = 0");
  593. }
  594. else if (dto.IsSure == 1) //已完成
  595. {
  596. sqlWhere += string.Format(@" And IsSure = 1");
  597. }
  598. //团组类型
  599. if (dto.TeamDid > 0)
  600. {
  601. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  602. }
  603. //团组名称
  604. if (!string.IsNullOrEmpty(dto.TeamName))
  605. {
  606. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  607. }
  608. //客户名称
  609. if (!string.IsNullOrEmpty(dto.ClientName))
  610. {
  611. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  612. }
  613. //客户单位
  614. if (!string.IsNullOrEmpty(dto.ClientUnit))
  615. {
  616. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  617. }
  618. //出访时间
  619. if (!string.IsNullOrEmpty(dto.visitDataTime))
  620. {
  621. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  622. orderbyStr = "order by gdi.VisitDate";
  623. }
  624. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  625. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  626. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  627. JietuanOperator,IsSure,CreateTime
  628. From (
  629. Select row_number() over({0}) as Row_Number,
  630. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  631. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  632. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  633. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  634. From Grp_DelegationInfo gdi
  635. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  636. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  637. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  638. Where gdi.IsDel = 0 {1}
  639. ) temp ", orderbyStr, sqlWhere);
  640. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  641. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  642. #region 处理所属部门
  643. /*
  644. * 1.sq 和 gyy 等显示 市场部
  645. * 2.王鸽和主管及张总还有管理员号统一国交部
  646. * 2-1. 4 管理员 ,21 张海麟
  647. */
  648. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  649. List<int> userIds1 = new List<int>() { 4, 21 };
  650. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  651. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  652. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  653. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  654. .ToList();
  655. foreach (var item in _DelegationList)
  656. {
  657. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  658. }
  659. #endregion
  660. var _view = new
  661. {
  662. PageFuncAuth = pageFunAuthView,
  663. Data = _DelegationList
  664. };
  665. return Ok(JsonView(true, "查询成功!", _view, total));
  666. }
  667. /// <summary>
  668. /// 接团信息详情
  669. /// </summary>
  670. /// <param name="dto">团组info请求dto</param>
  671. /// <returns></returns>
  672. [HttpPost]
  673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  674. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  675. {
  676. var groupData = await _groupRepository.GetGroupInfo(dto);
  677. if (groupData.Code != 0)
  678. {
  679. return Ok(JsonView(false, groupData.Msg));
  680. }
  681. return Ok(JsonView(groupData.Data));
  682. }
  683. /// <summary>
  684. /// 接团信息 编辑添加
  685. /// 基础信息数据源
  686. /// </summary>
  687. /// <param name="dto"></param>
  688. /// <returns></returns>
  689. [HttpPost]
  690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  691. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  692. {
  693. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  694. if (groupData.Code != 0)
  695. {
  696. return Ok(JsonView(false, groupData.Msg));
  697. }
  698. return Ok(JsonView(groupData.Data));
  699. }
  700. /// <summary>
  701. /// 接团信息 操作(增改)
  702. /// </summary>
  703. /// <param name="dto"></param>
  704. /// <returns></returns>
  705. [HttpPost]
  706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  707. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  708. {
  709. // 创建 Stopwatch 实例
  710. Stopwatch stopwatch = Stopwatch.StartNew();
  711. decimal ffrPrice = 0.00M;
  712. DateTime? visitDt = null;
  713. if (dto.Status == 2)
  714. {
  715. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  716. if (groupInfo != null)
  717. {
  718. ffrPrice = groupInfo.PaymentMoney;
  719. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  720. }
  721. }
  722. var groupData = await _groupRepository.GroupOperation(dto);
  723. if (groupData.Code != 0)
  724. {
  725. return Ok(JsonView(false, groupData.Msg));
  726. }
  727. int diId = 0;
  728. try
  729. {
  730. //添加时 默认加入团组汇率
  731. if (dto.Status == 1) //添加
  732. {
  733. diId = groupData.Data;
  734. //添加默认币种
  735. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  736. //默认分配权限
  737. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  738. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  739. var _managerIds = new List<int>() { 22, 32, 21 };
  740. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  741. if (userIds.Count > 0)
  742. {
  743. userIds.Add(208);
  744. //创建团组管控
  745. GroupStepForDelegation.CreateWorkStep(diId);
  746. //发送消息
  747. string groupName = dto.TeamName;
  748. string createGroupUser = string.Empty;
  749. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  750. if (userInfo != null) createGroupUser = userInfo.CnName;
  751. string title = $"系统通知";
  752. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  753. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  754. }
  755. //默认创建倒推表
  756. await _invertedListRep._Create(dto.UserId, diId);
  757. }
  758. else if (dto.Status == 2)
  759. {
  760. diId = dto.Id;
  761. }
  762. #region 签证人员团组时间通知
  763. #region 计算出访起止时间
  764. var startTime = new DateTime();
  765. var endTime = new DateTime();
  766. if (DateTime.TryParse(dto.VisitDate, out startTime))
  767. {
  768. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  769. }
  770. #endregion
  771. #endregion
  772. #region 团组操作默认添加/修改收款账单
  773. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  774. {
  775. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  776. .Where(x => x.IsDel == 0 &&
  777. x.Diid == diId &&
  778. x.Remark.Equals("预付款")
  779. )
  780. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  781. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  782. .FirstAsync();
  783. ffrInfo = new Fin_ForeignReceivables()
  784. {
  785. Diid = diId,
  786. PriceName = dto.ClientUnit,
  787. Price = dto.PaymentMoney,
  788. Count = 1,
  789. Unit = $"元",
  790. ItemSumPrice = dto.PaymentMoney,
  791. Rate = 1.0000M,
  792. Currency = 836,
  793. AddingWay = 0,
  794. CreateUserId = dto.UserId,
  795. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  796. Remark = $"预付款"
  797. };
  798. if (ffrInfo == null) //Add
  799. {
  800. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  801. }
  802. else //修改
  803. {
  804. await _sqlSugar.Updateable(ffrInfo)
  805. .UpdateColumns(x => new
  806. {
  807. x.PriceName,
  808. x.Price,
  809. x.ItemSumPrice,
  810. x.CreateTime,
  811. x.CreateUserId
  812. })
  813. .WhereColumns(x => x.Id)
  814. .ExecuteCommandAsync();
  815. }
  816. }
  817. #endregion
  818. if (diId > 0)
  819. {
  820. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  821. }
  822. // 停止计时
  823. stopwatch.Stop();
  824. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  825. }
  826. catch (Exception ex)
  827. {
  828. // 停止计时
  829. stopwatch.Stop();
  830. Logs("[response]" + JsonConvert.SerializeObject(dto));
  831. Logs(ex.Message);
  832. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  833. }
  834. // 停止计时
  835. stopwatch.Stop();
  836. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  837. }
  838. /// <summary>
  839. /// 接团流程操作(增改)
  840. /// 安卓端使用 建团时添加客户名单
  841. /// </summary>
  842. /// <param name="dto"></param>
  843. /// <returns></returns>
  844. [HttpPost]
  845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  846. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  847. {
  848. #region 参数验证
  849. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  850. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  851. #region 页面操作权限验证
  852. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  853. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  854. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  855. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  856. #endregion
  857. #endregion
  858. try
  859. {
  860. //_sqlSugar.BeginTran();
  861. decimal ffrPrice = 0.00M;
  862. DateTime? visitDt = null;
  863. if (dto.Status == 2)
  864. {
  865. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  866. if (groupInfo != null)
  867. {
  868. ffrPrice = groupInfo.PaymentMoney;
  869. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  870. }
  871. }
  872. var _dto = new GroupOperationDto();
  873. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  874. var groupData = await _groupRepository.GroupOperation(_dto);
  875. if (groupData.Code != 0)
  876. {
  877. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  878. }
  879. int diId = 0;
  880. //添加时 默认加入团组汇率
  881. if (dto.Status == 1) //添加
  882. {
  883. diId = groupData.Data;
  884. //添加默认币种
  885. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  886. //默认分配权限
  887. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  888. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  889. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  890. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  891. if (userIds.Count > 0)
  892. {
  893. userIds.Add(208);
  894. //创建团组管控
  895. GroupStepForDelegation.CreateWorkStep(diId);
  896. //发送消息
  897. string groupName = dto.TeamName;
  898. string createGroupUser = string.Empty;
  899. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  900. if (userInfo != null) createGroupUser = userInfo.CnName;
  901. string title = $"系统通知";
  902. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  903. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  904. }
  905. #region 应用推送
  906. try
  907. {
  908. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  909. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  910. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  911. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  912. {
  913. List<string> userList = new List<string>() { users.QiyeChatUserId };
  914. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  915. }
  916. }
  917. catch (Exception ex)
  918. {
  919. }
  920. #endregion
  921. //默认创建倒推表
  922. await _invertedListRep._Create(dto.UserId, diId);
  923. }
  924. if (dto.Status == 2)
  925. {
  926. diId = dto.Id;
  927. if (diId == 0)
  928. {
  929. //_sqlSugar.RollbackTran();
  930. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  931. }
  932. }
  933. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  934. if (viewData.Code != 0)
  935. {
  936. //_sqlSugar.RollbackTran();
  937. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  938. }
  939. #region 团组操作默认添加/修改收款账单
  940. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  941. {
  942. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  943. .Where(x => x.IsDel == 0 &&
  944. x.Diid == diId &&
  945. x.Remark.Equals("预付款")
  946. )
  947. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  948. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  949. .FirstAsync();
  950. ffrInfo = new Fin_ForeignReceivables()
  951. {
  952. Diid = diId,
  953. PriceName = dto.ClientUnit,
  954. Price = dto.PaymentMoney,
  955. Count = 1,
  956. Unit = $"元",
  957. ItemSumPrice = dto.PaymentMoney,
  958. Rate = 1.0000M,
  959. Currency = 836,
  960. AddingWay = 0,
  961. CreateUserId = dto.UserId,
  962. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  963. Remark = $"预付款"
  964. };
  965. if (ffrInfo == null) //Add
  966. {
  967. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  968. }
  969. else //修改
  970. {
  971. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  972. .UpdateColumns(x => new
  973. {
  974. x.PriceName,
  975. x.Price,
  976. x.ItemSumPrice,
  977. x.CreateTime,
  978. x.CreateUserId
  979. })
  980. .WhereColumns(x => x.Id)
  981. .ExecuteCommandAsync();
  982. }
  983. }
  984. #endregion
  985. #region 签证人员团组时间通知
  986. #region 计算出访起止时间
  987. var startTime = new DateTime();
  988. var endTime = new DateTime();
  989. if (DateTime.TryParse(dto.VisitDate, out startTime))
  990. {
  991. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  992. }
  993. #endregion
  994. if (diId > 0)
  995. {
  996. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  997. }
  998. #endregion
  999. //_sqlSugar.CommitTran();
  1000. return Ok(JsonView(true, "添加成功"));
  1001. }
  1002. catch (Exception ex)
  1003. {
  1004. _sqlSugar.RollbackTran();
  1005. return Ok(JsonView(false, ex.Message));
  1006. }
  1007. }
  1008. /// <summary>
  1009. /// 接团流程操作(增改)
  1010. /// 安卓端使用 建团时添加客户名单
  1011. /// </summary>
  1012. /// <param name="dto"></param>
  1013. /// <returns></returns>
  1014. [HttpPost]
  1015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1016. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1017. {
  1018. #region 参数验证
  1019. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1020. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1021. #region 页面操作权限验证
  1022. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1023. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1024. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1025. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1026. #endregion
  1027. #endregion
  1028. _sqlSugar.BeginTran();
  1029. decimal ffrPrice = 0.00M;
  1030. DateTime? visitDt = null;
  1031. if (dto.Status == 2)
  1032. {
  1033. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1034. if (groupInfo != null)
  1035. {
  1036. ffrPrice = groupInfo.PaymentMoney;
  1037. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1038. }
  1039. }
  1040. var _dto = new GroupOperationDto();
  1041. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1042. var groupData = await _groupRepository.GroupOperation(_dto);
  1043. if (groupData.Code != 0)
  1044. {
  1045. _sqlSugar.RollbackTran();
  1046. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1047. }
  1048. try
  1049. {
  1050. int diId = 0;
  1051. //添加时 默认加入团组汇率
  1052. if (dto.Status == 1) //添加
  1053. {
  1054. diId = groupData.Data;
  1055. //添加默认币种
  1056. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1057. //默认分配权限
  1058. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1059. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1060. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1061. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1062. if (userIds.Count > 0)
  1063. {
  1064. userIds.Add(208);
  1065. //创建团组管控
  1066. GroupStepForDelegation.CreateWorkStep(diId);
  1067. //发送消息
  1068. string groupName = dto.TeamName;
  1069. string createGroupUser = string.Empty;
  1070. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1071. if (userInfo != null) createGroupUser = userInfo.CnName;
  1072. string title = $"系统通知";
  1073. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1074. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1075. }
  1076. #region 应用推送
  1077. try
  1078. {
  1079. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1080. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1081. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1082. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1083. {
  1084. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1085. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1086. }
  1087. }
  1088. catch (Exception ex)
  1089. {
  1090. _sqlSugar.CommitTran();
  1091. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1092. }
  1093. #endregion
  1094. //默认创建倒推表
  1095. await _invertedListRep._Create(dto.UserId, diId);
  1096. }
  1097. else if (dto.Status == 2)
  1098. {
  1099. diId = dto.Id;
  1100. if (diId == 0)
  1101. {
  1102. _sqlSugar.RollbackTran();
  1103. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1104. }
  1105. }
  1106. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1107. if (viewData.Code != 0)
  1108. {
  1109. _sqlSugar.RollbackTran();
  1110. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1111. }
  1112. #region 团组操作默认添加/修改收款账单
  1113. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1114. {
  1115. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1116. .Where(x => x.IsDel == 0 &&
  1117. x.Diid == diId &&
  1118. x.Remark.Equals("预付款")
  1119. )
  1120. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1121. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1122. .FirstAsync();
  1123. ffrInfo = new Fin_ForeignReceivables()
  1124. {
  1125. Diid = diId,
  1126. PriceName = dto.ClientUnit,
  1127. Price = dto.PaymentMoney,
  1128. Count = 1,
  1129. Unit = $"元",
  1130. ItemSumPrice = dto.PaymentMoney,
  1131. Rate = 1.0000M,
  1132. Currency = 836,
  1133. AddingWay = 0,
  1134. CreateUserId = dto.UserId,
  1135. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1136. Remark = $"预付款"
  1137. };
  1138. if (ffrInfo == null) //Add
  1139. {
  1140. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1141. }
  1142. else //修改
  1143. {
  1144. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1145. .UpdateColumns(x => new
  1146. {
  1147. x.PriceName,
  1148. x.Price,
  1149. x.ItemSumPrice,
  1150. x.CreateTime,
  1151. x.CreateUserId
  1152. })
  1153. .WhereColumns(x => x.Id)
  1154. .ExecuteCommandAsync();
  1155. }
  1156. }
  1157. #endregion
  1158. #region 签证人员团组时间通知
  1159. #region 计算出访起止时间
  1160. var startTime = new DateTime();
  1161. var endTime = new DateTime();
  1162. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1163. {
  1164. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1165. }
  1166. #endregion
  1167. if (diId > 0)
  1168. {
  1169. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1170. }
  1171. #endregion
  1172. _sqlSugar.CommitTran();
  1173. return Ok(JsonView(true));
  1174. }
  1175. catch (Exception ex)
  1176. {
  1177. _sqlSugar.RollbackTran();
  1178. return Ok(JsonView(false, ex.Message));
  1179. }
  1180. }
  1181. /// <summary>
  1182. /// 接团信息 操作(删除)
  1183. /// </summary>
  1184. /// <param name="dto"></param>
  1185. /// <returns></returns>
  1186. [HttpPost]
  1187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1188. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1189. {
  1190. var diId = dto.Id;
  1191. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1192. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1193. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1194. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1195. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1196. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1197. #endregion
  1198. var groupData = await _groupRepository.GroupDel(dto);
  1199. if (groupData.Code != 0)
  1200. {
  1201. return Ok(JsonView(false, groupData.Msg));
  1202. }
  1203. return Ok(JsonView(true));
  1204. }
  1205. /// <summary>
  1206. /// 获取团组销售报价号
  1207. /// 团组添加时 使用
  1208. /// </summary>
  1209. /// <returns></returns>
  1210. [HttpPost]
  1211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1212. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1213. {
  1214. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1215. if (groupData.Code != 0)
  1216. {
  1217. return Ok(JsonView(false, groupData.Msg));
  1218. }
  1219. object salesQuoteNo = new
  1220. {
  1221. SalesQuoteNo = groupData.Data
  1222. };
  1223. return Ok(JsonView(salesQuoteNo));
  1224. }
  1225. /// <summary>
  1226. /// 设置确认出团
  1227. /// </summary>
  1228. /// <param name="dto"></param>
  1229. /// <returns></returns>
  1230. [HttpPost]
  1231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1232. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1233. {
  1234. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1235. if (groupData.Code != 0)
  1236. {
  1237. return Ok(JsonView(false, groupData.Msg));
  1238. }
  1239. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1240. #region OA消息推送
  1241. try
  1242. {
  1243. string groupName = groupInfo.TeamName;
  1244. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1245. string title = $"系统通知";
  1246. string content = $"团组[{groupName}]已确认出团!";
  1247. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1248. }
  1249. catch (Exception ex)
  1250. {
  1251. }
  1252. #endregion
  1253. #region 应用推送
  1254. try
  1255. {
  1256. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1257. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1258. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1259. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1260. {
  1261. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1262. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1263. }
  1264. }
  1265. catch (Exception ex)
  1266. {
  1267. }
  1268. #endregion
  1269. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1270. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1271. }
  1272. /// <summary>
  1273. /// 获取团组名称data And 签证国别Data
  1274. /// </summary>
  1275. /// <param name="dto"></param>
  1276. /// <returns></returns>
  1277. [HttpPost]
  1278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1279. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1280. {
  1281. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1282. if (groupData.Code != 0)
  1283. {
  1284. return Ok(JsonView(false, groupData.Msg));
  1285. }
  1286. return Ok(JsonView(groupData.Data));
  1287. }
  1288. /// <summary>
  1289. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1290. /// </summary>
  1291. /// <returns></returns>
  1292. [HttpPost]
  1293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1294. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1295. {
  1296. try
  1297. {
  1298. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1299. if (groupData.Code != 0)
  1300. {
  1301. return Ok(JsonView(false, groupData.Msg));
  1302. }
  1303. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1304. }
  1305. catch (Exception ex)
  1306. {
  1307. return Ok(JsonView(false, "程序错误!"));
  1308. throw;
  1309. }
  1310. }
  1311. /// <summary>
  1312. /// 团组清单 Excel
  1313. /// </summary>
  1314. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1315. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1316. /// <returns></returns>
  1317. [HttpGet]
  1318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1319. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1320. {
  1321. DateTime _beginDt, _endDt;
  1322. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1323. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1324. if (!beginBool && !endBool)
  1325. {
  1326. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1327. }
  1328. string sql = string.Format(@"
  1329. SELECT
  1330. ROW_NUMBER,
  1331. Id,
  1332. SalesQuoteNo,
  1333. TourCode,
  1334. TeamTypeId,
  1335. TeamType,
  1336. TeamLevId,
  1337. TeamLev,
  1338. TeamName,
  1339. ClientName,
  1340. ClientUnit,
  1341. VisitDate,
  1342. VisitDays,
  1343. VisitPNumber,
  1344. JietuanOperatorId,
  1345. JietuanOperator,
  1346. IsSure,
  1347. CreateUserName,
  1348. IsBid
  1349. FROM
  1350. (
  1351. SELECT
  1352. ROW_NUMBER() OVER(
  1353. ORDER BY
  1354. gdi.CreateTime Desc
  1355. ) AS ROW_NUMBER,
  1356. gdi.Id,
  1357. SalesQuoteNo,
  1358. TourCode,
  1359. ssd.Id TeamTypeId,
  1360. ssd.Name TeamType,
  1361. ssd1.Id TeamLevId,
  1362. ssd1.Name TeamLev,
  1363. TeamName,
  1364. ClientName,
  1365. ClientUnit,
  1366. VisitDate,
  1367. VisitDays,
  1368. VisitPNumber,
  1369. JietuanOperator JietuanOperatorId,
  1370. su.CnName JietuanOperator,
  1371. IsSure,
  1372. gdi.CreateTime,
  1373. su1.CnName As CreateUserName,
  1374. gdi.IsBid
  1375. FROM
  1376. Grp_DelegationInfo gdi
  1377. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1378. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1379. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1380. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1381. WHERE
  1382. gdi.IsDel = 0
  1383. AND gdi.IsBid = 0
  1384. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1385. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1386. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1387. #region 处理所属部门
  1388. /*
  1389. * 1.sq 和 gyy 等显示 市场部
  1390. * 2.王鸽和主管及张总还有管理员号统一国交部
  1391. * 2-1. 4 管理员 ,21 张海麟
  1392. */
  1393. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1394. List<int> userIds1 = new List<int>() { 4, 21 };
  1395. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1396. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1397. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1398. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1399. .ToListAsync();
  1400. var droupIds = groupList.Select(it => it.Id).ToList();
  1401. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1402. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1403. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1404. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1405. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1406. {
  1407. DiId = tcl.DiId,
  1408. LastName = dc.LastName,
  1409. FirstName = dc.FirstName,
  1410. Sex = dc.Sex,
  1411. Birthday = dc.BirthDay,
  1412. Company = cc.CompanyFullName,
  1413. Job = dc.Job,
  1414. CreateTime = tcl.CreateTime,
  1415. })
  1416. .ToList();
  1417. foreach (var item in groupList)
  1418. {
  1419. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1420. string groupFirstName = "";
  1421. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1422. if (currDatas.Any())
  1423. {
  1424. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1425. }
  1426. item.GroupFirst = groupFirstName;
  1427. }
  1428. #endregion
  1429. #region Excel
  1430. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1431. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1432. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1433. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1434. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1435. //载入模板
  1436. WorkbookDesigner designer = new WorkbookDesigner();
  1437. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1438. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1439. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1440. dt.TableName = "GroupList";
  1441. designer.SetDataSource(dt);
  1442. designer.Process();
  1443. if (!Directory.Exists(savePath))
  1444. {
  1445. Directory.CreateDirectory(savePath);
  1446. }
  1447. string serverPath = $"{savePath}{fileName}";
  1448. designer.Workbook.Save(serverPath);
  1449. string rst = $"{servicePath}{ftpPath}{fileName}";
  1450. #endregion
  1451. return Ok(JsonView(true, "操作成功!", rst));
  1452. }
  1453. #endregion
  1454. #region 团组&签证
  1455. /// <summary>
  1456. /// 根据团组Id获取签证客户信息List
  1457. /// </summary>
  1458. /// <param name="dto">请求dto</param>
  1459. /// <returns></returns>
  1460. [HttpPost]
  1461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1462. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1463. {
  1464. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1465. if (groupData.Code != 0)
  1466. {
  1467. return Ok(JsonView(false, groupData.Msg));
  1468. }
  1469. return Ok(JsonView(groupData.Data));
  1470. }
  1471. /// <summary>
  1472. /// IOS获取团组签证拍照上传进度01(团组列表)
  1473. /// </summary>
  1474. /// <param name="dto">请求dto</param>
  1475. /// <returns></returns>
  1476. [HttpPost]
  1477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1478. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1479. {
  1480. if (dto == null)
  1481. {
  1482. return Ok(JsonView(false, "参数为空"));
  1483. }
  1484. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1485. return Ok(JsonView(visaList));
  1486. }
  1487. /// <summary>
  1488. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1489. /// </summary>
  1490. /// <returns></returns>
  1491. [HttpPost]
  1492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1493. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1494. {
  1495. if (dto == null)
  1496. {
  1497. return Ok(JsonView(false, "请求错误:"));
  1498. }
  1499. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1500. return Ok(JsonView(list));
  1501. }
  1502. /// <summary>
  1503. /// IOS获取团组签证拍照上传进度03(相册)
  1504. /// </summary>
  1505. /// <returns></returns>
  1506. [HttpPost]
  1507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1508. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1509. {
  1510. if (dto == null)
  1511. {
  1512. return Ok(JsonView(false, "请求错误:"));
  1513. }
  1514. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1515. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1516. list.ForEach(s => s.url = url);
  1517. return Ok(JsonView(list));
  1518. }
  1519. /// <summary>
  1520. /// IOS获取团组签证拍照上传进度04(图片上传)
  1521. /// </summary>
  1522. /// <param name="dto"></param>
  1523. /// <returns></returns>
  1524. [HttpPost]
  1525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1526. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1527. {
  1528. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1529. //if (!string.IsNullOrEmpty(result))
  1530. //{
  1531. //}
  1532. //else {
  1533. // return Ok(JsonView(false, "上传失败"));
  1534. //}
  1535. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1536. int sucNum = 0;
  1537. try
  1538. {
  1539. foreach (var item in dto.base64DataList)
  1540. {
  1541. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1542. string result = DecodeBase64ToImage(item, imageName);
  1543. if (!string.IsNullOrEmpty(result))
  1544. {
  1545. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1546. pic.CreateUserId = dto.CreateUserId;
  1547. pic.PicName = imageName;
  1548. pic.PicPath = result;
  1549. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1550. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1551. if (insertResult > 0)
  1552. {
  1553. sucNum++;
  1554. }
  1555. }
  1556. }
  1557. }
  1558. catch (Exception ex)
  1559. {
  1560. return Ok(JsonView(false, ex.Message));
  1561. }
  1562. string msg = string.Format(@"成功上传{0}张", sucNum);
  1563. return Ok(JsonView(true, msg));
  1564. }
  1565. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1566. {
  1567. string filename = "";//声明一个string类型的相对路径
  1568. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1569. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1570. try//会有异常抛出,try,catch一下
  1571. {
  1572. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1573. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1574. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1575. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1576. //文件名称
  1577. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1578. //上传的文件的路径
  1579. string filePath = "";
  1580. if (!Directory.Exists(fileDir))
  1581. {
  1582. Directory.CreateDirectory(fileDir);
  1583. }
  1584. //上传的文件的路径
  1585. filePath = fileDir + filename;
  1586. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1587. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1588. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1589. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1590. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1591. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1592. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1593. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1594. bitmap.Dispose();
  1595. }
  1596. catch (Exception e)
  1597. {
  1598. string massage = e.Message;
  1599. Logs("IOS图片上传Error:" + massage);
  1600. //filename = e.Message;
  1601. }
  1602. return filename;//返回相对路径
  1603. }
  1604. /// <summary>
  1605. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1606. /// </summary>
  1607. /// <param name="dto"></param>
  1608. /// <returns></returns>
  1609. [HttpPost]
  1610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1611. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1612. {
  1613. if (dto == null)
  1614. {
  1615. return Ok(JsonView(false, "请求错误:"));
  1616. }
  1617. string msg = "参数错误";
  1618. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1619. {
  1620. try
  1621. {
  1622. //_delegationVisaRep.BeginTran();
  1623. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1624. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1625. .Where(s => s.Id == dto.visaProgressCustomerId)
  1626. .ExecuteCommandAsync();
  1627. if (updCount > 0 && dto.publishCode == 1)
  1628. {
  1629. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1630. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1631. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1632. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1633. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1634. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1635. if (groupData == null)
  1636. {
  1637. _delegationVisaRep.RollbackTran();
  1638. }
  1639. string title = string.Format(@"[签证进度更新]");
  1640. string content = string.Format(@"测试文本");
  1641. bool rst = await _message.AddMsg(new MessageDto()
  1642. {
  1643. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1644. IssuerId = dto.publisher,
  1645. Title = title,
  1646. Content = content,
  1647. ReleaseTime = DateTime.Now,
  1648. UIdList = new List<int> {
  1649. 234
  1650. }
  1651. });
  1652. if (rst)
  1653. {
  1654. return Ok(JsonView(true, "发送通知成功"));
  1655. }
  1656. }
  1657. //_delegationVisaRep.CommitTran();
  1658. }
  1659. catch (Exception)
  1660. {
  1661. //_delegationVisaRep.RollbackTran();
  1662. }
  1663. }
  1664. return Ok(JsonView(true, msg));
  1665. }
  1666. #endregion
  1667. #region 团组任务分配
  1668. /// <summary>
  1669. /// 团组任务分配初始化
  1670. /// </summary>
  1671. /// <returns></returns>
  1672. [HttpPost]
  1673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1674. public async Task<IActionResult> GetTaskAssignmen()
  1675. {
  1676. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1677. if (groupData.Code != 0)
  1678. {
  1679. return Ok(JsonView(false, groupData.Msg));
  1680. }
  1681. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1682. }
  1683. /// <summary>
  1684. /// 团组任务分配查询
  1685. /// </summary>
  1686. /// <param name="dto"></param>
  1687. /// <returns></returns>
  1688. [HttpPost]
  1689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1690. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1691. {
  1692. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1693. if (groupData.Code != 0)
  1694. {
  1695. return Ok(JsonView(false, groupData.Msg));
  1696. }
  1697. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1698. }
  1699. /// <summary>
  1700. /// 团组任务分配操作
  1701. /// </summary>
  1702. /// <param name="dto"></param>
  1703. /// <returns></returns>
  1704. [HttpPost]
  1705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1706. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1707. {
  1708. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1709. if (groupData.Code != 0)
  1710. {
  1711. return Ok(JsonView(false, groupData.Msg));
  1712. }
  1713. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1714. }
  1715. /// <summary>
  1716. /// 团组任务分配
  1717. /// 批量分配
  1718. /// 查询团组
  1719. /// </summary>
  1720. /// <param name="dto"></param>
  1721. /// <returns></returns>
  1722. [HttpPost]
  1723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1724. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1725. {
  1726. //参数验证
  1727. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1728. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1729. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1730. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1731. }
  1732. /// <summary>
  1733. /// 团组任务分配
  1734. /// 批量分配
  1735. /// </summary>
  1736. /// <param name="dto"></param>
  1737. /// <returns></returns>
  1738. [HttpPost]
  1739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1740. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1741. {
  1742. //参数验证
  1743. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1744. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1745. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1746. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1747. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1748. }
  1749. #endregion
  1750. #region 团组费用审核
  1751. /// <summary>
  1752. /// 费用审核
  1753. /// 团组列表 Page
  1754. /// </summary>
  1755. /// <param name="_dto">团组列表请求dto</param>
  1756. /// <returns></returns>
  1757. [HttpPost]
  1758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1759. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1760. {
  1761. #region 参数验证
  1762. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1763. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1764. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1765. #region 页面操作权限验证
  1766. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1767. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1768. #endregion
  1769. #endregion
  1770. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1771. {
  1772. string sqlWhere = string.Empty;
  1773. if (_dto.IsSure == 0) //未完成
  1774. {
  1775. sqlWhere += string.Format(@" And IsSure = 0");
  1776. }
  1777. else if (_dto.IsSure == 1) //已完成
  1778. {
  1779. sqlWhere += string.Format(@" And IsSure = 1");
  1780. }
  1781. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1782. {
  1783. string tj = _dto.SearchCriteria;
  1784. 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}%')",
  1785. tj, tj, tj, tj, tj);
  1786. }
  1787. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1788. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1789. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1790. From (
  1791. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1792. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1793. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1794. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1795. From Grp_DelegationInfo gdi
  1796. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1797. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1798. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1799. Where gdi.IsDel = 0 {0}
  1800. ) temp ", sqlWhere);
  1801. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1802. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1803. var _view = new
  1804. {
  1805. PageFuncAuth = pageFunAuthView,
  1806. Data = _DelegationList
  1807. };
  1808. return Ok(JsonView(true, "查询成功!", _view, total));
  1809. }
  1810. else
  1811. {
  1812. return Ok(JsonView(false, "查询失败"));
  1813. }
  1814. }
  1815. /// <summary>
  1816. /// 获取团组费用审核
  1817. /// </summary>
  1818. /// <param name="_dto"></param>
  1819. /// <returns></returns>
  1820. [HttpPost]
  1821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1822. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1823. {
  1824. try
  1825. {
  1826. #region 参数验证
  1827. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1828. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1829. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1830. #region 页面操作权限验证
  1831. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1832. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1833. #endregion
  1834. #endregion
  1835. var _view = new Grp_CreditCardPaymentView();
  1836. var clientNameList = getSimplClientList(_dto.DiId);
  1837. #region 费用清单
  1838. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1839. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1840. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1841. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1842. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1843. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1844. /*
  1845. * 76://酒店预订
  1846. */
  1847. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1848. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1849. /*
  1850. * 79://车/导游地接
  1851. */
  1852. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1853. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1854. /*
  1855. * 80: //签证
  1856. */
  1857. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1858. /*
  1859. *81: //邀请/公务活动
  1860. */
  1861. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1862. /*
  1863. * 82: //团组客户保险
  1864. */
  1865. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1866. /*
  1867. * Lable = 85 机票预订
  1868. */
  1869. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1870. /*
  1871. * 85 机票预定
  1872. */
  1873. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1874. /*
  1875. * 98 其他款项
  1876. */
  1877. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1878. /*
  1879. * 285:收款退还
  1880. */
  1881. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1882. /*
  1883. * 1015: //超支费用
  1884. */
  1885. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1886. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1887. /*
  1888. * 币种信息
  1889. */
  1890. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1891. /*
  1892. * 车/导游地接 费用类型
  1893. */
  1894. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1895. /*
  1896. * 车/导游地接 费用类型
  1897. */
  1898. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1899. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1900. /*
  1901. * 用户信息
  1902. */
  1903. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1904. /*
  1905. * 费用模块
  1906. */
  1907. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1908. string priceModule = string.Empty;
  1909. if (sdPriceName != null)
  1910. {
  1911. priceModule = sdPriceName.Name;
  1912. }
  1913. /*
  1914. * 成本信息
  1915. */
  1916. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1917. decimal _groupRate = 0.0000M;
  1918. string _groupCurrencyCode = "-";
  1919. if (groupCost != null)
  1920. {
  1921. _groupRate = groupCost.Rate;
  1922. if (int.TryParse(groupCost.Currency, out int _currency))
  1923. {
  1924. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1925. }
  1926. else _groupCurrencyCode = groupCost.Currency;
  1927. }
  1928. string costContentSql = $"Select * From Grp_GroupCost";
  1929. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1930. //处理日期为空的天数
  1931. for (int i = 0; i < groupCostDetails.Count; i++)
  1932. if (i != 0)
  1933. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1934. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1935. /*
  1936. * 处理详情数据
  1937. */
  1938. foreach (var entity in entityList)
  1939. {
  1940. var _detail = new Grp_CreditCardPaymentDetailView();
  1941. _detail.Id = entity.Id;
  1942. _detail.PriceName = priceModule;
  1943. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1944. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1945. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1946. //处理金额
  1947. if (entity.CTable == 1015)
  1948. {
  1949. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1950. if (czInfo != null)
  1951. {
  1952. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1953. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1954. }
  1955. }
  1956. /*
  1957. * 应付款金额
  1958. */
  1959. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1960. string PaymentCurrency_WaitPay = "Unknown";
  1961. string hotelCurrncyCode = "Unknown";
  1962. string hotelCurrncyName = "Unknown";
  1963. if (sdPaymentCurrency_WaitPay != null)
  1964. {
  1965. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1966. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1967. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1968. if (hotelCurrncyCode.Equals("CNY"))
  1969. {
  1970. entity.DayRate = 1.0000M;
  1971. }
  1972. }
  1973. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1974. /*
  1975. * 此次付款金额
  1976. */
  1977. decimal CurrPayStr = 0.00M,
  1978. OriginalCurrPay = 0.00M;
  1979. if (entity.PayPercentage == 0)
  1980. {
  1981. if (entity.PayThenMoney != 0)
  1982. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1983. }
  1984. else
  1985. {
  1986. if (entity.PayMoney != 0)
  1987. {
  1988. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1989. }
  1990. }
  1991. //if (_dto.Label == 79)
  1992. //{
  1993. // string original = string.Empty;
  1994. // if (hotelCurrncyCode.Equals("CNY"))
  1995. // {
  1996. // OriginalCurrPay = CurrPayStr;
  1997. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1998. // }
  1999. // else
  2000. // {
  2001. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2002. // //760 EUR(7600.00 CNY)
  2003. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2004. // }
  2005. //}
  2006. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2007. string original = string.Empty;
  2008. if (hotelCurrncyCode.Equals("CNY"))
  2009. {
  2010. OriginalCurrPay = CurrPayStr;
  2011. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2012. }
  2013. else
  2014. {
  2015. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2016. //760 EUR(7600.00 CNY)
  2017. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2018. }
  2019. /*
  2020. * 剩余尾款
  2021. */
  2022. decimal BalanceStr = 0;
  2023. if (CurrPayStr != 0)
  2024. {
  2025. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2026. BalanceStr = 0;
  2027. else
  2028. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2029. }
  2030. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2031. /*
  2032. * Bus名称
  2033. */
  2034. _detail.BusName = "待增加";
  2035. /*
  2036. *费用所属
  2037. */
  2038. switch (entity.CTable)
  2039. {
  2040. case 76://酒店预订
  2041. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2042. if (hotelReservations != null)
  2043. {
  2044. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2045. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2046. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2047. string roomFeeStr = "", roomFeestr1 = "";
  2048. //是否比较房型价格
  2049. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2050. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2051. roomFeeStr += $"<br/>";
  2052. var roomTotal = 0.00M;
  2053. if (hotelReservations.SingleRoomPrice > 0)
  2054. {
  2055. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2056. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2057. //__isSingle = true;
  2058. roomTotal += fee;
  2059. }
  2060. if (hotelReservations.DoubleRoomPrice > 0)
  2061. {
  2062. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2063. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2064. // __isDouble = true;
  2065. roomTotal += fee;
  2066. }
  2067. if (hotelReservations.SuiteRoomPrice > 0)
  2068. {
  2069. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2070. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2071. //__isSuite = true;
  2072. roomTotal += fee;
  2073. }
  2074. if (hotelReservations.OtherRoomPrice > 0)
  2075. {
  2076. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2077. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2078. //__isOther = true;
  2079. roomTotal += fee;
  2080. }
  2081. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2082. else roomFeeStr += " 0.00 * 0";
  2083. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2084. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2085. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2086. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2087. /*
  2088. * 费用类型
  2089. * 1:房费
  2090. * 2:早餐
  2091. * 3:地税
  2092. * 4:城市税
  2093. * </summary>
  2094. */
  2095. //地税
  2096. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2097. if (governmentRentData != null)
  2098. {
  2099. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2100. governmentRentFee = governmentRentData.Price;
  2101. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2102. if (governmentRentCurrData != null)
  2103. {
  2104. governmentRentCode = governmentRentCurrData.Name;
  2105. governmentRentName = $"({governmentRentCurrData.Remark})";
  2106. }
  2107. }
  2108. //城市税
  2109. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2110. if (cityTaxData != null)
  2111. {
  2112. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2113. cityTaxFee = cityTaxData.Price;
  2114. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2115. if (cityTaxCurrData != null)
  2116. {
  2117. cityTaxCode = cityTaxCurrData.Name;
  2118. cityTaxName = $"({cityTaxCurrData.Remark})";
  2119. }
  2120. }
  2121. //酒店早餐
  2122. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2123. if (breakfastData != null)
  2124. {
  2125. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2126. breakfastFee = breakfastData.Price;
  2127. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2128. if (breakfastCurrData != null)
  2129. {
  2130. breakfastCode = breakfastCurrData.Name;
  2131. breakfastName = $"({breakfastCurrData.Remark})";
  2132. }
  2133. }
  2134. //房间费用
  2135. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2136. if (roomData != null)
  2137. {
  2138. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2139. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2140. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2141. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2142. roomFee = roomData.Price;
  2143. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2144. if (roomCurrData != null)
  2145. {
  2146. roomCode = roomCurrData.Name;
  2147. roomName = $"({roomCurrData.Remark})";
  2148. }
  2149. }
  2150. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2151. string hotelCostStr = "";
  2152. decimal hotelCsotTotal = 0.00M;
  2153. if (groupCost != null)
  2154. {
  2155. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2156. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2157. }
  2158. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2159. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2160. string hotelCost_day = "";
  2161. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2162. foreach (var item in hotelCostDetails1)
  2163. {
  2164. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2165. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2166. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2167. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2168. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2169. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2170. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2171. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2172. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2173. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2174. hotelCost_day += @$"<br/>";
  2175. }
  2176. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2177. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2178. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2179. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2180. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2181. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2182. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2183. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2184. $"房间说明: {hotelReservations.Remark} <br/>" +
  2185. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2186. $"{hotelBreakfastStr}" +
  2187. $"{hotelGovernmentRentStr}" +
  2188. $"{hotelCityTaxStr}";
  2189. _detail.PriceNameContent = hotelReservations.HotelName;
  2190. }
  2191. break;
  2192. case 79://车/导游地接
  2193. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2194. if (touristGuideGroundReservations != null)
  2195. {
  2196. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2197. {
  2198. _detail.BusName = touristGuideGroundReservations.BusName;
  2199. }
  2200. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2201. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2202. //if (isInt)
  2203. //{
  2204. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2205. // if (cityInfo != null)
  2206. // {
  2207. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2208. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2209. // if (carFeeItem != null)
  2210. // {
  2211. // nameContent += $@"({carFeeItem.Name})";
  2212. // }
  2213. // _detail.PriceNameContent = nameContent;
  2214. // }
  2215. //}
  2216. //else
  2217. //{
  2218. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2219. //}
  2220. var touristGuideGroundReservationsContents =
  2221. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2222. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2223. foreach (var item in touristGuideGroundReservationsContents)
  2224. {
  2225. string typeName = "Unknown";
  2226. string carCurrencyCode = "Unknown";
  2227. string carCurrencyName = "Unknown";
  2228. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2229. if (carTypeData != null) typeName = carTypeData.Name;
  2230. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2231. if (currencyData != null)
  2232. {
  2233. carCurrencyCode = currencyData.Name;
  2234. carCurrencyName = currencyData.Remark;
  2235. }
  2236. //op、成本 币种是否一致
  2237. bool IsCurrencyAgreement = false;
  2238. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2239. string opCostStr = string.Empty;
  2240. decimal opCostTypePrice = 0.00M;
  2241. #region 处理成本各项费用
  2242. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2243. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2244. if (opCost.Count > 0)
  2245. {
  2246. switch (item.SId)
  2247. {
  2248. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2249. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2250. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2251. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2252. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2253. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2254. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2255. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2256. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2257. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2258. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2259. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2260. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2261. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2262. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2263. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2264. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2265. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2266. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2267. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2268. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2269. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2270. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2271. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2272. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2273. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2274. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2275. }
  2276. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2277. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2278. }
  2279. #endregion
  2280. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2281. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2282. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2283. $"{opTypeStr} {opCostStr}<br/>" +
  2284. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2285. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2286. }
  2287. _detail.PriceMsgContent = priceMsg;
  2288. }
  2289. break;
  2290. case 80: //签证
  2291. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2292. if (visaInfo != null)
  2293. {
  2294. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2295. _detail.PriceNameContent = visaInfo.VisaDescription;
  2296. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2297. }
  2298. break;
  2299. case 81: //邀请/公务活动
  2300. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2301. if (_ioa != null)
  2302. {
  2303. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2304. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2305. sendCurrName = "Unknown", //快递费用币种 Name
  2306. sendCurrCode = "Unknown", //快递费用币种 Code
  2307. eventsCurrName = "Unknown", //公务活动费币种 Name
  2308. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2309. translateCurrName = "Unknown", //公务翻译费 Name
  2310. translateCurrCode = "Unknown"; //公务翻译费 Code
  2311. #region 处理费用币种
  2312. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2313. if (inviteCurrData != null)
  2314. {
  2315. inviteCurrName = inviteCurrData.Remark;
  2316. inviteCurrCode = inviteCurrData.Name;
  2317. }
  2318. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2319. if (sendCurrData != null)
  2320. {
  2321. sendCurrName = sendCurrData.Remark;
  2322. sendCurrCode = sendCurrData.Name;
  2323. }
  2324. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2325. if (eventsCurrData != null)
  2326. {
  2327. eventsCurrName = eventsCurrData.Remark;
  2328. eventsCurrCode = eventsCurrData.Name;
  2329. }
  2330. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2331. if (translateCurrData != null)
  2332. {
  2333. translateCurrName = translateCurrData.Remark;
  2334. translateCurrCode = translateCurrData.Name;
  2335. }
  2336. #endregion
  2337. _detail.PriceNameContent = _ioa.InviterArea;
  2338. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2339. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2340. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2341. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2342. $@"备注:" + _ioa.Remark + "<br/>";
  2343. }
  2344. break;
  2345. case 82: //团组客户保险
  2346. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2347. if (customers != null)
  2348. {
  2349. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2350. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2351. }
  2352. break;
  2353. case 85: //机票预订
  2354. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2355. if (jpRes != null)
  2356. {
  2357. string FlightsDescription = jpRes.FlightsDescription;
  2358. string PriceDescription = jpRes.PriceDescription;
  2359. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2360. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2361. }
  2362. break;
  2363. case 98://其他款项
  2364. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2365. if (gdpRes != null)
  2366. {
  2367. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2368. _detail.PriceNameContent = gdpRes.PriceName;
  2369. }
  2370. break;
  2371. case 285://收款退还
  2372. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2373. if (refundAndOtherMoney != null)
  2374. {
  2375. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2376. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2377. }
  2378. break;
  2379. case 751://酒店早餐
  2380. break;
  2381. case 1015://超支费用
  2382. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2383. if (groupExtraCost != null)
  2384. {
  2385. _detail.PriceNameContent = groupExtraCost.PriceName;
  2386. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2387. }
  2388. break;
  2389. default:
  2390. break;
  2391. }
  2392. /*
  2393. * 申请人
  2394. */
  2395. string operatorName = " - ";
  2396. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2397. if (_opUser != null)
  2398. {
  2399. operatorName = _opUser.CnName;
  2400. }
  2401. _detail.OperatorName = operatorName;
  2402. /*
  2403. * 审核人
  2404. */
  2405. string auditOperatorName = "Unknown";
  2406. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2407. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2408. else
  2409. {
  2410. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2411. if (_adUser != null)
  2412. {
  2413. auditOperatorName = _adUser.CnName;
  2414. }
  2415. }
  2416. _detail.AuditOperatorName = auditOperatorName;
  2417. /*
  2418. * 超预算比例
  2419. */
  2420. string overBudgetStr = "";
  2421. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2422. else if (entity.ExceedBudget == 0)
  2423. {
  2424. if (entity.CTable == 76 || entity.CTable == 79)
  2425. {
  2426. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2427. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2428. }
  2429. else
  2430. {
  2431. overBudgetStr = "未超预算";
  2432. }
  2433. }
  2434. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2435. _detail.OverBudget = overBudgetStr;
  2436. decimal auditFee = 0.00M; //已审核金额 人名币
  2437. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2438. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2439. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2440. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2441. {
  2442. auditedFeeOriginal = entity.PayMoney;
  2443. auditFee = CurrPayStr;
  2444. }
  2445. else if (entity.IsAuditGM == 0)
  2446. {
  2447. unAuditFeeCNY = CurrPayStr;
  2448. unAuditFeeOriginal = OriginalCurrPay;
  2449. OriginalCurrPay = 0.00M;
  2450. }
  2451. /*
  2452. * 费用总计
  2453. */
  2454. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2455. {
  2456. CurrencyId = entity.PaymentCurrency,
  2457. CurrencyName = PaymentCurrency_WaitPay,
  2458. AmountPayable = entity.PayMoney,
  2459. ThisPayment = OriginalCurrPay,
  2460. BalancePayment = BalanceStr,
  2461. AuditedFunds = auditFee,
  2462. AuditedFundsOriginal = auditedFeeOriginal,
  2463. UnAuditFundsCNY = unAuditFeeCNY,
  2464. UnAuditFundsOriginal = unAuditFeeOriginal
  2465. });
  2466. _detail.IsAuditGM = entity.IsAuditGM;
  2467. detailList.Add(_detail);
  2468. }
  2469. #endregion
  2470. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2471. /*
  2472. * 下方描述处理
  2473. */
  2474. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2475. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2476. if (ccpCurrencyPrice != null)
  2477. {
  2478. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2479. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2480. }
  2481. else
  2482. {
  2483. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2484. }
  2485. string amountPayableStr = string.Format(@"应付款总金额: ");
  2486. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2487. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2488. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2489. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2490. foreach (var item in nonDuplicat)
  2491. {
  2492. var currencyName = item.CurrencyName;
  2493. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2494. if (strs.Count > 0)
  2495. {
  2496. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2497. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2498. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2499. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2500. //单独处理此次付款金额
  2501. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2502. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2503. //单独处理已审核费用
  2504. //if (item.CurrencyId == 836) //人民币
  2505. //{
  2506. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2507. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2508. //}
  2509. //else
  2510. //{
  2511. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2512. //}
  2513. if (currencyName.Equals("CNY"))
  2514. {
  2515. //已审核费用
  2516. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2517. //未审核费用
  2518. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2519. }
  2520. else
  2521. {
  2522. //已审核费用
  2523. 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"));
  2524. //未审核费用
  2525. 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"));
  2526. }
  2527. }
  2528. }
  2529. _view.TotalStr1 = amountPayableStr[..^1];
  2530. _view.TotalStr2 = thisPaymentStr[..^1];
  2531. _view.TotalStr3 = balancePaymentStr[..^1];
  2532. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2533. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2534. var _view1 = new
  2535. {
  2536. PageFuncAuth = pageFunAuthView,
  2537. Data = _view
  2538. };
  2539. return Ok(JsonView(_view1));
  2540. }
  2541. catch (Exception ex)
  2542. {
  2543. return Ok(JsonView(false, ex.Message));
  2544. }
  2545. }
  2546. /// <summary>
  2547. /// 费用审核
  2548. /// 修改团组费用审核状态
  2549. /// </summary>
  2550. /// <param name="_dto">参数Json字符串</param>
  2551. /// <returns></returns>
  2552. [HttpPost]
  2553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2554. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2555. {
  2556. #region 参数验证
  2557. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2558. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2559. #endregion
  2560. #region 页面操作权限验证
  2561. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2562. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2563. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2564. #endregion
  2565. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2566. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2567. DateTime dtNow = DateTime.Now;
  2568. _groupRepository.BeginTran();
  2569. int rst = 0;
  2570. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2571. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2572. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2573. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2574. List<dynamic> msgDatas = new List<dynamic>();
  2575. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2576. foreach (var item in idList)
  2577. {
  2578. int CreditId = int.Parse(item);
  2579. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2580. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2581. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2582. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2583. .Where(s => s.Id == CreditId)
  2584. .ExecuteCommandAsync();
  2585. if (result < 1)
  2586. {
  2587. rst = -1;
  2588. _groupRepository.RollbackTran();
  2589. return Ok(JsonView(false, "操作失败并回滚!"));
  2590. }
  2591. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2592. if (creditData != null)
  2593. {
  2594. #region 应用通知配置
  2595. try
  2596. {
  2597. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2598. }
  2599. catch (Exception ex)
  2600. {
  2601. }
  2602. #endregion
  2603. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2604. string groupNameStr = string.Empty;
  2605. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2606. if (groupData != null) groupNameStr = groupData.TeamName;
  2607. string creditTypeStr = string.Empty;
  2608. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2609. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2610. string creditCurrency = string.Empty;
  2611. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2612. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2613. if (creditCurrency.Equals("CNY"))
  2614. {
  2615. creditData.DayRate = 1.0000M;
  2616. }
  2617. if (creditData.PayPercentage == 0.00M)
  2618. {
  2619. creditData.PayPercentage = 100M;
  2620. }
  2621. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2622. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2623. string msgContent = "";
  2624. if (creditCurrency.Equals("CNY"))
  2625. {
  2626. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2627. }
  2628. else
  2629. {
  2630. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2631. }
  2632. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2633. }
  2634. }
  2635. if (rst == 0)
  2636. {
  2637. _groupRepository.CommitTran();
  2638. foreach (var item in msgDatas)
  2639. {
  2640. //发送消息
  2641. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2642. }
  2643. #region 应用推送
  2644. try
  2645. {
  2646. foreach (var ccpId in dic_ccp_user.Keys)
  2647. {
  2648. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2649. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2650. }
  2651. }
  2652. catch (Exception)
  2653. {
  2654. }
  2655. #endregion
  2656. return Ok(JsonView(true, "操作成功!"));
  2657. }
  2658. return Ok(JsonView(false, "操作失败!"));
  2659. }
  2660. #endregion
  2661. #region 机票费用录入
  2662. /// <summary>
  2663. /// 机票录入当前登录人可操作团组
  2664. /// </summary>
  2665. /// <param name="dto"></param>
  2666. /// <returns></returns>
  2667. [HttpPost]
  2668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2669. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2670. {
  2671. try
  2672. {
  2673. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2674. if (groupData.Code != 0)
  2675. {
  2676. return Ok(JsonView(false, groupData.Msg));
  2677. }
  2678. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2679. }
  2680. catch (Exception ex)
  2681. {
  2682. return Ok(JsonView(false, "程序错误!"));
  2683. throw;
  2684. }
  2685. }
  2686. /// <summary>
  2687. /// 机票费用录入列表
  2688. /// </summary>
  2689. /// <param name="dto"></param>
  2690. /// <returns></returns>
  2691. [HttpPost]
  2692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2693. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2694. {
  2695. try
  2696. {
  2697. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2698. if (groupData.Code != 0)
  2699. {
  2700. return Ok(JsonView(false, groupData.Msg));
  2701. }
  2702. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2703. }
  2704. catch (Exception ex)
  2705. {
  2706. return Ok(JsonView(false, ex.Message));
  2707. throw;
  2708. }
  2709. }
  2710. /// <summary>
  2711. /// 根据id查询费用录入信息
  2712. /// </summary>
  2713. /// <param name="dto"></param>
  2714. /// <returns></returns>
  2715. [HttpPost]
  2716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2717. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2718. {
  2719. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2720. if (groupData.Code != 0)
  2721. {
  2722. return Ok(JsonView(false, groupData.Msg));
  2723. }
  2724. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2725. }
  2726. /// <summary>
  2727. /// 机票费用录入操作(Status:1.新增,2.修改)
  2728. /// </summary>
  2729. /// <param name="dto"></param>
  2730. /// <returns></returns>
  2731. [HttpPost]
  2732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2733. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2734. {
  2735. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2736. if (groupData.Code != 0)
  2737. {
  2738. return Ok(JsonView(false, groupData.Msg));
  2739. }
  2740. #region 应用推送
  2741. try
  2742. {
  2743. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2744. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2745. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2746. //2024-10-21 新增LZ UID
  2747. var userIds = new List<int>() { 21 };
  2748. string title = $"系统通知";
  2749. string content = "";
  2750. var diId = dto.AirTicketResOpData.DiId;
  2751. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2752. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2753. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2754. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2755. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2756. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2757. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2758. }
  2759. catch (Exception ex)
  2760. {
  2761. }
  2762. #endregion
  2763. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2764. }
  2765. /// <summary>
  2766. /// 根据舱位类型查询接团客户名单信息
  2767. /// </summary>
  2768. /// <param name="dto"></param>
  2769. /// <returns></returns>
  2770. [HttpPost]
  2771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2772. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2773. {
  2774. try
  2775. {
  2776. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2777. if (crm_Groups.Count != 0)
  2778. {
  2779. List<dynamic> Customer = new List<dynamic>();
  2780. foreach (var item in crm_Groups)
  2781. {
  2782. var data = new
  2783. {
  2784. Id = item.Id,
  2785. Pinyin = item.Pinyin,
  2786. Name = item.LastName + item.FirstName
  2787. };
  2788. Customer.Add(data);
  2789. }
  2790. return Ok(JsonView(true, "查询成功!", Customer));
  2791. }
  2792. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2793. }
  2794. catch (Exception ex)
  2795. {
  2796. return Ok(JsonView(false, "程序错误!"));
  2797. throw;
  2798. }
  2799. }
  2800. /// <summary>
  2801. /// 根据团号获取客户信息
  2802. /// </summary>
  2803. /// <param name="dto"></param>
  2804. /// <returns></returns>
  2805. [HttpPost]
  2806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2807. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2808. {
  2809. var jw = JsonView(false);
  2810. if (dto.DIID < 1)
  2811. {
  2812. jw.Msg += "请输入正确的diid";
  2813. return Ok(jw);
  2814. }
  2815. var arr = getSimplClientList(dto.DIID);
  2816. jw = JsonView(true, "获取成功!", arr);
  2817. return Ok(jw);
  2818. }
  2819. private List<SimplClientInfo> getSimplClientList(int diId)
  2820. {
  2821. 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);
  2822. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2823. foreach (var item in arr)
  2824. {
  2825. EncryptionProcessor.DecryptProperties(item);
  2826. }
  2827. return arr;
  2828. }
  2829. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2830. {
  2831. string result = origin;
  2832. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2833. {
  2834. string[] temparr = origin.Split(',');
  2835. string fistrStr = temparr[0];
  2836. int count = temparr.Count();
  2837. int tempId;
  2838. bool success = int.TryParse(fistrStr, out tempId);
  2839. if (success)
  2840. {
  2841. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2842. if (tempInfo != null)
  2843. {
  2844. if (count > 1)
  2845. {
  2846. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2847. }
  2848. else
  2849. {
  2850. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2851. }
  2852. }
  2853. }
  2854. }
  2855. return result;
  2856. }
  2857. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2858. {
  2859. string result = origin;
  2860. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2861. {
  2862. string[] temparr = origin.Split(',');
  2863. result = "";
  2864. foreach (var item in temparr)
  2865. {
  2866. int tempId;
  2867. bool success = int.TryParse(item, out tempId);
  2868. if (success)
  2869. {
  2870. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2871. if (tempInfo != null)
  2872. {
  2873. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2874. }
  2875. }
  2876. }
  2877. }
  2878. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2879. return result;
  2880. }
  2881. /// <summary>
  2882. /// 机票费用录入,删除
  2883. /// </summary>
  2884. /// <param name="dto"></param>
  2885. /// <returns></returns>
  2886. [HttpPost]
  2887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2888. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2889. {
  2890. try
  2891. {
  2892. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2893. if (res)
  2894. {
  2895. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2896. {
  2897. IsDel = 1,
  2898. DeleteUserId = dto.DeleteUserId,
  2899. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2900. }).ExecuteCommandAsync();
  2901. return Ok(JsonView(true, "删除成功!"));
  2902. }
  2903. return Ok(JsonView(false, "删除失败!"));
  2904. }
  2905. catch (Exception ex)
  2906. {
  2907. return Ok(JsonView(false, "程序错误!"));
  2908. throw;
  2909. }
  2910. }
  2911. /// <summary>
  2912. /// 导出机票录入报表
  2913. /// </summary>
  2914. /// <param name="dto"></param>
  2915. /// <returns></returns>
  2916. [HttpPost]
  2917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2918. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2919. {
  2920. try
  2921. {
  2922. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2923. if (groupData.Code != 0)
  2924. {
  2925. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2926. }
  2927. else
  2928. {
  2929. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2930. if (AirTicketReservations.Count != 0)
  2931. {
  2932. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2933. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2934. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2935. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2936. WorkbookDesigner designer = new WorkbookDesigner();
  2937. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2938. decimal countCost = 0;
  2939. foreach (var item in AirTicketReservations)
  2940. {
  2941. #region 处理客人姓名
  2942. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2943. item.ClientName = clientNames;
  2944. #endregion
  2945. if (item.BankType == "其他")
  2946. {
  2947. item.BankNo = "--";
  2948. }
  2949. else
  2950. {
  2951. if (!string.IsNullOrEmpty(item.BankType))
  2952. {
  2953. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2954. }
  2955. }
  2956. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2957. item.Price = System.Decimal.Round(item.Price, 2);
  2958. countCost += Convert.ToDecimal(item.Price);
  2959. }
  2960. designer.SetDataSource("Export", AirTicketReservations);
  2961. designer.SetDataSource("ExportDiCode", diCode);
  2962. designer.SetDataSource("ExportDiName", diName);
  2963. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2964. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2965. designer.Process();
  2966. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2967. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2968. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2969. return Ok(JsonView(true, "成功", url = rst));
  2970. }
  2971. else
  2972. {
  2973. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2974. }
  2975. }
  2976. }
  2977. catch (Exception ex)
  2978. {
  2979. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2980. throw;
  2981. }
  2982. }
  2983. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2984. /// <summary>
  2985. /// 行程单导出
  2986. /// </summary>
  2987. /// <param name="dto"></param>
  2988. /// <returns></returns>
  2989. [HttpPost]
  2990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2991. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2992. {
  2993. try
  2994. {
  2995. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2996. if (groupData.Code != 0)
  2997. {
  2998. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2999. }
  3000. else
  3001. {
  3002. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3003. if (dto.Language == "CN")
  3004. {
  3005. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3006. DocumentBuilder builder = new DocumentBuilder(doc);
  3007. int tableIndex = 0;//表格索引
  3008. //得到文档中的第一个表格
  3009. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3010. foreach (var item in _AirTicketReservations)
  3011. {
  3012. #region 处理固定数据
  3013. string[] FlightsCode = item.FlightsCode.Split('/');
  3014. if (FlightsCode.Length != 0)
  3015. {
  3016. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3017. if (_AirCompany != null)
  3018. {
  3019. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3020. }
  3021. else
  3022. {
  3023. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3024. }
  3025. }
  3026. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3027. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3028. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3029. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3030. string name = "";
  3031. foreach (string clientName in nameArray)
  3032. {
  3033. if (!name.Contains(clientName))
  3034. {
  3035. name += clientName + ",";
  3036. }
  3037. }
  3038. if (!string.IsNullOrWhiteSpace(name))
  3039. {
  3040. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3041. }
  3042. else
  3043. {
  3044. table.Range.Bookmarks["ClientName"].Text = "--";
  3045. }
  3046. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3047. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3048. table.Range.Bookmarks["JointTicket"].Text = "--";
  3049. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3050. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3051. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3052. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3053. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3054. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3055. #endregion
  3056. #region 循环数据处理
  3057. List<AirInfo> airs = new List<AirInfo>();
  3058. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3059. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3060. for (int i = 0; i < FlightsCode.Length; i++)
  3061. {
  3062. AirInfo air = new AirInfo();
  3063. string[] tempstr = DayArray[i]
  3064. .Replace("\r\n", string.Empty)
  3065. .Replace("\\r\\n", string.Empty)
  3066. .TrimStart().TrimEnd()
  3067. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3068. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3069. string starCity = "";
  3070. if (star_Three != null)
  3071. {
  3072. starCity = star_Three.AirPort;
  3073. }
  3074. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3075. string EndCity = "";
  3076. if (End_Three != null)
  3077. {
  3078. EndCity = End_Three.AirPort;
  3079. }
  3080. air.Destination = starCity + "/" + EndCity;
  3081. air.Flight = FlightsCode[i];
  3082. air.SeatingClass = item.CTypeName;
  3083. string dateTime = tempstr[2];
  3084. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3085. air.FlightDate = DateTemp;
  3086. air.DepartureTime = tempstr[5];
  3087. air.LandingTime = tempstr[6];
  3088. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3089. air.TicketStatus = "--";
  3090. air.Luggage = "--";
  3091. air.DepartureTerminal = "--";
  3092. air.LandingTerminal = "--";
  3093. airs.Add(air);
  3094. }
  3095. int row = 13;
  3096. for (int i = 0; i < airs.Count; i++)
  3097. {
  3098. if (airs.Count > 2)
  3099. {
  3100. for (int j = 0; j < airs.Count - 2; j++)
  3101. {
  3102. var CopyRow = table.Rows[12].Clone(true);
  3103. table.Rows.Add(CopyRow);
  3104. }
  3105. }
  3106. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3107. int index = 0;
  3108. foreach (PropertyInfo property in properties)
  3109. {
  3110. string value = property.GetValue(airs[i]).ToString();
  3111. Cell ishcel0 = table.Rows[row].Cells[index];
  3112. Paragraph p = new Paragraph(doc);
  3113. string s = value;
  3114. p.AppendChild(new Run(doc, s));
  3115. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3116. ishcel0.AppendChild(p);
  3117. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3118. index++;
  3119. }
  3120. row++;
  3121. }
  3122. #endregion
  3123. Paragraph lastParagraph = new Paragraph(doc);
  3124. //第一个表格末尾加段落
  3125. table.ParentNode.InsertAfter(lastParagraph, table);
  3126. //复制第一个表格
  3127. Table cloneTable = (Table)table.Clone(true);
  3128. //在文档末尾段落后面加入复制的表格
  3129. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3130. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3131. {
  3132. int rownewsIndex = 13;
  3133. for (int i = 0; i < 2; i++)
  3134. {
  3135. var CopyRow = table.Rows[12].Clone(true);
  3136. table.Rows.RemoveAt(13);
  3137. table.Rows.Add(CopyRow);
  3138. rownewsIndex++;
  3139. }
  3140. }
  3141. else
  3142. {
  3143. table.Rows.RemoveAt(12);
  3144. }
  3145. cloneTable.Rows.RemoveAt(12);
  3146. }
  3147. if (_AirTicketReservations.Count != 0)
  3148. {
  3149. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3150. if (FlightsCode.Length != 0)
  3151. {
  3152. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3153. if (_AirCompany != null)
  3154. {
  3155. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3156. }
  3157. else
  3158. {
  3159. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3160. }
  3161. }
  3162. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3163. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3164. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3165. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3166. string name = "";
  3167. foreach (string clientName in nameArray)
  3168. {
  3169. if (!name.Contains(clientName))
  3170. {
  3171. name += clientName + ",";
  3172. }
  3173. }
  3174. if (!string.IsNullOrWhiteSpace(name))
  3175. {
  3176. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3177. }
  3178. else
  3179. {
  3180. table.Range.Bookmarks["ClientName"].Text = "--";
  3181. }
  3182. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3183. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3184. table.Range.Bookmarks["JointTicket"].Text = "--";
  3185. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3186. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3187. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3188. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3189. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3190. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3191. }
  3192. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3193. //保存合并后的文档
  3194. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3195. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3196. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3197. return Ok(JsonView(true, "成功!", rst));
  3198. }
  3199. else
  3200. {
  3201. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3202. DocumentBuilder builder = new DocumentBuilder(doc);
  3203. int tableIndex = 0;//表格索引
  3204. //得到文档中的第一个表格
  3205. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3206. List<string> texts = new List<string>();
  3207. foreach (var item in _AirTicketReservations)
  3208. {
  3209. string[] FlightsCode = item.FlightsCode.Split('/');
  3210. if (FlightsCode.Length != 0)
  3211. {
  3212. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3213. if (_AirCompany != null)
  3214. {
  3215. if (!transDic.ContainsKey(_AirCompany.CnName))
  3216. {
  3217. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3218. }
  3219. }
  3220. else
  3221. {
  3222. if (!transDic.ContainsKey("--"))
  3223. {
  3224. transDic.Add("--", "--");
  3225. }
  3226. }
  3227. }
  3228. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3229. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3230. string name = "";
  3231. foreach (string clientName in nameArray)
  3232. {
  3233. name += clientName + ",";
  3234. }
  3235. if (!texts.Contains(name))
  3236. {
  3237. texts.Add(name);
  3238. }
  3239. List<AirInfo> airs = new List<AirInfo>();
  3240. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3241. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3242. for (int i = 0; i < FlightsCode.Length; i++)
  3243. {
  3244. AirInfo air = new AirInfo();
  3245. string[] tempstr = DayArray[i]
  3246. .Replace("\r\n", string.Empty)
  3247. .Replace("\\r\\n", string.Empty)
  3248. .TrimStart().TrimEnd()
  3249. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3250. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3251. if (star_Three != null)
  3252. {
  3253. if (!transDic.ContainsKey(star_Three.AirPort))
  3254. {
  3255. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3256. }
  3257. }
  3258. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3259. if (End_Three != null)
  3260. {
  3261. if (!transDic.ContainsKey(End_Three.AirPort))
  3262. {
  3263. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3264. }
  3265. }
  3266. if (!texts.Contains(item.CTypeName))
  3267. {
  3268. texts.Add(item.CTypeName);
  3269. }
  3270. }
  3271. }
  3272. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3273. if (transData.Count > 0)
  3274. {
  3275. foreach (TranslateResult item in transData)
  3276. {
  3277. if (!transDic.ContainsKey(item.Query))
  3278. {
  3279. transDic.Add(item.Query, item.Translation);
  3280. }
  3281. }
  3282. }
  3283. foreach (var item in _AirTicketReservations)
  3284. {
  3285. #region 处理固定数据
  3286. string[] FlightsCode = item.FlightsCode.Split('/');
  3287. if (FlightsCode.Length != 0)
  3288. {
  3289. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3290. if (_AirCompany != null)
  3291. {
  3292. string str = "--";
  3293. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3294. if (!string.IsNullOrEmpty(translateResult))
  3295. {
  3296. str = translateResult;
  3297. str = _airTicketResRep.Processing(str);
  3298. }
  3299. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3300. }
  3301. else
  3302. {
  3303. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3304. }
  3305. }
  3306. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3307. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3308. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3309. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3310. string names = "";
  3311. foreach (string clientName in nameArray)
  3312. {
  3313. names += clientName + ",";
  3314. }
  3315. if (!string.IsNullOrWhiteSpace(names))
  3316. {
  3317. string str = "--";
  3318. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3319. if (!string.IsNullOrEmpty(translateResult))
  3320. {
  3321. str = translateResult;
  3322. str = _airTicketResRep.Processing(str);
  3323. }
  3324. table.Range.Bookmarks["ClientName"].Text = str;
  3325. }
  3326. else
  3327. {
  3328. table.Range.Bookmarks["ClientName"].Text = "--";
  3329. }
  3330. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3331. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3332. table.Range.Bookmarks["JointTicket"].Text = "--";
  3333. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3334. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3335. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3336. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3337. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3338. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3339. #endregion
  3340. #region 循环数据处理
  3341. List<AirInfo> airs = new List<AirInfo>();
  3342. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3343. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3344. for (int i = 0; i < FlightsCode.Length; i++)
  3345. {
  3346. AirInfo air = new AirInfo();
  3347. string[] tempstr = DayArray[i]
  3348. .Replace("\r\n", string.Empty)
  3349. .Replace("\\r\\n", string.Empty)
  3350. .TrimStart().TrimEnd()
  3351. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3352. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3353. string starCity = "";
  3354. if (star_Three != null)
  3355. {
  3356. string str2 = "--";
  3357. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3358. if (!string.IsNullOrEmpty(translateResult2))
  3359. {
  3360. str2 = translateResult2;
  3361. str2 = _airTicketResRep.Processing(str2);
  3362. }
  3363. starCity = str2;
  3364. }
  3365. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3366. string EndCity = "";
  3367. if (End_Three != null)
  3368. {
  3369. string str1 = "--";
  3370. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3371. if (!string.IsNullOrEmpty(translateResult1))
  3372. {
  3373. str1 = translateResult1;
  3374. str1 = _airTicketResRep.Processing(str1);
  3375. }
  3376. EndCity = str1;
  3377. }
  3378. air.Destination = starCity + "/" + EndCity;
  3379. air.Flight = FlightsCode[i];
  3380. string str = "--";
  3381. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3382. if (!string.IsNullOrEmpty(translateResult))
  3383. {
  3384. str = translateResult;
  3385. str = _airTicketResRep.Processing(str);
  3386. }
  3387. air.SeatingClass = str;
  3388. string dateTime = tempstr[2];
  3389. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3390. air.FlightDate = DateTemp;
  3391. air.DepartureTime = tempstr[5];
  3392. air.LandingTime = tempstr[6];
  3393. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3394. air.TicketStatus = "--";
  3395. air.Luggage = "--";
  3396. air.DepartureTerminal = "--";
  3397. air.LandingTerminal = "--";
  3398. airs.Add(air);
  3399. }
  3400. int row = 13;
  3401. for (int i = 0; i < airs.Count; i++)
  3402. {
  3403. if (airs.Count > 2)
  3404. {
  3405. for (int j = 0; j < airs.Count - 2; j++)
  3406. {
  3407. var CopyRow = table.Rows[12].Clone(true);
  3408. table.Rows.Add(CopyRow);
  3409. }
  3410. }
  3411. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3412. int index = 0;
  3413. foreach (PropertyInfo property in properties)
  3414. {
  3415. string value = property.GetValue(airs[i]).ToString();
  3416. Cell ishcel0 = table.Rows[row].Cells[index];
  3417. Paragraph p = new Paragraph(doc);
  3418. string s = value;
  3419. p.AppendChild(new Run(doc, s));
  3420. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3421. ishcel0.AppendChild(p);
  3422. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3423. //ishcel0.CellFormat.VerticalAlignment=
  3424. index++;
  3425. }
  3426. row++;
  3427. }
  3428. #endregion
  3429. Paragraph lastParagraph = new Paragraph(doc);
  3430. //第一个表格末尾加段落
  3431. table.ParentNode.InsertAfter(lastParagraph, table);
  3432. //复制第一个表格
  3433. Table cloneTable = (Table)table.Clone(true);
  3434. //在文档末尾段落后面加入复制的表格
  3435. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3436. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3437. {
  3438. int rownewsIndex = 13;
  3439. for (int i = 0; i < 2; i++)
  3440. {
  3441. var CopyRow = table.Rows[12].Clone(true);
  3442. table.Rows.RemoveAt(13);
  3443. table.Rows.Add(CopyRow);
  3444. rownewsIndex++;
  3445. }
  3446. }
  3447. else
  3448. {
  3449. table.Rows.RemoveAt(12);
  3450. }
  3451. cloneTable.Rows.RemoveAt(12);
  3452. }
  3453. if (_AirTicketReservations.Count != 0)
  3454. {
  3455. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3456. if (FlightsCode.Length != 0)
  3457. {
  3458. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3459. if (_AirCompany != null)
  3460. {
  3461. string str = "--";
  3462. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3463. if (!string.IsNullOrEmpty(translateResult))
  3464. {
  3465. str = translateResult;
  3466. str = _airTicketResRep.Processing(str);
  3467. }
  3468. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3469. }
  3470. else
  3471. {
  3472. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3473. }
  3474. }
  3475. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3476. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3477. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3478. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3479. string names = "";
  3480. foreach (string clientName in nameArray)
  3481. {
  3482. names += clientName + ",";
  3483. }
  3484. if (!string.IsNullOrWhiteSpace(names))
  3485. {
  3486. string str = "--";
  3487. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3488. if (!string.IsNullOrEmpty(translateResult))
  3489. {
  3490. str = translateResult;
  3491. str = _airTicketResRep.Processing(str);
  3492. }
  3493. table.Range.Bookmarks["ClientName"].Text = str;
  3494. }
  3495. else
  3496. {
  3497. table.Range.Bookmarks["ClientName"].Text = "--";
  3498. }
  3499. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3500. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3501. table.Range.Bookmarks["JointTicket"].Text = "--";
  3502. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3503. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3504. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3505. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3506. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3507. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3508. }
  3509. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3510. //保存合并后的文档
  3511. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3512. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3513. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3514. return Ok(JsonView(true, "成功!", rst));
  3515. }
  3516. }
  3517. }
  3518. catch (Exception ex)
  3519. {
  3520. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3521. throw;
  3522. }
  3523. }
  3524. #endregion
  3525. #region 团组增减款项 --> 其他款项
  3526. /// <summary>
  3527. /// 团组增减款项下拉框绑定
  3528. /// </summary>
  3529. /// <param name="dto"></param>
  3530. /// <returns></returns>
  3531. [HttpPost]
  3532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3533. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3534. {
  3535. #region 参数验证
  3536. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3537. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3538. #endregion
  3539. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3540. }
  3541. /// <summary>
  3542. /// 根据团组Id查询团组增减款项
  3543. /// </summary>
  3544. /// <param name="dto"></param>
  3545. /// <returns></returns>
  3546. [HttpPost]
  3547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3548. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3549. {
  3550. #region 参数验证
  3551. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3552. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3553. #endregion
  3554. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3555. }
  3556. /// <summary>
  3557. /// 团组增减款项操作(Status:1.新增,2.修改)
  3558. /// </summary>
  3559. /// <param name="dto"></param>
  3560. /// <returns></returns>
  3561. [HttpPost]
  3562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3563. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3564. {
  3565. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3566. if (groupData.Code != 200)
  3567. {
  3568. return Ok(JsonView(false, groupData.Msg));
  3569. }
  3570. #region 应用推送
  3571. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3572. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3573. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3574. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3575. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3576. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3577. //自动审核
  3578. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3579. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3580. //2024-10-21 新增LZ UID
  3581. var userIds = new List<int>() { 21 };
  3582. string title = $"系统通知";
  3583. string content = "";
  3584. var diId = dto.DiId;
  3585. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3586. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3587. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3588. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3589. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3590. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3591. #endregion
  3592. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3593. }
  3594. /// <summary>
  3595. /// 团组增减款项操作 删除
  3596. /// </summary>
  3597. /// <param name="dto"></param>
  3598. /// <returns></returns>
  3599. [HttpPost]
  3600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3601. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3602. {
  3603. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3604. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3605. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3606. if (res.Code == 0)
  3607. {
  3608. return Ok(JsonView(true, "删除成功!"));
  3609. }
  3610. return Ok(JsonView(false, "删除失败!"));
  3611. }
  3612. /// <summary>
  3613. /// 根据团组增减款项Id查询
  3614. /// </summary>
  3615. /// <param name="dto"></param>
  3616. /// <returns></returns>
  3617. [HttpPost]
  3618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3619. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3620. {
  3621. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3622. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3623. }
  3624. /// <summary>
  3625. /// 查询供应商名称
  3626. /// </summary>
  3627. /// <param name="dto"></param>
  3628. /// <returns></returns>
  3629. [HttpPost]
  3630. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3631. {
  3632. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3633. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3634. ?? new List<Grp_DecreasePayments>();
  3635. dbResult = dbResult.Distinct(new
  3636. ProductComparer()).ToList();
  3637. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3638. {
  3639. x.Id,
  3640. x.SupplierAddress,
  3641. x.SupplierArea,
  3642. x.SupplierContact,
  3643. x.SupplierContactNumber,
  3644. x.SupplierEmail,
  3645. x.SupplierName,
  3646. x.SupplierSocialAccount,
  3647. x.SupplierTypeId,
  3648. }).ToList());
  3649. return Ok(jw);
  3650. }
  3651. /// <summary>
  3652. /// 团组增减款项 OTA匹配
  3653. /// </summary>
  3654. /// <param name="file"></param>
  3655. /// <returns></returns>
  3656. [HttpPost]
  3657. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3658. {
  3659. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3660. string fileName = file.FileName;
  3661. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3662. {
  3663. return Ok(JsonView(false, "请上传Excel文件!"));
  3664. }
  3665. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3666. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3667. if (!Directory.Exists(path))
  3668. {
  3669. Directory.CreateDirectory(path);
  3670. }
  3671. var filePath = @$"{path}/{fileName}";
  3672. //保存文件
  3673. using (FileStream fs = System.IO.File.Create(filePath))
  3674. {
  3675. file.CopyTo(fs);
  3676. fs.Flush();
  3677. }
  3678. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3679. //读取ExcelFile
  3680. DataTable dt = ConvertExcelToDataTable(filePath);
  3681. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3682. dt.TableName = "TB";
  3683. //修改table列名
  3684. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3685. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3686. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3687. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3688. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3689. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3690. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3691. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3692. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3693. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3694. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3695. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3696. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3697. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3698. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3699. var otaOrderNos = new List<string>();
  3700. foreach (DataRow item in dt.Rows)
  3701. {
  3702. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3703. }
  3704. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3705. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3706. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3707. .Select((dp, di) => new
  3708. {
  3709. dp.PriceName,
  3710. dp.OTAOrderNo,
  3711. dp.FeeTotal,
  3712. di.TeamName,
  3713. })
  3714. .ToListAsync();
  3715. foreach (DataRow item in dt.Rows)
  3716. {
  3717. var otaOrderNo = item["OTAOrderNo"].ToString();
  3718. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3719. if (oaData == null) continue;
  3720. item["GroupName"] = oaData.TeamName;
  3721. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3722. }
  3723. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3724. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3725. List<DataTable> datas = new List<DataTable>();
  3726. datas.Add(dt);
  3727. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3728. return Ok(JsonView(true, "操作成功", new { url = url }));
  3729. }
  3730. #region
  3731. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3732. {
  3733. // 创建Workbook对象
  3734. Workbook workbook = new Workbook(excelFilePath);
  3735. // 获取第一个工作表
  3736. Worksheet worksheet = workbook.Worksheets[0];
  3737. // 将工作表转换为DataTable
  3738. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3739. return dataTable;
  3740. }
  3741. #endregion
  3742. #endregion
  3743. #region 文件上传、删除
  3744. /// <summary>
  3745. /// region 文件上传 可以带参数
  3746. /// </summary>
  3747. /// <param name="file"></param>
  3748. /// <returns></returns>
  3749. [HttpPost]
  3750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3751. public async Task<IActionResult> UploadProject(IFormFile file)
  3752. {
  3753. //var TypeName = Request.Headers["TypeName"].ToString();
  3754. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3755. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3756. ////文件名称
  3757. //string projectFileName = file.FileName;
  3758. ////上传的文件的路径
  3759. //string filePath = $"{fileDir}/{projectFileName}";
  3760. //if (TypeName == "A")//A代表团组增减款项
  3761. //{
  3762. // filePath = fileDir + $@"\团组增减款项相关文件";
  3763. // if (!Directory.Exists(filePath))
  3764. // {
  3765. // Directory.CreateDirectory(filePath);
  3766. // }
  3767. // //上传的文件的路径
  3768. // filePath += $@"\{projectFileName}";
  3769. //}
  3770. //else if (TypeName == "B")//B代表商邀相关文件
  3771. //{
  3772. // //上传的文件的路径
  3773. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3774. // if (!Directory.Exists(filePath))
  3775. // {
  3776. // Directory.CreateDirectory(filePath);
  3777. // }
  3778. // //上传的文件的路径
  3779. // filePath = $@"\{projectFileName}";
  3780. //}
  3781. //try
  3782. //{
  3783. // using (FileStream fs = System.IO.File.Create(filePath))
  3784. // {
  3785. // file.CopyTo(fs);
  3786. // fs.Flush();
  3787. // }
  3788. //}
  3789. //catch (Exception ex)
  3790. //{
  3791. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3792. //}
  3793. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3794. try
  3795. {
  3796. var TypeName = Request.Headers["TypeName"].ToString();
  3797. if (file != null)
  3798. {
  3799. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3800. //文件名称
  3801. string projectFileName = file.FileName;
  3802. //上传的文件的路径
  3803. string filePath = $"{fileDir}/{projectFileName}";
  3804. if (TypeName == "A")//A代表团组增减款项
  3805. {
  3806. if (!Directory.Exists(fileDir))
  3807. {
  3808. Directory.CreateDirectory(fileDir);
  3809. }
  3810. //上传的文件的路径
  3811. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3812. }
  3813. else if (TypeName == "B")//B代表商邀相关文件
  3814. {
  3815. if (!Directory.Exists(fileDir))
  3816. {
  3817. Directory.CreateDirectory(fileDir);
  3818. }
  3819. //上传的文件的路径
  3820. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3821. }
  3822. using (FileStream fs = System.IO.File.Create(filePath))
  3823. {
  3824. file.CopyTo(fs);
  3825. fs.Flush();
  3826. }
  3827. return Ok(JsonView(true, "上传成功!", projectFileName));
  3828. }
  3829. else
  3830. {
  3831. return Ok(JsonView(false, "上传失败!"));
  3832. }
  3833. }
  3834. catch (Exception ex)
  3835. {
  3836. return Ok(JsonView(false, "程序错误!"));
  3837. }
  3838. }
  3839. /// <summary>
  3840. /// 删除指定文件
  3841. /// </summary>
  3842. /// <param name="dto"></param>
  3843. /// <returns></returns>
  3844. [HttpPost]
  3845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3846. public async Task<IActionResult> DelFile(DelFileDto dto)
  3847. {
  3848. try
  3849. {
  3850. var TypeName = Request.Headers["TypeName"].ToString();
  3851. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3852. string filePath = "";
  3853. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3854. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3855. int id = 0;
  3856. if (TypeName == "A")
  3857. {
  3858. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3859. // 删除该文件
  3860. System.IO.File.Delete(filePath);
  3861. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3862. .Where(a => a.Id == dto.Id)
  3863. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3864. .ExecuteCommandAsync();
  3865. }
  3866. else if (TypeName == "B")
  3867. {
  3868. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3869. // 删除该文件
  3870. System.IO.File.Delete(filePath);
  3871. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3872. if (info != null)
  3873. {
  3874. string[] files = new string[] { };
  3875. if (!string.IsNullOrEmpty(info.Attachment))
  3876. {
  3877. try
  3878. {
  3879. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3880. }
  3881. catch (Exception)
  3882. {
  3883. files = new List<string>() { info.Attachment }.ToArray();
  3884. }
  3885. }
  3886. if (files.Length > 0)
  3887. {
  3888. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3889. string filePath2 = string.Empty;
  3890. if (files1.Length > 0)
  3891. {
  3892. filePath2 = JsonConvert.SerializeObject(files1);
  3893. }
  3894. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3895. .Where(a => a.Id == dto.Id)
  3896. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3897. .ExecuteCommandAsync();
  3898. }
  3899. }
  3900. }
  3901. if (id != 0)
  3902. {
  3903. return Ok(JsonView(true, "成功!"));
  3904. }
  3905. else
  3906. {
  3907. return Ok(JsonView(false, "失败!"));
  3908. }
  3909. }
  3910. catch (Exception ex)
  3911. {
  3912. return Ok(JsonView(false, "程序错误!"));
  3913. throw;
  3914. }
  3915. }
  3916. /// <summary>
  3917. /// 文件上传多个文件 可以带参数
  3918. /// </summary>
  3919. /// <param name="files"></param>
  3920. /// <returns></returns>
  3921. [HttpPost]
  3922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3923. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3924. {
  3925. try
  3926. {
  3927. var TypeName = Request.Headers["TypeName"].ToString();
  3928. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3929. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3930. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3931. var filePahts = new List<string>();
  3932. foreach (var file in files)
  3933. {
  3934. //文件名称
  3935. string projectFileName = file.FileName;
  3936. //上传的文件的路径
  3937. string filePath = $"{fileDir}/{projectFileName}";
  3938. if (TypeName == "A")//A代表团组增减款项
  3939. {
  3940. if (!Directory.Exists(fileDir))
  3941. {
  3942. Directory.CreateDirectory(fileDir);
  3943. }
  3944. //上传的文件的路径
  3945. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3946. }
  3947. else if (TypeName == "B")//B代表商邀相关文件
  3948. {
  3949. if (!Directory.Exists(fileDir))
  3950. {
  3951. Directory.CreateDirectory(fileDir);
  3952. }
  3953. //上传的文件的路径
  3954. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3955. }
  3956. using (FileStream fs = System.IO.File.Create(filePath))
  3957. {
  3958. file.CopyTo(fs);
  3959. fs.Flush();
  3960. }
  3961. filePahts.Add(projectFileName);
  3962. }
  3963. return Ok(JsonView(true, "上传成功!", filePahts));
  3964. }
  3965. catch (Exception ex)
  3966. {
  3967. return Ok(JsonView(false, "程序错误!"));
  3968. }
  3969. }
  3970. #endregion
  3971. #region 商邀费用录入
  3972. /// <summary>
  3973. /// 根据团组Id查询商邀费用列表
  3974. /// </summary>
  3975. /// <param name="dto"></param>
  3976. /// <returns></returns>
  3977. [HttpPost]
  3978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3979. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3980. {
  3981. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3982. if (groupData.Code != 0)
  3983. {
  3984. return Ok(JsonView(false, groupData.Msg));
  3985. }
  3986. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3987. }
  3988. /// <summary>
  3989. /// 商邀费用列表
  3990. /// 下载文件
  3991. /// </summary>
  3992. /// <param name="id"></param>
  3993. /// <returns></returns>
  3994. [HttpGet("{id}")]
  3995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3996. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3997. {
  3998. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3999. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4000. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4001. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4002. var filePaths = new List<string>();
  4003. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4004. try
  4005. {
  4006. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4007. }
  4008. catch (Exception ex)
  4009. {
  4010. filePaths.Add(info.Attachment);
  4011. }
  4012. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4013. for (int i = 0; i < filePaths.Count; i++)
  4014. {
  4015. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4016. }
  4017. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4018. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4019. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4020. {
  4021. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4022. {
  4023. foreach (string filePath in filePaths)
  4024. {
  4025. if (System.IO.File.Exists(filePath))
  4026. {
  4027. // 获取文件名
  4028. string fileName = Path.GetFileName(filePath);
  4029. // 将文件添加到ZIP归档中
  4030. zipArchive.CreateEntryFromFile(filePath, fileName);
  4031. }
  4032. }
  4033. }
  4034. }
  4035. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4036. }
  4037. /// <summary>
  4038. /// 商邀费用 Info Page 基础数据源
  4039. /// </summary>
  4040. /// <returns></returns>
  4041. [HttpPost]
  4042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4043. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4044. {
  4045. try
  4046. {
  4047. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4048. if (groupData.Code != 0)
  4049. {
  4050. return Ok(JsonView(false, groupData.Msg));
  4051. }
  4052. return Ok(JsonView(true, "操作成功", groupData.Data));
  4053. }
  4054. catch (Exception ex)
  4055. {
  4056. return Ok(JsonView(false, ex.Message));
  4057. throw;
  4058. }
  4059. }
  4060. /// <summary>
  4061. /// 根据商邀费用ID查询C表和商邀费用数据
  4062. /// </summary>
  4063. /// <param name="dto"></param>
  4064. /// <returns></returns>
  4065. [HttpPost]
  4066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4067. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4068. {
  4069. try
  4070. {
  4071. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4072. if (groupData.Code != 0)
  4073. {
  4074. return Ok(JsonView(false, groupData.Msg));
  4075. }
  4076. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4077. }
  4078. catch (Exception ex)
  4079. {
  4080. return Ok(JsonView(false, ex.Message));
  4081. throw;
  4082. }
  4083. }
  4084. /// <summary>
  4085. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4086. /// </summary>
  4087. /// <param name="dto"></param>
  4088. /// <returns></returns>
  4089. [HttpPost]
  4090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4091. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4092. {
  4093. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4094. if (groupData.Code != 0)
  4095. {
  4096. return Ok(JsonView(false, groupData.Msg));
  4097. }
  4098. #region 应用推送
  4099. try
  4100. {
  4101. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4102. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4103. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4104. //2024-10-21 新增LZ UID
  4105. var userIds = new List<int>() { 21 };
  4106. string title = $"系统通知";
  4107. string content = "";
  4108. var diId = dto.DiId;
  4109. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4110. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4111. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4112. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4113. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4114. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4115. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4116. }
  4117. catch (Exception ex)
  4118. {
  4119. }
  4120. #endregion
  4121. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4122. }
  4123. /// <summary>
  4124. /// 商邀删除
  4125. /// </summary>
  4126. /// <param name="dto"></param>
  4127. /// <returns></returns>
  4128. [HttpPost]
  4129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4130. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4131. {
  4132. try
  4133. {
  4134. _sqlSugar.BeginTran();
  4135. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4136. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4137. {
  4138. IsDel = 1,
  4139. DeleteUserId = dto.DeleteUserId,
  4140. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4141. })
  4142. .Where(it => it.Id == dto.Id)
  4143. .ExecuteCommand();
  4144. if (res1 > 0)
  4145. {
  4146. int _diId = 0;
  4147. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4148. if (_ioaInfo != null)
  4149. {
  4150. _diId = _ioaInfo.DiId;
  4151. }
  4152. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4153. .SetColumns(a => new Grp_CreditCardPayment()
  4154. {
  4155. IsDel = 1,
  4156. DeleteUserId = dto.DeleteUserId,
  4157. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4158. })
  4159. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4160. .ExecuteCommand();
  4161. if (res2 > 0)
  4162. {
  4163. _sqlSugar.CommitTran();
  4164. return Ok(JsonView(true, "删除成功!"));
  4165. }
  4166. }
  4167. _sqlSugar.RollbackTran();
  4168. return Ok(JsonView(false, "删除失败"));
  4169. }
  4170. catch (Exception ex)
  4171. {
  4172. _sqlSugar.RollbackTran();
  4173. return Ok(JsonView(false, ex.Message));
  4174. }
  4175. }
  4176. /// <summary>
  4177. /// 团组模块文件上传
  4178. /// </summary>
  4179. /// <param name="dto"></param>
  4180. /// <returns></returns>
  4181. [HttpPost]
  4182. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4183. {
  4184. var jw = JsonView(false);
  4185. long M = 1024 * 1024;
  4186. if (dto.Files == null || dto.Files.Count == 0)
  4187. {
  4188. jw.Msg = "无文件信息!";
  4189. return Ok(jw);
  4190. }
  4191. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4192. {
  4193. jw.Msg = "文件大小超过20M!";
  4194. return Ok(jw);
  4195. }
  4196. //var nameSp = dto.File.FileName.Split(".");
  4197. //if (nameSp.Length < 2)
  4198. //{
  4199. // jw.Msg = "拓展名称有误!";
  4200. // return Ok(jw);
  4201. //}
  4202. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4203. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4204. //{
  4205. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4206. // return Ok(jw);
  4207. //}
  4208. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4209. if (Ctable == null)
  4210. {
  4211. jw.Msg = "Ctable指向有误!";
  4212. return Ok(jw);
  4213. }
  4214. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4215. if (groupInfo == null)
  4216. {
  4217. jw.Msg = "团组信息不存在!";
  4218. return Ok(jw);
  4219. }
  4220. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4221. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4222. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4223. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4224. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4225. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4226. try
  4227. {
  4228. if (!Directory.Exists(fileBase))
  4229. {
  4230. Directory.CreateDirectory(fileBase);
  4231. }
  4232. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4233. foreach (var fileStream in dto.Files)
  4234. {
  4235. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4236. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4237. {
  4238. Cid = dto.Cid,
  4239. CreateTime = DateTime.Now,
  4240. CreateUserId = dto.Userid,
  4241. Ctable = dto.Ctable,
  4242. Diid = dto.Diid,
  4243. IsDel = 0,
  4244. FilePath = saveFilePath,
  4245. FileName = fileStream.FileName
  4246. };
  4247. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4248. {
  4249. fileStream.CopyTo(fs);
  4250. fs.Flush();
  4251. }
  4252. saveArr.Add(file);
  4253. }
  4254. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4255. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4256. jw = JsonView(true, "保存成功!", new
  4257. {
  4258. count = addResult,
  4259. filesName = saveArr.Select(x => x.FileName)
  4260. });
  4261. }
  4262. catch (Exception ex)
  4263. {
  4264. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4265. {
  4266. count = 0,
  4267. filesName = new string[0],
  4268. });
  4269. }
  4270. return Ok(jw);
  4271. }
  4272. /// <summary>
  4273. /// 查询各模块已保存文件
  4274. /// </summary>
  4275. /// <param name="dto"></param>
  4276. /// <returns></returns>
  4277. [HttpPost]
  4278. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4279. {
  4280. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4281. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4282. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4283. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4284. {
  4285. expression = Expressionable.Create<Grp_GroupModelFile>()
  4286. .And(x => visaIds.Contains(x.CreateUserId));
  4287. }
  4288. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4289. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4290. .Where(expression.ToExpression())
  4291. .ToList();
  4292. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4293. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4294. {
  4295. x.FileName,
  4296. x.Id,
  4297. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4298. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4299. })));
  4300. }
  4301. /// <summary>
  4302. /// 下载该团组下的所有文件
  4303. /// </summary>
  4304. /// <param name="dto"></param>
  4305. /// <returns></returns>
  4306. [HttpPost]
  4307. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4308. {
  4309. var jw = JsonView(false);
  4310. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4311. if (groupInfo == null)
  4312. {
  4313. jw.Msg = "团组信息不存在!";
  4314. return Ok(jw);
  4315. }
  4316. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4317. var isModule = Convert.ToBoolean(dto.isModule);
  4318. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4319. IOOperatorHelper io = new IOOperatorHelper();
  4320. if (isModule)
  4321. {
  4322. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4323. foreach (var moduleArr in moduleGroup)
  4324. {
  4325. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4326. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4327. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4328. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4329. foreach (var item in moduleArr)
  4330. {
  4331. if (System.IO.File.Exists(item.FilePath))
  4332. {
  4333. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4334. {
  4335. byte[] bytes = new byte[fileStream.Length];
  4336. fileStream.Read(bytes, 0, bytes.Length);
  4337. fileStream.Close();
  4338. Stream stream = new MemoryStream(bytes);
  4339. chiZips.Add(item.FileName, stream);
  4340. }
  4341. }
  4342. }
  4343. if (chiZips.Count > 0)
  4344. {
  4345. var byts = io.ConvertZipStream(chiZips);
  4346. Stream stream = new MemoryStream(byts);
  4347. Zips.Add(key.Name + "_.zip", stream);
  4348. }
  4349. }
  4350. }
  4351. else
  4352. {
  4353. foreach (var item in dbQuery)
  4354. {
  4355. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4356. {
  4357. byte[] bytes = new byte[fileStream.Length];
  4358. fileStream.Read(bytes, 0, bytes.Length);
  4359. fileStream.Close();
  4360. Stream stream = new MemoryStream(bytes);
  4361. while (Zips.Keys.Contains(item.FileName))
  4362. {
  4363. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4364. }
  4365. Zips.Add(item.FileName, stream);
  4366. }
  4367. }
  4368. }
  4369. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4370. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4371. if (Zips.Count > 0)
  4372. {
  4373. var byts = io.ConvertZipStream(Zips);
  4374. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4375. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4376. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4377. }
  4378. else
  4379. {
  4380. jw.Msg = "暂无生成文件!";
  4381. }
  4382. return Ok(jw);
  4383. }
  4384. /// <summary>
  4385. /// 下载该团组下此模块的所有文件
  4386. /// </summary>
  4387. /// <param name="dto"></param>
  4388. /// <returns></returns>
  4389. [HttpPost]
  4390. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4391. {
  4392. var jw = JsonView(false);
  4393. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4394. if (groupInfo == null)
  4395. {
  4396. jw.Msg = "团组信息不存在!";
  4397. return Ok(jw);
  4398. }
  4399. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4400. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4401. && x.IsDel == 0);
  4402. if (key == null)
  4403. {
  4404. jw.Msg = "Ctable指向错误!";
  4405. return Ok(jw);
  4406. }
  4407. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4408. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4409. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4410. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4411. IOOperatorHelper io = new IOOperatorHelper();
  4412. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4413. foreach (var item in dbQuery)
  4414. {
  4415. if (System.IO.File.Exists(item.FilePath))
  4416. {
  4417. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4418. {
  4419. byte[] bytes = new byte[fileStream.Length];
  4420. fileStream.Read(bytes, 0, bytes.Length);
  4421. fileStream.Close();
  4422. Stream stream = new MemoryStream(bytes);
  4423. while (Zips.Keys.Contains(item.FileName))
  4424. {
  4425. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4426. }
  4427. Zips.Add(item.FileName, stream);
  4428. }
  4429. }
  4430. }
  4431. if (Zips.Count > 0)
  4432. {
  4433. var byts = io.ConvertZipStream(Zips);
  4434. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4435. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4436. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4437. }
  4438. else
  4439. {
  4440. jw.Msg = "暂无生成文件!";
  4441. }
  4442. return Ok(jw);
  4443. }
  4444. /// <summary>
  4445. /// 删除该团组下的指定文件
  4446. /// </summary>
  4447. /// <param name="dto"></param>
  4448. /// <returns></returns>
  4449. [HttpPost]
  4450. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4451. {
  4452. var jw = JsonView(false);
  4453. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4454. if (sing == null)
  4455. {
  4456. jw.Msg = "暂无";
  4457. return Ok(jw);
  4458. }
  4459. if (System.IO.File.Exists(sing.FilePath))
  4460. {
  4461. try
  4462. {
  4463. System.IO.File.Delete(sing.FilePath);
  4464. }
  4465. catch (Exception ex)
  4466. {
  4467. jw.Msg = "删除失败!" + ex.Message;
  4468. return Ok(jw);
  4469. }
  4470. }
  4471. sing.IsDel = 1;
  4472. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4473. sing.DeleteUserId = dto.UserId;
  4474. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4475. jw = JsonView(true, "删除成功!");
  4476. return Ok(jw);
  4477. }
  4478. #endregion
  4479. #region 团组英文资料
  4480. /// <summary>
  4481. /// 查询团组英文所有资料
  4482. /// </summary>
  4483. /// <param name="dto"></param>
  4484. /// <returns></returns>
  4485. [HttpPost]
  4486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4487. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4488. {
  4489. try
  4490. {
  4491. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4492. if (groupData.Code != 0)
  4493. {
  4494. return Ok(JsonView(false, groupData.Msg));
  4495. }
  4496. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4497. }
  4498. catch (Exception ex)
  4499. {
  4500. return Ok(JsonView(false, "程序错误!"));
  4501. throw;
  4502. }
  4503. }
  4504. /// <summary>
  4505. /// 团组英文资料操作(Status:1.新增,2.修改)
  4506. /// </summary>
  4507. /// <param name="dto"></param>
  4508. /// <returns></returns>
  4509. [HttpPost]
  4510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4511. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4512. {
  4513. try
  4514. {
  4515. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4516. if (groupData.Code != 0)
  4517. {
  4518. return Ok(JsonView(false, groupData.Msg));
  4519. }
  4520. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4521. }
  4522. catch (Exception ex)
  4523. {
  4524. return Ok(JsonView(false, "程序错误!"));
  4525. throw;
  4526. }
  4527. }
  4528. /// <summary>
  4529. /// 团组英文资料Id查询数据
  4530. /// </summary>
  4531. /// <param name="dto"></param>
  4532. /// <returns></returns>
  4533. [HttpPost]
  4534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4535. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4536. {
  4537. try
  4538. {
  4539. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4540. if (_DelegationEnData != null)
  4541. {
  4542. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4543. }
  4544. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4545. }
  4546. catch (Exception ex)
  4547. {
  4548. return Ok(JsonView(false, "程序错误!"));
  4549. throw;
  4550. }
  4551. }
  4552. /// <summary>
  4553. /// 团组英文资料删除
  4554. /// </summary>
  4555. /// <param name="dto"></param>
  4556. /// <returns></returns>
  4557. [HttpPost]
  4558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4559. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4560. {
  4561. try
  4562. {
  4563. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4564. if (!res)
  4565. {
  4566. return Ok(JsonView(false, "删除失败"));
  4567. }
  4568. return Ok(JsonView(true, "删除成功!"));
  4569. }
  4570. catch (Exception ex)
  4571. {
  4572. return Ok(JsonView(false, "程序错误!"));
  4573. throw;
  4574. }
  4575. }
  4576. #endregion
  4577. #region 导出邀请函
  4578. /// <summary>
  4579. /// 导出邀请函页面初始化
  4580. /// </summary>
  4581. /// <param name="dto"></param>
  4582. /// <returns></returns>
  4583. [HttpPost]
  4584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4585. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4586. {
  4587. try
  4588. {
  4589. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4590. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4591. if (dto.DiId == 0)
  4592. {
  4593. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4594. }
  4595. else
  4596. {
  4597. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4598. }
  4599. return Ok(JsonView(true, "查询成功!", new
  4600. {
  4601. deleClient = crm_Deles,
  4602. delegations = grp_Delegations
  4603. }));
  4604. }
  4605. catch (Exception ex)
  4606. {
  4607. return Ok(JsonView(false, "程序错误!"));
  4608. throw;
  4609. }
  4610. }
  4611. /// <summary>
  4612. /// 导出邀请函
  4613. /// </summary>
  4614. /// <param name="dto"></param>
  4615. /// <returns></returns>
  4616. [HttpPost]
  4617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4618. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4619. {
  4620. #region 参数验证
  4621. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4622. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4623. #endregion
  4624. try
  4625. {
  4626. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4627. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4628. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4629. From Grp_TourClientList tcl
  4630. Left Join
  4631. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4632. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4633. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4634. From Crm_DeleClient dc
  4635. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4636. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4637. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4638. Where dc.IsDel = 0) temp
  4639. On temp.DcId =tcl.ClientId
  4640. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4641. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4642. List<string> texts = new List<string>();
  4643. if (datas.Count != 0)
  4644. {
  4645. foreach (TourClientListDetailsView item in datas)
  4646. {
  4647. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4648. {
  4649. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4650. }
  4651. else
  4652. {
  4653. string name = item.LastName + item.FirstName;
  4654. texts.Add(name);
  4655. }
  4656. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4657. {
  4658. if (!transDic.ContainsKey(item.Job))
  4659. {
  4660. texts.Add(item.Job);
  4661. }
  4662. }
  4663. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4664. {
  4665. texts.Add(item.CompanyFullName);
  4666. }
  4667. }
  4668. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4669. if (transData.Count > 0)
  4670. {
  4671. foreach (TranslateResult item in transData)
  4672. {
  4673. if (!transDic.ContainsKey(item.Query))
  4674. {
  4675. transDic.Add(item.Query, item.Translation);
  4676. }
  4677. }
  4678. }
  4679. List<GuestList> list = new List<GuestList>();
  4680. foreach (TourClientListDetailsView dele in datas)
  4681. {
  4682. GuestList guestList = new GuestList();
  4683. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4684. {
  4685. guestList.Name = dele.Pinyin;
  4686. }
  4687. else
  4688. {
  4689. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4690. guestList.Name = Name;
  4691. }
  4692. if (dele.Sex == 0)
  4693. {
  4694. guestList.Sex = "Male";
  4695. }
  4696. else if (dele.Sex == 1)
  4697. {
  4698. guestList.Sex = "Female";
  4699. }
  4700. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4701. if (!string.IsNullOrEmpty(dele.Job))
  4702. {
  4703. guestList.Job = dele.Job;
  4704. }
  4705. list.Add(guestList);
  4706. }
  4707. //载入模板
  4708. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4709. DocumentBuilder builder = new DocumentBuilder(doc);
  4710. //获取word里所有表格
  4711. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4712. //获取所填表格的序数
  4713. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4714. var rowStart = tableOne.Rows[0]; //获取第1行
  4715. //循环赋值
  4716. for (int i = 0; i < list.Count; i++)
  4717. {
  4718. builder.MoveToCell(0, i + 1, 0, 0);
  4719. builder.Write(list[i].Name.ToString());
  4720. builder.MoveToCell(0, i + 1, 1, 0);
  4721. builder.Write(list[i].Sex.ToString());
  4722. builder.MoveToCell(0, i + 1, 2, 0);
  4723. builder.Write(list[i].DOB.ToString());
  4724. builder.MoveToCell(0, i + 1, 3, 0);
  4725. builder.Write(list[i].Job.ToString());
  4726. }
  4727. //删除多余行
  4728. while (tableOne.Rows.Count > list.Count + 1)
  4729. {
  4730. tableOne.Rows.RemoveAt(list.Count + 1);
  4731. }
  4732. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4733. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4734. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4735. doc.Save(filePath);
  4736. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4737. return Ok(JsonView(true, "操作成功!", Url));
  4738. }
  4739. else
  4740. {
  4741. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4742. }
  4743. }
  4744. catch (Exception ex)
  4745. {
  4746. return Ok(JsonView(false, ex.Message));
  4747. throw;
  4748. }
  4749. }
  4750. #endregion
  4751. #region 团组经理模块 出入境费用
  4752. /// <summary>
  4753. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4754. /// </summary>
  4755. /// <returns></returns>
  4756. [HttpPost]
  4757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4758. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4759. {
  4760. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4761. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4762. //SetDataInfoView
  4763. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4764. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4765. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4766. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4767. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4768. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4769. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4770. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4771. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4772. return Ok(JsonView(true, "查询成功!", new
  4773. {
  4774. GroupNameData = groupNameData.Data,
  4775. CurrencyData = _CurrencyData,
  4776. WordTypeData = _WordTypeData,
  4777. ExcelTypeData = _ExcelTypeData,
  4778. CurrencyInit = _currencyInfos,
  4779. ViewPermissionData = viewPermissionData
  4780. }));
  4781. }
  4782. /// <summary>
  4783. /// 团组模块 - 出入境费用
  4784. /// 实时汇率 tips
  4785. /// 签证费用 tips
  4786. /// 机票费用 tips
  4787. /// </summary>
  4788. /// <returns></returns>
  4789. [HttpPost]
  4790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4791. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4792. {
  4793. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4794. //默认币种显示
  4795. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4796. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4797. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4798. return Ok(JsonView(true, "查询成功!", new
  4799. {
  4800. //GroupNameData = groupNameData.Data,
  4801. visaData = visaData.Data,
  4802. airData = airData.Data,
  4803. reteInfos = reteInfos
  4804. }));
  4805. }
  4806. /// <summary>
  4807. /// 团组模块 - 出入境费用 - Info
  4808. /// </summary>
  4809. /// <returns></returns>
  4810. [HttpPost]
  4811. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4813. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4814. {
  4815. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4816. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4817. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4818. }
  4819. /// <summary>
  4820. /// 团组模块 - 出入境费用 - 设置view权限
  4821. /// </summary>
  4822. /// <returns></returns>
  4823. [HttpPost]
  4824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4825. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4826. {
  4827. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4828. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4829. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4830. var permissions = new List<Grp_EnterExitCostPermission>();
  4831. foreach (var userId in dto.UserIds)
  4832. {
  4833. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4834. }
  4835. if (permissions.Any())
  4836. {
  4837. _sqlSugar.BeginTran();
  4838. try
  4839. {
  4840. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4841. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4842. if (result < 1)
  4843. {
  4844. _sqlSugar.RollbackTran();
  4845. return Ok(JsonView(false));
  4846. }
  4847. }
  4848. catch (Exception ex)
  4849. {
  4850. _sqlSugar.RollbackTran();
  4851. return Ok(JsonView(false, ex.Message));
  4852. }
  4853. _sqlSugar.CommitTran();
  4854. return Ok(JsonView(true));
  4855. }
  4856. return Ok(JsonView(false));
  4857. }
  4858. /// <summary>
  4859. /// 团组模块 - 出入境费用 - Add And Update
  4860. /// </summary>
  4861. /// <returns></returns>
  4862. [HttpPost]
  4863. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4865. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4866. {
  4867. try
  4868. {
  4869. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4870. if (dto.DayOtherPriceData.Any())
  4871. {
  4872. var inserList = dto.DayOtherPriceData
  4873. .Where(x => x.Id == 0)
  4874. .Select(x => new Grp_DayOtherPrice
  4875. {
  4876. Cost = x.Cost,
  4877. Id = x.Id,
  4878. CreateTime = DateTime.Now,
  4879. CreateUserId = dto.UserId,
  4880. Currency = x.Currency,
  4881. Diid = x.DiId,
  4882. Index = x.Index,
  4883. IsDel = 0,
  4884. SetDataId = x.SetDataId,
  4885. SubTotal = x.SubTotal,
  4886. Remark = x.Remark
  4887. })
  4888. .ToList();
  4889. var updateList = dto.DayOtherPriceData
  4890. .Where(x => x.Id != 0)
  4891. .Select(x => new Grp_DayOtherPrice
  4892. {
  4893. Cost = x.Cost,
  4894. Id = x.Id,
  4895. CreateTime = DateTime.Now,
  4896. CreateUserId = dto.UserId,
  4897. Currency = x.Currency,
  4898. Diid = x.DiId,
  4899. Index = x.Index,
  4900. IsDel = 0,
  4901. SetDataId = x.SetDataId,
  4902. SubTotal = x.SubTotal,
  4903. Remark = x.Remark
  4904. })
  4905. .ToList();
  4906. //添加
  4907. _sqlSugar.BeginTran();
  4908. if (inserList.Any())
  4909. {
  4910. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4911. }
  4912. if (updateList.Any())
  4913. {
  4914. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4915. }
  4916. _sqlSugar.CommitTran();
  4917. }
  4918. if (data.Code != 0)
  4919. {
  4920. return Ok(JsonView(false, data.Msg));
  4921. }
  4922. //生成默认文件pdf并且通知人员
  4923. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4924. {
  4925. DiId = dto.DiId,
  4926. ExportType = 1,
  4927. SubTypeId = 1005
  4928. }, "pdf");
  4929. //发送通知
  4930. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4931. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4932. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4933. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4934. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4935. //汇率信息记录
  4936. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4937. return Ok(JsonView(true, data.Msg, data.Data));
  4938. }
  4939. catch (Exception ex)
  4940. {
  4941. return Ok(JsonView(false, ex.Message));
  4942. }
  4943. }
  4944. /// <summary>
  4945. /// 团组模块 - 出入境费用 - Confirm 费用
  4946. /// </summary>
  4947. /// <returns></returns>
  4948. [HttpPost]
  4949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4950. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4951. {
  4952. //TODO:测试完毕需把对应的用户ID更改
  4953. //1、数据表添加字段
  4954. //2、更改字段接口()
  4955. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4956. //3、确认成功 给财务发送消息
  4957. if (_view.Code == 200)
  4958. {
  4959. if (dto.Type == 1)
  4960. {
  4961. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4962. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4963. }
  4964. }
  4965. return Ok(_view);
  4966. }
  4967. /// <summary>
  4968. /// 团组模块 - 出入境费用 - File download
  4969. /// </summary>
  4970. /// <param name="dto"></param>
  4971. /// <returns></returns>
  4972. [HttpPost]
  4973. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  4974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4975. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4976. {
  4977. try
  4978. {
  4979. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4980. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4981. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4982. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4983. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4984. 3 团组成员名单 1 团组成员名单", ""));
  4985. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4986. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4987. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4988. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  4989. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  4990. //数据源
  4991. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4992. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4993. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4994. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4995. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4996. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4997. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4998. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4999. .Select((x, a, b) => new
  5000. {
  5001. x.Index,
  5002. itemName = a.Name,
  5003. CurrencyStr = b.Name,
  5004. x.Cost,
  5005. x.SubTotal,
  5006. x.Remark
  5007. })
  5008. .OrderBy((x) => x.Index)
  5009. .ToList(); //其他款项费用
  5010. var peiceItemCurrencys = new List<string>();
  5011. if (_DayAndCosts.Any())
  5012. {
  5013. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5014. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5015. }
  5016. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5017. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5018. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5019. {
  5020. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5021. }
  5022. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5023. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5024. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5025. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5026. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5027. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5028. .Select((tcl, dc, cc) => new ClientInfo
  5029. {
  5030. LastName = dc.LastName,
  5031. FirstName = dc.FirstName,
  5032. Sex = dc.Sex,
  5033. Birthday = dc.BirthDay,
  5034. Company = cc.CompanyFullName,
  5035. Job = dc.Job
  5036. })
  5037. .ToList();
  5038. foreach (var item in DeleClientList)
  5039. {
  5040. EncryptionProcessor.DecryptProperties(item);
  5041. }
  5042. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5043. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5044. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5045. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5046. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5047. if (dto.ExportType == 1) //明细表
  5048. {
  5049. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5050. {
  5051. //获取模板
  5052. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5053. //载入模板
  5054. Document doc = new Document(tempPath);
  5055. DocumentBuilder builder = new DocumentBuilder(doc);
  5056. //利用键值对存放数据
  5057. Dictionary<string, string> dic = new Dictionary<string, string>();
  5058. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5059. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5060. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5061. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5062. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5063. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5064. //境内费用(其他费用)
  5065. if (_EnterExitCosts.ChoiceOne == 1)
  5066. {
  5067. string row1_1 = "";
  5068. if (_EnterExitCosts.Visa > 0)
  5069. {
  5070. //insidePayTotal += _EnterExitCosts.Visa;
  5071. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5072. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5073. {
  5074. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5075. }
  5076. }
  5077. string row1_2 = "";
  5078. if (_EnterExitCosts.YiMiao > 0)
  5079. {
  5080. //insidePayTotal += _EnterExitCosts.YiMiao;
  5081. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5082. }
  5083. if (_EnterExitCosts.HeSuan > 0)
  5084. {
  5085. //insidePayTotal += _EnterExitCosts.HeSuan;
  5086. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5087. }
  5088. if (_EnterExitCosts.Service > 0)
  5089. {
  5090. //insidePayTotal += _EnterExitCosts.Service;
  5091. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5092. }
  5093. string row1_3 = "";
  5094. if (_EnterExitCosts.Safe > 0)
  5095. {
  5096. //insidePayTotal += _EnterExitCosts.Safe;
  5097. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5098. }
  5099. if (_EnterExitCosts.Ticket > 0)
  5100. {
  5101. //insidePayTotal += _EnterExitCosts.Ticket;
  5102. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5103. }
  5104. string row1 = "";
  5105. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5106. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5107. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5108. row1 += $"备注:{_EnterExitCosts.Remark}";
  5109. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5110. dic.Add("Row1Str", row1);
  5111. }
  5112. string airTotalStr = string.Empty,
  5113. airPriceStr = string.Empty;
  5114. //经济舱
  5115. if (_EnterExitCosts.SumJJC == 1)
  5116. {
  5117. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5118. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5119. }
  5120. //公务舱
  5121. if (_EnterExitCosts.SumGWC == 1)
  5122. {
  5123. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5124. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5125. }
  5126. //头等舱
  5127. if (_EnterExitCosts.SumTDC == 1)
  5128. {
  5129. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5130. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5131. }
  5132. //汇率描述
  5133. string rateStr = "";
  5134. if (peiceItemCurrencyInfos.Any())
  5135. {
  5136. rateStr = "\r\n汇率描述:";
  5137. foreach (var item in peiceItemCurrencyInfos)
  5138. {
  5139. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5140. }
  5141. }
  5142. string twoItemRemark = "备注:";
  5143. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5144. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5145. dic.Add("AirTotalStr", airTotalStr);
  5146. dic.Add("AirPriceStr", airPriceStr);
  5147. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5148. dic.Add("TwoItemRemark", twoItemRemark);
  5149. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5150. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5151. int table1Row = 0,
  5152. table2Row = 0,
  5153. table3Row = 0,
  5154. table4Row = 0,
  5155. table5Row = 0;
  5156. //住宿费
  5157. if (_EnterExitCosts.ChoiceThree == 1)
  5158. {
  5159. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5160. table1Row = dac1.Count;
  5161. #region 填充word表格内容
  5162. for (int i = 0; i < dac1.Count; i++)
  5163. {
  5164. Grp_DayAndCost dac = dac1[i];
  5165. if (dac == null) continue;
  5166. builder.MoveToCell(0, i, 0, 0);
  5167. builder.Write("第" + dac.Days.ToString() + "晚:");
  5168. builder.MoveToCell(0, i, 1, 0);
  5169. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5170. //builder.Write(dac.Place == null ? "" : dac.Place);
  5171. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5172. builder.MoveToCell(0, i, 2, 0);
  5173. builder.Write("费用标准:");
  5174. string curr = "";
  5175. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5176. if (currData != null)
  5177. {
  5178. curr = currData.Name;
  5179. }
  5180. builder.MoveToCell(0, i, 3, 0);
  5181. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5182. builder.MoveToCell(0, i, 4, 0);
  5183. builder.Write("费用小计:");
  5184. builder.MoveToCell(0, i, 5, 0);
  5185. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5186. }
  5187. #endregion
  5188. }
  5189. else dic.Add("SubZS", "0.00");
  5190. //删除多余行
  5191. while (table1.Rows.Count > table1Row)
  5192. {
  5193. table1.Rows.RemoveAt(table1Row);
  5194. }
  5195. //伙食费
  5196. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5197. if (_EnterExitCosts.ChoiceFour == 1)
  5198. {
  5199. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5200. table2Row = dac2.Count;
  5201. #region 填充word表格内容
  5202. for (int i = 0; i < dac2.Count; i++)
  5203. {
  5204. Grp_DayAndCost dac = dac2[i];
  5205. if (dac == null) continue;
  5206. builder.MoveToCell(1, i, 0, 0);
  5207. builder.Write("第" + dac.Days.ToString() + "天:");
  5208. builder.MoveToCell(1, i, 1, 0);
  5209. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5210. builder.MoveToCell(1, i, 2, 0);
  5211. builder.Write("费用标准:");
  5212. string curr = "";
  5213. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5214. if (currData != null)
  5215. {
  5216. curr = currData.Name;
  5217. }
  5218. builder.MoveToCell(1, i, 3, 0);
  5219. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5220. builder.MoveToCell(1, i, 4, 0);
  5221. builder.Write("费用小计:");
  5222. builder.MoveToCell(1, i, 5, 0);
  5223. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5224. }
  5225. #endregion
  5226. }
  5227. else dic.Add("SubHS", "0.00");
  5228. //删除多余行
  5229. while (table2.Rows.Count > table2Row)
  5230. {
  5231. table2.Rows.RemoveAt(table2Row);
  5232. }
  5233. //公杂费
  5234. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5235. if (_EnterExitCosts.ChoiceFive == 1)
  5236. {
  5237. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5238. table3Row = dac3.Count;
  5239. #region 填充word表格内容
  5240. for (int i = 0; i < dac3.Count; i++)
  5241. {
  5242. Grp_DayAndCost dac = dac3[i];
  5243. if (dac == null) continue;
  5244. builder.MoveToCell(2, i, 0, 0);
  5245. builder.Write("第" + dac.Days.ToString() + "天:");
  5246. builder.MoveToCell(2, i, 1, 0);
  5247. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5248. builder.MoveToCell(2, i, 2, 0);
  5249. builder.Write("费用标准:");
  5250. string curr = "";
  5251. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5252. if (currData != null)
  5253. {
  5254. curr = currData.Name;
  5255. }
  5256. builder.MoveToCell(2, i, 3, 0);
  5257. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5258. builder.MoveToCell(2, i, 4, 0);
  5259. builder.Write("费用小计:");
  5260. builder.MoveToCell(2, i, 5, 0);
  5261. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5262. }
  5263. //删除多余行
  5264. while (table3.Rows.Count > table3Row)
  5265. {
  5266. table3.Rows.RemoveAt(table3Row);
  5267. }
  5268. #endregion
  5269. }
  5270. else dic.Add("SubGZF", "0.00");
  5271. //删除多余行
  5272. while (table3.Rows.Count > table3Row)
  5273. {
  5274. table3.Rows.RemoveAt(table3Row);
  5275. }
  5276. //培训费
  5277. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5278. if (_EnterExitCosts.ChoiceSix == 1)
  5279. {
  5280. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5281. dic.Add("SubPX", pxStr);
  5282. table4Row = dac4.Count;
  5283. #region 填充word表格内容
  5284. for (int i = 0; i < dac4.Count; i++)
  5285. {
  5286. Grp_DayAndCost dac = dac4[i];
  5287. if (dac == null) continue;
  5288. builder.MoveToCell(3, i, 0, 0);
  5289. builder.Write("第" + dac.Days.ToString() + "天:");
  5290. builder.MoveToCell(3, i, 1, 0);
  5291. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5292. builder.MoveToCell(3, i, 2, 0);
  5293. builder.Write("费用标准:");
  5294. string curr = "";
  5295. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5296. if (currData != null)
  5297. {
  5298. curr = currData.Name;
  5299. }
  5300. builder.MoveToCell(3, i, 3, 0);
  5301. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5302. builder.MoveToCell(3, i, 4, 0);
  5303. builder.Write("费用小计:");
  5304. builder.MoveToCell(3, i, 5, 0);
  5305. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5306. }
  5307. #endregion
  5308. }
  5309. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5310. //删除多余行
  5311. while (table4.Rows.Count > table4Row)
  5312. {
  5313. table4.Rows.RemoveAt(table4Row);
  5314. }
  5315. //其他费用
  5316. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5317. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5318. {
  5319. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5320. dic.Add("titleQi", qtStr);
  5321. table5Row = dac5.Count;
  5322. #region 填充word表格内容
  5323. for (int i = 0; i < dac5.Count; i++)
  5324. {
  5325. var dac = dac5[i];
  5326. if (dac == null) continue;
  5327. builder.MoveToCell(4, i, 0, 0);
  5328. builder.Write("第" + dac.Index.ToString() + "项:");
  5329. builder.MoveToCell(4, i, 1, 0);
  5330. builder.Write(dac.itemName);
  5331. builder.MoveToCell(4, i, 2, 0);
  5332. builder.Write("费用标准:");
  5333. builder.MoveToCell(4, i, 3, 0);
  5334. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5335. builder.MoveToCell(4, i, 4, 0);
  5336. builder.Write("费用小计:");
  5337. builder.MoveToCell(4, i, 5, 0);
  5338. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5339. builder.MoveToCell(4, i, 6, 0);
  5340. builder.Write("备注:");
  5341. builder.MoveToCell(4, i, 7, 0);
  5342. builder.Write(dac.Remark);
  5343. }
  5344. #endregion
  5345. }
  5346. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5347. //删除多余行
  5348. while (table5.Rows.Count > table5Row)
  5349. {
  5350. table5.Rows.RemoveAt(table5Row);
  5351. }
  5352. //加上其他费用
  5353. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5354. decimal subJJC = 0.00M,
  5355. subGWC = 0.00M,
  5356. subTDC = 0.00M;
  5357. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5358. string totalLabel = string.Format("全部费用总计:");
  5359. //经济舱
  5360. if (_EnterExitCosts.SumJJC == 1)
  5361. {
  5362. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5363. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5364. }
  5365. //公务舱
  5366. if (_EnterExitCosts.SumGWC == 1) {
  5367. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5368. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5369. }
  5370. //头等舱
  5371. if (_EnterExitCosts.SumTDC == 1)
  5372. {
  5373. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5374. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5375. }
  5376. //TotalLabel
  5377. dic.Add("TotalLabel", totalLabel);
  5378. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5379. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5380. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5381. #region 填充word模板书签内容
  5382. foreach (var key in dic.Keys)
  5383. {
  5384. Bookmark bookmark = doc.Range.Bookmarks[key];
  5385. if (bookmark != null)
  5386. {
  5387. builder.MoveToBookmark(key);
  5388. builder.Write(dic[key]);
  5389. }
  5390. }
  5391. #endregion
  5392. #region 设置页眉
  5393. string userLabel = string.Empty;
  5394. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5395. if (currUserInfo != null)
  5396. {
  5397. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5398. if (userInfo != null)
  5399. {
  5400. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5401. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5402. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5403. }
  5404. }
  5405. //设置页脚
  5406. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5407. #endregion
  5408. //文件名
  5409. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5410. AsposeHelper.removewatermark_v2180();
  5411. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5412. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5413. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5414. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5415. }
  5416. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5417. {
  5418. //获取模板
  5419. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5420. //载入模板
  5421. Document doc = new Document(tempPath);
  5422. DocumentBuilder builder = new DocumentBuilder(doc);
  5423. Dictionary<string, string> dic = new Dictionary<string, string>();
  5424. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5425. {
  5426. List<string> list = new List<string>();
  5427. try
  5428. {
  5429. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5430. foreach (var item in spilitArr)
  5431. {
  5432. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5433. var depCode = spDotandEmpty[2].Substring(0, 3);
  5434. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5435. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5436. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5437. list.Add(depName);
  5438. list.Add(arrName);
  5439. }
  5440. list = list.Distinct().ToList();
  5441. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5442. }
  5443. catch (Exception)
  5444. {
  5445. dic.Add("ReturnCode", "行程录入不正确!");
  5446. }
  5447. }
  5448. else
  5449. {
  5450. dic.Add("ReturnCode", "未录入行程!");
  5451. }
  5452. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5453. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5454. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5455. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5456. {
  5457. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5458. dic.Add("Day", sp.Days.ToString());
  5459. }
  5460. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5461. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5462. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5463. //dic.Add("Names", Names);
  5464. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5465. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5466. decimal dac1totalPrice = 0.00M;
  5467. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5468. foreach (var dac in dac1)
  5469. {
  5470. if (dac.SubTotal == 0.00M)
  5471. {
  5472. continue;
  5473. }
  5474. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5475. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5476. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5477. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5478. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5479. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5480. builder.Write(currency);//币种
  5481. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5482. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5483. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5484. builder.Write("");//人数
  5485. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5486. builder.Write("");//天数
  5487. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5488. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5489. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5490. decimal rate = 0.00M;
  5491. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5492. builder.Write(rate.ToString("#0.0000"));//汇率
  5493. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5494. decimal rbmPrice = dac.SubTotal;
  5495. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5496. accommodationStartIndex++;
  5497. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5498. }
  5499. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5500. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5501. {
  5502. table1.Rows.RemoveAt(i - 1);
  5503. foodandotherStartIndex--;
  5504. }
  5505. if (dac2.Count == dac3.Count)//国家 币种 金额
  5506. {
  5507. for (int i = 0; i < dac2.Count; i++)
  5508. {
  5509. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5510. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5511. }
  5512. }
  5513. decimal dac2totalPrice = 0.00M;
  5514. foreach (var dac in dac2)
  5515. {
  5516. if (dac.SubTotal == 0)
  5517. {
  5518. continue;
  5519. }
  5520. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5521. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5522. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5523. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5524. builder.Write(currency);//币种
  5525. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5526. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5527. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5528. builder.Write("");//人数
  5529. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5530. builder.Write("");//天数
  5531. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5532. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5533. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5534. decimal rate = 0.00M;
  5535. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5536. builder.Write(rate.ToString("#0.0000"));//汇率
  5537. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5538. decimal rbmPrice = dac.SubTotal;
  5539. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5540. foodandotherStartIndex++;
  5541. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5542. }
  5543. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5544. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5545. {
  5546. table1.Rows.RemoveAt(i - 1);
  5547. }
  5548. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5549. string otherFeeStr = "";
  5550. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5551. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5552. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5553. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5554. foreach (var otherInfo in dac5)
  5555. {
  5556. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5557. }
  5558. #endregion
  5559. if (otherFeeStr.Length > 0)
  5560. {
  5561. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5562. otherFeeStr = $"({otherFeeStr})";
  5563. dic.Add("OtherFeeStr", otherFeeStr);
  5564. }
  5565. //总计
  5566. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5567. //国际旅费
  5568. string outsideAir = string.Empty;
  5569. string allPriceAir = string.Empty;
  5570. if (_EnterExitCosts.SumJJC == 1)
  5571. {
  5572. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5573. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5574. }
  5575. if (_EnterExitCosts.SumGWC == 1)
  5576. {
  5577. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5578. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5579. }
  5580. if (_EnterExitCosts.SumTDC == 1)
  5581. {
  5582. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5583. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5584. }
  5585. dic.Add("InTravelPrice", $"({outsideAir})");
  5586. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5587. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5588. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5589. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5590. foreach (var key in dic.Keys)
  5591. {
  5592. builder.MoveToBookmark(key);
  5593. builder.Write(dic[key]);
  5594. }
  5595. //模板文件名
  5596. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5597. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5598. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5599. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5600. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5601. }
  5602. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5603. {
  5604. //获取模板
  5605. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5606. //载入模板
  5607. WorkbookDesigner designer = new WorkbookDesigner();
  5608. designer.Workbook = new Workbook(tempPath);
  5609. Dictionary<string, string> dic = new Dictionary<string, string>();
  5610. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5611. {
  5612. List<string> list = new List<string>();
  5613. try
  5614. {
  5615. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5616. foreach (var item in spilitArr)
  5617. {
  5618. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5619. var depCode = spDotandEmpty[2].Substring(0, 3);
  5620. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5621. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5622. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5623. list.Add(depName);
  5624. list.Add(arrName);
  5625. }
  5626. list = list.Distinct().ToList();
  5627. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5628. }
  5629. catch (Exception)
  5630. {
  5631. dic.Add("ReturnCode", "行程录入不正确!");
  5632. }
  5633. }
  5634. else
  5635. {
  5636. dic.Add("ReturnCode", "未录入行程!");
  5637. }
  5638. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5639. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5640. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5641. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5642. {
  5643. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5644. dic.Add("Day", sp.Days.ToString());
  5645. }
  5646. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5647. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5648. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5649. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5650. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5651. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5652. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5653. designer.SetDataSource("Name", Names);
  5654. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5655. designer.SetDataSource("Day", dic["Day"] + "天");
  5656. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5657. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5658. int startIndex = 10;
  5659. const int startIndexcopy = 10;
  5660. if (dac2.Count == dac3.Count)//国家 币种 金额
  5661. {
  5662. for (int i = 0; i < dac2.Count; i++)
  5663. {
  5664. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5665. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5666. }
  5667. }
  5668. DataTable dtdac1 = new DataTable();
  5669. List<string> place = new List<string>();
  5670. dtdac1.Columns.AddRange(new DataColumn[] {
  5671. new DataColumn(){ ColumnName = "city"},
  5672. new DataColumn(){ ColumnName = "curr"},
  5673. new DataColumn(){ ColumnName = "criterion"},
  5674. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5675. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5676. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5677. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5678. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5679. });
  5680. DataTable dtdac2 = new DataTable();
  5681. dtdac2.Columns.AddRange(new DataColumn[] {
  5682. new DataColumn(){ ColumnName = "city"},
  5683. new DataColumn(){ ColumnName = "curr"},
  5684. new DataColumn(){ ColumnName = "criterion"},
  5685. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5686. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5687. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5688. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5689. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5690. });
  5691. dtdac1.TableName = "tb1";
  5692. dtdac2.TableName = "tb2";
  5693. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5694. foreach (var item in dac1)
  5695. {
  5696. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5697. if (place.Contains(item.Place))
  5698. {
  5699. continue;
  5700. }
  5701. DataRow row = dtdac1.NewRow();
  5702. row["city"] = item.Place;
  5703. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5704. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5705. row["curr"] = currency;
  5706. row["rate"] = rate.ToString("#0.0000");
  5707. row["criterion"] = item.Cost.ToString("#0.00");
  5708. row["number"] = 1;
  5709. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5710. //row["costRMB"] = rbmPrice;
  5711. dtdac1.Rows.Add(row);
  5712. place.Add(item.Place);
  5713. }
  5714. place = new List<string>();
  5715. foreach (var item in dac2)
  5716. {
  5717. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5718. if (place.Contains(item.Place))
  5719. {
  5720. continue;
  5721. }
  5722. DataRow row = dtdac2.NewRow();
  5723. row["city"] = item.Place;
  5724. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5725. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5726. row["curr"] = currency;
  5727. row["rate"] = rate.ToString("#0.0000");
  5728. row["criterion"] = item.Cost.ToString("#0.00");
  5729. row["number"] = 1;
  5730. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5731. //row["cost"] = item.SubTotal;
  5732. //row["costRMB"] = rbmPrice;
  5733. dtdac2.Rows.Add(row);
  5734. place.Add(item.Place);
  5735. //dac2totalPrice += rbmPrice;
  5736. }
  5737. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5738. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5739. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5740. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5741. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5742. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5743. string cell4Str1 = string.Empty;
  5744. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5745. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5746. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5747. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5748. string cellStr = $" 5.其他费用(";
  5749. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5750. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5751. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5752. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5753. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5754. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5755. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5756. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5757. foreach (var otherInfo in dac5)
  5758. {
  5759. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5760. }
  5761. #endregion
  5762. if (cellStr.Length > 8)
  5763. {
  5764. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5765. }
  5766. cellStr += ")";
  5767. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5768. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5769. decimal pxFee = dac4.Sum(it => it.Cost);
  5770. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5771. string celllastStr1 = "";
  5772. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5773. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5774. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5775. celllastStr1 += $",国际旅费 元";
  5776. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5777. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5778. designer.SetDataSource("cell4Str", cell4Str);
  5779. designer.SetDataSource("cellStr", cellStr);
  5780. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5781. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5782. designer.SetDataSource("celllastStr", celllastStr);
  5783. Workbook wb = designer.Workbook;
  5784. var sheet = wb.Worksheets[0];
  5785. //绑定datatable数据集
  5786. designer.SetDataSource(dtdac1);
  5787. designer.SetDataSource(dtdac2);
  5788. designer.Process();
  5789. var rowStart = dtdac1.Rows.Count;
  5790. while (rowStart > 0)
  5791. {
  5792. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5793. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5794. startIndex++;
  5795. rowStart--;
  5796. }
  5797. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5798. startIndex += 1; //总计行
  5799. rowStart = dtdac2.Rows.Count;
  5800. while (rowStart > 0)
  5801. {
  5802. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5803. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5804. startIndex++;
  5805. rowStart--;
  5806. }
  5807. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5808. wb.CalculateFormula(true);
  5809. //模板文件名
  5810. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5811. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5812. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5813. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5814. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5815. }
  5816. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5817. {
  5818. //获取模板
  5819. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5820. //载入模板
  5821. Document doc = new Document(tempPath);
  5822. DocumentBuilder builder = new DocumentBuilder(doc);
  5823. Dictionary<string, string> dic = new Dictionary<string, string>();
  5824. dic.Add("GroupName", _DelegationInfo.TeamName);
  5825. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5826. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5827. string missionLeaderJob = "";//负责人job
  5828. //int groupNumber = 0; //团人数
  5829. if (DeleClientList.Count > 0)
  5830. {
  5831. missionLeader = DeleClientList[0]?.Name ?? "";
  5832. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5833. }
  5834. dic.Add("MissionLeader", missionLeader); //团负责人
  5835. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5836. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5837. #region MyRegion
  5838. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5839. //{
  5840. // List<string> list = new List<string>();
  5841. // try
  5842. // {
  5843. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5844. // foreach (var item in spilitArr)
  5845. // {
  5846. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5847. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5848. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5849. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5850. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5851. // list.Add(depName);
  5852. // list.Add(arrName);
  5853. // }
  5854. // list = list.Distinct().ToList();
  5855. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5856. // }
  5857. // catch (Exception)
  5858. // {
  5859. // dic.Add("ReturnCode", "行程录入不正确!");
  5860. // }
  5861. //}
  5862. //else
  5863. //{
  5864. // dic.Add("ReturnCode", "未录入行程!");
  5865. //}
  5866. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5867. dic.Add("ReturnCode", string.Join("、", countrys));
  5868. #endregion
  5869. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5870. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5871. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5872. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5873. //{
  5874. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5875. // dic.Add("Day", sp.Days.ToString());
  5876. //}
  5877. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5878. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5879. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5880. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5881. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5882. //培训人员名单
  5883. int cultivateRowIndex = 7;
  5884. foreach (var item in DeleClientList)
  5885. {
  5886. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5887. builder.Write(item.Name);
  5888. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5889. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5890. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5891. string birthDay = "";
  5892. if (item.Birthday != null)
  5893. {
  5894. DateTime dt = Convert.ToDateTime(item.Birthday);
  5895. birthDay = $"{dt.Year}.{dt.Month}";
  5896. }
  5897. builder.Write(birthDay);
  5898. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5899. builder.Write(item.Company);
  5900. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5901. builder.Write(item.Job);
  5902. cultivateRowIndex++;
  5903. }
  5904. //删除多余行
  5905. //cultivateRowIndex -= 2;
  5906. int delRows = 10 + 7 - cultivateRowIndex;
  5907. if (delRows > 0)
  5908. {
  5909. for (int i = 0; i < delRows; i++)
  5910. {
  5911. table1.Rows.RemoveAt(cultivateRowIndex);
  5912. //cultivateRowIndex++;
  5913. }
  5914. }
  5915. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5916. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5917. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5918. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5919. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5920. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5921. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5922. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5923. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5924. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5925. //其他费用
  5926. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5927. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5928. //其他费用合计
  5929. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5930. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5931. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5932. //公务舱合计
  5933. //国际旅费
  5934. //string outsideJJ = "";
  5935. //string allPriceJJ = "";
  5936. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5937. {
  5938. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5939. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5940. }
  5941. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5942. {
  5943. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5944. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5945. }
  5946. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5947. {
  5948. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5949. dic.Add("AirFeeTotal", airFeeTotalStr);
  5950. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5951. dic.Add("FeeTotal", feeTotalStr);
  5952. }
  5953. foreach (var key in dic.Keys)
  5954. {
  5955. builder.MoveToBookmark(key);
  5956. builder.Write(dic[key]);
  5957. }
  5958. //模板文件名
  5959. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5960. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5961. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5962. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5963. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5964. }
  5965. }
  5966. else if (dto.ExportType == 2) //表格
  5967. {
  5968. //利用键值对存放数据
  5969. Dictionary<string, string> dic = new Dictionary<string, string>();
  5970. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5971. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5972. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5973. dic.Add("Day", sp.Days.ToString());
  5974. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5975. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5976. {
  5977. //获取模板
  5978. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5979. //载入模板
  5980. Document doc = new Document(tempPath);
  5981. DocumentBuilder builder = new DocumentBuilder(doc);
  5982. dic.Add("TeamName", _DelegationInfo.TeamName);
  5983. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5984. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5985. string missionLeaderName = "",
  5986. missionLeaderJob = "";
  5987. if (DeleClientList.Count > 0)
  5988. {
  5989. missionLeaderName = DeleClientList[0].Name;
  5990. missionLeaderJob = DeleClientList[0].Job;
  5991. }
  5992. dic.Add("MissionLeaderName", missionLeaderName);
  5993. dic.Add("MissionLeaderJob", missionLeaderJob);
  5994. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5995. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5996. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5997. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5998. int rowCount = 10;//总人数行
  5999. int startRowIndex = 7; //起始行
  6000. for (int i = 0; i < DeleClientList.Count; i++)
  6001. {
  6002. builder.MoveToCell(0, startRowIndex, 0, 0);
  6003. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6004. builder.MoveToCell(0, startRowIndex, 1, 0);
  6005. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6006. builder.Write(sex);//性别
  6007. builder.MoveToCell(0, startRowIndex, 2, 0);
  6008. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6009. builder.MoveToCell(0, startRowIndex, 3, 0);
  6010. builder.Write(DeleClientList[i].Company);//工作单位
  6011. builder.MoveToCell(0, startRowIndex, 4, 0);
  6012. builder.Write(DeleClientList[i].Job);//职务及级别
  6013. builder.MoveToCell(0, startRowIndex, 5, 0);
  6014. builder.Write("");//人员属性
  6015. builder.MoveToCell(0, startRowIndex, 6, 0);
  6016. builder.Write("");//上次出国时间
  6017. startRowIndex++;
  6018. }
  6019. int nullRow = rowCount - DeleClientList.Count;//空行
  6020. for (int i = 0; i < nullRow; i++)
  6021. {
  6022. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6023. }
  6024. foreach (var key in dic.Keys)
  6025. {
  6026. builder.MoveToBookmark(key);
  6027. builder.Write(dic[key]);
  6028. }
  6029. //模板文件名
  6030. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6031. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6032. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6033. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6034. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6035. }
  6036. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6037. {
  6038. //获取模板
  6039. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6040. //载入模板
  6041. Document doc = new Document(tempPath);
  6042. DocumentBuilder builder = new DocumentBuilder(doc);
  6043. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6044. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6045. dic.Add("Names", Names);
  6046. int accommodationRows = 12;
  6047. //int foodandotherRows = 12;
  6048. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6049. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6050. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6051. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6052. int accommodationStartIndex = 6;
  6053. decimal dac1totalPrice = 0.00M;
  6054. foreach (var dac in dac1)
  6055. {
  6056. if (dac.SubTotal == 0)
  6057. {
  6058. continue;
  6059. }
  6060. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6061. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6062. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6063. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6064. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6065. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6066. builder.Write(currency);//币种
  6067. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6068. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6069. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6070. builder.Write("");//人数
  6071. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6072. builder.Write("");//天数
  6073. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6074. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6075. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6076. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6077. builder.Write(rate.ToString("#0.0000"));//汇率
  6078. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6079. decimal rbmPrice = rate * dac.SubTotal;
  6080. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6081. accommodationStartIndex++;
  6082. dac1totalPrice += rbmPrice;
  6083. }
  6084. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6085. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6086. builder.Write("小计");
  6087. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6088. builder.Write(dac1totalPrice.ToString("#0.00"));
  6089. accommodationStartIndex++;
  6090. int nullRow = accommodationRows - dac1.Count;
  6091. //删除空行
  6092. //if (nullRow > 0)
  6093. //{
  6094. // int rowIndex = accommodationStartIndex;
  6095. // for (int i = 0; i < nullRow; i++)
  6096. // {
  6097. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6098. // row.Remove();
  6099. // rowIndex++;
  6100. // }
  6101. //}
  6102. if (dac2.Count == dac3.Count)//国家 币种 金额
  6103. {
  6104. for (int i = 0; i < dac2.Count; i++)
  6105. {
  6106. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6107. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6108. }
  6109. }
  6110. int foodandotherStartIndex = 19;//
  6111. decimal dac2totalPrice = 0.00M;
  6112. foreach (var dac in dac2)
  6113. {
  6114. if (dac.SubTotal == 0)
  6115. {
  6116. continue;
  6117. }
  6118. //foodandotherStartIndex = 12;
  6119. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6120. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6121. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6122. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6123. builder.Write(currency);//币种
  6124. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6125. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6126. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6127. builder.Write("");//人数
  6128. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6129. builder.Write("");//天数
  6130. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6131. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6132. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6133. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6134. builder.Write(rate.ToString("#0.0000"));//汇率
  6135. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6136. decimal rbmPrice = rate * dac.SubTotal;
  6137. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6138. foodandotherStartIndex++;
  6139. dac2totalPrice += rbmPrice;
  6140. }
  6141. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6142. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6143. //删除空行
  6144. //if (dac2.Count < foodandotherRows)
  6145. //{
  6146. // while (table2.Rows.Count > dac2.Count)
  6147. // {
  6148. // table2.Rows.RemoveAt(dac2.Count);
  6149. // }
  6150. //}
  6151. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6152. string otherFeeStr = "";
  6153. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6154. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6155. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6156. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6157. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6158. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6159. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6160. foreach (var otherInfo in dac5)
  6161. {
  6162. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6163. }
  6164. #endregion
  6165. if (otherFeeStr.Length > 0)
  6166. {
  6167. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6168. otherFeeStr = $"({otherFeeStr})";
  6169. dic.Add("OtherFeeStr", otherFeeStr);
  6170. }
  6171. foreach (var key in dic.Keys)
  6172. {
  6173. builder.MoveToBookmark(key);
  6174. builder.Write(dic[key]);
  6175. }
  6176. //模板文件名
  6177. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6178. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6179. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6180. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6181. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6182. }
  6183. }
  6184. else if (dto.ExportType == 3)
  6185. {
  6186. if (dto.SubTypeId == 1) //团组成员名单
  6187. {
  6188. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6189. //获取模板
  6190. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6191. //载入模板
  6192. Document doc = new Document(tempPath);
  6193. DocumentBuilder builder = new DocumentBuilder(doc);
  6194. //获取word里所有表格
  6195. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6196. //获取所填表格的序数
  6197. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6198. var rowStart = tableOne.Rows[0]; //获取第1行
  6199. //循环赋值
  6200. for (int i = 0; i < DeleClientList.Count; i++)
  6201. {
  6202. builder.MoveToCell(0, i + 1, 0, 0);
  6203. builder.Write(DeleClientList[i].Name);
  6204. builder.MoveToCell(0, i + 1, 1, 0);
  6205. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6206. builder.Write(sex);
  6207. builder.MoveToCell(0, i + 1, 2, 0);
  6208. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6209. builder.MoveToCell(0, i + 1, 3, 0);
  6210. builder.Write(DeleClientList[i].Company);
  6211. builder.MoveToCell(0, i + 1, 4, 0);
  6212. builder.Write(DeleClientList[i].Job);
  6213. }
  6214. //删除多余行
  6215. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6216. {
  6217. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6218. }
  6219. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6220. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6221. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6222. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6223. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6224. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6225. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6226. }
  6227. }
  6228. return Ok(JsonView(400, "操作失败!", ""));
  6229. }
  6230. catch (Exception ex)
  6231. {
  6232. return Ok(JsonView(400, ex.Message, ""));
  6233. }
  6234. }
  6235. /// <summary>
  6236. /// 获取三公费用标准city
  6237. /// </summary>
  6238. /// <param name="placeData"></param>
  6239. /// <param name="nationalTravelFeeId"></param>
  6240. /// <returns></returns>
  6241. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6242. {
  6243. string _city = string.Empty;
  6244. if (placeData.Count < 1) return _city;
  6245. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6246. if (data == null) return _city;
  6247. string country = data.Country;
  6248. string city = data.City;
  6249. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6250. else _city = city;
  6251. return _city;
  6252. }
  6253. /// <summary>
  6254. /// 团组模块 - 出入境费用 - 明细表导出
  6255. /// </summary>
  6256. /// <returns></returns>
  6257. [HttpPost]
  6258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6259. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6260. {
  6261. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6262. if (data.Code != 0)
  6263. {
  6264. return Ok(JsonView(false, data.Msg));
  6265. }
  6266. return Ok(JsonView(true, data.Msg, data.Data));
  6267. }
  6268. /// <summary>
  6269. /// 团组模块 - 出入境费用 - 一键清空
  6270. /// </summary>
  6271. /// <returns></returns>
  6272. [HttpPost]
  6273. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6275. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6276. {
  6277. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6278. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6279. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6280. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6281. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6282. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6283. .SetColumns(x => new Grp_DayOtherPrice
  6284. {
  6285. IsDel = 1,
  6286. DeleteUserId = dto.UserId,
  6287. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6288. })
  6289. .ExecuteCommandAsync();
  6290. if (_view.Code == 0)
  6291. {
  6292. return Ok(JsonView(true, "操作成功"));
  6293. }
  6294. return Ok(JsonView(false, "操作失败"));
  6295. }
  6296. /// <summary>
  6297. /// 团组模块 - 出入境费用 - 子项删除
  6298. /// </summary>
  6299. /// <returns></returns>
  6300. [HttpPost]
  6301. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6303. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6304. {
  6305. try
  6306. {
  6307. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6308. if (data.Code != 0)
  6309. {
  6310. return Ok(JsonView(false, data.Msg));
  6311. }
  6312. return Ok(JsonView(true, "操作成功!", data.Data));
  6313. }
  6314. catch (Exception ex)
  6315. {
  6316. return Ok(JsonView(false, ex.Message));
  6317. }
  6318. }
  6319. /// <summary>
  6320. /// 删除三公其他费用
  6321. /// </summary>
  6322. /// <param name="dto"></param>
  6323. /// <returns></returns>
  6324. [HttpPost]
  6325. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6326. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6327. {
  6328. var jw = JsonView(false, "删除失败!");
  6329. var data = new Grp_DayOtherPrice()
  6330. {
  6331. Id = dto.Id,
  6332. IsDel = 1,
  6333. DeleteUserId = dto.DeleteUserId,
  6334. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6335. };
  6336. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6337. if (del > 0)
  6338. {
  6339. jw.Code = 200;
  6340. jw.Msg = "删除成功!";
  6341. }
  6342. return Ok(jw);
  6343. }
  6344. /// <summary>
  6345. /// 团组模块 - 出入境国家费用标准 List
  6346. /// </summary>
  6347. /// <returns></returns>
  6348. [HttpPost]
  6349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6350. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6351. {
  6352. try
  6353. {
  6354. Stopwatch sw = new Stopwatch();
  6355. sw.Start();
  6356. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6357. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6358. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6359. Where gntf.Isdel = 0");
  6360. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6361. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6362. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6363. //foreach (var item in nationalTravel)
  6364. //{
  6365. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6366. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6367. // if (otherData != null)
  6368. // {
  6369. // cityData.Remove(otherData);
  6370. // cityData.Add(otherData);
  6371. // }
  6372. // nationalTravelFeeData1.Add(new
  6373. // {
  6374. // Country = item.Country,
  6375. // CityData = cityData
  6376. // });
  6377. //}
  6378. sw.Stop();
  6379. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6380. }
  6381. catch (Exception ex)
  6382. {
  6383. return Ok(JsonView(false, ex.Message));
  6384. throw;
  6385. }
  6386. }
  6387. /// <summary>
  6388. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6389. /// </summary>
  6390. /// <returns></returns>
  6391. [HttpPost]
  6392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6393. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6394. {
  6395. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6396. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6397. List<string> countryData = new List<string>();
  6398. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6399. countryData = countryData.Distinct().ToList();
  6400. List<dynamic> dataSource = new List<dynamic>();
  6401. foreach (var item in countryData)
  6402. {
  6403. var cityData1 = new List<string>();
  6404. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6405. var countryData2 = new
  6406. {
  6407. CountryName = item,
  6408. CityData = cityData1
  6409. };
  6410. dataSource.Add(countryData2);
  6411. }
  6412. return Ok(JsonView(true, "查询成功!", dataSource));
  6413. }
  6414. /// <summary>
  6415. /// 团组模块 - 出入境国家费用标准 Page List
  6416. /// </summary>
  6417. /// <returns></returns>
  6418. [HttpPost]
  6419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6420. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6421. {
  6422. int portId = dto.PortType;
  6423. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6424. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6425. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6426. string whereSql = string.Empty;
  6427. if (!string.IsNullOrEmpty(dto.Country))
  6428. {
  6429. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6430. }
  6431. if (!string.IsNullOrEmpty(dto.City))
  6432. {
  6433. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6434. }
  6435. string pageSql = string.Format(@"Select * From (
  6436. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6437. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6438. From Grp_NationalTravelFee gntf
  6439. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6440. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6441. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6442. RefAsync<int> total = 0;
  6443. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6444. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6445. }
  6446. /// <summary>
  6447. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6448. /// </summary>
  6449. /// <returns></returns>
  6450. [HttpPost]
  6451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6452. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6453. {
  6454. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6455. int portId = dto.PortType;
  6456. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6457. string whereSql = string.Empty;
  6458. if (!string.IsNullOrEmpty(dto.Country))
  6459. {
  6460. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6461. }
  6462. if (!string.IsNullOrEmpty(dto.City))
  6463. {
  6464. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6465. }
  6466. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6467. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6468. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6469. From Grp_NationalTravelFee gntf
  6470. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6471. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6472. Where gntf.Isdel = 0 {0} ", whereSql);
  6473. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6474. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6475. }
  6476. /// <summary>
  6477. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6478. /// </summary>
  6479. /// <returns></returns>
  6480. [HttpPost]
  6481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6482. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6483. {
  6484. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6485. if (data.Code != 0)
  6486. {
  6487. return Ok(JsonView(false, data.Msg));
  6488. }
  6489. return Ok(JsonView(true, "操作成功!", data.Data));
  6490. }
  6491. /// <summary>
  6492. /// 团组模块 - 出入境国家费用标准 - Del
  6493. /// </summary>
  6494. /// <returns></returns>
  6495. [HttpPost]
  6496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6497. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6498. {
  6499. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6500. {
  6501. Id = dto.Id,
  6502. DeleteUserId = dto.DeleteUserId,
  6503. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6504. IsDel = 1
  6505. };
  6506. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6507. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6508. .WhereColumns(it => new { it.Id })
  6509. .ExecuteCommandAsync();
  6510. if (delStatus <= 0)
  6511. {
  6512. return Ok(JsonView(false, "删除失败!"));
  6513. }
  6514. return Ok(JsonView(true, "操作成功!"));
  6515. }
  6516. /// <summary>
  6517. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6518. /// 注:Get 请求Headers 加 Token
  6519. /// </summary>
  6520. /// <param name="groupId"></param>
  6521. /// <returns></returns>
  6522. [HttpGet("{groupId}")]
  6523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6524. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6525. {
  6526. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6527. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6528. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6529. data.ForEach(x =>
  6530. {
  6531. x.CreateUserId = _currUserInfo.UserId;
  6532. });
  6533. if (data.Any())
  6534. {
  6535. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6536. if (add > 0)
  6537. {
  6538. return Ok(JsonView(true, "操作成功!"));
  6539. }
  6540. }
  6541. return Ok(JsonView(false, "未操作!"));
  6542. }
  6543. #endregion
  6544. #region 团组经理模块 出入境费用-草稿
  6545. /// <summary>
  6546. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6547. /// </summary>
  6548. /// <returns></returns>
  6549. [HttpPost]
  6550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6551. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6552. {
  6553. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6554. .Where(x => x.IsDel == 0)
  6555. .OrderByDescending(x => x.CreateTime)
  6556. .Select(x => new { x.Id, x.DraftName })
  6557. .ToListAsync();
  6558. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6559. //SetDataInfoView
  6560. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6561. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6562. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6563. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6564. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6565. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6566. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6567. //默认币种显示
  6568. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6569. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6570. return Ok(JsonView(true, "查询成功!", new
  6571. {
  6572. DraftNameDatas = draftNameDatas,
  6573. CurrencyData = _CurrencyData,
  6574. WordTypeData = _WordTypeData,
  6575. ExcelTypeData = _ExcelTypeData,
  6576. CurrencyInit = _currencyInfos,
  6577. ViewPermissionData = viewPermissionData
  6578. }));
  6579. }
  6580. /// <summary>
  6581. /// 团组模块 - 出入境费用-草稿
  6582. /// 实时汇率 tips
  6583. /// 机票费用 tips
  6584. /// </summary>
  6585. /// <returns></returns>
  6586. [HttpPost]
  6587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6588. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6589. {
  6590. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6591. return Ok(JsonView(true, "查询成功!", new
  6592. {
  6593. //GroupNameData = groupNameData.Data,
  6594. //visaData = visaData.Data,
  6595. //airData = airData.Data,
  6596. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6597. }));
  6598. }
  6599. /// <summary>
  6600. /// 团组模块 - 出入境费用-草稿
  6601. /// 签证费用 tips
  6602. /// </summary>
  6603. /// <returns></returns>
  6604. [HttpPost]
  6605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6606. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6607. {
  6608. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6609. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6610. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6611. .Select(x => x.NationalTravelFeeId)
  6612. .Distinct()
  6613. .ToListAsync();
  6614. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6615. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6616. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6617. .Select(x => x.Country)
  6618. .Distinct()
  6619. .ToArrayAsync();
  6620. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6621. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6622. return Ok(JsonView(true, "查询成功!", new
  6623. {
  6624. totalAmt = totalAmt,
  6625. remark = remark
  6626. }));
  6627. }
  6628. /// <summary>
  6629. /// 团组模块 - 出入境费用-草稿 - Info
  6630. /// </summary>
  6631. /// <returns></returns>
  6632. [HttpPost]
  6633. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6635. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6636. {
  6637. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6638. }
  6639. /// <summary>
  6640. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6641. /// </summary>
  6642. /// <returns></returns>
  6643. [HttpPost]
  6644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6645. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6646. {
  6647. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6648. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6649. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6650. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6651. foreach (var userId in dto.UserIds)
  6652. {
  6653. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6654. }
  6655. if (permissions.Any())
  6656. {
  6657. _sqlSugar.BeginTran();
  6658. try
  6659. {
  6660. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6661. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6662. if (result < 1)
  6663. {
  6664. _sqlSugar.RollbackTran();
  6665. return Ok(JsonView(false));
  6666. }
  6667. }
  6668. catch (Exception ex)
  6669. {
  6670. _sqlSugar.RollbackTran();
  6671. return Ok(JsonView(false, ex.Message));
  6672. }
  6673. _sqlSugar.CommitTran();
  6674. return Ok(JsonView(true));
  6675. }
  6676. return Ok(JsonView(false));
  6677. }
  6678. /// <summary>
  6679. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6680. /// </summary>
  6681. /// <returns></returns>
  6682. [HttpPost]
  6683. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6685. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6686. {
  6687. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6688. if (data.Code != 0)
  6689. {
  6690. return Ok(JsonView(false, data.Msg));
  6691. }
  6692. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6693. //汇率信息记录
  6694. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6695. return Ok(JsonView(true, data.Msg, data.Data));
  6696. }
  6697. /// <summary>
  6698. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6699. /// </summary>
  6700. /// <param name="dto"></param>
  6701. /// <returns></returns>
  6702. [HttpPost]
  6703. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6705. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6706. {
  6707. try
  6708. {
  6709. var id = dto.Id;
  6710. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6711. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6712. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6713. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6714. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6715. 3 团组成员名单 1 团组成员名单", ""));
  6716. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6717. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6718. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6719. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6720. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6721. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6722. //数据源
  6723. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6724. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6725. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6726. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6727. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6728. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6729. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6730. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6731. .Select((x, a, b) => new
  6732. {
  6733. x.Index,
  6734. itemName = a.Name,
  6735. CurrencyStr = b.Name,
  6736. x.Cost,
  6737. x.SubTotal,
  6738. x.Remark
  6739. })
  6740. .OrderBy((x) => x.Index)
  6741. .ToList(); //其他款项费用
  6742. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6743. var peiceItemCurrencys = new List<string>();
  6744. if (_DayAndCosts.Any())
  6745. {
  6746. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6747. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6748. }
  6749. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6750. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6751. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6752. {
  6753. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6754. }
  6755. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6756. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6757. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6758. if (dto.ExportType == 1) //明细表
  6759. {
  6760. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6761. {
  6762. //获取模板
  6763. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6764. //载入模板
  6765. Document doc = new Document(tempPath);
  6766. DocumentBuilder builder = new DocumentBuilder(doc);
  6767. //利用键值对存放数据
  6768. Dictionary<string, string> dic = new Dictionary<string, string>();
  6769. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6770. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6771. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6772. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6773. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6774. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6775. //境内费用(其他费用)
  6776. if (_EnterExitCosts.ChoiceOne == 1)
  6777. {
  6778. string row1_1 = "";
  6779. if (_EnterExitCosts.Visa > 0)
  6780. {
  6781. //insidePayTotal += _EnterExitCosts.Visa;
  6782. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6783. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6784. {
  6785. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6786. }
  6787. }
  6788. string row1_2 = "";
  6789. if (_EnterExitCosts.YiMiao > 0)
  6790. {
  6791. //insidePayTotal += _EnterExitCosts.YiMiao;
  6792. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6793. }
  6794. if (_EnterExitCosts.HeSuan > 0)
  6795. {
  6796. //insidePayTotal += _EnterExitCosts.HeSuan;
  6797. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6798. }
  6799. if (_EnterExitCosts.Service > 0)
  6800. {
  6801. //insidePayTotal += _EnterExitCosts.Service;
  6802. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6803. }
  6804. string row1_3 = "";
  6805. if (_EnterExitCosts.Safe > 0)
  6806. {
  6807. //insidePayTotal += _EnterExitCosts.Safe;
  6808. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6809. }
  6810. if (_EnterExitCosts.Ticket > 0)
  6811. {
  6812. //insidePayTotal += _EnterExitCosts.Ticket;
  6813. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6814. }
  6815. string row1 = "";
  6816. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6817. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6818. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6819. row1 += $"备注:{_EnterExitCosts.Remark}";
  6820. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6821. dic.Add("Row1Str", row1);
  6822. }
  6823. string airTotalStr = string.Empty,
  6824. airPriceStr = string.Empty;
  6825. //经济舱
  6826. if (_EnterExitCosts.SumJJC == 1)
  6827. {
  6828. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6829. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6830. }
  6831. //公务舱
  6832. if (_EnterExitCosts.SumGWC == 1)
  6833. {
  6834. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6835. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6836. }
  6837. //头等舱
  6838. if (_EnterExitCosts.SumTDC == 1)
  6839. {
  6840. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6841. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6842. }
  6843. //汇率描述
  6844. string rateStr = "";
  6845. if (peiceItemCurrencyInfos.Any())
  6846. {
  6847. rateStr = "\r\n汇率描述:";
  6848. foreach (var item in peiceItemCurrencyInfos)
  6849. {
  6850. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6851. }
  6852. }
  6853. string twoItemRemark = "备注:";
  6854. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6855. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6856. dic.Add("AirTotalStr", airTotalStr);
  6857. dic.Add("AirPriceStr", airPriceStr);
  6858. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6859. dic.Add("TwoItemRemark", twoItemRemark);
  6860. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6861. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6862. int table1Row = 0,
  6863. table2Row = 0,
  6864. table3Row = 0,
  6865. table4Row = 0,
  6866. table5Row = 0;
  6867. //住宿费
  6868. if (_EnterExitCosts.ChoiceThree == 1)
  6869. {
  6870. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6871. table1Row = dac1.Count;
  6872. #region 填充word表格内容
  6873. for (int i = 0; i < dac1.Count; i++)
  6874. {
  6875. var dac = dac1[i];
  6876. if (dac == null) continue;
  6877. builder.MoveToCell(0, i, 0, 0);
  6878. builder.Write("第" + dac.Days.ToString() + "晚:");
  6879. builder.MoveToCell(0, i, 1, 0);
  6880. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6881. //builder.Write(dac.Place == null ? "" : dac.Place);
  6882. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6883. builder.MoveToCell(0, i, 2, 0);
  6884. builder.Write("费用标准:");
  6885. string curr = "";
  6886. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6887. if (currData != null)
  6888. {
  6889. curr = currData.Name;
  6890. }
  6891. builder.MoveToCell(0, i, 3, 0);
  6892. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6893. builder.MoveToCell(0, i, 4, 0);
  6894. builder.Write("费用小计:");
  6895. builder.MoveToCell(0, i, 5, 0);
  6896. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6897. }
  6898. #endregion
  6899. }
  6900. else dic.Add("SubZS", "0.00");
  6901. //删除多余行
  6902. while (table1.Rows.Count > table1Row)
  6903. {
  6904. table1.Rows.RemoveAt(table1Row);
  6905. }
  6906. //伙食费
  6907. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6908. if (_EnterExitCosts.ChoiceFour == 1)
  6909. {
  6910. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6911. table2Row = dac2.Count;
  6912. #region 填充word表格内容
  6913. for (int i = 0; i < dac2.Count; i++)
  6914. {
  6915. var dac = dac2[i];
  6916. if (dac == null) continue;
  6917. builder.MoveToCell(1, i, 0, 0);
  6918. builder.Write("第" + dac.Days.ToString() + "天:");
  6919. builder.MoveToCell(1, i, 1, 0);
  6920. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6921. builder.MoveToCell(1, i, 2, 0);
  6922. builder.Write("费用标准:");
  6923. string curr = "";
  6924. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6925. if (currData != null)
  6926. {
  6927. curr = currData.Name;
  6928. }
  6929. builder.MoveToCell(1, i, 3, 0);
  6930. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6931. builder.MoveToCell(1, i, 4, 0);
  6932. builder.Write("费用小计:");
  6933. builder.MoveToCell(1, i, 5, 0);
  6934. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6935. }
  6936. #endregion
  6937. }
  6938. else dic.Add("SubHS", "0.00");
  6939. //删除多余行
  6940. while (table2.Rows.Count > table2Row)
  6941. {
  6942. table2.Rows.RemoveAt(table2Row);
  6943. }
  6944. //公杂费
  6945. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6946. if (_EnterExitCosts.ChoiceFive == 1)
  6947. {
  6948. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6949. table3Row = dac3.Count;
  6950. #region 填充word表格内容
  6951. for (int i = 0; i < dac3.Count; i++)
  6952. {
  6953. var dac = dac3[i];
  6954. if (dac == null) continue;
  6955. builder.MoveToCell(2, i, 0, 0);
  6956. builder.Write("第" + dac.Days.ToString() + "天:");
  6957. builder.MoveToCell(2, i, 1, 0);
  6958. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6959. builder.MoveToCell(2, i, 2, 0);
  6960. builder.Write("费用标准:");
  6961. string curr = "";
  6962. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6963. if (currData != null)
  6964. {
  6965. curr = currData.Name;
  6966. }
  6967. builder.MoveToCell(2, i, 3, 0);
  6968. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6969. builder.MoveToCell(2, i, 4, 0);
  6970. builder.Write("费用小计:");
  6971. builder.MoveToCell(2, i, 5, 0);
  6972. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6973. }
  6974. //删除多余行
  6975. while (table3.Rows.Count > table3Row)
  6976. {
  6977. table3.Rows.RemoveAt(table3Row);
  6978. }
  6979. #endregion
  6980. }
  6981. else dic.Add("SubGZF", "0.00");
  6982. //删除多余行
  6983. while (table3.Rows.Count > table3Row)
  6984. {
  6985. table3.Rows.RemoveAt(table3Row);
  6986. }
  6987. //培训费
  6988. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6989. if (_EnterExitCosts.ChoiceSix == 1)
  6990. {
  6991. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6992. dic.Add("SubPX", pxStr);
  6993. table4Row = dac4.Count;
  6994. #region 填充word表格内容
  6995. for (int i = 0; i < dac4.Count; i++)
  6996. {
  6997. var dac = dac4[i];
  6998. if (dac == null) continue;
  6999. builder.MoveToCell(3, i, 0, 0);
  7000. builder.Write("第" + dac.Days.ToString() + "天:");
  7001. builder.MoveToCell(3, i, 1, 0);
  7002. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7003. builder.MoveToCell(3, i, 2, 0);
  7004. builder.Write("费用标准:");
  7005. string curr = "";
  7006. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7007. if (currData != null)
  7008. {
  7009. curr = currData.Name;
  7010. }
  7011. builder.MoveToCell(3, i, 3, 0);
  7012. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7013. builder.MoveToCell(3, i, 4, 0);
  7014. builder.Write("费用小计:");
  7015. builder.MoveToCell(3, i, 5, 0);
  7016. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7017. }
  7018. #endregion
  7019. }
  7020. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7021. //删除多余行
  7022. while (table4.Rows.Count > table4Row)
  7023. {
  7024. table4.Rows.RemoveAt(table4Row);
  7025. }
  7026. //其他费用
  7027. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7028. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7029. {
  7030. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7031. dic.Add("titleQi", qtStr);
  7032. table5Row = dac5.Count;
  7033. #region 填充word表格内容
  7034. for (int i = 0; i < dac5.Count; i++)
  7035. {
  7036. var dac = dac5[i];
  7037. if (dac == null) continue;
  7038. builder.MoveToCell(4, i, 0, 0);
  7039. builder.Write("第" + dac.Index.ToString() + "项:");
  7040. builder.MoveToCell(4, i, 1, 0);
  7041. builder.Write(dac.itemName);
  7042. builder.MoveToCell(4, i, 2, 0);
  7043. builder.Write("费用标准:");
  7044. builder.MoveToCell(4, i, 3, 0);
  7045. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7046. builder.MoveToCell(4, i, 4, 0);
  7047. builder.Write("费用小计:");
  7048. builder.MoveToCell(4, i, 5, 0);
  7049. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7050. builder.MoveToCell(4, i, 6, 0);
  7051. builder.Write("备注:");
  7052. builder.MoveToCell(4, i, 7, 0);
  7053. builder.Write(dac.Remark);
  7054. }
  7055. #endregion
  7056. }
  7057. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7058. //删除多余行
  7059. while (table5.Rows.Count > table5Row)
  7060. {
  7061. table5.Rows.RemoveAt(table5Row);
  7062. }
  7063. //加上其他费用
  7064. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7065. decimal subJJC = 0.00M,
  7066. subGWC = 0.00M,
  7067. subTDC = 0.00M;
  7068. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7069. string totalLabel = string.Format("全部费用总计:");
  7070. //经济舱
  7071. if (_EnterExitCosts.SumJJC == 1)
  7072. {
  7073. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7074. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7075. }
  7076. //公务舱
  7077. if (_EnterExitCosts.SumGWC == 1)
  7078. {
  7079. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7080. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7081. }
  7082. //头等舱
  7083. if (_EnterExitCosts.SumTDC == 1)
  7084. {
  7085. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7086. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7087. }
  7088. //TotalLabel
  7089. dic.Add("TotalLabel", totalLabel);
  7090. #region 填充word模板书签内容
  7091. foreach (var key in dic.Keys)
  7092. {
  7093. Bookmark bookmark = doc.Range.Bookmarks[key];
  7094. if (bookmark != null)
  7095. {
  7096. builder.MoveToBookmark(key);
  7097. builder.Write(dic[key]);
  7098. }
  7099. }
  7100. #endregion
  7101. //文件名
  7102. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7103. strFileName = CommonFun.ValidFileName(strFileName);
  7104. AsposeHelper.removewatermark_v2180();
  7105. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7106. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7107. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7108. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7109. }
  7110. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7111. {
  7112. //获取模板
  7113. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7114. //载入模板
  7115. Document doc = new Document(tempPath);
  7116. DocumentBuilder builder = new DocumentBuilder(doc);
  7117. Dictionary<string, string> dic = new Dictionary<string, string>();
  7118. string returnCodeLabel = string.Empty;
  7119. if (nationalTravelFeeData.Any())
  7120. {
  7121. List<string> list = new List<string>();
  7122. foreach (var item in nationalTravelFeeData)
  7123. {
  7124. list.Add($"{item.Country}({item.City})");
  7125. }
  7126. list = list.Distinct().ToList();
  7127. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7128. }
  7129. var countryLabel = string.Empty;
  7130. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7131. if (countryData.Any())
  7132. {
  7133. countryLabel = string.Join("、", countryData);
  7134. }
  7135. dic.Add("ReturnCodeAir", returnCodeLabel);
  7136. dic.Add("VisitStartDate", "-");
  7137. dic.Add("VisitEndDate", "-");
  7138. dic.Add("Day", "-");
  7139. dic.Add("VisitCountry", countryLabel);
  7140. dic.Add("ClientUnit", "-");
  7141. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7142. //dic.Add("Names", Names);
  7143. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7144. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7145. decimal dac1totalPrice = 0.00M;
  7146. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7147. foreach (var dac in dac1)
  7148. {
  7149. if (dac.SubTotal == 0.00M)
  7150. {
  7151. continue;
  7152. }
  7153. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7154. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7155. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7156. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7157. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7158. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7159. builder.Write(currency);//币种
  7160. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7161. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7162. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7163. builder.Write("");//人数
  7164. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7165. builder.Write("");//天数
  7166. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7167. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7168. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7169. decimal rate = 0.00M;
  7170. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7171. builder.Write(rate.ToString("#0.0000"));//汇率
  7172. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7173. decimal rbmPrice = dac.SubTotal;
  7174. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7175. accommodationStartIndex++;
  7176. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7177. }
  7178. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7179. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7180. {
  7181. table1.Rows.RemoveAt(i - 1);
  7182. foodandotherStartIndex--;
  7183. }
  7184. if (dac2.Count == dac3.Count)//国家 币种 金额
  7185. {
  7186. for (int i = 0; i < dac2.Count; i++)
  7187. {
  7188. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7189. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7190. }
  7191. }
  7192. decimal dac2totalPrice = 0.00M;
  7193. foreach (var dac in dac2)
  7194. {
  7195. if (dac.SubTotal == 0)
  7196. {
  7197. continue;
  7198. }
  7199. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7200. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7201. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7202. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7203. builder.Write(currency);//币种
  7204. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7205. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7206. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7207. builder.Write("");//人数
  7208. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7209. builder.Write("");//天数
  7210. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7211. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7212. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7213. decimal rate = 0.00M;
  7214. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7215. builder.Write(rate.ToString("#0.0000"));//汇率
  7216. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7217. decimal rbmPrice = dac.SubTotal;
  7218. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7219. foodandotherStartIndex++;
  7220. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7221. }
  7222. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7223. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7224. {
  7225. table1.Rows.RemoveAt(i - 1);
  7226. }
  7227. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7228. string otherFeeStr = "";
  7229. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7230. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7231. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7232. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7233. foreach (var otherInfo in dac5)
  7234. {
  7235. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7236. }
  7237. #endregion
  7238. if (otherFeeStr.Length > 0)
  7239. {
  7240. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7241. otherFeeStr = $"({otherFeeStr})";
  7242. dic.Add("OtherFeeStr", otherFeeStr);
  7243. }
  7244. //总计
  7245. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7246. //国际旅费
  7247. string outsideAir = string.Empty;
  7248. string allPriceAir = string.Empty;
  7249. if (_EnterExitCosts.SumJJC == 1)
  7250. {
  7251. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7252. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7253. }
  7254. if (_EnterExitCosts.SumGWC == 1)
  7255. {
  7256. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7257. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7258. }
  7259. if (_EnterExitCosts.SumTDC == 1)
  7260. {
  7261. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7262. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7263. }
  7264. dic.Add("InTravelPrice", $"({outsideAir})");
  7265. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7266. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7267. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7268. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7269. foreach (var key in dic.Keys)
  7270. {
  7271. builder.MoveToBookmark(key);
  7272. builder.Write(dic[key]);
  7273. }
  7274. //模板文件名
  7275. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7276. strFileName = CommonFun.ValidFileName(strFileName);
  7277. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7278. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7279. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7280. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7281. }
  7282. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7283. {
  7284. //获取模板
  7285. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7286. //载入模板
  7287. WorkbookDesigner designer = new WorkbookDesigner();
  7288. designer.Workbook = new Workbook(tempPath);
  7289. Dictionary<string, string> dic = new Dictionary<string, string>();
  7290. string returnCodeLabel = string.Empty;
  7291. if (nationalTravelFeeData.Any())
  7292. {
  7293. List<string> list = new List<string>();
  7294. foreach (var item in nationalTravelFeeData)
  7295. {
  7296. list.Add($"{item.Country}({item.City})");
  7297. }
  7298. list = list.Distinct().ToList();
  7299. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7300. }
  7301. var countryLabel = string.Empty;
  7302. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7303. if (countryData.Any())
  7304. {
  7305. countryLabel = string.Join("、", countryData);
  7306. }
  7307. dic.Add("ReturnCodeAir", returnCodeLabel);
  7308. dic.Add("VisitStartDate", "-");
  7309. dic.Add("VisitEndDate", "-");
  7310. dic.Add("Day", "0");
  7311. dic.Add("VisitCountry", countryLabel);
  7312. dic.Add("ClientUnit", "-");
  7313. designer.SetDataSource("ClientUnit", "-");
  7314. designer.SetDataSource("VisitCountry", countryLabel);
  7315. designer.SetDataSource("Group", "-");
  7316. designer.SetDataSource("ClientUnitTitle", "-");
  7317. designer.SetDataSource("Name", "-");
  7318. designer.SetDataSource("VisitStartDate", "-");
  7319. designer.SetDataSource("Day", "0");
  7320. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7321. designer.SetDataSource("ReturnCodeAir", "-");
  7322. int startIndex = 10;
  7323. const int startIndexcopy = 10;
  7324. if (dac2.Count == dac3.Count)//国家 币种 金额
  7325. {
  7326. for (int i = 0; i < dac2.Count; i++)
  7327. {
  7328. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7329. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7330. }
  7331. }
  7332. DataTable dtdac1 = new DataTable();
  7333. List<string> place = new List<string>();
  7334. dtdac1.Columns.AddRange(new DataColumn[] {
  7335. new DataColumn(){ ColumnName = "city"},
  7336. new DataColumn(){ ColumnName = "curr"},
  7337. new DataColumn(){ ColumnName = "criterion"},
  7338. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7339. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7340. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7341. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7342. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7343. });
  7344. DataTable dtdac2 = new DataTable();
  7345. dtdac2.Columns.AddRange(new DataColumn[] {
  7346. new DataColumn(){ ColumnName = "city"},
  7347. new DataColumn(){ ColumnName = "curr"},
  7348. new DataColumn(){ ColumnName = "criterion"},
  7349. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7350. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7351. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7352. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7353. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7354. });
  7355. dtdac1.TableName = "tb1";
  7356. dtdac2.TableName = "tb2";
  7357. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7358. foreach (var item in dac1)
  7359. {
  7360. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7361. if (place.Contains(item.Place))
  7362. {
  7363. continue;
  7364. }
  7365. DataRow row = dtdac1.NewRow();
  7366. row["city"] = item.Place;
  7367. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7368. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7369. row["curr"] = currency;
  7370. row["rate"] = rate.ToString("#0.0000");
  7371. row["criterion"] = item.Cost.ToString("#0.00");
  7372. row["number"] = 1;
  7373. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7374. //row["costRMB"] = rbmPrice;
  7375. dtdac1.Rows.Add(row);
  7376. place.Add(item.Place);
  7377. }
  7378. place = new List<string>();
  7379. foreach (var item in dac2)
  7380. {
  7381. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7382. if (place.Contains(item.Place))
  7383. {
  7384. continue;
  7385. }
  7386. DataRow row = dtdac2.NewRow();
  7387. row["city"] = item.Place;
  7388. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7389. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7390. row["curr"] = currency;
  7391. row["rate"] = rate.ToString("#0.0000");
  7392. row["criterion"] = item.Cost.ToString("#0.00");
  7393. row["number"] = 1;
  7394. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7395. //row["cost"] = item.SubTotal;
  7396. //row["costRMB"] = rbmPrice;
  7397. dtdac2.Rows.Add(row);
  7398. place.Add(item.Place);
  7399. //dac2totalPrice += rbmPrice;
  7400. }
  7401. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7402. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7403. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7404. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7405. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7406. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7407. string cell4Str1 = string.Empty;
  7408. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7409. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7410. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7411. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7412. string cellStr = $" 5.其他费用(";
  7413. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7414. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7415. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7416. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7417. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7418. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7419. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7420. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7421. foreach (var otherInfo in dac5)
  7422. {
  7423. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7424. }
  7425. #endregion
  7426. if (cellStr.Length > 8)
  7427. {
  7428. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7429. }
  7430. cellStr += ")";
  7431. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7432. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7433. decimal pxFee = dac4.Sum(it => it.Cost);
  7434. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7435. string celllastStr1 = "";
  7436. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7437. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7438. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7439. celllastStr1 += $",国际旅费 元";
  7440. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7441. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7442. designer.SetDataSource("cell4Str", cell4Str);
  7443. designer.SetDataSource("cellStr", cellStr);
  7444. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7445. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7446. designer.SetDataSource("celllastStr", celllastStr);
  7447. Workbook wb = designer.Workbook;
  7448. var sheet = wb.Worksheets[0];
  7449. //绑定datatable数据集
  7450. designer.SetDataSource(dtdac1);
  7451. designer.SetDataSource(dtdac2);
  7452. designer.Process();
  7453. var rowStart = dtdac1.Rows.Count;
  7454. while (rowStart > 0)
  7455. {
  7456. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7457. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7458. startIndex++;
  7459. rowStart--;
  7460. }
  7461. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7462. startIndex += 1; //总计行
  7463. rowStart = dtdac2.Rows.Count;
  7464. while (rowStart > 0)
  7465. {
  7466. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7467. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7468. startIndex++;
  7469. rowStart--;
  7470. }
  7471. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7472. wb.CalculateFormula(true);
  7473. //模板文件名
  7474. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7475. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7476. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7477. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7478. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7479. }
  7480. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7481. {
  7482. //获取模板
  7483. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7484. //载入模板
  7485. Document doc = new Document(tempPath);
  7486. DocumentBuilder builder = new DocumentBuilder(doc);
  7487. Dictionary<string, string> dic = new Dictionary<string, string>();
  7488. dic.Add("GroupName", "-");
  7489. dic.Add("ClientUnit", "-");
  7490. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7491. //string missionLeaderJob = "";//负责人job
  7492. //int groupNumber = 0; //团人数
  7493. dic.Add("MissionLeader", "-"); //团负责人
  7494. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7495. dic.Add("GroupNumber", "0"); //团人数
  7496. dic.Add("Day", "0");
  7497. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7498. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7499. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7500. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7501. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7502. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7503. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7504. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7505. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7506. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7507. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7508. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7509. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7510. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7511. //其他费用
  7512. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7513. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7514. //其他费用合计
  7515. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7516. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7517. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7518. //公务舱合计
  7519. //国际旅费
  7520. //string outsideJJ = "";
  7521. //string allPriceJJ = "";
  7522. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7523. {
  7524. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7525. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7526. }
  7527. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7528. {
  7529. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7530. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7531. }
  7532. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7533. {
  7534. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7535. dic.Add("AirFeeTotal", airFeeTotalStr);
  7536. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7537. dic.Add("FeeTotal", feeTotalStr);
  7538. }
  7539. foreach (var key in dic.Keys)
  7540. {
  7541. builder.MoveToBookmark(key);
  7542. builder.Write(dic[key]);
  7543. }
  7544. //模板文件名
  7545. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7546. strFileName = CommonFun.ValidFileName(strFileName);
  7547. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7548. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7549. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7550. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7551. }
  7552. }
  7553. else if (dto.ExportType == 2) //表格
  7554. {
  7555. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7556. }
  7557. else if (dto.ExportType == 3)
  7558. {
  7559. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7560. }
  7561. return Ok(JsonView(400, "只可导出明细表!", ""));
  7562. }
  7563. catch (Exception ex)
  7564. {
  7565. return Ok(JsonView(400, ex.Message, ""));
  7566. }
  7567. }
  7568. /// <summary>
  7569. /// 获取三公费用标准city
  7570. /// </summary>
  7571. /// <param name="placeData"></param>
  7572. /// <param name="nationalTravelFeeId"></param>
  7573. /// <returns></returns>
  7574. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7575. {
  7576. string _city = string.Empty;
  7577. if (!placeData.Any()) return _city;
  7578. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7579. if (data == null) return _city;
  7580. string country = data.Country;
  7581. string city = data.City;
  7582. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7583. else _city = city;
  7584. return _city;
  7585. }
  7586. /// <summary>
  7587. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7588. /// </summary>
  7589. /// <returns></returns>
  7590. [HttpPost]
  7591. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7593. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7594. {
  7595. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7596. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7597. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7598. if (_view.Code == 0)
  7599. {
  7600. return Ok(JsonView(true, "操作成功"));
  7601. }
  7602. return Ok(JsonView(false, "操作失败"));
  7603. }
  7604. /// <summary>
  7605. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7606. /// </summary>
  7607. /// <returns></returns>
  7608. [HttpPost]
  7609. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7611. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7612. {
  7613. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7614. if (data.Code != 0)
  7615. {
  7616. return Ok(JsonView(false, data.Msg));
  7617. }
  7618. return Ok(JsonView(true, "操作成功!", data.Data));
  7619. }
  7620. /// <summary>
  7621. /// 三公其他费用草稿 删除
  7622. /// </summary>
  7623. /// <param name="dto"></param>
  7624. /// <returns></returns>
  7625. [HttpPost]
  7626. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7627. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7628. {
  7629. var jw = JsonView(false, "删除失败!");
  7630. var data = new Grp_DayOtherPriceDraft()
  7631. {
  7632. Id = dto.Id,
  7633. IsDel = 1,
  7634. DeleteUserId = dto.DeleteUserId,
  7635. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7636. };
  7637. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7638. if (del > 0)
  7639. {
  7640. jw.Code = 200;
  7641. jw.Msg = "删除成功!";
  7642. }
  7643. return Ok(jw);
  7644. }
  7645. /// <summary>
  7646. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7647. /// </summary>
  7648. /// <returns></returns>
  7649. [HttpPost]
  7650. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7651. {
  7652. var jw = JsonView(false);
  7653. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7654. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7655. jw.Code = StatusCodes.Status200OK;
  7656. jw.Msg = "操作成功!";
  7657. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7658. return Ok(jw);
  7659. }
  7660. /// <summary>
  7661. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7662. /// </summary>
  7663. /// <param name="dto"></param>
  7664. /// <returns></returns>
  7665. [HttpPost]
  7666. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7667. {
  7668. int userId = dto.UserId,
  7669. portId = dto.PortType,
  7670. groupId = dto.GroupId,
  7671. draftId = dto.DraftId;
  7672. _portTypeData.Add(1);
  7673. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7674. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7675. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7676. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7677. _sqlSugar.BeginTran();
  7678. try
  7679. {
  7680. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7681. if (draftDatas == null)
  7682. {
  7683. _sqlSugar.RollbackTran();
  7684. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7685. }
  7686. //验证可覆盖已有数据 两边创建人需为同一人;
  7687. int draftCreateUserId = draftDatas.CreateUserId,
  7688. formalCreateUserId = 0;
  7689. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7690. if (formalData != null)
  7691. {
  7692. formalCreateUserId = formalData.CreateUserId;
  7693. if (draftCreateUserId != formalCreateUserId)
  7694. {
  7695. _sqlSugar.RollbackTran();
  7696. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7697. }
  7698. }
  7699. //默认添加查看、编辑权限(创建人、自己)
  7700. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7701. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7702. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7703. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7704. newExterData.DiId = groupId;
  7705. newExterData.CreateUserId = userId;
  7706. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7707. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7708. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7709. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7710. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7711. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7712. //数据如果存在执行删除
  7713. if (enterExitCostInfo != null)
  7714. {
  7715. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7716. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7717. .Where(x => x.Id == enterExitCostInfo.Id)
  7718. .ExecuteCommand();
  7719. _sqlSugar.Updateable<Grp_DayAndCost>()
  7720. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7721. .Where(x => x.DiId == groupId)
  7722. .ExecuteCommand();
  7723. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7724. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7725. .Where(x => x.Diid == groupId)
  7726. .ExecuteCommand();
  7727. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7728. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7729. .Where(x => x.GroupId == groupId)
  7730. .ExecuteCommand();
  7731. }
  7732. //执行insert
  7733. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7734. if (insertId < 1)
  7735. {
  7736. _sqlSugar.RollbackTran();
  7737. return Ok(JsonView(false, "草稿数据导入失败!"));
  7738. }
  7739. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7740. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7741. #region 默认添加权限
  7742. #endregion
  7743. _sqlSugar.CommitTran();
  7744. //执行操作之后
  7745. //生成默认文件pdf并且通知人员
  7746. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7747. {
  7748. DiId = groupId,
  7749. ExportType = 1,
  7750. SubTypeId = 1005
  7751. }, "pdf");
  7752. //发送通知
  7753. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7754. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7755. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7756. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7757. //汇率信息记录
  7758. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7759. return Ok(JsonView(true));
  7760. }
  7761. catch (Exception ex)
  7762. {
  7763. _sqlSugar.RollbackTran();
  7764. return Ok(JsonView(false, ex.Message));
  7765. }
  7766. }
  7767. #endregion
  7768. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7769. /// <summary>
  7770. /// 获取币种基础数据(含逻辑处理)
  7771. /// </summary>
  7772. /// <returns></returns>
  7773. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7774. {
  7775. return await GeneralMethod.EnterExitCostInitRate();
  7776. }
  7777. /// <summary>
  7778. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7779. /// </summary>
  7780. /// <returns></returns>
  7781. [HttpPost]
  7782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7783. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7784. {
  7785. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7786. //SetDataInfoView
  7787. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7788. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7789. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7790. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7791. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7792. //默认币种显示
  7793. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7794. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7795. return Ok(JsonView(true, "查询成功!", new
  7796. {
  7797. WordTypeData = _WordTypeData,
  7798. ExcelTypeData = _ExcelTypeData,
  7799. CurrencyInit = _currencyInfos,
  7800. viewPermissionData = viewPermissionData
  7801. }));
  7802. }
  7803. /// <summary>
  7804. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7805. /// </summary>
  7806. /// <returns></returns>
  7807. [HttpPost]
  7808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7809. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7810. {
  7811. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7812. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7813. RefAsync<int> total = 0;
  7814. int diId = 0;
  7815. var status = int.TryParse(dto.GroupName, out diId);
  7816. string sql = string.Format(@"SELECT
  7817. Id,
  7818. TeamName GroupName,
  7819. CASE WHEN EXISTS (
  7820. SELECT
  7821. 1
  7822. FROM
  7823. Grp_EnterExitCost
  7824. WHERE
  7825. IsDel = 0
  7826. AND DiId = di.Id
  7827. ) THEN 1 ELSE 0 END AS [IsNull],
  7828. CASE WHEN EXISTS(
  7829. SELECT
  7830. TOP 1 *
  7831. FROM
  7832. Grp_EnterExitCost
  7833. WHERE
  7834. IsDel = 0
  7835. AND DiId = di.Id
  7836. AND CreateUserId = {0}
  7837. ORDER BY
  7838. CreateTime DESC
  7839. ) THEN 1 ELSE 0 END AS [IsEdit],
  7840. CASE WHEN EXISTS(
  7841. SELECT
  7842. TOP 1 *
  7843. FROM
  7844. Grp_EnterExitCost
  7845. WHERE
  7846. IsDel = 0
  7847. AND DiId = di.Id
  7848. AND CreateUserId = {0}
  7849. ORDER BY
  7850. CreateTime DESC
  7851. ) THEN 1 WHEN EXISTS(
  7852. SELECT
  7853. TOP 1 *
  7854. FROM
  7855. Grp_EnterExitCostPermission
  7856. WHERE
  7857. IsDel = 0
  7858. AND GroupId = di.Id
  7859. AND Permission = 1
  7860. AND UserId = {0}
  7861. ORDER BY
  7862. CreateTime DESC
  7863. ) THEN 1 ELSE 0 END AS [IsView]
  7864. FROM
  7865. Grp_DelegationInfo di
  7866. WHERE
  7867. di.Isdel = 0 ", dto.CurrUserId);
  7868. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7869. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7870. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7871. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7872. .OrderByDescending(x => x.Id)
  7873. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7874. return Ok(JsonView(true, "查询成功!", data, total));
  7875. }
  7876. /// <summary>
  7877. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7878. /// </summary>
  7879. /// <returns></returns>
  7880. [HttpPost]
  7881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7882. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7883. {
  7884. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7885. RefAsync<int> total = 0;
  7886. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7887. .Where(x => x.IsDel == 0 && x.STid == 66)
  7888. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7889. .Select(x => new
  7890. {
  7891. id = x.Id,
  7892. name = x.Name,
  7893. remark = x.Remark,
  7894. })
  7895. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7896. return Ok(JsonView(true, "查询成功!", data, total));
  7897. }
  7898. /// <summary>
  7899. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7900. /// </summary>
  7901. /// <returns></returns>
  7902. [HttpPost]
  7903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7904. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7905. {
  7906. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7907. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7908. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7909. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7910. var groupOtherRateData = groupRateData.TeamRates;
  7911. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7912. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7913. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7914. groupOtherRateData = groupOtherRateData
  7915. .Select(x => new TeamRateDescAddCurrencyIdView
  7916. {
  7917. CurrencyId = x.CurrencyId,
  7918. CurrencyName = x.CurrencyName,
  7919. CurrencyCode = x.CurrencyCode,
  7920. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7921. }).ToList();
  7922. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7923. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7924. }
  7925. /// <summary>
  7926. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7927. /// </summary>
  7928. /// <returns></returns>
  7929. [HttpPost]
  7930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7931. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7932. {
  7933. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7934. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7935. var tipsData = new List<int>() { 1, 2, 3 };
  7936. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7937. if (dto.TipsType == 1)
  7938. {
  7939. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  7940. }
  7941. else if (dto.TipsType == 2)
  7942. {
  7943. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  7944. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7945. }
  7946. else if (dto.TipsType == 3)
  7947. {
  7948. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7949. return Ok(JsonView(true, "查询成功!", airData.Data));
  7950. }
  7951. return Ok(JsonView(false));
  7952. }
  7953. /// <summary>
  7954. /// 团组模块 - 出入境国家费用标准-移动端 List
  7955. /// </summary>
  7956. /// <returns></returns>
  7957. [HttpPost]
  7958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7959. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7960. {
  7961. Stopwatch sw = new Stopwatch();
  7962. sw.Start();
  7963. RefAsync<int> total = 0;
  7964. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7965. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7966. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7967. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7968. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7969. .Select((ntf, sd, u) => new
  7970. {
  7971. Id = ntf.Id,
  7972. Area = $"{ntf.Country}-{ntf.City}",
  7973. Currency = ntf.Currency,
  7974. CurrencyCode = sd.Name,
  7975. CurrencyName = sd.Remark,
  7976. RoomCost = ntf.RoomCost,
  7977. FoodCost = ntf.FoodCost,
  7978. PublicCost = ntf.PublicCost,
  7979. LastUpdateUserId = ntf.LastUpdateUserId,
  7980. LastUpdateUserName = u.CnName,
  7981. LastUpdateTime = ntf.LastUpdateTime,
  7982. })
  7983. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7984. sw.Stop();
  7985. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  7986. }
  7987. /// <summary>
  7988. /// 团组模块 - 出入境费用-移动端 - Info
  7989. /// </summary>
  7990. /// <returns></returns>
  7991. [HttpPost]
  7992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7993. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7994. {
  7995. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7996. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7997. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7998. return Ok(data);
  7999. }
  8000. /// <summary>
  8001. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8002. /// </summary>
  8003. /// <returns></returns>
  8004. [HttpPost]
  8005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8006. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8007. {
  8008. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8009. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8010. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8011. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8012. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8013. mobileInfo.DiId = dto.DiId;
  8014. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8015. if (eecInfo == null) return Ok(mobileInfo);
  8016. //验证查看权限
  8017. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8018. //if (!isView) return Ok(JsonView(false, msg));
  8019. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8020. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8021. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8022. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8023. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8024. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8025. {
  8026. SubId = dac.Id,
  8027. DiId = dac.DiId,
  8028. Type = dac.Type,
  8029. Days = dac.Days,
  8030. NationalTravelFeeId = dac.NationalTravelFeeId,
  8031. Arae = $"{ntf.Country}-{ntf.City}",
  8032. Cost = dac.Cost,
  8033. Currency = dac.Currency,
  8034. CurrencyName = sd.Name,
  8035. SubTotal = dac.SubTotal,
  8036. })
  8037. .ToList();
  8038. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8039. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8040. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8041. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8042. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8043. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8044. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8045. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8046. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8047. //其他款项
  8048. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8049. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8050. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8051. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8052. .OrderBy((dop, sd1, sd2) => dop.Index)
  8053. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8054. {
  8055. SubId = dop.Id,
  8056. DiId = dop.Diid,
  8057. Index = dop.Index,
  8058. SetDataId = dop.SetDataId,
  8059. SetDataName = sd1.Name,
  8060. Cost = dop.Cost,
  8061. Currency = dop.Currency,
  8062. CurrencyName = sd2.Remark,
  8063. SubTotal = dop.SubTotal,
  8064. Remark = dop.Remark,
  8065. })
  8066. .ToArray();
  8067. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8068. return Ok(mobileInfo);
  8069. }
  8070. /// <summary>
  8071. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8072. /// </summary>
  8073. /// <returns></returns>
  8074. [HttpPost]
  8075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8076. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8077. {
  8078. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8079. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8080. //验证查看权限
  8081. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8082. if (!isView) return Ok(JsonView(false, msg));
  8083. var userIds = Array.Empty<int>();
  8084. userIds = await _sqlSugar
  8085. .Queryable<Grp_EnterExitCostPermission>()
  8086. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8087. .Select(x => x.UserId)
  8088. .ToArrayAsync();
  8089. return Ok(userIds);
  8090. }
  8091. /// <summary>
  8092. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8093. /// </summary>
  8094. /// <returns></returns>
  8095. [HttpPost]
  8096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8097. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8098. {
  8099. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8100. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8101. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8102. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8103. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8104. //验证查看权限
  8105. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8106. //if (!isView) return Ok(JsonView(false, msg));
  8107. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8108. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8109. var subType = dto.SubType;
  8110. if (subType == 1) //1:境内费用
  8111. {
  8112. var oneData = new ChoiceOneMobileSubInfoView()
  8113. {
  8114. Id = eecInfo.Id,
  8115. ChoiceOne = eecInfo.ChoiceOne,
  8116. ChoiceOneTotalCost = eecInfo.InsidePay,
  8117. Visa = eecInfo.Visa,
  8118. VisaRemark = eecInfo.VisaRemark,
  8119. YiMiao = eecInfo.YiMiao,
  8120. HeSuan = eecInfo.HeSuan,
  8121. Service = eecInfo.Service,
  8122. Ticket = eecInfo.Ticket,
  8123. Safe = eecInfo.Safe,
  8124. FirstItemRemark = eecInfo.FirstItemRemark
  8125. };
  8126. return Ok(JsonView(oneData));
  8127. }
  8128. else if (subType == 2) //2:国际旅费
  8129. {
  8130. var twoData = new ChoiceTwoMobileSubInfoView()
  8131. {
  8132. Id = eecInfo.Id,
  8133. ChoiceTwoJJ = eecInfo.SumJJC,
  8134. OutsideJJPay = eecInfo.OutsideJJPay,
  8135. ChoiceTwoGW = eecInfo.SumGWC,
  8136. OutsideGWPay = eecInfo.OutsideGWPay,
  8137. ChoiceTwoTD = eecInfo.SumTDC,
  8138. OutsideTDPay = eecInfo.OutsideTDPay,
  8139. AirJJ = eecInfo.AirJJ,
  8140. AirGW = eecInfo.AirGW,
  8141. AirTD = eecInfo.AirTD,
  8142. CityTranffic = eecInfo.CityTranffic,
  8143. TwoItemRemark = eecInfo.TwoItemRemark
  8144. };
  8145. return Ok(JsonView(twoData));
  8146. }
  8147. else if (subType == 3) //3:住宿费
  8148. {
  8149. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8150. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8151. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8152. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8153. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8154. {
  8155. SubId = dac.Id,
  8156. DiId = dac.DiId,
  8157. Type = dac.Type,
  8158. Days = dac.Days,
  8159. NationalTravelFeeId = dac.NationalTravelFeeId,
  8160. Arae = $"{ntf.Country}-{ntf.City}",
  8161. Cost = dac.Cost,
  8162. Currency = dac.Currency,
  8163. CurrencyName = sd.Name,
  8164. SubTotal = dac.SubTotal,
  8165. })
  8166. .ToArray();
  8167. var data = new ChoiceMobileSubInfo3To6View()
  8168. {
  8169. ParentId = eecInfo.Id,
  8170. Choice = eecInfo.ChoiceThree,
  8171. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8172. Details = dayAndCostDatas
  8173. };
  8174. return Ok(JsonView(data));
  8175. }
  8176. else if (subType == 4) //4:伙食费
  8177. {
  8178. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8179. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8180. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8181. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8182. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8183. {
  8184. SubId = dac.Id,
  8185. DiId = dac.DiId,
  8186. Type = dac.Type,
  8187. Days = dac.Days,
  8188. NationalTravelFeeId = dac.NationalTravelFeeId,
  8189. Arae = $"{ntf.Country}-{ntf.City}",
  8190. Cost = dac.Cost,
  8191. Currency = dac.Currency,
  8192. CurrencyName = sd.Name,
  8193. SubTotal = dac.SubTotal,
  8194. })
  8195. .ToArray();
  8196. var data = new ChoiceMobileSubInfo3To6View()
  8197. {
  8198. ParentId = eecInfo.Id,
  8199. Choice = eecInfo.ChoiceFour,
  8200. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8201. Details = dayAndCostDatas
  8202. };
  8203. return Ok(JsonView(data));
  8204. }
  8205. else if (subType == 5) //5:公杂费
  8206. {
  8207. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8208. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8209. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8210. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8211. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8212. {
  8213. SubId = dac.Id,
  8214. DiId = dac.DiId,
  8215. Type = dac.Type,
  8216. Days = dac.Days,
  8217. NationalTravelFeeId = dac.NationalTravelFeeId,
  8218. Arae = $"{ntf.Country}-{ntf.City}",
  8219. Cost = dac.Cost,
  8220. Currency = dac.Currency,
  8221. CurrencyName = sd.Name,
  8222. SubTotal = dac.SubTotal,
  8223. })
  8224. .ToArray();
  8225. var data = new ChoiceMobileSubInfo3To6View()
  8226. {
  8227. ParentId = eecInfo.Id,
  8228. Choice = eecInfo.ChoiceFive,
  8229. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8230. Details = dayAndCostDatas
  8231. };
  8232. return Ok(JsonView(data));
  8233. }
  8234. else if (subType == 6) //6:培训费
  8235. {
  8236. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8237. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8238. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8239. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8240. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8241. {
  8242. SubId = dac.Id,
  8243. DiId = dac.DiId,
  8244. Type = dac.Type,
  8245. Days = dac.Days,
  8246. NationalTravelFeeId = dac.NationalTravelFeeId,
  8247. Arae = $"{ntf.Country}-{ntf.City}",
  8248. Cost = dac.Cost,
  8249. Currency = dac.Currency,
  8250. CurrencyName = sd.Name,
  8251. SubTotal = dac.SubTotal,
  8252. })
  8253. .ToArray();
  8254. var data = new ChoiceMobileSubInfo3To6View()
  8255. {
  8256. ParentId = eecInfo.Id,
  8257. Choice = eecInfo.ChoiceSix,
  8258. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8259. Details = dayAndCostDatas
  8260. };
  8261. return Ok(JsonView(data));
  8262. }
  8263. else if (subType == 7) //7:其他
  8264. {
  8265. //其他款项
  8266. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8267. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8268. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8269. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8270. .OrderBy((dop, sd1, sd2) => dop.Index)
  8271. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8272. {
  8273. SubId = dop.Id,
  8274. DiId = dop.Diid,
  8275. Index = dop.Index,
  8276. SetDataId = dop.SetDataId,
  8277. SetDataName = sd1.Name,
  8278. Cost = dop.Cost,
  8279. Currency = dop.Currency,
  8280. CurrencyName = sd2.Name,
  8281. SubTotal = dop.SubTotal,
  8282. Remark = dop.Remark,
  8283. })
  8284. .ToArray();
  8285. var data = new ChoiceSevenMobileSubInfoView()
  8286. {
  8287. ParentId = eecInfo.Id,
  8288. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8289. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8290. Details = otherData
  8291. };
  8292. return Ok(JsonView(data));
  8293. }
  8294. return Ok(JsonView(false));
  8295. }
  8296. #region op
  8297. /// <summary>
  8298. /// 移动端更新费用消息通知
  8299. /// </summary>
  8300. /// <param name="diid"></param>
  8301. /// <param name="id"></param>
  8302. /// <param name="currUserId"></param>
  8303. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8304. {
  8305. try
  8306. {
  8307. ////生成默认文件pdf并且通知人员
  8308. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8309. //{
  8310. // DiId = diid,
  8311. // ExportType = 1,
  8312. // SubTypeId = 1005
  8313. //}, "pdf");
  8314. ////发送通知
  8315. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8316. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8317. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8318. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8319. ////汇率信息记录
  8320. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8321. }
  8322. catch (Exception ex)
  8323. {
  8324. //记录日志
  8325. throw;
  8326. }
  8327. }
  8328. /// <summary>
  8329. /// 验证出入境费用数据是否存在
  8330. /// 不存在添加
  8331. /// </summary>
  8332. /// <param name="diId"></param>
  8333. /// <param name="currUserId"></param>
  8334. /// <returns></returns>
  8335. /// <exception cref="CustomException"></exception>
  8336. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8337. {
  8338. var parentId = 0;
  8339. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8340. if (info != null)
  8341. {
  8342. parentId = info.Id;
  8343. }
  8344. else
  8345. {
  8346. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8347. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8348. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8349. parentId = addId;
  8350. }
  8351. return parentId;
  8352. }
  8353. /// <summary>
  8354. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8355. /// </summary>
  8356. /// <returns></returns>
  8357. [HttpPost]
  8358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8359. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8360. {
  8361. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8362. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8363. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8364. //验证编辑权限
  8365. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8366. //if (!isEdit) return Ok(JsonView(false, msg));
  8367. var permissions = new List<Grp_EnterExitCostPermission>();
  8368. foreach (var userId in dto.UserIds)
  8369. {
  8370. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8371. }
  8372. if (permissions.Any())
  8373. {
  8374. _sqlSugar.BeginTran();
  8375. try
  8376. {
  8377. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8378. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8379. if (result < 1)
  8380. {
  8381. _sqlSugar.RollbackTran();
  8382. return Ok(JsonView(false));
  8383. }
  8384. }
  8385. catch (Exception ex)
  8386. {
  8387. _sqlSugar.RollbackTran();
  8388. return Ok(JsonView(false, ex.Message));
  8389. }
  8390. _sqlSugar.CommitTran();
  8391. return Ok(JsonView(true));
  8392. }
  8393. return Ok(JsonView(false));
  8394. }
  8395. /// <summary>
  8396. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8397. /// </summary>
  8398. /// <returns></returns>
  8399. [HttpPost]
  8400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8401. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8402. {
  8403. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8404. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8405. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8406. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8407. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8408. int id = dto.Id;
  8409. if (id <= 0) //add
  8410. {
  8411. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8412. if (add < 1) return Ok(JsonView(false));
  8413. id = add;
  8414. }
  8415. else //update
  8416. {
  8417. ////验证编辑权限
  8418. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8419. //if (!isEdit) return Ok(JsonView(false, msg));
  8420. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8421. if (upd < 1) return Ok(JsonView(false));
  8422. }
  8423. #region 汇率变更时更改币种相关费用
  8424. var opDayCosts = new List<Grp_DayAndCost>();
  8425. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8426. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8427. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8428. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8429. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8430. .Select((dac, sd) => new
  8431. {
  8432. dac.Id,
  8433. dac.DiId,
  8434. CurrencyCode = sd.Name,
  8435. dac.Cost
  8436. })
  8437. .ToList();
  8438. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8439. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8440. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8441. .Select((dop, sd) => new
  8442. {
  8443. dop.Id,
  8444. dop.Diid,
  8445. CurrencyCode = sd.Name,
  8446. dop.Cost
  8447. })
  8448. .ToList();
  8449. if (dayCosts.Count > 0)
  8450. {
  8451. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8452. foreach (var dc in new_dayCosts)
  8453. {
  8454. var thisCurrency = dc.Key.ToUpper();
  8455. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8456. if (thisRate == 0.00M) continue;
  8457. foreach (var dcSub in dc)
  8458. {
  8459. opDayCosts.Add(new Grp_DayAndCost()
  8460. {
  8461. Id = dcSub.Id,
  8462. DiId = dcSub.DiId,
  8463. Cost = dcSub.Cost,
  8464. SubTotal = dcSub.Cost * thisRate,
  8465. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8466. });
  8467. }
  8468. }
  8469. if (opDayCosts.Count > 0)
  8470. {
  8471. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8472. }
  8473. }
  8474. if (dayOtherCosts.Count > 0)
  8475. {
  8476. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8477. foreach (var dc in new_dayOtherCosts)
  8478. {
  8479. var thisCurrency = dc.Key.ToUpper();
  8480. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8481. if (thisRate == 0.00M) continue;
  8482. foreach (var dcSub in dc)
  8483. {
  8484. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8485. {
  8486. Id = dcSub.Id,
  8487. Diid = dcSub.Diid,
  8488. Cost = dcSub.Cost,
  8489. SubTotal = dcSub.Cost * thisRate,
  8490. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8491. });
  8492. }
  8493. }
  8494. if (opDayOtherCosts.Count > 0)
  8495. {
  8496. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8497. }
  8498. }
  8499. #endregion
  8500. //消息通知
  8501. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8502. //汇率信息记录
  8503. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8504. return Ok(JsonView(new { parentId = id }));
  8505. }
  8506. /// <summary>
  8507. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8508. /// </summary>
  8509. /// <returns></returns>
  8510. [HttpPost]
  8511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8512. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8513. {
  8514. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8515. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8516. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8517. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8518. int id = dto.Id;
  8519. if (id <= 0) //add
  8520. {
  8521. checkboxInfo.CreateUserId = dto.CurrUserId;
  8522. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8523. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8524. if (add < 1) return Ok(JsonView(false));
  8525. }
  8526. else //update
  8527. {
  8528. ////验证编辑权限
  8529. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8530. //if (!isEdit) return Ok(JsonView(false, msg));
  8531. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8532. .UpdateColumns(x => new
  8533. {
  8534. x.ChoiceOne,
  8535. x.ChoiceTwo,
  8536. x.SumJJC,
  8537. x.SumGWC,
  8538. x.SumTDC,
  8539. x.ChoiceThree,
  8540. x.ChoiceFour,
  8541. x.ChoiceFive,
  8542. x.ChoiceSix,
  8543. x.OtherExpenses_Checked
  8544. })
  8545. .Where(x => x.Id == id)
  8546. .ExecuteCommandAsync();
  8547. if (upd < 1) return Ok(JsonView(false));
  8548. }
  8549. return Ok(JsonView(new { parentId = id }));
  8550. }
  8551. /// <summary>
  8552. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8553. /// </summary>
  8554. /// <returns></returns>
  8555. [HttpPost]
  8556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8557. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8558. {
  8559. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8560. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8561. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8562. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8563. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8564. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8565. var checkboxInfo = new Grp_EnterExitCost()
  8566. {
  8567. Id = id,
  8568. DiId = diId,
  8569. CreateUserId = currUserId
  8570. };
  8571. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8572. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8573. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8574. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8575. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8576. if (id <= 0) //add
  8577. {
  8578. checkboxInfo.CreateUserId = dto.CurrUserId;
  8579. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8580. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8581. if (add < 1) return Ok(JsonView(false));
  8582. }
  8583. else //update
  8584. {
  8585. ////验证编辑权限
  8586. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8587. //if (!isEdit) return Ok(JsonView(false, msg));
  8588. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8589. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8590. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8591. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8592. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8593. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8594. .Where(x => x.Id == id)
  8595. .ExecuteCommandAsync();
  8596. if (upd < 1) return Ok(JsonView(false));
  8597. }
  8598. return Ok(JsonView(new { parentId = id }));
  8599. }
  8600. /// <summary>
  8601. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8602. /// </summary>
  8603. /// <returns></returns>
  8604. [HttpPost]
  8605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8606. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8607. {
  8608. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8609. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8610. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8611. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8612. info.FirstItemRemark = dto.FirstItemRemark;
  8613. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8614. int id = dto.Id;
  8615. if (id <= 0) //add
  8616. {
  8617. info.CreateUserId = dto.CurrUserId;
  8618. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8619. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8620. if (add < 1) return Ok(JsonView(false));
  8621. id = add;
  8622. }
  8623. else //update
  8624. {
  8625. ////验证编辑权限
  8626. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8627. //if (!isEdit) return Ok(JsonView(false, msg));
  8628. var upd = await _sqlSugar.Updateable(info)
  8629. .UpdateColumns(x => new
  8630. {
  8631. x.ChoiceOne,
  8632. x.InsidePay,
  8633. x.VisaRemark,
  8634. x.Visa,
  8635. x.Service,
  8636. x.Safe,
  8637. x.Ticket,
  8638. x.HeSuan,
  8639. x.YiMiao,
  8640. x.FirstItemRemark
  8641. })
  8642. .Where(x => x.Id == id)
  8643. .ExecuteCommandAsync();
  8644. if (upd < 1) return Ok(JsonView(false));
  8645. }
  8646. //消息通知
  8647. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8648. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8649. }
  8650. /// <summary>
  8651. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8652. /// </summary>
  8653. /// <returns></returns>
  8654. [HttpPost]
  8655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8656. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8657. {
  8658. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8659. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8660. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8661. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8662. info.OutsideJJPay = dto.OutsideJJPay;
  8663. info.OutsideGWPay = dto.OutsideGWPay;
  8664. info.OutsideTDPay = dto.OutsideTDPay;
  8665. info.AirJJ = dto.AirJJ;
  8666. info.AirGW = dto.AirGW;
  8667. info.AirTD = dto.AirTD;
  8668. info.CityTranffic = dto.CityTranffic;
  8669. info.TwoItemRemark = dto.TwoItemRemark;
  8670. info.SumJJC = dto.ChoiceTwoJJ;
  8671. info.SumGWC = dto.ChoiceTwoGW;
  8672. info.SumTDC = dto.ChoiceTwoTD;
  8673. int id = dto.Id;
  8674. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8675. if (id <= 0) //add
  8676. {
  8677. info.CreateUserId = dto.CurrUserId;
  8678. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8679. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8680. if (addId <= 0) return Ok(JsonView(false));
  8681. id = addId;
  8682. }
  8683. else //update
  8684. {
  8685. ////验证编辑权限
  8686. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8687. //if (!isEdit) return Ok(JsonView(false, msg));
  8688. var upd = await _sqlSugar.Updateable(info)
  8689. .UpdateColumns(x => new
  8690. {
  8691. x.SumJJC,
  8692. x.OutsideJJPay,
  8693. x.SumGWC,
  8694. x.OutsideGWPay,
  8695. x.SumTDC,
  8696. x.OutsideTDPay,
  8697. x.AirJJ,
  8698. x.AirGW,
  8699. x.AirTD,
  8700. x.CityTranffic,
  8701. x.TwoItemRemark
  8702. })
  8703. .Where(x => x.Id == id)
  8704. .ExecuteCommandAsync();
  8705. if (upd < 1) return Ok(JsonView(false));
  8706. }
  8707. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8708. gwcItemTotal = info.AirGW + info.CityTranffic;
  8709. tdcItemTotal = info.AirTD + info.CityTranffic;
  8710. //消息通知
  8711. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8712. return Ok(JsonView(new
  8713. {
  8714. parentId = id,
  8715. choiceTwoJJ = dto.ChoiceTwoJJ,
  8716. jjcItemTotal = jjcItemTotal,
  8717. choiceTwoGW = dto.ChoiceTwoGW,
  8718. gwcItemTotal = gwcItemTotal,
  8719. choiceTwoTD = dto.ChoiceTwoTD,
  8720. tdcItemTotal = tdcItemTotal
  8721. }));
  8722. }
  8723. /// <summary>
  8724. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8725. /// </summary>
  8726. /// <returns></returns>
  8727. [HttpPost]
  8728. [ApiExplorerSettings(IgnoreApi = true)]
  8729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8730. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8731. {
  8732. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8733. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8734. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8735. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8736. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8737. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8738. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8739. var infos = infos1.Select(x => new Grp_DayAndCost
  8740. {
  8741. Id = x.Id,
  8742. DiId = dto.DiId,
  8743. Type = dto.FeeType,
  8744. Days = x.Days,
  8745. NationalTravelFeeId = x.NationalTravelFeeId,
  8746. Cost = x.Cost,
  8747. Currency = x.Currency,
  8748. SubTotal = x.SubTotal,
  8749. CreateUserId = dto.CurrUserId
  8750. })
  8751. .ToList();
  8752. var adds = infos.Where(x => x.Id <= 0).ToList();
  8753. var upds = infos.Where(x => x.Id > 0).ToList();
  8754. if (adds.Count > 0)
  8755. {
  8756. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8757. if (add < 1) return Ok(JsonView(false));
  8758. }
  8759. if (upds.Count > 0)
  8760. {
  8761. var upd = await _sqlSugar.Updateable(adds)
  8762. .UpdateColumns(x => new
  8763. {
  8764. x.Days,
  8765. x.NationalTravelFeeId,
  8766. x.Cost,
  8767. x.Currency,
  8768. x.SubTotal
  8769. })
  8770. .WhereColumns(x => new { x.Id })
  8771. .ExecuteCommandAsync();
  8772. if (upd < 1) return Ok(JsonView(false));
  8773. }
  8774. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8775. //消息通知
  8776. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8777. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8778. return Ok(JsonView(new { itemTotal = itemTotal }));
  8779. }
  8780. /// <summary>
  8781. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8782. /// </summary>
  8783. /// <returns></returns>
  8784. [HttpPost]
  8785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8786. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8787. {
  8788. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8789. int subId = dto.SubId, feeType = dto.FeeType;
  8790. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8791. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8792. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8793. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8794. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8795. subInfo.Id = subId;
  8796. subInfo.DiId = dto.DiId;
  8797. if (feeType == 3) subInfo.Type = 1;
  8798. else if (feeType == 4) subInfo.Type = 2;
  8799. else if (feeType == 5) subInfo.Type = 3;
  8800. else if (feeType == 6) subInfo.Type = 4;
  8801. subInfo.CreateUserId = dto.CurrUserId;
  8802. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8803. if (parentId < 1) return Ok(JsonView(false));
  8804. //子表op
  8805. if (subId < 1)
  8806. {
  8807. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8808. if (subAdd < 1) return Ok(JsonView(false));
  8809. }
  8810. else
  8811. {
  8812. ////验证编辑权限
  8813. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8814. //if (!isEdit) return Ok(JsonView(false, msg));
  8815. var subUpd = await _sqlSugar.Updateable(subInfo)
  8816. .UpdateColumns(x => new
  8817. {
  8818. x.Days,
  8819. x.NationalTravelFeeId,
  8820. x.Cost,
  8821. x.Currency,
  8822. x.SubTotal
  8823. })
  8824. .WhereColumns(x => new { x.Id })
  8825. .ExecuteCommandAsync();
  8826. if (subUpd < 1) return Ok(JsonView(false));
  8827. }
  8828. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8829. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8830. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8831. }
  8832. /// <summary>
  8833. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8834. /// </summary>
  8835. /// <returns></returns>
  8836. [HttpPost]
  8837. [ApiExplorerSettings(IgnoreApi = true)]
  8838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8839. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8840. {
  8841. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8842. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8843. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8844. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8845. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8846. {
  8847. Id = x.Id,
  8848. Diid = dto.DiId,
  8849. SetDataId = x.SetDataId,
  8850. Index = x.Index,
  8851. Cost = x.Cost,
  8852. Currency = x.Currency,
  8853. SubTotal = x.SubTotal,
  8854. CreateUserId = dto.CurrUserId,
  8855. Remark = x.Remark
  8856. }).ToList();
  8857. var adds = infos.Where(x => x.Id <= 0).ToList();
  8858. var upds = infos.Where(x => x.Id > 0).ToList();
  8859. if (adds.Count > 0)
  8860. {
  8861. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8862. if (add < 1) return Ok(JsonView(false));
  8863. }
  8864. if (upds.Count > 0)
  8865. {
  8866. var upd = await _sqlSugar.Updateable(adds)
  8867. .UpdateColumns(x => new
  8868. {
  8869. x.Index,
  8870. x.SetDataId,
  8871. x.Cost,
  8872. x.Currency,
  8873. x.SubTotal,
  8874. x.Remark
  8875. })
  8876. .WhereColumns(x => new { x.Id })
  8877. .ExecuteCommandAsync();
  8878. if (upd < 1) return Ok(JsonView(false));
  8879. }
  8880. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8881. //消息通知
  8882. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8883. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8884. return Ok(JsonView(new { itemTotal = itemTotal }));
  8885. }
  8886. /// <summary>
  8887. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8888. /// </summary>
  8889. /// <returns></returns>
  8890. [HttpPost]
  8891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8892. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8893. {
  8894. int subId = dto.SubId;
  8895. int diId = dto.Diid;
  8896. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8897. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8898. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8899. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8900. subInfo.Id = subId;
  8901. subInfo.Diid = dto.Diid;
  8902. subInfo.CreateUserId = dto.CurrUserId;
  8903. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8904. if (parentId < 1) return Ok(JsonView(false));
  8905. #region 子表op
  8906. if (subId < 1)//add
  8907. {
  8908. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8909. if (subAdd < 1) return Ok(JsonView(false));
  8910. }
  8911. else //upd
  8912. {
  8913. ////验证编辑权限
  8914. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8915. //if (!isEdit) return Ok(JsonView(false, msg));
  8916. var subUpd = await _sqlSugar.Updateable(subInfo)
  8917. .UpdateColumns(x => new
  8918. {
  8919. x.Index,
  8920. x.SetDataId,
  8921. x.Cost,
  8922. x.Currency,
  8923. x.SubTotal,
  8924. x.Remark
  8925. })
  8926. .WhereColumns(x => new { x.Id })
  8927. .ExecuteCommandAsync();
  8928. if (subUpd < 1) return Ok(JsonView(false));
  8929. }
  8930. #endregion
  8931. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8932. //消息通知
  8933. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8934. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8935. }
  8936. /// <summary>
  8937. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8938. /// </summary>
  8939. /// <returns></returns>
  8940. [HttpPost]
  8941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8942. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8943. {
  8944. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8945. if (data.Code != 0)
  8946. {
  8947. return Ok(JsonView(false, data.Msg));
  8948. }
  8949. return Ok(JsonView(true, "操作成功!", data.Data));
  8950. }
  8951. /// <summary>
  8952. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8953. /// </summary>
  8954. /// <param name="dto"></param>
  8955. /// <returns></returns>
  8956. [HttpPost]
  8957. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8958. {
  8959. var data = new Grp_DayOtherPrice()
  8960. {
  8961. Id = dto.Id,
  8962. IsDel = 1,
  8963. DeleteUserId = dto.DeleteUserId,
  8964. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8965. };
  8966. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8967. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  8968. return Ok(JsonView(false, "删除失败!"));
  8969. }
  8970. #endregion
  8971. #endregion
  8972. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  8973. /// <summary>
  8974. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  8975. /// </summary>
  8976. /// <returns></returns>
  8977. [HttpPost]
  8978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8979. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  8980. {
  8981. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8982. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8983. RefAsync<int> total = 0;
  8984. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8985. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  8986. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  8987. .Select(x => new
  8988. {
  8989. Id = x.Id,
  8990. DraftName = x.DraftName,
  8991. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  8992. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  8993. .Any()
  8994. })
  8995. .OrderByDescending(x => x.Id)
  8996. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8997. return Ok(JsonView(true, "查询成功!", data, total));
  8998. }
  8999. /// <summary>
  9000. /// 出入境费用-草稿 移动端
  9001. /// 获取币种基础数据(含逻辑处理)
  9002. /// </summary>
  9003. /// <returns></returns>
  9004. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9005. {
  9006. return await GeneralMethod.EnterExitCostInitRate();
  9007. }
  9008. /// <summary>
  9009. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9010. /// </summary>
  9011. /// <returns></returns>
  9012. [HttpPost]
  9013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9014. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9015. {
  9016. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9017. //SetDataInfoView
  9018. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9019. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9020. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9021. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9022. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9023. //默认币种显示
  9024. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9025. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9026. return Ok(JsonView(true, "查询成功!", new
  9027. {
  9028. WordTypeData = _WordTypeData,
  9029. ExcelTypeData = _ExcelTypeData,
  9030. CurrencyInit = _currencyInfos,
  9031. viewPermissionData = viewPermissionData
  9032. }));
  9033. }
  9034. /// <summary>
  9035. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9036. /// </summary>
  9037. /// <returns></returns>
  9038. [HttpPost]
  9039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9040. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9041. {
  9042. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9043. RefAsync<int> total = 0;
  9044. int diId = 0;
  9045. var status = int.TryParse(dto.GroupName, out diId);
  9046. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9047. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9048. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9049. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9050. .Select(x => new
  9051. {
  9052. Id = x.Id,
  9053. GroupName = x.TeamName
  9054. })
  9055. .OrderByDescending(x => x.Id)
  9056. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9057. return Ok(JsonView(true, "查询成功!", data, total));
  9058. }
  9059. /// <summary>
  9060. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9061. /// </summary>
  9062. /// <returns></returns>
  9063. [HttpPost]
  9064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9065. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9066. {
  9067. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9068. RefAsync<int> total = 0;
  9069. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9070. .Where(x => x.IsDel == 0 && x.STid == 66)
  9071. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9072. .Select(x => new
  9073. {
  9074. id = x.Id,
  9075. name = x.Name,
  9076. remark = x.Remark,
  9077. })
  9078. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9079. return Ok(JsonView(true, "查询成功!", data, total));
  9080. }
  9081. /// <summary>
  9082. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9083. /// </summary>
  9084. /// <returns></returns>
  9085. [HttpPost]
  9086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9087. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9088. {
  9089. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9090. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9091. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9092. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9093. var groupOtherRateData = groupRateData.TeamRates;
  9094. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9095. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9096. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9097. groupOtherRateData = groupOtherRateData
  9098. .Select(x => new TeamRateDescAddCurrencyIdView
  9099. {
  9100. CurrencyId = x.CurrencyId,
  9101. CurrencyName = x.CurrencyName,
  9102. CurrencyCode = x.CurrencyCode,
  9103. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9104. }).ToList();
  9105. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9106. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9107. }
  9108. /// <summary>
  9109. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9110. /// </summary>
  9111. /// <returns></returns>
  9112. [HttpPost]
  9113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9114. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9115. {
  9116. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9117. var tipsData = new List<int>() { 1, 2, 3 };
  9118. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9119. if (dto.TipsType == 1)
  9120. {
  9121. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9122. }
  9123. else if (dto.TipsType == 2)
  9124. {
  9125. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9126. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9127. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9128. .Select(x => x.NationalTravelFeeId)
  9129. .Distinct()
  9130. .ToListAsync();
  9131. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9132. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9133. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9134. .Select(x => x.Country)
  9135. .Distinct()
  9136. .ToArrayAsync();
  9137. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9138. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9139. return Ok(JsonView(true, "查询成功!", new
  9140. {
  9141. totalAmt = totalAmt,
  9142. remark = remark
  9143. }));
  9144. }
  9145. else if (dto.TipsType == 3)
  9146. {
  9147. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9148. }
  9149. return Ok(JsonView(false));
  9150. }
  9151. /// <summary>
  9152. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9153. /// </summary>
  9154. /// <returns></returns>
  9155. [HttpPost]
  9156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9157. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9158. {
  9159. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9160. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9161. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9162. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9163. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9164. var info = new Grp_EnterExitCostDraft() {
  9165. DraftName = dto.DraftName,
  9166. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9167. CreateUserId = dto.CurrUserId
  9168. };
  9169. _sqlSugar.BeginTran();
  9170. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9171. if (draftId < 1) {
  9172. _sqlSugar.RollbackTran();
  9173. return Ok(JsonView(false, "草稿创建失败!"));
  9174. }
  9175. //添加默认权限
  9176. await _enterExitCostDraftRep.InitPerm(draftId,dto.CurrUserId);
  9177. _sqlSugar.CommitTran();
  9178. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9179. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9180. mobileInfo.Id = draftId;
  9181. mobileInfo.DraftName = dto.DraftName;
  9182. mobileInfo.Currencys = rateInfos;
  9183. mobileInfo.IsAssignPerm = assignPerm;
  9184. return Ok(JsonView(mobileInfo));
  9185. }
  9186. /// <summary>
  9187. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9188. /// </summary>
  9189. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9190. /// <summary>
  9191. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9192. /// </summary>
  9193. /// <returns></returns>
  9194. [HttpPost]
  9195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9196. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9197. {
  9198. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9199. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9200. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9201. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9202. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9203. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9204. //验证查看编辑权限
  9205. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9206. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9207. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9208. mobileInfo.IsAssignPerm = assignPerm;
  9209. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9210. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9211. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9212. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9213. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9214. {
  9215. ParentId = dac.ParentId,
  9216. SubId = dac.Id,
  9217. Type = dac.Type,
  9218. Days = dac.Days,
  9219. NationalTravelFeeId = dac.NationalTravelFeeId,
  9220. Arae = $"{ntf.Country}-{ntf.City}",
  9221. Cost = dac.Cost,
  9222. Currency = dac.Currency,
  9223. CurrencyName = sd.Name,
  9224. SubTotal = dac.SubTotal,
  9225. })
  9226. .ToList();
  9227. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9228. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9229. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9230. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9231. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9232. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9233. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9234. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9235. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9236. //其他款项
  9237. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9238. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9239. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9240. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9241. .OrderBy((dop, sd1, sd2) => dop.Index)
  9242. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9243. {
  9244. ParentId = dop.ParentId,
  9245. SubId = dop.Id,
  9246. Index = dop.Index,
  9247. SetDataId = dop.SetDataId,
  9248. SetDataName = sd1.Name,
  9249. Cost = dop.Cost,
  9250. Currency = dop.Currency,
  9251. CurrencyName = sd2.Remark,
  9252. SubTotal = dop.SubTotal,
  9253. Remark = dop.Remark,
  9254. })
  9255. .ToArray();
  9256. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9257. return Ok(mobileInfo);
  9258. }
  9259. /// <summary>
  9260. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9261. /// </summary>
  9262. /// <returns></returns>
  9263. [HttpPost]
  9264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9265. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9266. {
  9267. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9268. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9269. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9270. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9271. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9272. //验证查看编辑权限
  9273. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9274. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9275. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9276. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9277. var subType = dto.SubType;
  9278. if (subType == 1) //1:境内费用
  9279. {
  9280. var oneData = new ChoiceOneMobileSubInfoView()
  9281. {
  9282. Id = eecInfo.Id,
  9283. ChoiceOne = eecInfo.ChoiceOne,
  9284. ChoiceOneTotalCost = eecInfo.InsidePay,
  9285. Visa = eecInfo.Visa,
  9286. VisaRemark = eecInfo.VisaRemark,
  9287. YiMiao = eecInfo.YiMiao,
  9288. HeSuan = eecInfo.HeSuan,
  9289. Service = eecInfo.Service,
  9290. Ticket = eecInfo.Ticket,
  9291. Safe = eecInfo.Safe,
  9292. FirstItemRemark = eecInfo.FirstItemRemark
  9293. };
  9294. return Ok(JsonView(oneData));
  9295. }
  9296. else if (subType == 2) //2:国际旅费
  9297. {
  9298. var twoData = new ChoiceTwoMobileSubInfoView()
  9299. {
  9300. Id = eecInfo.Id,
  9301. ChoiceTwoJJ = eecInfo.SumJJC,
  9302. OutsideJJPay = eecInfo.OutsideJJPay,
  9303. ChoiceTwoGW = eecInfo.SumGWC,
  9304. OutsideGWPay = eecInfo.OutsideGWPay,
  9305. ChoiceTwoTD = eecInfo.SumTDC,
  9306. OutsideTDPay = eecInfo.OutsideTDPay,
  9307. AirJJ = eecInfo.AirJJ,
  9308. AirGW = eecInfo.AirGW,
  9309. AirTD = eecInfo.AirTD,
  9310. CityTranffic = eecInfo.CityTranffic,
  9311. TwoItemRemark = eecInfo.TwoItemRemark
  9312. };
  9313. return Ok(JsonView(twoData));
  9314. }
  9315. else if (subType == 3) //3:住宿费
  9316. {
  9317. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9318. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9319. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9320. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9321. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9322. {
  9323. ParentId = dac.ParentId,
  9324. SubId = dac.Id,
  9325. Type = dac.Type,
  9326. Days = dac.Days,
  9327. NationalTravelFeeId = dac.NationalTravelFeeId,
  9328. Arae = $"{ntf.Country}-{ntf.City}",
  9329. Cost = dac.Cost,
  9330. Currency = dac.Currency,
  9331. CurrencyName = sd.Name,
  9332. SubTotal = dac.SubTotal,
  9333. })
  9334. .ToArray();
  9335. var data = new ChoiceDraftMobileSubInfo3To6View()
  9336. {
  9337. ParentId = eecInfo.Id,
  9338. Choice = eecInfo.ChoiceThree,
  9339. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9340. Details = dayAndCostDatas
  9341. };
  9342. return Ok(JsonView(data));
  9343. }
  9344. else if (subType == 4) //4:伙食费
  9345. {
  9346. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9347. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9348. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9349. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9350. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9351. {
  9352. ParentId = dac.ParentId,
  9353. SubId = dac.Id,
  9354. Type = dac.Type,
  9355. Days = dac.Days,
  9356. NationalTravelFeeId = dac.NationalTravelFeeId,
  9357. Arae = $"{ntf.Country}-{ntf.City}",
  9358. Cost = dac.Cost,
  9359. Currency = dac.Currency,
  9360. CurrencyName = sd.Name,
  9361. SubTotal = dac.SubTotal,
  9362. })
  9363. .ToArray();
  9364. var data = new ChoiceDraftMobileSubInfo3To6View()
  9365. {
  9366. ParentId = eecInfo.Id,
  9367. Choice = eecInfo.ChoiceFour,
  9368. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9369. Details = dayAndCostDatas
  9370. };
  9371. return Ok(JsonView(data));
  9372. }
  9373. else if (subType == 5) //5:公杂费
  9374. {
  9375. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9376. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9377. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9378. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9379. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9380. {
  9381. ParentId = dac.ParentId,
  9382. SubId = dac.Id,
  9383. Type = dac.Type,
  9384. Days = dac.Days,
  9385. NationalTravelFeeId = dac.NationalTravelFeeId,
  9386. Arae = $"{ntf.Country}-{ntf.City}",
  9387. Cost = dac.Cost,
  9388. Currency = dac.Currency,
  9389. CurrencyName = sd.Name,
  9390. SubTotal = dac.SubTotal,
  9391. })
  9392. .ToArray();
  9393. var data = new ChoiceDraftMobileSubInfo3To6View()
  9394. {
  9395. ParentId = eecInfo.Id,
  9396. Choice = eecInfo.ChoiceFive,
  9397. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9398. Details = dayAndCostDatas
  9399. };
  9400. return Ok(JsonView(data));
  9401. }
  9402. else if (subType == 6) //6:培训费
  9403. {
  9404. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9405. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9406. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9407. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9408. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9409. {
  9410. ParentId = dac.ParentId,
  9411. SubId = dac.Id,
  9412. Type = dac.Type,
  9413. Days = dac.Days,
  9414. NationalTravelFeeId = dac.NationalTravelFeeId,
  9415. Arae = $"{ntf.Country}-{ntf.City}",
  9416. Cost = dac.Cost,
  9417. Currency = dac.Currency,
  9418. CurrencyName = sd.Name,
  9419. SubTotal = dac.SubTotal,
  9420. })
  9421. .ToArray();
  9422. var data = new ChoiceDraftMobileSubInfo3To6View()
  9423. {
  9424. ParentId = eecInfo.Id,
  9425. Choice = eecInfo.ChoiceSix,
  9426. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9427. Details = dayAndCostDatas
  9428. };
  9429. return Ok(JsonView(data));
  9430. }
  9431. else if (subType == 7) //7:其他
  9432. {
  9433. //其他款项
  9434. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9435. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9436. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9437. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9438. .OrderBy((dop, sd1, sd2) => dop.Index)
  9439. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9440. {
  9441. ParentId = dop.ParentId,
  9442. SubId = dop.Id,
  9443. Index = dop.Index,
  9444. SetDataId = dop.SetDataId,
  9445. SetDataName = sd1.Name,
  9446. Cost = dop.Cost,
  9447. Currency = dop.Currency,
  9448. CurrencyName = sd2.Name,
  9449. SubTotal = dop.SubTotal,
  9450. Remark = dop.Remark,
  9451. })
  9452. .ToArray();
  9453. var data = new ChoiceSevenDraftMobileSubInfoView()
  9454. {
  9455. ParentId = eecInfo.Id,
  9456. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9457. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9458. Details = otherData
  9459. };
  9460. return Ok(JsonView(data));
  9461. }
  9462. return Ok(JsonView(false));
  9463. }
  9464. #region op
  9465. /// <summary>
  9466. /// 移动端更新费用消息通知
  9467. /// </summary>
  9468. /// <param name="draftId"></param>
  9469. /// <param name="id"></param>
  9470. /// <param name="currUserId"></param>
  9471. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9472. {
  9473. try
  9474. {
  9475. ////生成默认文件pdf并且通知人员
  9476. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9477. //{
  9478. // DiId = draftId,
  9479. // ExportType = 1,
  9480. // SubTypeId = 1005
  9481. //}, "pdf");
  9482. ////发送通知
  9483. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9484. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9485. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9486. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9487. ////汇率信息记录
  9488. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9489. }
  9490. catch (Exception ex)
  9491. {
  9492. //记录日志
  9493. throw;
  9494. }
  9495. }
  9496. /// <summary>
  9497. /// 验证出入境费用数据是否存在
  9498. /// 不存在添加
  9499. /// </summary>
  9500. /// <param name="draftId"></param>
  9501. /// <param name="currUserId"></param>
  9502. /// <returns></returns>
  9503. /// <exception cref="CustomException"></exception>
  9504. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9505. {
  9506. var parentId = 0;
  9507. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9508. if (info != null) parentId = info.Id;
  9509. else
  9510. {
  9511. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9512. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9513. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9514. parentId = addId;
  9515. }
  9516. return parentId;
  9517. }
  9518. /// <summary>
  9519. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9520. /// </summary>
  9521. /// <returns></returns>
  9522. [HttpPost]
  9523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9524. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9525. {
  9526. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9527. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9528. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9529. //验证查看编辑权限
  9530. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9531. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9532. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9533. foreach (var userId in dto.UserIds)
  9534. {
  9535. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9536. }
  9537. if (permissions.Any())
  9538. {
  9539. _sqlSugar.BeginTran();
  9540. try
  9541. {
  9542. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9543. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9544. if (result < 1)
  9545. {
  9546. _sqlSugar.RollbackTran();
  9547. return Ok(JsonView(false));
  9548. }
  9549. }
  9550. catch (Exception ex)
  9551. {
  9552. _sqlSugar.RollbackTran();
  9553. return Ok(JsonView(false, ex.Message));
  9554. }
  9555. _sqlSugar.CommitTran();
  9556. return Ok(JsonView(true));
  9557. }
  9558. return Ok(JsonView(false));
  9559. }
  9560. /// <summary>
  9561. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9562. /// </summary>
  9563. /// <returns></returns>
  9564. [HttpPost]
  9565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9566. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9567. {
  9568. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9569. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9570. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9571. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9572. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9573. int id = dto.DraftId;
  9574. if (id <= 0) //add
  9575. {
  9576. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9577. if (add < 1) return Ok(JsonView(false));
  9578. id = add;
  9579. }
  9580. else //update
  9581. {
  9582. //验证查看编辑权限
  9583. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9584. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9585. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9586. if (upd < 1) return Ok(JsonView(false));
  9587. }
  9588. #region 汇率变更时更改币种相关费用
  9589. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9590. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9591. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9592. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9593. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9594. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9595. .Select((dac, sd) => new
  9596. {
  9597. dac.Id,
  9598. dac.ParentId,
  9599. CurrencyCode = sd.Name,
  9600. dac.Cost
  9601. })
  9602. .ToList();
  9603. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9604. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9605. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9606. .Select((dop, sd) => new
  9607. {
  9608. dop.Id,
  9609. dop.ParentId,
  9610. CurrencyCode = sd.Name,
  9611. dop.Cost
  9612. })
  9613. .ToList();
  9614. if (dayCosts.Count > 0)
  9615. {
  9616. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9617. foreach (var dc in new_dayCosts)
  9618. {
  9619. var thisCurrency = dc.Key.ToUpper();
  9620. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9621. if (thisRate == 0.00M) continue;
  9622. foreach (var dcSub in dc)
  9623. {
  9624. opDayCosts.Add(new Grp_DayAndCostDraft()
  9625. {
  9626. Id = dcSub.Id,
  9627. ParentId = dcSub.ParentId,
  9628. Cost = dcSub.Cost,
  9629. SubTotal = dcSub.Cost * thisRate,
  9630. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9631. });
  9632. }
  9633. }
  9634. if (opDayCosts.Count > 0)
  9635. {
  9636. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9637. }
  9638. }
  9639. if (dayOtherCosts.Count > 0)
  9640. {
  9641. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9642. foreach (var dc in new_dayOtherCosts)
  9643. {
  9644. var thisCurrency = dc.Key.ToUpper();
  9645. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9646. if (thisRate == 0.00M) continue;
  9647. foreach (var dcSub in dc)
  9648. {
  9649. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9650. {
  9651. Id = dcSub.Id,
  9652. ParentId = dcSub.ParentId,
  9653. Cost = dcSub.Cost,
  9654. SubTotal = dcSub.Cost * thisRate,
  9655. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9656. });
  9657. }
  9658. }
  9659. if (opDayOtherCosts.Count > 0)
  9660. {
  9661. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9662. }
  9663. }
  9664. #endregion
  9665. ////消息通知
  9666. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9667. ////汇率信息记录
  9668. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9669. return Ok(JsonView(new { parentId = id }));
  9670. }
  9671. /// <summary>
  9672. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9673. /// </summary>
  9674. /// <returns></returns>
  9675. [HttpPost]
  9676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9677. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9678. {
  9679. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9680. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9681. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9682. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9683. int id = dto.DraftId;
  9684. if (id <= 0) //add
  9685. {
  9686. checkboxInfo.CreateUserId = dto.CurrUserId;
  9687. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9688. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9689. if (add < 1) return Ok(JsonView(false));
  9690. }
  9691. else //update
  9692. {
  9693. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9694. .UpdateColumns(x => new
  9695. {
  9696. x.ChoiceOne,
  9697. x.ChoiceTwo,
  9698. x.SumJJC,
  9699. x.SumGWC,
  9700. x.SumTDC,
  9701. x.ChoiceThree,
  9702. x.ChoiceFour,
  9703. x.ChoiceFive,
  9704. x.ChoiceSix,
  9705. x.OtherExpenses_Checked
  9706. })
  9707. .Where(x => x.Id == id)
  9708. .ExecuteCommandAsync();
  9709. if (upd < 1) return Ok(JsonView(false));
  9710. }
  9711. return Ok(JsonView(new { parentId = id }));
  9712. }
  9713. /// <summary>
  9714. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9715. /// </summary>
  9716. /// <returns></returns>
  9717. [HttpPost]
  9718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9719. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9720. {
  9721. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9722. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9723. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9724. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9725. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9726. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9727. var checkboxInfo = new Grp_EnterExitCostDraft()
  9728. {
  9729. Id = draftId,
  9730. CreateUserId = currUserId
  9731. };
  9732. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9733. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9734. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9735. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9736. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9737. if (draftId <= 0) //add
  9738. {
  9739. checkboxInfo.CreateUserId = dto.CurrUserId;
  9740. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9741. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9742. if (add < 1) return Ok(JsonView(false));
  9743. }
  9744. else //update
  9745. {
  9746. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9747. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9748. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9749. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9750. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9751. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9752. .Where(x => x.Id == draftId)
  9753. .ExecuteCommandAsync();
  9754. if (upd < 1) return Ok(JsonView(false));
  9755. }
  9756. return Ok(JsonView(new { parentId = draftId }));
  9757. }
  9758. /// <summary>
  9759. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9760. /// </summary>
  9761. /// <returns></returns>
  9762. [HttpPost]
  9763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9764. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9765. {
  9766. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9767. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9768. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9769. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9770. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9771. info.FirstItemRemark = dto.FirstItemRemark;
  9772. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9773. if (id <= 0) //add
  9774. {
  9775. info.CreateUserId = dto.CurrUserId;
  9776. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9777. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9778. if (add < 1) return Ok(JsonView(false));
  9779. id = add;
  9780. }
  9781. else //update
  9782. {
  9783. var upd = await _sqlSugar.Updateable(info)
  9784. .UpdateColumns(x => new
  9785. {
  9786. x.ChoiceOne,
  9787. x.InsidePay,
  9788. x.VisaRemark,
  9789. x.Visa,
  9790. x.Service,
  9791. x.Safe,
  9792. x.Ticket,
  9793. x.HeSuan,
  9794. x.YiMiao,
  9795. x.FirstItemRemark
  9796. })
  9797. .Where(x => x.Id == id)
  9798. .ExecuteCommandAsync();
  9799. if (upd < 1) return Ok(JsonView(false));
  9800. }
  9801. ////消息通知
  9802. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9803. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9804. }
  9805. /// <summary>
  9806. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9807. /// </summary>
  9808. /// <returns></returns>
  9809. [HttpPost]
  9810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9811. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9812. {
  9813. int id = dto.DraftId;
  9814. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9815. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9816. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9817. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9818. info.OutsideJJPay = dto.OutsideJJPay;
  9819. info.OutsideGWPay = dto.OutsideGWPay;
  9820. info.OutsideTDPay = dto.OutsideTDPay;
  9821. info.AirJJ = dto.AirJJ;
  9822. info.AirGW = dto.AirGW;
  9823. info.AirTD = dto.AirTD;
  9824. info.CityTranffic = dto.CityTranffic;
  9825. info.TwoItemRemark = dto.TwoItemRemark;
  9826. info.SumJJC = dto.ChoiceTwoJJ;
  9827. info.SumGWC = dto.ChoiceTwoGW;
  9828. info.SumTDC = dto.ChoiceTwoTD;
  9829. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9830. if (id <= 0) //add
  9831. {
  9832. info.CreateUserId = dto.CurrUserId;
  9833. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9834. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9835. if (addId <= 0) return Ok(JsonView(false));
  9836. id = addId;
  9837. }
  9838. else //update
  9839. {
  9840. var upd = await _sqlSugar.Updateable(info)
  9841. .UpdateColumns(x => new
  9842. {
  9843. x.SumJJC,
  9844. x.OutsideJJPay,
  9845. x.SumGWC,
  9846. x.OutsideGWPay,
  9847. x.SumTDC,
  9848. x.OutsideTDPay,
  9849. x.AirJJ,
  9850. x.AirGW,
  9851. x.AirTD,
  9852. x.CityTranffic,
  9853. x.TwoItemRemark
  9854. })
  9855. .Where(x => x.Id == id)
  9856. .ExecuteCommandAsync();
  9857. if (upd < 1) return Ok(JsonView(false));
  9858. }
  9859. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9860. gwcItemTotal = info.AirGW + info.CityTranffic;
  9861. tdcItemTotal = info.AirTD + info.CityTranffic;
  9862. ////消息通知
  9863. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9864. return Ok(JsonView(new
  9865. {
  9866. parentId = id,
  9867. choiceTwoJJ = dto.ChoiceTwoJJ,
  9868. jjcItemTotal = jjcItemTotal,
  9869. choiceTwoGW = dto.ChoiceTwoGW,
  9870. gwcItemTotal = gwcItemTotal,
  9871. choiceTwoTD = dto.ChoiceTwoTD,
  9872. tdcItemTotal = tdcItemTotal
  9873. }));
  9874. }
  9875. /// <summary>
  9876. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9877. /// </summary>
  9878. /// <returns></returns>
  9879. [HttpPost]
  9880. [ApiExplorerSettings(IgnoreApi = true)]
  9881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9882. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9883. {
  9884. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9885. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9886. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9887. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9888. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9889. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9890. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9891. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9892. {
  9893. Id = x.Id,
  9894. ParentId = dto.DraftId,
  9895. Type = dto.FeeType,
  9896. Days = x.Days,
  9897. NationalTravelFeeId = x.NationalTravelFeeId,
  9898. Cost = x.Cost,
  9899. Currency = x.Currency,
  9900. SubTotal = x.SubTotal,
  9901. CreateUserId = dto.CurrUserId
  9902. })
  9903. .ToList();
  9904. var adds = infos.Where(x => x.Id <= 0).ToList();
  9905. var upds = infos.Where(x => x.Id > 0).ToList();
  9906. if (adds.Count > 0)
  9907. {
  9908. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9909. if (add < 1) return Ok(JsonView(false));
  9910. }
  9911. if (upds.Count > 0)
  9912. {
  9913. var upd = await _sqlSugar.Updateable(adds)
  9914. .UpdateColumns(x => new
  9915. {
  9916. x.Days,
  9917. x.NationalTravelFeeId,
  9918. x.Cost,
  9919. x.Currency,
  9920. x.SubTotal
  9921. })
  9922. .WhereColumns(x => new { x.Id })
  9923. .ExecuteCommandAsync();
  9924. if (upd < 1) return Ok(JsonView(false));
  9925. }
  9926. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9927. ////消息通知
  9928. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9929. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9930. return Ok(JsonView(new { itemTotal = itemTotal }));
  9931. }
  9932. /// <summary>
  9933. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9934. /// </summary>
  9935. /// <returns></returns>
  9936. [HttpPost]
  9937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9938. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9939. {
  9940. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9941. int subId = dto.SubId, feeType = dto.FeeType;
  9942. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9943. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9944. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9945. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9946. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9947. subInfo.Id = subId;
  9948. subInfo.ParentId = dto.DraftId;
  9949. if (feeType == 3) subInfo.Type = 1;
  9950. else if (feeType == 4) subInfo.Type = 2;
  9951. else if (feeType == 5) subInfo.Type = 3;
  9952. else if (feeType == 6) subInfo.Type = 4;
  9953. subInfo.CreateUserId = dto.CurrUserId;
  9954. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9955. if (parentId < 1) return Ok(JsonView(false));
  9956. //子表op
  9957. if (subId < 1)
  9958. {
  9959. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9960. if (subAdd < 1) return Ok(JsonView(false));
  9961. }
  9962. else
  9963. {
  9964. var subUpd = await _sqlSugar.Updateable(subInfo)
  9965. .UpdateColumns(x => new
  9966. {
  9967. x.Days,
  9968. x.NationalTravelFeeId,
  9969. x.Cost,
  9970. x.Currency,
  9971. x.SubTotal
  9972. })
  9973. .WhereColumns(x => new { x.Id })
  9974. .ExecuteCommandAsync();
  9975. if (subUpd < 1) return Ok(JsonView(false));
  9976. }
  9977. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9978. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9979. }
  9980. /// <summary>
  9981. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9982. /// </summary>
  9983. /// <returns></returns>
  9984. [HttpPost]
  9985. [ApiExplorerSettings(IgnoreApi = true)]
  9986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9987. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  9988. {
  9989. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9990. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9991. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9992. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  9993. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  9994. {
  9995. Id = x.Id,
  9996. ParentId = dto.DraftId,
  9997. SetDataId = x.SetDataId,
  9998. Index = x.Index,
  9999. Cost = x.Cost,
  10000. Currency = x.Currency,
  10001. SubTotal = x.SubTotal,
  10002. CreateUserId = dto.CurrUserId,
  10003. Remark = x.Remark
  10004. }).ToList();
  10005. var adds = infos.Where(x => x.Id <= 0).ToList();
  10006. var upds = infos.Where(x => x.Id > 0).ToList();
  10007. if (adds.Count > 0)
  10008. {
  10009. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10010. if (add < 1) return Ok(JsonView(false));
  10011. }
  10012. if (upds.Count > 0)
  10013. {
  10014. var upd = await _sqlSugar.Updateable(adds)
  10015. .UpdateColumns(x => new
  10016. {
  10017. x.Index,
  10018. x.SetDataId,
  10019. x.Cost,
  10020. x.Currency,
  10021. x.SubTotal,
  10022. x.Remark
  10023. })
  10024. .WhereColumns(x => new { x.Id })
  10025. .ExecuteCommandAsync();
  10026. if (upd < 1) return Ok(JsonView(false));
  10027. }
  10028. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10029. //消息通知
  10030. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10031. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10032. return Ok(JsonView(new { itemTotal = itemTotal }));
  10033. }
  10034. /// <summary>
  10035. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10036. /// </summary>
  10037. /// <returns></returns>
  10038. [HttpPost]
  10039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10040. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10041. {
  10042. int subId = dto.SubId, id = dto.DraftId;
  10043. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10044. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10045. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10046. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10047. subInfo.Id = subId;
  10048. subInfo.ParentId = id;
  10049. subInfo.CreateUserId = dto.CurrUserId;
  10050. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10051. if (parentId < 1) return Ok(JsonView(false));
  10052. #region 子表op
  10053. if (subId < 1)//add
  10054. {
  10055. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10056. if (subAdd < 1) return Ok(JsonView(false));
  10057. }
  10058. else //upd
  10059. {
  10060. var subUpd = await _sqlSugar.Updateable(subInfo)
  10061. .UpdateColumns(x => new
  10062. {
  10063. x.Index,
  10064. x.SetDataId,
  10065. x.Cost,
  10066. x.Currency,
  10067. x.SubTotal,
  10068. x.Remark
  10069. })
  10070. .WhereColumns(x => new { x.Id })
  10071. .ExecuteCommandAsync();
  10072. if (subUpd < 1) return Ok(JsonView(false));
  10073. }
  10074. #endregion
  10075. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10076. ////消息通知
  10077. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10078. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10079. }
  10080. /// <summary>
  10081. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10082. /// </summary>
  10083. /// <returns></returns>
  10084. [HttpPost]
  10085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10086. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10087. {
  10088. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10089. if (data.Code != 0)
  10090. {
  10091. return Ok(JsonView(false, data.Msg));
  10092. }
  10093. return Ok(JsonView(true, "操作成功!", data.Data));
  10094. }
  10095. /// <summary>
  10096. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10097. /// </summary>
  10098. /// <param name="dto"></param>
  10099. /// <returns></returns>
  10100. [HttpPost]
  10101. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10102. {
  10103. var data = new Grp_DayOtherPriceDraft()
  10104. {
  10105. Id = dto.Id,
  10106. IsDel = 1,
  10107. DeleteUserId = dto.DeleteUserId,
  10108. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10109. };
  10110. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10111. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10112. return Ok(JsonView(false, "删除失败!"));
  10113. }
  10114. #endregion
  10115. #endregion
  10116. #region 团组经理模块 出入境费用报价表
  10117. /// <summary>
  10118. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10119. /// </summary>
  10120. /// <returns></returns>
  10121. [HttpPost]
  10122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10123. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10124. {
  10125. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10126. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10127. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10128. initRates.Insert(0, cnyInfo);
  10129. liveRates.Insert(0, cnyInfo);
  10130. return Ok(JsonView(true, "查询成功!", new
  10131. {
  10132. InitRates = initRates,
  10133. LiveRates = liveRates
  10134. }));
  10135. }
  10136. /// <summary>
  10137. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10138. /// </summary>
  10139. /// <returns></returns>
  10140. [HttpPost]
  10141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10142. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10143. {
  10144. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10145. }
  10146. /// <summary>
  10147. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10148. /// </summary>
  10149. /// <returns></returns>
  10150. [HttpPost]
  10151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10152. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10153. {
  10154. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10155. }
  10156. /// <summary>
  10157. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10158. /// </summary>
  10159. /// <returns></returns>
  10160. [HttpPost]
  10161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10162. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10163. {
  10164. int groupId = dto.DiId,
  10165. currUserId = dto.CurrUserId;
  10166. if (groupId < 1) return Ok(JsonView(false,"请传入有效的GroupId;"));
  10167. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10168. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10169. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10170. var infoView = info.Data as EnterExitCostInfoView;
  10171. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10172. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10173. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10174. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10175. var eecRates = infoView.Currencys;
  10176. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10177. int pplNum = 1;
  10178. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10179. var views = new List<QuoteSubItemInfo>();
  10180. #region 数据填充
  10181. var intTravelCosts = new List<QuoteSubItemInfo>();
  10182. #region 机票费用 1354
  10183. int intTravelIndex = 1;
  10184. if (infoView.SumJJC == 1)
  10185. {
  10186. intTravelCosts.Add(new QuoteSubItemInfo
  10187. {
  10188. ItemId = 1354,
  10189. Index = intTravelIndex,
  10190. FeeName = "经济舱",
  10191. UnitPrice = infoView.AirJJ,
  10192. Currency = "CNY",
  10193. Quantity = 1,
  10194. PplNum = 1,
  10195. TotalAmt = infoView.AirJJ,
  10196. Remark = "",
  10197. });
  10198. intTravelIndex++;
  10199. }
  10200. if (infoView.SumGWC == 1)
  10201. {
  10202. intTravelCosts.Add(new QuoteSubItemInfo
  10203. {
  10204. ItemId = 1354,
  10205. Index = intTravelIndex,
  10206. FeeName = "公务舱",
  10207. UnitPrice = infoView.AirGW,
  10208. Currency = "CNY",
  10209. Quantity = 1,
  10210. PplNum = 1,
  10211. TotalAmt = infoView.AirGW,
  10212. Remark = "",
  10213. });
  10214. intTravelIndex++;
  10215. }
  10216. if (infoView.SumTDC == 1)
  10217. {
  10218. intTravelCosts.Add(new QuoteSubItemInfo
  10219. {
  10220. ItemId = 1354,
  10221. Index = intTravelIndex,
  10222. FeeName = "头等舱",
  10223. UnitPrice = infoView.AirTD,
  10224. Currency = "CNY",
  10225. Quantity = 1,
  10226. PplNum = 1,
  10227. TotalAmt = infoView.AirTD,
  10228. Remark = "",
  10229. });
  10230. intTravelIndex++;
  10231. }
  10232. intTravelCosts.Add(new QuoteSubItemInfo
  10233. {
  10234. ItemId = 1354,
  10235. Index = intTravelIndex,
  10236. FeeName = "城市间交通费用",
  10237. UnitPrice = infoView.CityTranffic,
  10238. Currency = "CNY",
  10239. Quantity = 1,
  10240. PplNum = pplNum,
  10241. TotalAmt = infoView.CityTranffic * pplNum,
  10242. Remark = "",
  10243. });
  10244. views.AddRange(intTravelCosts);
  10245. #endregion
  10246. var accomCosts = new List<QuoteSubItemInfo>();
  10247. #region 住宿费 1355
  10248. if (infoView.QuarterageData.Any())
  10249. {
  10250. int accomIndex = 1;
  10251. int accomItemTypeId = 1355;
  10252. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10253. foreach (var item in groupData)
  10254. {
  10255. string feeName = string.Empty;
  10256. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10257. if (countryInfo != null)
  10258. {
  10259. feeName = countryInfo.Country;
  10260. var city = countryInfo.City;
  10261. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10262. {
  10263. feeName += $"-{city}";
  10264. }
  10265. }
  10266. var hotelInfo = item.FirstOrDefault();
  10267. if (hotelInfo == null) continue;
  10268. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10269. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10270. int quantity = item.ToList().Count;
  10271. accomCosts.Add(new QuoteSubItemInfo
  10272. {
  10273. ItemId = accomItemTypeId,
  10274. Index = accomIndex,
  10275. FeeName = feeName,
  10276. UnitPrice = hotelInfo.Cost,
  10277. Currency = thisCurrency,
  10278. Quantity = quantity,
  10279. PplNum = pplNum,
  10280. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10281. Remark = "",
  10282. });
  10283. accomIndex++;
  10284. }
  10285. views.AddRange(accomCosts);
  10286. }
  10287. #endregion
  10288. var mealCosts = new List<QuoteSubItemInfo>();
  10289. #region 餐饮费 1356
  10290. if (infoView.BoardWagesData.Any())
  10291. {
  10292. var mealIndex = 1;
  10293. int mealItemTypeId = 1356;
  10294. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10295. foreach (var item in groupData)
  10296. {
  10297. string feeName = string.Empty;
  10298. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10299. if (countryInfo != null)
  10300. {
  10301. feeName = countryInfo.Country;
  10302. var city = countryInfo.City;
  10303. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10304. {
  10305. feeName += $"-{city}";
  10306. }
  10307. }
  10308. var mealInfo = item.FirstOrDefault();
  10309. if (mealInfo == null) continue;
  10310. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10311. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10312. int quantity = item.ToList().Count;
  10313. mealCosts.Add(new QuoteSubItemInfo
  10314. {
  10315. ItemId = mealItemTypeId,
  10316. Index = mealIndex,
  10317. FeeName = feeName,
  10318. UnitPrice = mealInfo.Cost,
  10319. Currency = thisCurrency,
  10320. Quantity = quantity,
  10321. PplNum = pplNum,
  10322. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10323. Remark = "",
  10324. });
  10325. mealIndex++;
  10326. }
  10327. views.AddRange(mealCosts);
  10328. }
  10329. #endregion
  10330. var miscCosts = new List<QuoteSubItemInfo>();
  10331. #region 公杂费 1364
  10332. if (infoView.MiscellaneousFeeData.Any())
  10333. {
  10334. var miscIndex = 1;
  10335. int miscItemTypeId = 1364;
  10336. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10337. foreach (var item in groupData)
  10338. {
  10339. string feeName = string.Empty;
  10340. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10341. if (countryInfo != null)
  10342. {
  10343. feeName = countryInfo.Country;
  10344. var city = countryInfo.City;
  10345. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10346. {
  10347. feeName += $"-{city}";
  10348. }
  10349. }
  10350. var miscInfo = item.FirstOrDefault();
  10351. if (miscInfo == null) continue;
  10352. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10353. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10354. int quantity = item.ToList().Count;
  10355. mealCosts.Add(new QuoteSubItemInfo
  10356. {
  10357. ItemId = miscItemTypeId,
  10358. Index = miscIndex,
  10359. FeeName = feeName,
  10360. UnitPrice = miscInfo.Cost,
  10361. Currency = thisCurrency,
  10362. Quantity = quantity,
  10363. PplNum = pplNum,
  10364. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10365. Remark = "",
  10366. });
  10367. miscIndex++;
  10368. }
  10369. views.AddRange(mealCosts);
  10370. }
  10371. #endregion
  10372. #region 签证+保险 1362
  10373. int visaInsIndex = 1;
  10374. int visaInsItemTypeId = 1362;
  10375. if (infoView.Visa > 0)
  10376. {
  10377. views.Add(new QuoteSubItemInfo() {
  10378. ItemId = visaInsItemTypeId,
  10379. Index = visaInsIndex,
  10380. FeeName = $"签证",
  10381. UnitPrice = infoView.Visa,
  10382. Currency = $"CNY",
  10383. Quantity = 1,
  10384. PplNum = pplNum,
  10385. TotalAmt = infoView.Visa * pplNum,
  10386. Remark = "",
  10387. });
  10388. visaInsIndex++;
  10389. }
  10390. if (infoView.Safe > 0)
  10391. {
  10392. views.Add(new QuoteSubItemInfo()
  10393. {
  10394. ItemId = visaInsItemTypeId,
  10395. Index = visaInsIndex,
  10396. FeeName = $"保险",
  10397. UnitPrice = infoView.Safe,
  10398. Currency = $"CNY",
  10399. Quantity = 1,
  10400. PplNum = pplNum,
  10401. TotalAmt = infoView.Safe * pplNum,
  10402. Remark = "",
  10403. });
  10404. }
  10405. #endregion
  10406. #region 服务费 1363
  10407. int serviceFeeIndex = 1;
  10408. int serviceFeeItemTypeId = 1363;
  10409. if (infoView.Service > 0)
  10410. {
  10411. views.Add(new QuoteSubItemInfo()
  10412. {
  10413. ItemId = serviceFeeItemTypeId,
  10414. Index = serviceFeeIndex,
  10415. FeeName = $"服务费",
  10416. UnitPrice = infoView.Service,
  10417. Currency = $"CNY",
  10418. Quantity = 1,
  10419. PplNum = pplNum,
  10420. TotalAmt = infoView.Service * pplNum,
  10421. Remark = "",
  10422. });
  10423. }
  10424. #endregion
  10425. #endregion
  10426. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10427. result.Rates = eecRates.ToArray();
  10428. if (result.FeeItems.Any())
  10429. {
  10430. result.FeeItems.Select(x =>
  10431. {
  10432. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10433. if (feeInfos.Any()) x.Infos = feeInfos;
  10434. return x;
  10435. }
  10436. )
  10437. .OrderBy(x => x.Index)
  10438. .ToList();
  10439. }
  10440. return Ok(JsonView(result));
  10441. }
  10442. /// <summary>
  10443. /// 团组模块 - 出入境费用报价表 - Info
  10444. /// </summary>
  10445. /// <returns></returns>
  10446. [HttpPost]
  10447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10448. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10449. {
  10450. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10451. if (!info.Rates.Any())
  10452. {
  10453. var rates = await GeneralMethod.EnterExitCostInitRate();
  10454. info.Rates = rates.ToArray();
  10455. }
  10456. return Ok(JsonView(info));
  10457. }
  10458. /// <summary>
  10459. /// 团组模块 - 出入境费用报价表 - OP
  10460. /// </summary>
  10461. /// <returns></returns>
  10462. [HttpPost]
  10463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10464. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10465. {
  10466. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10467. }
  10468. /// <summary>
  10469. /// 团组模块 - 出入境费用报价表 - 删除 项
  10470. /// </summary>
  10471. /// <returns></returns>
  10472. [HttpPost]
  10473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10474. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10475. {
  10476. if (dto.Id < 1) return Ok(JsonView(false,MsgTips.Id));
  10477. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10478. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10479. }
  10480. /// <summary>
  10481. /// 团组模块 - 出入境费用报价表 - 导出
  10482. /// </summary>
  10483. /// <returns></returns>
  10484. [HttpPost]
  10485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10486. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10487. {
  10488. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10489. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10490. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id= dto.Id });
  10491. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10492. var rates = info.Rates;
  10493. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10494. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10495. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10496. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10497. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10498. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10499. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10500. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10501. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10502. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10503. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10504. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10505. //获取模板
  10506. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10507. var designer = new WorkbookDesigner();
  10508. designer.Workbook = new Workbook(tempPath);
  10509. designer.SetDataSource("QuoteName", info.Name);
  10510. designer.SetDataSource("CompanyTitle", "公司名称");
  10511. designer.SetDataSource("CompanyLabel", "");
  10512. #region 国际旅费
  10513. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10514. if (intTravelCosts.Infos.Any())
  10515. {
  10516. var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
  10517. string label = string.Empty;
  10518. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10519. if (infos.Any())
  10520. {
  10521. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10522. }
  10523. foreach (var item in intTravelCosts.Infos)
  10524. {
  10525. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10526. }
  10527. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10528. designer.SetDataSource("IntTravelLabel", label);
  10529. }
  10530. #endregion
  10531. #region 住宿费
  10532. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10533. if (accomCosts.Infos.Any())
  10534. {
  10535. string currencyName = string.Empty;
  10536. decimal rate = 1.0000M;
  10537. string label = "全程五星酒店,每人1间房\r\n";
  10538. foreach (var item in accomCosts.Infos)
  10539. {
  10540. string hotelName = string.Empty;
  10541. if (item.FeeName.Contains("-"))
  10542. {
  10543. var feeName = item.FeeName.Split('-');
  10544. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10545. }
  10546. else hotelName = $"\r\n{item.FeeName}:";
  10547. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10548. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10549. rate = rateInfo?.Rate ?? 1.0000M;
  10550. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10551. }
  10552. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10553. designer.SetDataSource("AccomLabel", label);
  10554. }
  10555. #endregion
  10556. designer.Process();
  10557. //文件名
  10558. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10559. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10560. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10561. return Ok(JsonView(true, "成功", url));
  10562. }
  10563. #endregion
  10564. #region 签证费用录入
  10565. /// <summary>
  10566. /// 根据diid查询签证费用列表
  10567. /// </summary>
  10568. /// <param name="dto"></param>
  10569. /// <returns></returns>
  10570. [HttpPost]
  10571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10572. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10573. {
  10574. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10575. if (groupData.Code != 0)
  10576. {
  10577. return Ok(JsonView(false, groupData.Msg));
  10578. }
  10579. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10580. }
  10581. /// <summary>
  10582. /// 根据签证费用Id查询单条数据及c表数据
  10583. /// </summary>
  10584. /// <param name="dto"></param>
  10585. /// <returns></returns>
  10586. [HttpPost]
  10587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10588. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10589. {
  10590. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10591. if (groupData.Code != 0)
  10592. {
  10593. return Ok(JsonView(false, groupData.Msg));
  10594. }
  10595. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10596. }
  10597. /// <summary>
  10598. /// 签证费用删除
  10599. /// </summary>
  10600. /// <param name="dto"></param>
  10601. /// <returns></returns>
  10602. [HttpPost]
  10603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10604. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10605. {
  10606. _sqlSugar.BeginTran();
  10607. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10608. if (!res)
  10609. {
  10610. _sqlSugar.RollbackTran();
  10611. return Ok(JsonView(false, "删除失败"));
  10612. }
  10613. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10614. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10615. .SetColumns(a => new Grp_CreditCardPayment()
  10616. {
  10617. IsDel = 1,
  10618. DeleteUserId = dto.DeleteUserId,
  10619. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10620. })
  10621. .ExecuteCommand();
  10622. if (resSub < 1)
  10623. {
  10624. _sqlSugar.RollbackTran();
  10625. return Ok(JsonView(false, "删除失败"));
  10626. }
  10627. _sqlSugar.CommitTran();
  10628. return Ok(JsonView(true, "删除成功!"));
  10629. }
  10630. /// <summary>
  10631. /// 签证费用录入下拉框初始化
  10632. /// </summary>
  10633. /// <returns></returns>
  10634. [HttpPost]
  10635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10636. public async Task<IActionResult> VisaPriceAddSelect()
  10637. {
  10638. //支付方式
  10639. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10640. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10641. //币种
  10642. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10643. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10644. //乘客类型
  10645. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10646. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10647. //卡类型
  10648. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10649. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10650. //代办费类型
  10651. var agencyFeeTypeData = new List<dynamic>() {
  10652. new { id = 0 , Text = "未选择" },
  10653. new { id = 1 , Text = "小公务" },
  10654. new { id = 2 , Text = "大公务" },
  10655. };
  10656. //签证费用标准国家Data
  10657. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10658. var data = new
  10659. {
  10660. Payment = _Payment,
  10661. CurrencyList = _CurrencyList,
  10662. PassengerType = _PassengerType,
  10663. BankCard = _BankCard,
  10664. AgencyFeeType = agencyFeeTypeData,
  10665. CountryFeeData = visaCountryFeeData
  10666. };
  10667. return Ok(JsonView(true, "查询成功!", data));
  10668. }
  10669. /// <summary>
  10670. /// 签证费用录入操作(Status:1.新增,2.修改)
  10671. /// </summary>
  10672. /// <param name="dto"></param>
  10673. /// <returns></returns>
  10674. [HttpPost]
  10675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10676. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10677. {
  10678. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10679. if (groupData.Code != 0)
  10680. {
  10681. return Ok(JsonView(false, groupData.Msg));
  10682. }
  10683. #region 应用推送
  10684. try
  10685. {
  10686. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10687. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10688. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10689. //2024-10-21 新增LZ UID
  10690. var userIds = new List<int>() { 21 };
  10691. string title = $"系统通知";
  10692. string content = "";
  10693. var diId = dto.DiId;
  10694. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10695. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10696. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10697. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10698. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10699. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10700. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10701. }
  10702. catch (Exception ex)
  10703. {
  10704. }
  10705. #endregion
  10706. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10707. }
  10708. #endregion
  10709. #region 签证提成录入
  10710. /// <summary>
  10711. /// 签证提成录入
  10712. /// 基础数据
  10713. /// </summary>
  10714. /// <returns></returns>
  10715. [HttpGet]
  10716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10717. public async Task<IActionResult> VisaCommissionInit()
  10718. {
  10719. return Ok(await _visaCommissionRep.Init());
  10720. }
  10721. /// <summary>
  10722. /// 签证提成录入
  10723. /// Item
  10724. /// </summary>
  10725. /// <param name="_dto"></param>
  10726. /// <returns></returns>
  10727. [HttpPost]
  10728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10729. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10730. {
  10731. var validator = new VisaCommissionItemDtoValidator();
  10732. var validatorRes = await validator.ValidateAsync(_dto);
  10733. if (!validatorRes.IsValid)
  10734. {
  10735. StringBuilder sb = new StringBuilder();
  10736. foreach (var item in validatorRes.Errors)
  10737. {
  10738. sb.AppendLine(item.ErrorMessage);
  10739. }
  10740. return Ok(JsonView(false, sb.ToString()));
  10741. }
  10742. return Ok(await _visaCommissionRep.Item(_dto));
  10743. }
  10744. /// <summary>
  10745. /// 签证提成录入
  10746. /// Save
  10747. /// </summary>
  10748. /// <param name="_dto"></param>
  10749. /// <returns></returns>
  10750. [HttpPost]
  10751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10752. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10753. {
  10754. //参数验证
  10755. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10756. foreach (var item in _dto.Items)
  10757. {
  10758. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10759. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10760. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10761. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10762. }
  10763. return Ok(await _visaCommissionRep.Save(_dto));
  10764. }
  10765. /// <summary>
  10766. /// 签证提成录入
  10767. /// Create
  10768. /// </summary>
  10769. /// <param name="_dto"></param>
  10770. /// <returns></returns>
  10771. [HttpPost]
  10772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10773. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10774. {
  10775. var validator = new VisaCommissionCreateDtoValidator();
  10776. var validatorRes = await validator.ValidateAsync(_dto);
  10777. if (!validatorRes.IsValid)
  10778. {
  10779. StringBuilder sb = new StringBuilder();
  10780. foreach (var item in validatorRes.Errors)
  10781. {
  10782. sb.AppendLine(item.ErrorMessage);
  10783. }
  10784. return Ok(JsonView(false, sb.ToString()));
  10785. }
  10786. return Ok(await _visaCommissionRep.Create(_dto));
  10787. }
  10788. /// <summary>
  10789. /// 签证提成录入
  10790. /// Put(编辑)
  10791. /// </summary>
  10792. /// <param name="id"></param>
  10793. /// <param name="_dto"></param>
  10794. /// <returns></returns>
  10795. [HttpPut]
  10796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10797. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10798. {
  10799. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10800. var validator = new VisaCommissionCreateDtoValidator();
  10801. var validatorRes = await validator.ValidateAsync(_dto);
  10802. if (!validatorRes.IsValid)
  10803. {
  10804. StringBuilder sb = new StringBuilder();
  10805. foreach (var item in validatorRes.Errors)
  10806. {
  10807. sb.AppendLine(item.ErrorMessage);
  10808. }
  10809. return Ok(JsonView(false, sb.ToString()));
  10810. }
  10811. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10812. }
  10813. /// <summary>
  10814. /// 签证提成录入
  10815. /// Del
  10816. /// </summary>
  10817. /// <param name="id"></param>
  10818. /// <param name="currUserId"></param>
  10819. /// <returns></returns>
  10820. [HttpPost]
  10821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10822. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10823. {
  10824. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10825. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10826. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10827. }
  10828. #endregion
  10829. #region op费用录入
  10830. /// <summary>
  10831. /// 根据diid查询op费用列表
  10832. /// </summary>
  10833. /// <param name="dto"></param>
  10834. /// <returns></returns>
  10835. [HttpPost]
  10836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10837. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10838. {
  10839. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10840. if (groupData.Code != 0)
  10841. {
  10842. return Ok(JsonView(false, groupData.Msg));
  10843. }
  10844. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10845. }
  10846. /// <summary>
  10847. /// 根据op费用Id查询单条数据及c表数据
  10848. /// </summary>
  10849. /// <param name="dto"></param>
  10850. /// <returns></returns>
  10851. [HttpPost]
  10852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10853. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10854. {
  10855. try
  10856. {
  10857. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10858. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10859. var data = new
  10860. {
  10861. CarTouristGuideGround = _groupData,
  10862. CreditCardPayment = _creditCardPayment
  10863. };
  10864. return Ok(JsonView(true, "查询成功!", data));
  10865. }
  10866. catch (Exception ex)
  10867. {
  10868. return Ok(JsonView(false, "程序错误!"));
  10869. }
  10870. }
  10871. /// <summary>
  10872. /// op费用删除
  10873. /// </summary>
  10874. /// <param name="dto"></param>
  10875. /// <returns></returns>
  10876. [HttpPost]
  10877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10878. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10879. {
  10880. try
  10881. {
  10882. _sqlSugar.BeginTran();
  10883. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10884. if (!res)
  10885. {
  10886. return Ok(JsonView(false, "删除失败"));
  10887. }
  10888. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10889. {
  10890. IsDel = 1,
  10891. DeleteUserId = dto.DeleteUserId,
  10892. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10893. }).ExecuteCommandAsync();
  10894. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10895. {
  10896. IsDel = 1,
  10897. DeleteUserId = dto.DeleteUserId,
  10898. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10899. }).ExecuteCommandAsync();
  10900. #region 删除超支相关数据
  10901. //删除导入的超支数据
  10902. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10903. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10904. {
  10905. IsDel = 1,
  10906. DeleteUserId = dto.DeleteUserId,
  10907. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10908. }).ExecuteCommand();
  10909. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10910. {
  10911. IsDel = 1,
  10912. DeleteUserId = dto.DeleteUserId,
  10913. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10914. }).ExecuteCommand();
  10915. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10916. {
  10917. IsDel = 1,
  10918. DeleteUserId = dto.DeleteUserId,
  10919. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10920. }).ExecuteCommand();
  10921. #endregion
  10922. _sqlSugar.CommitTran();
  10923. return Ok(JsonView(true, "删除成功!"));
  10924. }
  10925. catch (Exception ex)
  10926. {
  10927. _sqlSugar.RollbackTran();
  10928. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10929. }
  10930. }
  10931. /// <summary>
  10932. /// op费用录入操作(Status:1.新增,2.修改)
  10933. /// </summary>
  10934. /// <param name="dto"></param>
  10935. /// <returns></returns>
  10936. [HttpPost]
  10937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10938. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10939. {
  10940. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10941. if (groupData.Code != 0)
  10942. {
  10943. return Ok(JsonView(false, groupData.Msg));
  10944. }
  10945. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10946. }
  10947. /// <summary>
  10948. /// 填写费用详细页面初始化绑定
  10949. /// </summary>
  10950. /// <param name="dto"></param>
  10951. /// <returns></returns>
  10952. [HttpPost]
  10953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10954. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10955. {
  10956. try
  10957. {
  10958. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10959. if (groupData.Code != 0)
  10960. {
  10961. return Ok(JsonView(false, groupData.Msg));
  10962. }
  10963. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10964. }
  10965. catch (Exception ex)
  10966. {
  10967. return Ok(JsonView(false, ex.Message));
  10968. }
  10969. }
  10970. /// <summary>
  10971. /// 根据op费用Id查询详细数据
  10972. /// </summary>
  10973. /// <param name="dto"></param>
  10974. /// <returns></returns>
  10975. [HttpPost]
  10976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10977. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10978. {
  10979. try
  10980. {
  10981. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10982. if (groupData.Code != 0)
  10983. {
  10984. return Ok(JsonView(false, groupData.Msg));
  10985. }
  10986. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10987. }
  10988. catch (Exception ex)
  10989. {
  10990. return Ok(JsonView(false, ex.Message));
  10991. }
  10992. }
  10993. /// <summary>
  10994. /// OP费用录入填写详情
  10995. /// </summary>
  10996. /// <param name="dto"></param>
  10997. /// <returns></returns>
  10998. [HttpPost]
  10999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11000. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11001. {
  11002. try
  11003. {
  11004. #region 参数校验
  11005. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11006. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11007. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11008. #endregion
  11009. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11010. if (groupData.Code != 0)
  11011. {
  11012. return Ok(JsonView(false, groupData.Msg));
  11013. }
  11014. //自动审核
  11015. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11016. #region 应用推送
  11017. try
  11018. {
  11019. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11020. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11021. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11022. //2024-10-21 新增LZ UID
  11023. var userIds = new List<int>() { 21 };
  11024. string title = $"系统通知";
  11025. var diId = dto.DiId;
  11026. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11027. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11028. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11029. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11030. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11031. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11032. }
  11033. catch (Exception ex)
  11034. {
  11035. }
  11036. #endregion
  11037. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11038. }
  11039. catch (Exception ex)
  11040. {
  11041. return Ok(JsonView(false, ex.Message));
  11042. }
  11043. }
  11044. /// <summary>
  11045. /// 获取三公详细所有城市
  11046. /// </summary>
  11047. /// <returns></returns>
  11048. [HttpGet]
  11049. public IActionResult OpCarCityResult()
  11050. {
  11051. var jw = JsonView(false);
  11052. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11053. {
  11054. x.Id,
  11055. x.Country,
  11056. x.City,
  11057. }).ToList();
  11058. if (data.Count > 0)
  11059. {
  11060. jw = JsonView(true, "获取成功!", data);
  11061. }
  11062. else
  11063. {
  11064. jw.Msg = "城市数据为空!";
  11065. jw.Data = new string[0];
  11066. }
  11067. return Ok(jw);
  11068. }
  11069. /// <summary>
  11070. /// 导出地接费用明细
  11071. /// </summary>
  11072. /// <param name="dto"></param>
  11073. /// <returns></returns>
  11074. [HttpPost]
  11075. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11076. {
  11077. var jw = JsonView(false);
  11078. if (dto.Diid < 1)
  11079. {
  11080. jw.Msg = "请输入正确的diid!";
  11081. return Ok(jw);
  11082. }
  11083. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11084. if (group == null)
  11085. {
  11086. jw.Msg = "未找到团组信息!";
  11087. return Ok(jw);
  11088. }
  11089. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11090. if (localGuideArr.Count == 0)
  11091. {
  11092. jw.Msg = "该团组暂无地接信息!";
  11093. return Ok(jw);
  11094. }
  11095. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11096. var overspendSoure = new Dictionary<int, int>
  11097. {
  11098. { 91, 982 }, //车
  11099. { 92 , 1059} ,//导游
  11100. { 994 , 1073}, //翻译
  11101. { 988 , 1074 }, //早餐
  11102. { 93 , 1075 }, //午餐
  11103. { 989 , 1076 }, //晚餐
  11104. };
  11105. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11106. foreach (var groupArr in localGroup)
  11107. {
  11108. var keyValue = groupArr.Key;
  11109. if (int.TryParse(keyValue, out int cityid))
  11110. {
  11111. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11112. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11113. }
  11114. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11115. foreach (var item in groupArr)
  11116. {
  11117. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11118. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11119. new Grp_CarTouristGuideGroundReservationsContentExtend
  11120. {
  11121. Count = a.Count,
  11122. CreateTime = a.CreateTime,
  11123. CreateUserId = a.CreateUserId,
  11124. CTGGRId = a.CTGGRId,
  11125. Currency = a.Currency,
  11126. DatePrice = a.DatePrice,
  11127. DeleteTime = a.DeleteTime,
  11128. DeleteUserId = a.DeleteUserId,
  11129. DiId = a.DiId,
  11130. Id = a.Id,
  11131. IsDel = a.IsDel,
  11132. Price = a.Price,
  11133. PriceContent = a.PriceContent,
  11134. Remark = a.Remark,
  11135. SId = a.SId,
  11136. SidName = b.Name,
  11137. Units = a.Units,
  11138. }
  11139. ).ToList();
  11140. if (content.Count > 0)
  11141. {
  11142. contentArr.Add(content);
  11143. }
  11144. }
  11145. //open excel
  11146. //set excel
  11147. //save excel
  11148. try
  11149. {
  11150. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11151. IWorkbook workbook;
  11152. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11153. {
  11154. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11155. }
  11156. else
  11157. {
  11158. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11159. }
  11160. ISheet sheet = workbook.GetSheetAt(0);
  11161. var rowStartIndex = 2;
  11162. var clounmCount = 10;
  11163. var initStyleRow = sheet.GetRow(2);
  11164. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11165. //var overspendArrDetail =
  11166. var existsId = new List<CarCompare>();
  11167. var lastElem = arr.Last();
  11168. var thisSid = -1;
  11169. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11170. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11171. {
  11172. Name = "未知币种!",
  11173. Remark = "未知币种!",
  11174. };
  11175. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11176. Action cloneRowFn = () =>
  11177. {
  11178. rowStartIndex++;
  11179. var cloneRow = sheet.CreateRow(rowStartIndex);
  11180. // 复制样式
  11181. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11182. {
  11183. ICell sourceCell = initStyleRow.GetCell(i);
  11184. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11185. // 确保单元格存在样式
  11186. if (sourceCell.CellStyle != null)
  11187. {
  11188. targetCell.CellStyle = sourceCell.CellStyle;
  11189. }
  11190. }
  11191. };
  11192. var mergeRow = () =>
  11193. {
  11194. for (int i = 2; i < sheet.LastRowNum; i++)
  11195. {
  11196. var row = sheet.GetRow(i);
  11197. var cellFirst = row.GetCell(0);
  11198. var thisIndex = i + 1;
  11199. while (thisIndex < sheet.LastRowNum)
  11200. {
  11201. var nextRow = sheet.GetRow(thisIndex);
  11202. var nextCellFirst = nextRow.GetCell(0);
  11203. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11204. {
  11205. thisIndex++;
  11206. }
  11207. else
  11208. {
  11209. break;
  11210. }
  11211. }
  11212. thisIndex--;
  11213. if (thisIndex != i)
  11214. {
  11215. //合并row
  11216. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11217. i, // 起始行索引(0-based)
  11218. thisIndex, // 结束行索引(0-based)
  11219. 0, // 起始列索引(0-based)
  11220. 0 // 结束列索引(0-based)
  11221. );
  11222. sheet.AddMergedRegion(cellRangeAddress);
  11223. i = thisIndex;
  11224. }
  11225. }
  11226. };
  11227. var chaoshiNumber = 0;
  11228. var totalNumber = 0.00M;
  11229. string lastStr = "";
  11230. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11231. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11232. {
  11233. b.IsAuditGM,
  11234. x.Id,
  11235. x.Area,
  11236. b.PayPercentage,
  11237. b.PayMoney,
  11238. }).ToList();
  11239. string yesPayment = "", noPayment = "";
  11240. foreach (var item in queryCarArrByCityAndDiid)
  11241. {
  11242. if (item.IsAuditGM == 1)
  11243. {
  11244. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11245. }
  11246. else
  11247. {
  11248. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11249. }
  11250. }
  11251. lastStr = yesPayment + noPayment;
  11252. foreach (var item in arr)
  11253. {
  11254. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11255. {
  11256. if (thisSid != item.SId)
  11257. {
  11258. if (thisSid == -1)
  11259. {
  11260. thisSid = item.SId;
  11261. }
  11262. else
  11263. {
  11264. //合并小计行
  11265. //创建合并区域的实例
  11266. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11267. rowStartIndex, // 起始行索引(0-based)
  11268. rowStartIndex, // 结束行索引(0-based)
  11269. 0, // 起始列索引(0-based)
  11270. 3 // 结束列索引(0-based)
  11271. );
  11272. sheet.AddMergedRegion(cellRangeAddress);
  11273. var CellStyle = workbook.CreateCellStyle();
  11274. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11275. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11276. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11277. for (int i = 0; i <= clounmCount; i++)
  11278. {
  11279. if (i > 6)
  11280. {
  11281. var CellStyle1 = workbook.CreateCellStyle();
  11282. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11283. IFont Font = workbook.CreateFont(); // 创建字体
  11284. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11285. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11286. CellStyle1.SetFont(Font);
  11287. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11288. }
  11289. else
  11290. {
  11291. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11292. }
  11293. }
  11294. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11295. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11296. //超时合计
  11297. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11298. //超时数
  11299. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11300. //超时合计费用
  11301. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11302. thisSid = item.SId;
  11303. cloneRowFn();
  11304. chaoshiNumber = 0;
  11305. totalNumber = 0;
  11306. }
  11307. }
  11308. IRow row = sheet.GetRow(rowStartIndex);
  11309. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11310. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11311. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11312. if (isOpenOverspendSoure)
  11313. {
  11314. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11315. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11316. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11317. }
  11318. for (int i = 0; i <= clounmCount; i++)
  11319. {
  11320. var cell = row.GetCell(i);
  11321. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11322. if (cell == null)
  11323. {
  11324. cell = row.CreateCell(i);
  11325. }
  11326. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11327. fontRed.CloneStyleFrom(cell.CellStyle);
  11328. IFont Font = workbook.CreateFont(); // 创建字体
  11329. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11330. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11331. fontRed.SetFont(Font);
  11332. byte[] rgb = new byte[3] { 255, 242, 204 };
  11333. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11334. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11335. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11336. if (workbook is XSSFWorkbook)
  11337. {
  11338. BackgroundColor255_242_204.FillForegroundColor = 0;
  11339. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11340. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11341. }
  11342. else
  11343. {
  11344. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11345. }
  11346. if (i == 1 || i > 6)
  11347. {
  11348. if (i > 6)
  11349. {
  11350. fontRed.FillForegroundColor = 0;
  11351. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11352. fontRed.FillPattern = FillPattern.SolidForeground;
  11353. }
  11354. cell.CellStyle = fontRed;
  11355. }
  11356. if (i > 2 && i < 7)
  11357. {
  11358. cell.CellStyle = BackgroundColor255_242_204;
  11359. }
  11360. cell.SetCellValue(setCellValue); //写入单元格
  11361. }
  11362. if (overspendSoure.ContainsKey(thisSid))
  11363. {
  11364. var overspendId = overspendSoure[thisSid];
  11365. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11366. }
  11367. cloneRowFn();
  11368. existsId.Add(new CarCompare
  11369. {
  11370. DataPrice = item.DatePrice.ObjToDate(),
  11371. Sid = item.SId
  11372. });
  11373. }
  11374. if (item.Equals(lastElem))
  11375. {
  11376. //合并小计行
  11377. //创建合并区域的实例
  11378. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11379. rowStartIndex, // 起始行索引(0-based)
  11380. rowStartIndex, // 结束行索引(0-based)
  11381. 0, // 起始列索引(0-based)
  11382. 3 // 结束列索引(0-based)
  11383. );
  11384. sheet.AddMergedRegion(cellRangeAddress);
  11385. var CellStyle = workbook.CreateCellStyle();
  11386. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11387. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11388. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11389. for (int i = 0; i <= clounmCount; i++)
  11390. {
  11391. if (i > 6)
  11392. {
  11393. var CellStyle1 = workbook.CreateCellStyle();
  11394. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11395. IFont Font = workbook.CreateFont(); // 创建字体
  11396. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11397. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11398. CellStyle1.SetFont(Font);
  11399. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11400. }
  11401. else
  11402. {
  11403. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11404. }
  11405. }
  11406. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11407. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11408. //超时合计
  11409. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11410. //超时数
  11411. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11412. //超时合计费用
  11413. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11414. cloneRowFn();
  11415. // 创建合并区域的实例
  11416. cellRangeAddress = new CellRangeAddress(
  11417. rowStartIndex, // 起始行索引(0-based)
  11418. rowStartIndex, // 结束行索引(0-based)
  11419. 0, // 起始列索引(0-based)
  11420. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11421. );
  11422. // 添加合并区域
  11423. sheet.AddMergedRegion(cellRangeAddress);
  11424. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11425. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11426. }
  11427. }
  11428. mergeRow();
  11429. // 保存修改后的Excel文件到新文件
  11430. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11431. // new FileStream(newFilePath, FileMode.CreateNew)
  11432. using (var stream = new MemoryStream())
  11433. {
  11434. workbook.Write(stream, true);
  11435. stream.Flush();
  11436. stream.Seek(0, SeekOrigin.Begin);
  11437. MemoryStream memoryStream = new MemoryStream();
  11438. stream.CopyTo(memoryStream);
  11439. memoryStream.Seek(0, SeekOrigin.Begin);
  11440. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11441. }
  11442. workbook.Close();
  11443. workbook.Dispose();
  11444. }
  11445. catch (Exception ex)
  11446. {
  11447. jw.Msg = "出现异常!" + ex.Message;
  11448. return Ok(jw);
  11449. }
  11450. }
  11451. if (Zips.Count > 0)
  11452. {
  11453. IOOperatorHelper io = new IOOperatorHelper();
  11454. var byts = io.ConvertZipStream(Zips);
  11455. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11456. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11457. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11458. }
  11459. else
  11460. {
  11461. jw.Msg = "暂无生成文件!";
  11462. }
  11463. return Ok(jw);
  11464. }
  11465. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11466. {
  11467. string outStr = string.Empty;
  11468. switch (i)
  11469. {
  11470. case 0:
  11471. outStr = arr[0].SidName;
  11472. break;
  11473. case 1:
  11474. outStr = arr[0].DataPriceStr;
  11475. break;
  11476. case 2:
  11477. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11478. break;
  11479. case 4:
  11480. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11481. break;
  11482. case 7:
  11483. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11484. {
  11485. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11486. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11487. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11488. }
  11489. break;
  11490. case 8:
  11491. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11492. {
  11493. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11494. }
  11495. break;
  11496. case 9:
  11497. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11498. {
  11499. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11500. }
  11501. break;
  11502. case 10:
  11503. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11504. {
  11505. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11506. }
  11507. break;
  11508. }
  11509. return outStr;
  11510. }
  11511. #region OP行程单
  11512. /// <summary>
  11513. /// OP行程单初始化
  11514. /// </summary>
  11515. /// <param name="dto"></param>
  11516. /// <returns></returns>
  11517. [HttpPost]
  11518. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11519. {
  11520. var jw = JsonView(false);
  11521. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11522. var group = groupList.First();
  11523. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11524. if (group == null)
  11525. {
  11526. jw.Msg = "暂无团组!";
  11527. return Ok(jw);
  11528. }
  11529. group = groupList.Find(x => x.Id == diid);
  11530. if (group == null)
  11531. {
  11532. jw.Msg = "请输入正确的团组ID!";
  11533. return Ok(jw);
  11534. }
  11535. string city = string.Empty;
  11536. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11537. if (blackCode.Count > 0)
  11538. {
  11539. var black = blackCode.First();
  11540. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11541. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11542. if (blackSp.Length > 0)
  11543. {
  11544. try
  11545. {
  11546. var cityArrCode = new List<string>(20);
  11547. foreach (var item in blackSp)
  11548. {
  11549. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11550. var IndexSelect = itemSp[2];
  11551. var cityArrCodeLength = cityArrCode.Count - 1;
  11552. var startCity = IndexSelect.Substring(0, 3);
  11553. if (cityArrCodeLength > 0)
  11554. {
  11555. var arrEndCity = cityArrCode[cityArrCodeLength];
  11556. if (arrEndCity != startCity)
  11557. {
  11558. cityArrCode.Add(startCity.ToUpper());
  11559. }
  11560. }
  11561. else
  11562. {
  11563. cityArrCode.Add(startCity.ToUpper());
  11564. }
  11565. var endCity = IndexSelect.Substring(3, 3);
  11566. cityArrCode.Add(endCity.ToUpper());
  11567. }
  11568. var cityThree = string.Empty;
  11569. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11570. cityThree = cityThree.TrimEnd(',');
  11571. if (string.IsNullOrWhiteSpace(cityThree))
  11572. {
  11573. throw new
  11574. Exception("error");
  11575. }
  11576. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11577. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11578. foreach (var item in cityArrCode)
  11579. {
  11580. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11581. if (find != null)
  11582. {
  11583. city += find.City + "/";
  11584. }
  11585. else
  11586. {
  11587. city += item + "三字码未收入/";
  11588. }
  11589. }
  11590. city = city.TrimEnd('/');
  11591. }
  11592. catch (Exception e)
  11593. {
  11594. city = "黑屏代码格式不正确!";
  11595. }
  11596. }
  11597. }
  11598. else
  11599. {
  11600. city = "未录入黑屏代码";
  11601. }
  11602. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11603. {
  11604. Date = x.Date,
  11605. Days = x.Days,
  11606. Diffgroup = x.Diffgroup,
  11607. Diid = x.Diid,
  11608. Traffic_First = x.Traffic_First,
  11609. Traffic_Second = x.Traffic_Second,
  11610. Trip = x.Trip,
  11611. WeekDay = x.WeekDay,
  11612. Id = x.Id
  11613. }).ToList();
  11614. jw.Data = new
  11615. {
  11616. groupList = groupList.Select(x => new
  11617. {
  11618. x.Id,
  11619. x.TeamName,
  11620. x.TourCode
  11621. }).ToList(),
  11622. groupInfo = new
  11623. {
  11624. group.VisitDays,
  11625. group.TourCode,
  11626. group.VisitPNumber,
  11627. group.TeamName,
  11628. city
  11629. },
  11630. OpTravelList
  11631. };
  11632. jw.Code = 200;
  11633. jw.Msg = "操作成功!";
  11634. return Ok(jw);
  11635. }
  11636. /// <summary>
  11637. /// 删除团组行程单
  11638. /// </summary>
  11639. /// <returns></returns>
  11640. [HttpPost]
  11641. public IActionResult DelTravel(DelOpTravelDto dto)
  11642. {
  11643. var jw = JsonView(false);
  11644. if (dto.UserId <= 0 || dto.Diid <= 0)
  11645. {
  11646. jw.Msg = "请输入正确的参数!";
  11647. return Ok(jw);
  11648. }
  11649. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11650. .SetColumns(x => new Grp_TravelList
  11651. {
  11652. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11653. DeleteUserId = dto.UserId,
  11654. IsDel = 1,
  11655. }).ExecuteCommand();
  11656. jw = JsonView(true);
  11657. return Ok(jw);
  11658. }
  11659. /// <summary>
  11660. /// 行程单保存
  11661. /// </summary>
  11662. /// <returns></returns>
  11663. [HttpPost]
  11664. public IActionResult TravelSave(TravelSaveDto dto)
  11665. {
  11666. var jw = JsonView(false);
  11667. if (dto.Arr.Count > 0)
  11668. {
  11669. try
  11670. {
  11671. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11672. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11673. .ToList();
  11674. _sqlSugar.BeginTran();
  11675. foreach (var item in dto.Arr)
  11676. {
  11677. if (item.Id == 0)
  11678. {
  11679. throw new Exception("请传入正确的Id");
  11680. }
  11681. //比较上一次的差异
  11682. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11683. if (findTravel != null)
  11684. {
  11685. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11686. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11687. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11688. }
  11689. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11690. .SetColumns(x => new Grp_TravelList
  11691. {
  11692. Trip = item.Trip
  11693. }).ExecuteCommand();
  11694. }
  11695. _sqlSugar.CommitTran();
  11696. jw = JsonView(true);
  11697. }
  11698. catch (Exception ex)
  11699. {
  11700. _sqlSugar.RollbackTran();
  11701. jw.Msg = "程序异常!" + ex.Message;
  11702. }
  11703. }
  11704. else
  11705. {
  11706. jw.Msg = "请传入正确的参数!";
  11707. }
  11708. return Ok(jw);
  11709. }
  11710. private string CheckStr(string original, string changed)
  11711. {
  11712. // 创建diff_match_patch对象
  11713. var dmp = new diff_match_patch();
  11714. // 计算差异
  11715. List<Diff> diffs = dmp.diff_main(original, changed);
  11716. // 清理和合并差异
  11717. dmp.diff_cleanupSemantic(diffs);
  11718. // 使用StringBuilder构建最终的字符串
  11719. StringBuilder finalString = new StringBuilder();
  11720. // 输出差异结果,并构建变动后的字符串
  11721. foreach (Diff diff in diffs)
  11722. {
  11723. switch (diff.operation)
  11724. {
  11725. case Operation.EQUAL:
  11726. // 相等的部分,直接添加到最终字符串
  11727. finalString.Append(diff.text);
  11728. break;
  11729. case Operation.INSERT:
  11730. // 插入的部分,添加标记并添加到最终字符串
  11731. finalString.Append("[++]" + diff.text + "[++]");
  11732. break;
  11733. case Operation.DELETE:
  11734. // 删除的部分,不添加到最终字符串
  11735. //finalString.Append("[++]" + diff.text + "[++]");
  11736. break;
  11737. }
  11738. }
  11739. // 输出变动后的字符串
  11740. return finalString.ToString();
  11741. }
  11742. private class tagContent
  11743. {
  11744. public DateTime Date { get; set; }
  11745. public string StartTag { get; set; }
  11746. public string EndTag { get; set; }
  11747. public string Content { get; set; }
  11748. public static int tagLength { get { return 3; } }
  11749. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11750. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11751. public bool IsFinally { get; set; }
  11752. }
  11753. private List<string> ExtractContentBetweenTags(string input, string tag)
  11754. {
  11755. List<string> results = new List<string>();
  11756. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11757. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11758. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11759. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11760. string[] strValueArr = new string[1];
  11761. foreach (System.Text.RegularExpressions.Match match in matches)
  11762. {
  11763. var strValue = match.Groups[1].Value;
  11764. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11765. }
  11766. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11767. return results;
  11768. }
  11769. /// <summary>
  11770. /// 导出行程单
  11771. /// </summary>
  11772. /// <param name="dto"></param>
  11773. /// <returns></returns>
  11774. [HttpPost]
  11775. public IActionResult ExportTravel(ExportTravelDto dto)
  11776. {
  11777. var jw = JsonView(false);
  11778. jw.Data = "";
  11779. int diid = 0;
  11780. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11781. if (Find == null)
  11782. {
  11783. jw.Msg = "请选择正确的团组!";
  11784. return Ok(jw);
  11785. }
  11786. else
  11787. {
  11788. diid = Find.Id;
  11789. }
  11790. //数据源
  11791. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11792. DataTable dtBlack = null;
  11793. try
  11794. {
  11795. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11796. }
  11797. catch (Exception)
  11798. {
  11799. jw.Msg = "机票黑屏代码有误!";
  11800. return Ok(jw);
  11801. }
  11802. string CityStr = string.Empty;
  11803. if (dtBlack.Rows.Count == 0)
  11804. {
  11805. jw.Msg = "机票黑屏代码有误!";
  11806. return Ok(jw);
  11807. }
  11808. else
  11809. {
  11810. foreach (DataRow row in dtBlack.Rows)
  11811. {
  11812. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11813. {
  11814. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11815. return Ok(jw);
  11816. }
  11817. }
  11818. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11819. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11820. }
  11821. // 指定的文字
  11822. var targetTextDic = new Dictionary<string, List<string>>();
  11823. //创建数据源Table
  11824. DataTable dtSource = new DataTable();
  11825. dtSource.Columns.Add("Days", typeof(string));
  11826. dtSource.Columns.Add("Date", typeof(string));
  11827. dtSource.Columns.Add("Week", typeof(string));
  11828. dtSource.Columns.Add("Traffic", typeof(string));
  11829. dtSource.Columns.Add("Trip", typeof(string));
  11830. //获取数据,放到datatable
  11831. foreach (var item in _travelList)
  11832. {
  11833. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11834. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11835. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11836. .Replace("[++]", string.Empty);
  11837. DataRow dr = dtSource.NewRow();
  11838. dr["Days"] = item.Days;
  11839. dr["Date"] = item.Date;
  11840. dr["Week"] = item.WeekDay;
  11841. dr["Traffic"] = item.Traffic_First
  11842. + "\r\n"
  11843. + item.Traffic_Second;
  11844. dr["Trip"] = item.Trip;
  11845. dtSource.Rows.Add(dr);
  11846. }
  11847. Dictionary<string, string> dic = new Dictionary<string, string>();
  11848. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11849. dic.Add("City", CityStr);
  11850. dic.Add("Days", Find.VisitDays.ToString());
  11851. dic.Add("DeleCode", Find.TourCode);
  11852. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11853. //模板路径
  11854. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11855. //载入模板
  11856. Document doc = null;
  11857. DocumentBuilder builder = null;
  11858. try
  11859. {
  11860. //载入模板
  11861. doc = new Document(tempPath);
  11862. builder = new DocumentBuilder(doc);
  11863. }
  11864. catch (Exception)
  11865. {
  11866. jw.Msg = "模板位置不存在!";
  11867. return Ok(jw);
  11868. }
  11869. foreach (var key in dic.Keys)
  11870. {
  11871. Bookmark bookmark = doc.Range.Bookmarks[key];
  11872. if (bookmark != null)
  11873. {
  11874. builder.MoveToBookmark(key);
  11875. builder.Write(dic[key]);
  11876. }
  11877. }
  11878. //获取word里所有表格
  11879. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11880. //获取所填表格的序数
  11881. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11882. try
  11883. {
  11884. //循环赋值
  11885. for (int i = 0; i < dtSource.Rows.Count; i++)
  11886. {
  11887. builder.MoveToCell(0, i + 1, 0, 0);
  11888. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11889. builder.MoveToCell(0, i + 1, 1, 0);
  11890. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11891. builder.MoveToCell(0, i + 1, 2, 0);
  11892. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11893. var trip = dtSource.Rows[i]["Trip"].ToString();
  11894. builder.MoveToCell(0, i + 1, 3, 0);
  11895. builder.Write(trip);
  11896. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11897. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11898. // 获取特定索引的段落
  11899. Paragraph paragraph = (Paragraph)paragraphs[0];
  11900. Run run = paragraph.Runs[0];
  11901. Aspose.Words.Font font = run.Font;
  11902. font.Name = "黑体";
  11903. //设置双休红色
  11904. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11905. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11906. paragraph = (Paragraph)paragraphs[1];
  11907. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11908. {
  11909. run = paragraph.Runs[0];
  11910. font = run.Font;
  11911. font.Color = Color.Red;
  11912. }
  11913. }
  11914. }
  11915. catch (Exception ex)
  11916. {
  11917. }
  11918. //删除多余行
  11919. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11920. {
  11921. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11922. }
  11923. var targetTextList = new List<string>();
  11924. // 遍历文档中的表格
  11925. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11926. {
  11927. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11928. {
  11929. var cellIndex = 0;
  11930. foreach (Cell cell in row.Cells)
  11931. {
  11932. if (cellIndex == 1 && row.Cells.Count == 4)
  11933. {
  11934. foreach (var target in targetTextDic.Keys)
  11935. {
  11936. if (cell.GetText().Contains(target))
  11937. {
  11938. targetTextList = targetTextDic[target];
  11939. break;
  11940. }
  11941. }
  11942. }
  11943. // 遍历单元格中的所有段落
  11944. foreach (Paragraph paragraph in cell.Paragraphs)
  11945. {
  11946. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11947. List<Run> runs = new List<Run>();
  11948. foreach (Run run in paragraph.Runs)
  11949. {
  11950. runs.Add(run);
  11951. }
  11952. foreach (Run run in runs)
  11953. {
  11954. foreach (var targetText in targetTextList)
  11955. {
  11956. // 检查文字是否包含指定文字
  11957. if (run.Text.Contains(targetText))
  11958. {
  11959. // 将包含的部分设置为红色
  11960. HighlightText(run, targetText, Color.Red);
  11961. }
  11962. }
  11963. }
  11964. }
  11965. cellIndex++;
  11966. }
  11967. }
  11968. }
  11969. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11970. if (!Directory.Exists(savePath))
  11971. {
  11972. try
  11973. {
  11974. Directory.CreateDirectory(savePath);
  11975. }
  11976. catch
  11977. {
  11978. }
  11979. }
  11980. string path = savePath + Find.TeamName + "出访日程";
  11981. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11982. try
  11983. {
  11984. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11985. string postfix = ".docx";
  11986. if (dto.IsPDF == 1)
  11987. {
  11988. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11989. postfix = ".pdf";
  11990. }
  11991. doc.Save(path + postfix, saveFormat);
  11992. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11993. }
  11994. catch (Exception)
  11995. {
  11996. jw = JsonView(false);
  11997. }
  11998. return Ok(jw);
  11999. }
  12000. /// <summary>
  12001. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12002. /// </summary>
  12003. /// <param name="num"></param>
  12004. /// <returns></returns>
  12005. string GetNum(string num)
  12006. {
  12007. string str = "";
  12008. switch (num)
  12009. {
  12010. case "1":
  12011. str = "一";
  12012. break;
  12013. case "2":
  12014. str = "二";
  12015. break;
  12016. case "3":
  12017. str = "三";
  12018. break;
  12019. case "4":
  12020. str = "四";
  12021. break;
  12022. case "5":
  12023. str = "五";
  12024. break;
  12025. case "6":
  12026. str = "六";
  12027. break;
  12028. case "7":
  12029. str = "七";
  12030. break;
  12031. case "8":
  12032. str = "八";
  12033. break;
  12034. case "9":
  12035. str = "九";
  12036. break;
  12037. case "10":
  12038. str = "十";
  12039. break;
  12040. case "11":
  12041. str = "十一";
  12042. break;
  12043. case "12":
  12044. str = "十二";
  12045. break;
  12046. case "一":
  12047. str = "1";
  12048. break;
  12049. case "二":
  12050. str = "2";
  12051. break;
  12052. case "三":
  12053. str = "3";
  12054. break;
  12055. case "四":
  12056. str = "4";
  12057. break;
  12058. case "五":
  12059. str = "5";
  12060. break;
  12061. case "六":
  12062. str = "6";
  12063. break;
  12064. case "七":
  12065. str = "7";
  12066. break;
  12067. case "八":
  12068. str = "8";
  12069. break;
  12070. case "九":
  12071. str = "9";
  12072. break;
  12073. case "十":
  12074. str = "10";
  12075. break;
  12076. case "十一":
  12077. str = "11";
  12078. break;
  12079. case "十二":
  12080. str = "12";
  12081. break;
  12082. }
  12083. return str;
  12084. }
  12085. // 高亮包含指定文字的部分
  12086. void HighlightText(Run run, string targetText, Color color)
  12087. {
  12088. string text = run.Text;
  12089. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12090. if (startIndex >= 0)
  12091. {
  12092. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12093. // 前部分
  12094. if (startIndex > 0)
  12095. {
  12096. Run beforeRun = (Run)run.Clone(true);
  12097. beforeRun.Text = text.Substring(0, startIndex);
  12098. parentParagraph.InsertBefore(beforeRun, run);
  12099. }
  12100. // 匹配部分
  12101. Run matchRun = (Run)run.Clone(true);
  12102. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12103. matchRun.Font.Color = color;
  12104. parentParagraph.InsertBefore(matchRun, run);
  12105. // 后部分
  12106. if (startIndex + targetText.Length < text.Length)
  12107. {
  12108. Run afterRun = (Run)run.Clone(true);
  12109. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12110. parentParagraph.InsertBefore(afterRun, run);
  12111. }
  12112. // 删除原始Run
  12113. run.Remove();
  12114. }
  12115. }
  12116. #endregion
  12117. #endregion
  12118. #region 团组成本
  12119. /// <summary>
  12120. /// 团组成本数据初始化
  12121. /// </summary>
  12122. /// <param name="dto"></param>
  12123. /// <returns></returns>
  12124. [HttpPost]
  12125. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12126. {
  12127. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12128. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12129. WHEN COUNT(*) >= 0 THEN 'True'
  12130. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12131. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12132. ").ToList(); //团组列表
  12133. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12134. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12135. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12136. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12137. if (groupinfoValue != null)
  12138. {
  12139. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12140. var spArr = new string[1] { countryArr };
  12141. if (countryArr.Contains("|"))
  12142. {
  12143. spArr = countryArr.Split("|");
  12144. }
  12145. else if (countryArr.Contains("、"))
  12146. {
  12147. spArr = countryArr.Split("、");
  12148. }
  12149. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12150. {
  12151. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12152. if (dbQueryCountry != null)
  12153. {
  12154. visaCountryInfoArr.Add(dbQueryCountry);
  12155. }
  12156. }
  12157. }
  12158. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12159. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12160. var create = _GroupCostRepository.
  12161. CreateGroupCostByBlackCode(dto.Diid);
  12162. if (groupCost.Count == 0 && create.Code == 0)
  12163. {
  12164. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12165. }
  12166. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12167. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12168. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12169. groupCostMap = groupCostMap.Select(x =>
  12170. {
  12171. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12172. {
  12173. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12174. }
  12175. return x;
  12176. }).ToList();
  12177. //GroupCostParameter.Add(new
  12178. // Grp_GroupCostParameter());
  12179. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12180. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12181. return Ok(JsonView(new
  12182. {
  12183. groupList,
  12184. groupInfo,
  12185. groupChecks,
  12186. groupCost = groupCostMap,
  12187. hotelNumber,
  12188. GroupCostParameter = GroupCostParameterMap,
  12189. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12190. {
  12191. x.VisaCountry,
  12192. x.VisaPrice,
  12193. x.Id,
  12194. }).ToList(),
  12195. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12196. blackCodeIsTrue = create.Code == 0 ? true : false,
  12197. hotelIsTrue = hotelIsTrue,
  12198. }));
  12199. }
  12200. /// <summary>
  12201. /// 团组成本信息保存
  12202. /// </summary>
  12203. /// <param name="dto"></param>
  12204. /// <returns></returns>
  12205. [HttpPost]
  12206. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12207. {
  12208. if (dto.Diid <= 0 || dto.Userid <= 0)
  12209. {
  12210. return Ok(JsonView(false));
  12211. }
  12212. JsonView jw = null;
  12213. bool isTrue = false;
  12214. #region 复制团组成本
  12215. //if (dto.Diid == 2581)
  12216. //{
  12217. // dto.Diid = 2599;
  12218. // dto.CheckBoxs.ForEach(x =>
  12219. // {
  12220. // x.Diid = 2599;
  12221. // });
  12222. // dto.GroupCosts.ForEach(x =>
  12223. // {
  12224. // x.Diid = 2599;
  12225. // });
  12226. // dto.CostTypeHotelNumbers.ForEach(x =>
  12227. // {
  12228. // x.Diid = 2599;
  12229. // });
  12230. // dto.GroupCostParameters.ForEach(x =>
  12231. // {
  12232. // x.DiId = 2599;
  12233. // });
  12234. //}
  12235. #endregion
  12236. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12237. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12238. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12239. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12240. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12241. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12242. try
  12243. {
  12244. _sqlSugar.BeginTran();
  12245. isTrue = await _GroupCostRepository.
  12246. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12247. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12248. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12249. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12250. _sqlSugar.CommitTran();
  12251. jw = JsonView(true, "保存成功!", isTrue);
  12252. }
  12253. catch (Exception)
  12254. {
  12255. _sqlSugar.RollbackTran();
  12256. jw = JsonView(false);
  12257. }
  12258. return Ok(jw);
  12259. }
  12260. /// <summary>
  12261. /// 司兼导数据
  12262. /// </summary>
  12263. /// <param name="dto"></param>
  12264. /// <returns></returns>
  12265. [HttpPost]
  12266. public IActionResult GetCarGuides(CarGuidesDto dto)
  12267. {
  12268. JsonView jw = null;
  12269. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12270. jw = JsonView(true, "获取成功!", Data);
  12271. return Ok(jw);
  12272. }
  12273. /// <summary>
  12274. /// 导游数据
  12275. /// </summary>
  12276. /// <param name="dto"></param>
  12277. /// <returns></returns>
  12278. [HttpPost]
  12279. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12280. {
  12281. JsonView jw = null;
  12282. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12283. // 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
  12284. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12285. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12286. jw = JsonView(true, "获取成功!", Data);
  12287. return Ok(jw);
  12288. }
  12289. /// <summary>
  12290. /// 成本车数据
  12291. /// </summary>
  12292. /// <param name="dto"></param>
  12293. /// <returns></returns>
  12294. [HttpPost]
  12295. public IActionResult GetCarInfo(CarGuidesDto dto)
  12296. {
  12297. JsonView jw = null;
  12298. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12299. jw = JsonView(true, "获取成功!", Data);
  12300. return Ok(jw);
  12301. }
  12302. /// <summary>
  12303. /// 景点数据
  12304. /// </summary>
  12305. /// <param name="dto"></param>
  12306. /// <returns></returns>
  12307. [HttpPost]
  12308. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12309. {
  12310. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12311. return Ok(JsonView(true, "获取成功!", Data));
  12312. }
  12313. /// <summary>
  12314. /// 成本通知
  12315. /// </summary>
  12316. /// <param name="dto"></param>
  12317. /// <returns></returns>
  12318. [HttpPost]
  12319. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12320. {
  12321. if (dto.Diid < 0)
  12322. {
  12323. return Ok(JsonView(false));
  12324. }
  12325. JsonView jw = null;
  12326. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12327. if (GroupCostParameter != null)
  12328. {
  12329. int IsShare = 0;
  12330. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12331. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12332. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12333. string msg = string.Empty;
  12334. if (isTrue)
  12335. {
  12336. if (IsShare == 0)
  12337. {
  12338. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12339. }
  12340. else
  12341. {
  12342. #region 企微通知对应岗位用户
  12343. try
  12344. {
  12345. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12346. }
  12347. catch (Exception ex)
  12348. {
  12349. }
  12350. #endregion
  12351. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12352. }
  12353. jw = JsonView(isTrue, msg, new { IsShare });
  12354. }
  12355. else
  12356. {
  12357. msg = "修改失败!";
  12358. jw = JsonView(isTrue, msg);
  12359. }
  12360. }
  12361. else
  12362. {
  12363. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12364. }
  12365. return Ok(jw);
  12366. }
  12367. /// <summary>
  12368. /// 导出报价单
  12369. /// </summary>
  12370. /// <param name="dto"></param>
  12371. /// <returns></returns>
  12372. [HttpPost]
  12373. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12374. {
  12375. if (dto.Diid == 0)
  12376. {
  12377. return Ok(JsonView(false, "请传递团组id"));
  12378. }
  12379. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12380. if (deleInfo.Code != 0)
  12381. {
  12382. return Ok(JsonView(false, "团组信息查询失败!"));
  12383. }
  12384. var di = deleInfo.Data as DelegationInfoWebView;
  12385. if (di != null)
  12386. {
  12387. di.TeamName = di.TeamName.Replace("|", "、");
  12388. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12389. //文件名
  12390. string strFileName = di.TeamName + "-收款账单.doc";
  12391. //获取模板
  12392. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12393. //载入模板
  12394. Document doc = new Document(tmppath);
  12395. decimal TotalPrice = 0.00M;
  12396. string itemStr = string.Empty;
  12397. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12398. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12399. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12400. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12401. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12402. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12403. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12404. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12405. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12406. foreach (var cost in groupCostType)
  12407. {
  12408. var List = cost.ToList();
  12409. if (cost.Key == "A")
  12410. {
  12411. foreach (var ListItem in List)
  12412. {
  12413. if (ListItem.number > 0)
  12414. {
  12415. if (ListItem.code.Contains("TBR"))
  12416. {
  12417. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12418. }
  12419. else
  12420. {
  12421. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12422. }
  12423. TotalPrice += (ListItem.number * ListItem.price);
  12424. }
  12425. }
  12426. }
  12427. else
  12428. {
  12429. itemStr = itemStr.Insert(0, "A段\r\n");
  12430. itemStr += "B段\r\n";
  12431. foreach (var ListItem in List)
  12432. {
  12433. if (ListItem.number > 0)
  12434. {
  12435. if (ListItem.code.Contains("TBR"))
  12436. {
  12437. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12438. }
  12439. else
  12440. {
  12441. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12442. }
  12443. TotalPrice += (ListItem.number * ListItem.price);
  12444. }
  12445. }
  12446. }
  12447. }
  12448. #region 替换Word模板书签内容
  12449. Dictionary<string, string> marks = new Dictionary<string, string>();
  12450. marks.Add("To", di.ClientUnit);//付款方
  12451. marks.Add("ToTel", di.TellPhone);//付款方电话
  12452. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12453. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12454. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12455. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12456. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12457. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12458. marks.Add("PayItemContent", itemStr);//详细信息
  12459. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12460. #endregion
  12461. ////注
  12462. //if (doc.Range.Bookmarks["Attention"] != null)
  12463. //{
  12464. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12465. // mark.Text = frList[0].Attention;
  12466. //}
  12467. foreach (var item in marks.Keys)
  12468. {
  12469. if (doc.Range.Bookmarks[item] != null)
  12470. {
  12471. Bookmark mark = doc.Range.Bookmarks[item];
  12472. mark.Text = marks[item];
  12473. }
  12474. }
  12475. byte[] bytes = null;
  12476. using (MemoryStream stream = new MemoryStream())
  12477. {
  12478. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12479. bytes = stream.ToArray();
  12480. }
  12481. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12482. return Ok(JsonView(true, "", new
  12483. {
  12484. Data = bytes,
  12485. strFileName,
  12486. }));
  12487. }
  12488. else
  12489. {
  12490. return Ok(JsonView(false, "团组信息不存在!"));
  12491. }
  12492. }
  12493. /// <summary>
  12494. /// 导出团组成本
  12495. /// </summary>
  12496. /// <param name="dto"></param>
  12497. /// <returns></returns>
  12498. [HttpPost]
  12499. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12500. {
  12501. var jw = JsonView(false);
  12502. if (dto.Diid == 0)
  12503. {
  12504. return Ok(JsonView(false, "请传递团组id"));
  12505. }
  12506. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12507. if (deleInfo.Code != 0)
  12508. {
  12509. return Ok(JsonView(false, "团组信息查询失败!"));
  12510. }
  12511. var di = deleInfo.Data as DelegationInfoWebView;
  12512. if (di == null)
  12513. {
  12514. return Ok(JsonView(false, "团组信息查询失败!"));
  12515. }
  12516. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12517. WorkbookDesigner designer = new WorkbookDesigner();
  12518. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12519. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12520. for (int i = 0; i < List_GC.Count; i++)
  12521. {
  12522. GroupCost_Excel gc = new GroupCost_Excel();
  12523. gc.Id = List_GC[i].Id;
  12524. gc.Diid = List_GC[i].Diid.ToString();
  12525. gc.DAY = List_GC[i].DAY;
  12526. string week = "";
  12527. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12528. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12529. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12530. gc.ITIN = List_GC[i].ITIN;
  12531. gc.CarType = List_GC[i].CarType;
  12532. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12533. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12534. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12535. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12536. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12537. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12538. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12539. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12540. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12541. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12542. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12543. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12544. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12545. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12546. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12547. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12548. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12549. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12550. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12551. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12552. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12553. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12554. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12555. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12556. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12557. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12558. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12559. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12560. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12561. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12562. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12563. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12564. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12565. List_GC1.Add(gc);
  12566. }
  12567. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12568. dt.TableName = "TB";
  12569. //报表标题等不用dt的值
  12570. designer.SetDataSource("TeamName", dto.title.TeamName);
  12571. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12572. designer.SetDataSource("Tax", dto.title.Tax);
  12573. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12574. designer.SetDataSource("Currency", dto.title.Currency);
  12575. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12576. designer.SetDataSource("Rate", dto.title.Rate);
  12577. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12578. var Aparams = hotels.Find(x => x.Type == "Default");
  12579. if (Aparams == null)
  12580. {
  12581. return Ok(jw);
  12582. }
  12583. //酒店数量
  12584. var txtSGRNumber = Aparams.SGR.ToString();
  12585. var txtTBRNumber = Aparams.TBR.ToString();
  12586. var txtJSESNumber = Aparams.JSES.ToString();
  12587. var txtSUITENumbe = Aparams.SUITE.ToString();
  12588. if (dto.costType == "B")
  12589. {
  12590. Aparams = hotels.Find(x => x.Type == "A");
  12591. var Bparams = hotels.Find(x => x.Type == "B");
  12592. if (Aparams == null || Bparams == null)
  12593. {
  12594. return Ok(jw);
  12595. }
  12596. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12597. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12598. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12599. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12600. }
  12601. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12602. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12603. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12604. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12605. var ws = designer.Workbook.Worksheets[0];
  12606. int Row = List_GC.Count;
  12607. int startIndex = 11;
  12608. int HideRows = 0;
  12609. List<int> hideRowsList = new List<int>();
  12610. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12611. #region A段left数据
  12612. var left = dto.leftInfo.Find(x => x.Type == "A");
  12613. if (left == null)
  12614. {
  12615. return Ok(jw);
  12616. }
  12617. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12618. if (leftBindData != null)
  12619. {
  12620. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12621. designer.SetDataSource("VisaRS", leftBindData.rs);
  12622. designer.SetDataSource("VisaXS", leftBindData.xs);
  12623. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12624. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12625. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12626. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12627. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12628. }
  12629. else
  12630. {
  12631. hideRowsList.Add(Row + startIndex + HideRows);
  12632. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12633. }
  12634. HideRows += 2;
  12635. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12636. if (leftBindData != null)
  12637. {
  12638. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12639. designer.SetDataSource("BXRS", leftBindData.rs);
  12640. designer.SetDataSource("BXXS", leftBindData.xs);
  12641. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12642. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12643. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12644. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12645. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12646. }
  12647. else
  12648. {
  12649. hideRowsList.Add(Row + startIndex + HideRows);
  12650. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12651. }
  12652. HideRows += 2;
  12653. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12654. if (leftBindData != null)
  12655. {
  12656. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12657. designer.SetDataSource("HSRS", leftBindData.rs);
  12658. designer.SetDataSource("HSXS", leftBindData.xs);
  12659. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12660. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12661. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12662. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12663. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12664. }
  12665. else
  12666. {
  12667. hideRowsList.Add(Row + startIndex + HideRows);
  12668. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12669. }
  12670. HideRows += 2;
  12671. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12672. if (leftBindData != null)
  12673. {
  12674. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12675. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12676. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12677. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12678. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12679. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12680. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12681. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12682. }
  12683. else
  12684. {
  12685. hideRowsList.Add(Row + startIndex + HideRows);
  12686. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12687. }
  12688. HideRows += 2;
  12689. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12690. if (leftBindData != null)
  12691. {
  12692. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12693. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12694. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12695. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12696. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12697. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12698. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12699. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12700. }
  12701. else
  12702. {
  12703. hideRowsList.Add(Row + startIndex + HideRows);
  12704. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12705. }
  12706. HideRows += 2;
  12707. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12708. if (leftBindData != null)
  12709. {
  12710. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12711. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12712. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12713. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12714. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12715. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12716. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12717. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12718. }
  12719. else
  12720. {
  12721. hideRowsList.Add(Row + startIndex + HideRows);
  12722. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12723. }
  12724. HideRows += 2;
  12725. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12726. if (leftBindData != null)
  12727. {
  12728. ////TBR
  12729. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12730. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12731. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12732. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12733. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12734. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12735. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12736. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12737. }
  12738. else
  12739. {
  12740. hideRowsList.Add(Row + startIndex + HideRows);
  12741. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12742. }
  12743. HideRows += 2;
  12744. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12745. if (leftBindData != null)
  12746. {
  12747. ////SGR
  12748. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12749. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12750. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12751. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12752. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12753. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12754. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12755. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12756. }
  12757. else
  12758. {
  12759. hideRowsList.Add(Row + startIndex + HideRows);
  12760. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12761. }
  12762. HideRows += 2;
  12763. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12764. if (leftBindData != null)
  12765. {
  12766. ////JS/ES
  12767. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12768. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12769. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12770. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12771. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12772. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12773. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12774. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12775. }
  12776. else
  12777. {
  12778. hideRowsList.Add(Row + startIndex + HideRows);
  12779. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12780. }
  12781. HideRows += 2;
  12782. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12783. if (leftBindData != null)
  12784. {
  12785. ////SUITE
  12786. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12787. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12788. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12789. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12790. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12791. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12792. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12793. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12794. }
  12795. else
  12796. {
  12797. hideRowsList.Add(Row + startIndex + HideRows);
  12798. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12799. }
  12800. HideRows += 2;
  12801. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12802. if (leftBindData != null)
  12803. {
  12804. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12805. designer.SetDataSource("DJRS", leftBindData.rs);
  12806. designer.SetDataSource("DJXS", leftBindData.xs);
  12807. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12808. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12809. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12810. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12811. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12812. }
  12813. else
  12814. {
  12815. hideRowsList.Add(Row + startIndex + HideRows);
  12816. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12817. }
  12818. HideRows += 2;
  12819. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12820. if (leftBindData != null)
  12821. {
  12822. designer.SetDataSource("HCPCB", leftBindData.cb);
  12823. designer.SetDataSource("HCPRS", leftBindData.rs);
  12824. designer.SetDataSource("HCPXS", leftBindData.xs);
  12825. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12826. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12827. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12828. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12829. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12830. }
  12831. else
  12832. {
  12833. hideRowsList.Add(Row + startIndex + HideRows);
  12834. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12835. }
  12836. HideRows += 2;
  12837. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12838. if (leftBindData != null)
  12839. {
  12840. designer.SetDataSource("CPCB", leftBindData.cb);
  12841. designer.SetDataSource("CPRS", leftBindData.rs);
  12842. designer.SetDataSource("CPXS", leftBindData.xs);
  12843. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12844. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12845. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12846. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12847. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12848. }
  12849. else
  12850. {
  12851. hideRowsList.Add(Row + startIndex + HideRows);
  12852. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12853. }
  12854. HideRows += 2;
  12855. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12856. if (leftBindData != null)
  12857. {
  12858. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12859. designer.SetDataSource("GWRS", leftBindData.rs);
  12860. designer.SetDataSource("GWXS", leftBindData.xs);
  12861. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12862. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12863. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12864. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12865. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12866. }
  12867. else
  12868. {
  12869. hideRowsList.Add(Row + startIndex + HideRows);
  12870. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12871. }
  12872. HideRows += 2;
  12873. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12874. if (leftBindData != null)
  12875. {
  12876. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12877. designer.SetDataSource("LYJRS", leftBindData.rs);
  12878. designer.SetDataSource("LYJXS", leftBindData.xs);
  12879. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12880. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12881. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12882. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12883. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12884. }
  12885. else
  12886. {
  12887. hideRowsList.Add(Row + startIndex + HideRows);
  12888. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12889. }
  12890. #endregion
  12891. #region A段Right信息
  12892. var right = dto.rightInfo.Find(x => x.Type == "A");
  12893. if (right == null)
  12894. {
  12895. return Ok(jw);
  12896. }
  12897. HideRows += 4;
  12898. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12899. if (rightBindData != null)
  12900. {
  12901. //经济舱 + 双人间 TBR
  12902. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12903. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12904. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12905. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12906. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12907. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12908. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12909. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12910. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12911. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12912. }
  12913. else
  12914. {
  12915. hideRowsList.Add(Row + startIndex + HideRows);
  12916. }
  12917. HideRows += 2;
  12918. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12919. if (rightBindData != null)
  12920. {
  12921. //经济舱 + 单人间 SGR
  12922. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12923. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12924. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12925. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12926. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12927. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12928. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12929. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12930. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12931. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12932. }
  12933. else
  12934. {
  12935. hideRowsList.Add(Row + startIndex + HideRows);
  12936. }
  12937. HideRows += 2;
  12938. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12939. if (rightBindData != null)
  12940. {
  12941. //公务舱 + 单人间 SGR
  12942. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12943. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12944. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12945. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12946. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12947. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12948. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12949. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12950. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12951. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12952. }
  12953. else
  12954. {
  12955. hideRowsList.Add(Row + startIndex + HideRows);
  12956. }
  12957. HideRows += 2;
  12958. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12959. if (rightBindData != null)
  12960. {
  12961. //公务舱 + 小套房 JSES
  12962. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12963. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12964. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12965. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12966. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12967. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12968. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12969. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12970. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12971. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12972. }
  12973. else
  12974. {
  12975. hideRowsList.Add(Row + startIndex + HideRows);
  12976. }
  12977. HideRows += 2;
  12978. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12979. if (rightBindData != null)
  12980. {
  12981. //公务舱 + 小套房 JSES
  12982. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12983. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12984. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12985. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12986. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12987. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12988. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12989. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12990. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12991. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12992. }
  12993. else
  12994. {
  12995. hideRowsList.Add(Row + startIndex + HideRows);
  12996. }
  12997. HideRows += 2;
  12998. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12999. if (rightBindData != null)
  13000. {
  13001. //经济舱 + 大套房
  13002. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13003. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13004. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13005. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13006. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13007. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13008. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13009. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13010. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13011. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13012. }
  13013. else
  13014. {
  13015. hideRowsList.Add(Row + startIndex + HideRows);
  13016. }
  13017. HideRows += 2;
  13018. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13019. if (rightBindData != null)
  13020. {
  13021. //头等舱 + 小套房 JSES
  13022. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13023. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13024. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13025. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13026. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13027. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13028. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13029. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13030. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13031. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13032. }
  13033. else
  13034. {
  13035. hideRowsList.Add(Row + startIndex + HideRows);
  13036. }
  13037. HideRows += 2;
  13038. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13039. if (rightBindData != null)
  13040. {
  13041. //头等舱 + 大套房
  13042. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13043. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13044. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13045. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13046. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13047. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13048. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13049. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13050. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13051. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13052. }
  13053. else
  13054. {
  13055. hideRowsList.Add(Row + startIndex + HideRows);
  13056. }
  13057. #endregion
  13058. #region B段标题清空
  13059. designer.SetDataSource("CostBDRCB", "");
  13060. designer.SetDataSource("CostBRS", "");
  13061. designer.SetDataSource("CostBXS", "");
  13062. designer.SetDataSource("CostBZCB", "");
  13063. designer.SetDataSource("CostBDRBJ", "");
  13064. designer.SetDataSource("CostBZBJ", "");
  13065. designer.SetDataSource("CostBDRLR", "");
  13066. designer.SetDataSource("CostBZLR", "");
  13067. designer.SetDataSource("CostBDRCBOM", "");
  13068. designer.SetDataSource("CostBRSOM", "");
  13069. designer.SetDataSource("CostBZCBOM", "");
  13070. designer.SetDataSource("CostBDRBJOM", "");
  13071. designer.SetDataSource("CostBZBJOM", "");
  13072. designer.SetDataSource("CostBDRLROM", "");
  13073. designer.SetDataSource("CostBZLROM", "");
  13074. #endregion
  13075. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13076. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13077. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13078. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13079. designer.SetDataSource("DJName", "地接(CNY)");
  13080. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13081. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13082. designer.SetDataSource("GWName", "公务(CNY)");
  13083. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13084. designer.SetDataSource("LYJName", "零用金(CNY)");
  13085. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13086. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13087. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13088. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13089. designer.SetDataSource("BXName", "保险(CNY)");
  13090. designer.SetDataSource("VisaName", "签证(CNY)");
  13091. #region B段基本数据
  13092. if (dto.costType == "B")
  13093. {
  13094. left = dto.leftInfo.Find(x => x.Type == "B");
  13095. if (left == null)
  13096. {
  13097. return Ok(jw);
  13098. }
  13099. #region B段left数据
  13100. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13101. if (leftBindData != null)
  13102. {
  13103. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13104. designer.SetDataSource("BHSRS", leftBindData.rs);
  13105. designer.SetDataSource("BHSXS", leftBindData.xs);
  13106. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13107. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13108. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13109. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13110. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13111. }
  13112. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13113. if (leftBindData != null)
  13114. {
  13115. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13116. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13117. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13118. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13119. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13120. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13121. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13122. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13123. }
  13124. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13125. if (leftBindData != null)
  13126. {
  13127. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13128. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13129. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13130. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13131. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13132. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13133. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13134. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13135. }
  13136. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13137. if (leftBindData != null)
  13138. {
  13139. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13140. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13141. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13142. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13143. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13144. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13145. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13146. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13147. }
  13148. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13149. if (leftBindData != null)
  13150. {
  13151. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13152. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13153. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13154. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13155. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13156. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13157. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13158. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13159. }
  13160. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13161. if (leftBindData != null)
  13162. {
  13163. designer.SetDataSource("BCPCB", leftBindData.cb);
  13164. designer.SetDataSource("BCPRS", leftBindData.rs);
  13165. designer.SetDataSource("BCPXS", leftBindData.xs);
  13166. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13167. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13168. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13169. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13170. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13171. }
  13172. //TBR
  13173. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13174. if (leftBindData != null)
  13175. {
  13176. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13177. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13178. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13179. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13180. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13181. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13182. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13183. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13184. }
  13185. //SGR
  13186. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13187. if (leftBindData != null)
  13188. {
  13189. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13190. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13191. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13192. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13193. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13194. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13195. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13196. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13197. }
  13198. //JS/ES
  13199. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13200. if (leftBindData != null)
  13201. {
  13202. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13203. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13204. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13205. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13206. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13207. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13208. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13209. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13210. }
  13211. //SUITE
  13212. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13213. if (leftBindData != null)
  13214. {
  13215. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13216. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13217. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13218. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13219. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13220. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13221. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13222. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13223. }
  13224. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13225. if (leftBindData != null)
  13226. {
  13227. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13228. designer.SetDataSource("BDJRS", leftBindData.rs);
  13229. designer.SetDataSource("BDJXS", leftBindData.xs);
  13230. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13231. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13232. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13233. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13234. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13235. }
  13236. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13237. if (leftBindData != null)
  13238. {
  13239. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13240. designer.SetDataSource("BGWRS", leftBindData.rs);
  13241. designer.SetDataSource("BGWXS", leftBindData.xs);
  13242. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13243. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13244. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13245. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13246. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13247. }
  13248. #region 优化方案
  13249. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13250. //excelBind.Add("零用金", new {
  13251. //cb="",
  13252. //rs="",
  13253. //xs ="",
  13254. //zcb = "",
  13255. //});
  13256. #endregion
  13257. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13258. if (leftBindData != null)
  13259. {
  13260. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13261. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13262. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13263. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13264. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13265. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13266. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13267. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13268. }
  13269. #endregion
  13270. #region B段Right信息
  13271. right = dto.rightInfo.Find(x => x.Type == "B");
  13272. if (right == null)
  13273. {
  13274. return Ok(jw);
  13275. }
  13276. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13277. if (rightBindData != null)
  13278. {
  13279. //经济舱 + 双人间 TBR
  13280. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13281. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13282. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13283. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13284. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13285. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13286. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13287. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13288. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13289. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13290. }
  13291. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13292. if (rightBindData != null)
  13293. {
  13294. //经济舱 + 单人间 SGR
  13295. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13296. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13297. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13298. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13299. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13300. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13301. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13302. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13303. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13304. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13305. }
  13306. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13307. if (rightBindData != null)
  13308. {
  13309. //公务舱 + 单人间 SGR
  13310. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13311. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13312. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13313. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13314. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13315. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13316. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13317. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13318. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13319. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13320. }
  13321. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13322. if (rightBindData != null)
  13323. {
  13324. //公务舱 + 小套房 JSES
  13325. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13326. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13327. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13328. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13329. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13330. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13331. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13332. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13333. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13334. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13335. }
  13336. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13337. if (rightBindData != null)
  13338. {
  13339. //公务舱 + 小套房 JSES
  13340. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13341. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13342. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13343. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13344. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13345. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13346. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13347. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13348. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13349. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13350. }
  13351. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13352. if (rightBindData != null)
  13353. {
  13354. //经济舱 + 大套房
  13355. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13356. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13357. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13358. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13359. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13360. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13361. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13362. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13363. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13364. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13365. }
  13366. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13367. if (rightBindData != null)
  13368. {
  13369. //头等舱 + 小套房 JSES
  13370. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13371. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13372. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13373. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13374. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13375. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13376. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13377. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13378. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13379. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13380. }
  13381. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13382. if (rightBindData != null)
  13383. {
  13384. //头等舱 + 大套房
  13385. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13386. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13387. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13388. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13389. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13390. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13391. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13392. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13393. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13394. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13395. }
  13396. #endregion
  13397. #region 标题
  13398. designer.SetDataSource("CostBDRCB", "单人成本");
  13399. designer.SetDataSource("CostBRS", "人数");
  13400. designer.SetDataSource("CostBXS", "系数");
  13401. designer.SetDataSource("CostBZCB", "总成本");
  13402. designer.SetDataSource("CostBDRBJ", "单人报价");
  13403. designer.SetDataSource("CostBZBJ", "总报价");
  13404. designer.SetDataSource("CostBDRLR", "单人利润");
  13405. designer.SetDataSource("CostBZLR", "总利润");
  13406. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13407. designer.SetDataSource("CostBRSOM", "人数");
  13408. designer.SetDataSource("CostBZCBOM", "总成本");
  13409. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13410. designer.SetDataSource("CostBZBJOM", "总报价");
  13411. designer.SetDataSource("CostBDRLROM", "单人利润");
  13412. designer.SetDataSource("CostBZLROM", "总利润");
  13413. #endregion
  13414. }
  13415. #endregion
  13416. designer.SetDataSource("TzZCB2", TzZCB2);
  13417. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13418. designer.SetDataSource("TzZLR2", TzZLR2);
  13419. string[] dataSourceKeys = new string[]
  13420. {
  13421. "VF",
  13422. "TGS",
  13423. "TGOF",
  13424. "TGM",
  13425. "TGA",
  13426. "TGTF",
  13427. "TGEF",
  13428. "CFM",
  13429. "CFOF",
  13430. "B",
  13431. "L",
  13432. "D",
  13433. "TBR",
  13434. "SGR",
  13435. "JSES",
  13436. "Suite",
  13437. "TV",
  13438. "1L",
  13439. "IF",
  13440. "EF",
  13441. "BRF",
  13442. "TE",
  13443. "TGT",
  13444. "DRVT",
  13445. "PC",
  13446. "TLF",
  13447. "ECT"
  13448. };
  13449. foreach (var item in dataSourceKeys)
  13450. {
  13451. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13452. if (find != null)
  13453. {
  13454. designer.SetDataSource(item, find.text);
  13455. }
  13456. else
  13457. {
  13458. designer.SetDataSource(item, 0);
  13459. }
  13460. }
  13461. designer.SetDataSource(dt);
  13462. //根据数据源处理生成报表内容
  13463. designer.Process();
  13464. designer.Workbook.Worksheets[0].Name = "清单";
  13465. Worksheet sheet = designer.Workbook.Worksheets[0];
  13466. foreach (var Rowindex in hideRowsList)
  13467. {
  13468. ws.Cells.HideRows(Rowindex, 2);
  13469. }
  13470. byte[] bytes = null;
  13471. string strFileName = di.TeamName + "-团组-成本.xls";
  13472. using (MemoryStream stream = new MemoryStream())
  13473. {
  13474. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13475. bytes = stream.ToArray();
  13476. }
  13477. return Ok(JsonView(true, "", new
  13478. {
  13479. Data = bytes,
  13480. strFileName,
  13481. }));
  13482. }
  13483. /// <summary>
  13484. /// 导出客户报表
  13485. /// </summary>
  13486. /// <returns></returns>
  13487. [HttpPost]
  13488. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13489. {
  13490. var jw = JsonView(false);
  13491. if (dto.Diid == 0)
  13492. {
  13493. return Ok(JsonView(false, "请传递团组id"));
  13494. }
  13495. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13496. if (deleInfo.Code != 0)
  13497. {
  13498. return Ok(JsonView(false, "团组信息查询失败!"));
  13499. }
  13500. var di = deleInfo.Data as DelegationInfoWebView;
  13501. if (di == null)
  13502. {
  13503. return Ok(JsonView(false, "团组信息查询失败!"));
  13504. }
  13505. //文件名
  13506. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13507. //获取模板
  13508. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13509. //载入模板
  13510. Document doc = new Document(tmppath);
  13511. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13512. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13513. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13514. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13515. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13516. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13517. if (AParameter == null)
  13518. {
  13519. return Ok(JsonView(false, "系数不存在!"));
  13520. }
  13521. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13522. , TzAirDesc, TzZCost;
  13523. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13524. = TzAirDesc = TzZCost = string.Empty;
  13525. TzNumber = AParameter.CostTypenumber.ToString();
  13526. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13527. CarGuides1 = dto.CarGuides1;
  13528. Meal = dto.Meal;
  13529. SubsidizedMeals = dto.SubsidizedMeals;
  13530. NightRepair = dto.NightRepair;
  13531. AttractionsTickets = dto.AttractionsTickets;
  13532. MiscellaneousFees = dto.MiscellaneousFees;
  13533. ATip = dto.ATip;
  13534. TzHotelDesc = "";
  13535. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13536. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13537. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13538. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13539. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13540. TzAirDesc = "";
  13541. TzZCost = dto.TzZCost;
  13542. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13543. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13544. var index = 1;
  13545. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13546. foreach (var item in TzHotelDescArr)
  13547. {
  13548. if (AinfoArr != null)
  13549. {
  13550. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13551. if (Ainfo != null)
  13552. {
  13553. if (int.Parse(Ainfo.rs) <= 0)
  13554. {
  13555. continue;
  13556. }
  13557. var hotelText = string.Empty;
  13558. switch (item)
  13559. {
  13560. case "SGR":
  13561. hotelText = "单人间";
  13562. break;
  13563. case "JSES":
  13564. hotelText = "小套房";
  13565. break;
  13566. case "SUITE":
  13567. hotelText = "套房";
  13568. break;
  13569. case "TBR":
  13570. hotelText = "双人间";
  13571. break;
  13572. }
  13573. if (item != "TBR")
  13574. {
  13575. 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";
  13576. }
  13577. else
  13578. {
  13579. 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";
  13580. }
  13581. index++;
  13582. }
  13583. }
  13584. }
  13585. index = 1;
  13586. foreach (var item in TzAirDescArr)
  13587. {
  13588. if (AinfoArr != null)
  13589. {
  13590. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13591. if (Ainfo != null)
  13592. {
  13593. if (int.Parse(Ainfo.rs) <= 0)
  13594. {
  13595. continue;
  13596. }
  13597. 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";
  13598. index++;
  13599. }
  13600. }
  13601. }
  13602. if (dto.costType == "B")
  13603. {
  13604. if (BParameter == null)
  13605. {
  13606. return Ok(JsonView(false, "B段系数不存在!"));
  13607. }
  13608. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13609. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13610. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13611. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13612. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13613. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13614. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13615. foreach (var item in TzHotelDescArr)
  13616. {
  13617. if (AinfoArr != null)
  13618. {
  13619. TzHotelDesc += "B段信息 \r\n";
  13620. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13621. if (Ainfo != null)
  13622. {
  13623. if (int.Parse(Ainfo.rs) <= 0)
  13624. {
  13625. continue;
  13626. }
  13627. var hotelText = string.Empty;
  13628. switch (item)
  13629. {
  13630. case "SGR":
  13631. hotelText = "单人间";
  13632. break;
  13633. case "JSES":
  13634. hotelText = "小套房";
  13635. break;
  13636. case "SUITE":
  13637. hotelText = "套房";
  13638. break;
  13639. case "TBR":
  13640. hotelText = "双人间";
  13641. break;
  13642. }
  13643. if (item != "TBR")
  13644. {
  13645. 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";
  13646. }
  13647. else
  13648. {
  13649. 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";
  13650. }
  13651. index++;
  13652. }
  13653. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13654. }
  13655. }
  13656. index = 1;
  13657. foreach (var item in TzAirDescArr)
  13658. {
  13659. if (AinfoArr != null)
  13660. {
  13661. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13662. if (Ainfo != null)
  13663. {
  13664. if (int.Parse(Ainfo.rs) <= 0)
  13665. {
  13666. continue;
  13667. }
  13668. 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";
  13669. index++;
  13670. }
  13671. }
  13672. }
  13673. }
  13674. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13675. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13676. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13677. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13678. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13679. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13680. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13681. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13682. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13683. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13684. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13685. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13686. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13687. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13688. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13689. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13690. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13691. DickeyValue.Add("TzZCost", TzZCost);
  13692. foreach (var key in DickeyValue.Keys)
  13693. {
  13694. if (doc.Range.Bookmarks[key] != null)
  13695. {
  13696. Bookmark mark = doc.Range.Bookmarks[key];
  13697. mark.Text = DickeyValue[key];
  13698. }
  13699. }
  13700. byte[] bytes = null;
  13701. string strFileName = di.TeamName + "-客户报价.doc";
  13702. using (MemoryStream stream = new MemoryStream())
  13703. {
  13704. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13705. bytes = stream.ToArray();
  13706. }
  13707. return Ok(JsonView(true, "", new
  13708. {
  13709. Data = bytes,
  13710. strFileName,
  13711. }));
  13712. }
  13713. /// <summary>
  13714. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13715. /// </summary>
  13716. /// <param name="dto"></param>
  13717. /// <returns></returns>
  13718. [HttpPost]
  13719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13720. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13721. {
  13722. try
  13723. {
  13724. #region 参数验证
  13725. if (dto.DiId < 0)
  13726. {
  13727. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13728. }
  13729. List<int> cTableIds = new List<int>() {
  13730. 76 ,//酒店预订
  13731. 77 ,//行程
  13732. 79 ,//车/导游地接
  13733. 80 ,//签证
  13734. 81 ,//邀请/公务活
  13735. 82 ,//团组客户保险
  13736. 85 ,//机票预订
  13737. 98 ,//其他款项
  13738. 285 ,//收款退还
  13739. 751 ,//酒店早餐
  13740. 1015 // 超支费用
  13741. };
  13742. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13743. {
  13744. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13745. }
  13746. #endregion
  13747. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13748. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13749. if (_GroupCostParameters.Count <= 0)
  13750. {
  13751. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13752. }
  13753. if (_GroupCostParameters[0].IsShare == 0)
  13754. {
  13755. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13756. }
  13757. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13758. //处理date为空问题
  13759. if (_GroupCosts.Count > 0)
  13760. {
  13761. for (int i = 0; i < _GroupCosts.Count; i++)
  13762. {
  13763. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13764. {
  13765. if (i > 0)
  13766. {
  13767. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13768. }
  13769. }
  13770. }
  13771. }
  13772. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13773. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13774. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13775. string currCode = "";
  13776. #region currCode 验证
  13777. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13778. if (isInt)
  13779. {
  13780. var currData = currDatas.Find(it => it.Id == intCurrency);
  13781. if (currData != null)
  13782. {
  13783. currCode = currData.Name;
  13784. }
  13785. }
  13786. else
  13787. {
  13788. currCode = _GroupCostParameters[0].Currency.Trim();
  13789. }
  13790. #endregion
  13791. //op,酒店单段模式存储
  13792. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13793. {
  13794. CurrencyCode = currCode,
  13795. Rate = _GroupCostParameters[0].Rate,
  13796. CostType = _GroupCostParameters[0].CostType,
  13797. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13798. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13799. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13800. };
  13801. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13802. if (_GroupCostParameters.Count == 2)
  13803. {
  13804. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13805. }
  13806. foreach (var item in _GroupCostParameters)
  13807. {
  13808. decimal _rate = 1;
  13809. decimal _rate1 = item.Rate;
  13810. decimal _scale = 1;
  13811. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13812. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13813. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13814. //if (userInfo != null)
  13815. //{
  13816. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13817. // {
  13818. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13819. // {
  13820. // _scale = 1.00M;
  13821. // }
  13822. // }
  13823. //}
  13824. #endregion
  13825. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13826. {
  13827. CurrencyCode = currCode,
  13828. Rate = _rate1,
  13829. CostType = item.CostType,
  13830. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13831. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13832. CostTypeNumber = item.CostTypenumber
  13833. };
  13834. if (_GroupCostParameters.Count > 1)
  13835. {
  13836. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13837. }
  13838. else
  13839. {
  13840. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13841. }
  13842. if (dto.CTable == 79)//
  13843. {
  13844. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13845. modulePromptInfo.TotalCost = item.DJCB;
  13846. }
  13847. List<string> costTypes = new List<string>() { "A", "B" };
  13848. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13849. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13850. if (_GroupCostsDuplicates.Count() == 1)
  13851. {
  13852. _GroupCostsTypeData = _GroupCosts;
  13853. }
  13854. else
  13855. {
  13856. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13857. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13858. }
  13859. /*
  13860. * 76 酒店预订
  13861. * 77 行程
  13862. * 79 车/导游地接
  13863. * 80 签证
  13864. * 81 邀请/公务活动
  13865. * 82 团组客户保险
  13866. * 85 机票预订
  13867. * 98 其他款项
  13868. * 285 收款退还
  13869. * 751 酒店早餐
  13870. * 1015 超支费用
  13871. */
  13872. switch (dto.CTable)
  13873. {
  13874. case 76: // 酒店预订
  13875. _ModuleSubPromptInfo.AddRange(
  13876. _GroupCostsTypeData.Select(it => new
  13877. {
  13878. it.DAY,
  13879. it.Date,
  13880. it.ACCON,
  13881. it.ITIN,
  13882. it.SGR,
  13883. it.TBR,
  13884. it.JS_ES,
  13885. it.Suite
  13886. })
  13887. );
  13888. break;
  13889. case 79: // 车/导游地接
  13890. _ModuleSubPromptInfo.AddRange(
  13891. _GroupCostsTypeData.Select(it => new
  13892. {
  13893. Date = it.Date, //日期
  13894. CarFee = it.CarCost * _rate * _scale, //车费用
  13895. CarType = it.CarType, //车型
  13896. DriverFee = it.CFS * _rate * _scale, //司机工资
  13897. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13898. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13899. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13900. GuideFee = it.TGS * _rate * _scale, //导游费用
  13901. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13902. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13903. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13904. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13905. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13906. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13907. Breakfast = it.B * _rate * _scale, //早餐费
  13908. Lunch = it.L * _rate * _scale, //午餐费
  13909. Dinner = it.D * _rate * _scale, //晚餐费
  13910. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13911. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13912. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13913. TicketFee = it.EF * _rate * _scale, //门票费
  13914. TicketRemark = it.EFR, //门票费描述
  13915. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13916. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13917. SpentCash = it.PC * _rate * _scale, //零用金
  13918. LeadersFee = it.TLF * _rate * _scale, //领队费
  13919. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13920. })
  13921. );
  13922. break;
  13923. case 85: // 机票
  13924. List<dynamic> datas = new List<dynamic>();
  13925. datas.Add(
  13926. new
  13927. {
  13928. AirType = "经济舱",
  13929. AirNum = item.JJCRS,
  13930. AirDRCB = item.JJCCB,
  13931. AirZCB = (item.JJCRS * item.JJCCB)
  13932. }
  13933. );
  13934. datas.Add(
  13935. new
  13936. {
  13937. AirType = "公务舱",
  13938. AirNum = item.GWCRS,
  13939. AirDRCB = item.GWCCB,
  13940. AirZCB = (item.GWCRS * item.GWCCB)
  13941. }
  13942. );
  13943. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13944. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13945. modulePromptInfo.Data = new
  13946. {
  13947. airFeeData = datas,
  13948. airInitData = initDatas
  13949. };
  13950. _ModulePromptInfos.Add(modulePromptInfo);
  13951. break;
  13952. default:
  13953. break;
  13954. }
  13955. }
  13956. if (dto.CTable != 85)
  13957. {
  13958. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13959. _ModulePromptInfos.Add(_ModulePromptInfo);
  13960. }
  13961. _view.ModulePromptInfos = _ModulePromptInfos;
  13962. return Ok(JsonView(true, "操作成功!", _view));
  13963. }
  13964. catch (Exception ex)
  13965. {
  13966. return Ok(JsonView(false, ex.Message));
  13967. }
  13968. }
  13969. /// <summary>
  13970. /// 根据黑屏代码重新生成行程
  13971. /// </summary>
  13972. /// <param name="dto"></param>
  13973. /// <returns></returns>
  13974. [HttpPost]
  13975. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13976. {
  13977. var jw = JsonView(false);
  13978. var Create = _GroupCostRepository.
  13979. CreateGroupCostByBlackCode(dto.Diid);
  13980. jw.Msg = Create.Msg;
  13981. if (Create.Code == 0)
  13982. {
  13983. jw.Code = 200;
  13984. jw.Data = new
  13985. {
  13986. groupCost = Create.Data,
  13987. blackCodeIsTrue = true
  13988. };
  13989. }
  13990. else
  13991. {
  13992. jw.Code = 400;
  13993. jw.Data = new
  13994. {
  13995. groupCost = Create.Data,
  13996. blackCodeIsTrue = false,
  13997. };
  13998. }
  13999. return Ok(jw);
  14000. }
  14001. /// <summary>
  14002. /// 成本获取OP历史车费用
  14003. /// </summary>
  14004. /// <param name="dto"></param>
  14005. /// <returns></returns>
  14006. [HttpPost]
  14007. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14008. {
  14009. var jw = JsonView(false);
  14010. try
  14011. {
  14012. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14013. //获取现有所有车的数据
  14014. if (!dto.Param.IsNullOrWhiteSpace())
  14015. {
  14016. string sql = $@"
  14017. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14018. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14019. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14020. 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
  14021. AND gctggr.ServiceEndTime is not NULL
  14022. ORDER by gctggrc.id DESC
  14023. ";
  14024. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14025. var numeberResult = await Task.Run(() =>
  14026. {
  14027. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14028. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14029. return numberArr;
  14030. });
  14031. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14032. foreach (var item in numeberResult)
  14033. {
  14034. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14035. {
  14036. Country = "数据异常!",
  14037. City = string.Empty,
  14038. };
  14039. item.Area = find.Country + " " + find.City;
  14040. }
  14041. dbResult.AddRange(numeberResult);
  14042. if (dto.Param.Contains("、"))
  14043. {
  14044. var sp = dto.Param.Split("、");
  14045. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14046. .Where(x =>
  14047. {
  14048. return System.Array.Exists(sp, e =>
  14049. {
  14050. bool where = false;
  14051. if (x.Area != null)
  14052. {
  14053. where = x.Area.Contains(e);
  14054. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14055. {
  14056. return false;
  14057. }
  14058. }
  14059. if (x.PriceName != null && !where)
  14060. {
  14061. where = x.PriceName.Contains(e);
  14062. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14063. {
  14064. return false;
  14065. }
  14066. }
  14067. return where;
  14068. });
  14069. }).ToList();
  14070. }
  14071. else
  14072. {
  14073. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14074. .Where(x =>
  14075. {
  14076. bool where = false;
  14077. if (x.Area != null)
  14078. {
  14079. where = x.Area.Contains(dto.Param);
  14080. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14081. {
  14082. return false;
  14083. }
  14084. }
  14085. if (x.PriceName != null && !where)
  14086. {
  14087. where = x.PriceName.Contains(dto.Param);
  14088. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14089. {
  14090. return false;
  14091. }
  14092. }
  14093. return where;
  14094. }
  14095. )
  14096. .ToList();
  14097. }
  14098. }
  14099. var view = dbResult.Select(x =>
  14100. {
  14101. decimal dp = 0.00M;
  14102. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14103. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14104. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14105. {
  14106. if (startB && endB)
  14107. {
  14108. var timesp = endD.Subtract(startD);
  14109. if ((timesp.Days + 1) != 0)
  14110. {
  14111. dp = x.Price / (timesp.Days + 1);
  14112. }
  14113. }
  14114. }
  14115. else
  14116. {
  14117. dp = x.Price;
  14118. }
  14119. return new
  14120. {
  14121. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14122. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14123. x.Area,
  14124. x.id,
  14125. price = x.Price.ToString("F2"),
  14126. x.PriceName,
  14127. x.PriceContent,
  14128. x.TeamName,
  14129. x.DatePrice,
  14130. dayPrice = dp.ToString("F2"),
  14131. };
  14132. }).OrderByDescending(x => x.id).ToList();
  14133. jw = JsonView(true, "获取成功!", view);
  14134. }
  14135. catch (Exception e)
  14136. {
  14137. jw = JsonView(false, e.Message);
  14138. }
  14139. return Ok(jw);
  14140. }
  14141. #endregion
  14142. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14143. /// <summary>
  14144. /// 酒店预订
  14145. /// 酒店费用列表 根据团组Id查询
  14146. /// </summary>
  14147. /// <param name="_dto"></param>
  14148. /// <returns></returns>
  14149. [HttpPost]
  14150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14151. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14152. {
  14153. #region 参数验证
  14154. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14155. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14156. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14157. #region 团组操作权限验证 76 酒店预定模块
  14158. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14159. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14160. #endregion
  14161. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14162. #region 页面操作权限验证
  14163. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14164. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14165. #endregion
  14166. #endregion
  14167. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14168. }
  14169. /// <summary>
  14170. /// 酒店预订
  14171. /// 基础数据
  14172. /// </summary>
  14173. /// <param name="_dto"></param>
  14174. /// <returns></returns>
  14175. [HttpPost]
  14176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14177. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14178. {
  14179. #region 参数验证
  14180. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14181. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14182. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14183. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14184. #region 页面操作权限验证
  14185. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14186. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14187. #endregion
  14188. #region 团组操作权限验证 76 酒店预定模块
  14189. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14190. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14191. #endregion
  14192. #endregion
  14193. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14194. }
  14195. /// <summary>
  14196. /// 酒店预订
  14197. /// 创建 入住卷号码
  14198. /// </summary>
  14199. /// <param name="_dto"></param>
  14200. /// <returns></returns>
  14201. [HttpPost]
  14202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14203. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14204. {
  14205. #region 参数验证
  14206. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14207. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14208. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14209. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14210. #region 页面操作权限验证
  14211. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14212. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14213. #endregion
  14214. #region 团组操作权限验证 76 酒店预定模块
  14215. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14216. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14217. #endregion
  14218. #endregion
  14219. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14220. if (data.Code != 0)
  14221. {
  14222. return Ok(JsonView(false, data.Msg));
  14223. }
  14224. return Ok(JsonView(true, data.Msg, data.Data));
  14225. }
  14226. /// <summary>
  14227. /// 酒店预订
  14228. /// 详情
  14229. /// </summary>
  14230. /// <param name="_dto"></param>
  14231. /// <returns></returns>
  14232. [HttpPost]
  14233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14234. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14235. {
  14236. #region 参数验证
  14237. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14238. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14239. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14240. #region 团组操作权限验证 76 酒店预定模块
  14241. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14242. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14243. #endregion
  14244. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14245. #region 页面操作权限验证
  14246. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14247. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14248. #endregion
  14249. #endregion
  14250. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14251. }
  14252. /// <summary>
  14253. /// 酒店预订
  14254. /// Add Or Edit
  14255. /// </summary>
  14256. /// <param name="_dto"></param>
  14257. /// <returns></returns>
  14258. [HttpPost]
  14259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14260. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14261. {
  14262. #region 参数验证
  14263. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14264. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14265. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14266. #region 团组操作权限验证 76 酒店预定模块
  14267. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14268. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14269. #endregion
  14270. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14271. #region 页面操作权限验证
  14272. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14273. if (_dto.Id == 0) // Add
  14274. {
  14275. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14276. }
  14277. else if (_dto.Id > 1) // Edit
  14278. {
  14279. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14280. }
  14281. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14282. #endregion
  14283. #endregion
  14284. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14285. if (_view.Code != 200)
  14286. {
  14287. return Ok(_view);
  14288. }
  14289. #region 成本无酒店价格数据进入超支
  14290. _sqlSugar.BeginTran();
  14291. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14292. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14293. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14294. for (int i = 0; i < groupCost.Count; i++)
  14295. {
  14296. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14297. {
  14298. groupCost[i].Date = groupCost[i - 1].Date;
  14299. }
  14300. }
  14301. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14302. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14303. List<Fin_GroupExtraCostDto_OP>();
  14304. if (start_Bool && end_Bool)
  14305. {
  14306. while (start_Time < end_Time)
  14307. {
  14308. foreach (var item in groupCost_Grp)
  14309. {
  14310. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14311. {
  14312. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14313. {
  14314. extraCostList.Add(new
  14315. Fin_GroupExtraCostDto_OP
  14316. {
  14317. Area = _dto.AreaId,
  14318. coefficient = 1.5M,
  14319. createUser = _dto.UserId,
  14320. currency = _dto.CardPriceCurrency,
  14321. diId = _dto.DiId,
  14322. ManagerConfirm = 0,
  14323. SupervisorConfirm = 0,
  14324. SYsupervisorConfirm = 0,
  14325. editType = 1,
  14326. PortType = 1,
  14327. price = _dto.CardPrice,
  14328. PriceCount = 1,
  14329. priceType = 1027,
  14330. priceDetailType = 1044,
  14331. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14332. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14333. });
  14334. }
  14335. }
  14336. }
  14337. start_Time = start_Time.AddDays(1);
  14338. }
  14339. }
  14340. if (extraCostList.Any())
  14341. {
  14342. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14343. }
  14344. _sqlSugar.CommitTran();
  14345. #endregion
  14346. #region 应用推送
  14347. try
  14348. {
  14349. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14350. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14351. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14352. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14353. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14354. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14355. var diId = _dto.DiId;
  14356. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14357. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14358. #region 操作记录
  14359. var opInfo = new Crm_TableOperationRecord()
  14360. {
  14361. TableName = "Grp_HotelReservations",
  14362. PortType = _dto.PortType,
  14363. DataId = hotelId,
  14364. CreateUserId = _dto.UserId
  14365. };
  14366. //var opStatus = OperationEnum.NoOperation;
  14367. if (_dto.Id < 1) //添加操作
  14368. {
  14369. opInfo.OperationItem = OperationEnum.Add;
  14370. }
  14371. else if (_dto.Id > 0)
  14372. {
  14373. opInfo.OperationItem = OperationEnum.Edit;
  14374. }
  14375. string opRemark = string.Empty;
  14376. if (ccpInfo != null)
  14377. {
  14378. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14379. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14380. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14381. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14382. }
  14383. opInfo.Remark = opRemark;
  14384. await _tableorRep.AddAsync(opInfo);
  14385. #endregion
  14386. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14387. //2024-10-21 新增LZ UID
  14388. var userIds = new List<int>() { 21 };
  14389. string title = $"费用审核";
  14390. string content = "";
  14391. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14392. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14393. try
  14394. {
  14395. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14396. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14397. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14398. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14399. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14400. }
  14401. catch (Exception ex)
  14402. {
  14403. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14404. }
  14405. }
  14406. catch (Exception ex)
  14407. {
  14408. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14409. }
  14410. try
  14411. {
  14412. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14413. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14414. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14415. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14416. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14417. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14418. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14419. //自动审核
  14420. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14421. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14422. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14423. //2024-10-21 新增LZ UID
  14424. var userIds = new List<int>() { 21 };
  14425. string title = $"系统通知";
  14426. var diId = _dto.DiId;
  14427. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14428. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14429. string content = "";
  14430. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14431. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14432. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14433. }
  14434. catch (Exception ex)
  14435. {
  14436. }
  14437. #endregion
  14438. return Ok(_view);
  14439. }
  14440. /// <summary>
  14441. /// 酒店自动审核测试
  14442. /// Add Or Edit
  14443. /// </summary>
  14444. /// <param name="diid"></param>
  14445. /// <param name="dataId"></param>
  14446. /// <returns></returns>
  14447. [HttpPost]
  14448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14449. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14450. {
  14451. #region 应用推送
  14452. try
  14453. {
  14454. //自动审核
  14455. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14456. }
  14457. catch (Exception ex)
  14458. {
  14459. return Ok(JsonView(false, "操作失败"));
  14460. }
  14461. #endregion
  14462. return Ok(JsonView(false, "操作成功"));
  14463. }
  14464. /// <summary>
  14465. /// 酒店预订
  14466. /// Del
  14467. /// </summary>
  14468. /// <param name="_dto"></param>
  14469. /// <returns></returns>
  14470. [HttpPost]
  14471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14472. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14473. {
  14474. #region 参数验证
  14475. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14476. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14477. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14478. #region 团组操作权限验证 76 酒店预定模块
  14479. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14480. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14481. #endregion
  14482. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14483. #region 页面操作权限验证
  14484. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14485. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14486. #endregion
  14487. #endregion
  14488. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14489. #region 操作记录
  14490. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14491. {
  14492. TableName = "Grp_HotelReservations",
  14493. PortType = _dto.PortType,
  14494. OperationItem = OperationEnum.Del,
  14495. DataId = _dto.Id,
  14496. CreateUserId = _dto.UserId
  14497. });
  14498. #endregion
  14499. return Ok(data);
  14500. }
  14501. /// <summary>
  14502. /// 酒店预订
  14503. /// 生成VOUCHER
  14504. /// 2024.05.06 之前版本
  14505. /// </summary>
  14506. /// <param name="_dto"></param>
  14507. /// <returns></returns>
  14508. [HttpPost]
  14509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14510. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14511. {
  14512. try
  14513. {
  14514. #region 参数验证
  14515. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14516. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14517. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14518. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14519. #region 团组操作权限验证 76 酒店预定模块
  14520. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14521. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14522. #endregion
  14523. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14524. #region 页面操作权限验证
  14525. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14526. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14527. #endregion
  14528. #endregion
  14529. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14530. //判断数据是否完整
  14531. if (hr != null)
  14532. {
  14533. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14534. {
  14535. string strFileName = "HotelStatement/";
  14536. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14537. if (dele != null)
  14538. strFileName += dele.TourCode;
  14539. //载入模板
  14540. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14541. Document doc = new Document(sss);
  14542. DocumentBuilder builder = new DocumentBuilder(doc);
  14543. #region 替换Word模板书签内容
  14544. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14545. //入住卷预定号码
  14546. if (doc.Range.Bookmarks["VNO"] != null)
  14547. {
  14548. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14549. mark.Text = hr.CheckNumber;
  14550. }
  14551. //酒店时间
  14552. if (doc.Range.Bookmarks["Date"] != null)
  14553. {
  14554. Bookmark mark = doc.Range.Bookmarks["Date"];
  14555. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14556. }
  14557. //团号
  14558. if (doc.Range.Bookmarks["TNo"] != null)
  14559. {
  14560. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14561. mark.Text = dele.TourCode;
  14562. }
  14563. //预定号码
  14564. if (doc.Range.Bookmarks["BookingId"] != null)
  14565. {
  14566. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14567. mark.Text = hr.ReservationsNo;
  14568. }
  14569. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14570. {
  14571. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14572. mark.Text = hr.DetermineNo;
  14573. }
  14574. //酒店城市
  14575. if (doc.Range.Bookmarks["City"] != null)
  14576. {
  14577. Bookmark mark = doc.Range.Bookmarks["City"];
  14578. mark.Text = hr.City;
  14579. }
  14580. //酒店名称
  14581. if (doc.Range.Bookmarks["HName"] != null)
  14582. {
  14583. Bookmark mark = doc.Range.Bookmarks["HName"];
  14584. mark.Text = hr.HotelName;
  14585. }
  14586. //酒店地址
  14587. if (doc.Range.Bookmarks["Address"] != null)
  14588. {
  14589. Bookmark mark = doc.Range.Bookmarks["Address"];
  14590. mark.Text = hr.HotelAddress;
  14591. }
  14592. //酒店电话
  14593. if (doc.Range.Bookmarks["Tel"] != null)
  14594. {
  14595. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14596. mark.Text = hr.HotelTel;
  14597. }
  14598. //酒店传真
  14599. if (doc.Range.Bookmarks["Fax"] != null)
  14600. {
  14601. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14602. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14603. {
  14604. mark.Text = hr.HotelFax;
  14605. }
  14606. }
  14607. //入住时间
  14608. if (doc.Range.Bookmarks["CIn"] != null)
  14609. {
  14610. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14611. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14612. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14613. }
  14614. //退房时间
  14615. if (doc.Range.Bookmarks["COut"] != null)
  14616. {
  14617. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14618. Bookmark mark = doc.Range.Bookmarks["COut"];
  14619. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14620. }
  14621. //客户名称
  14622. if (doc.Range.Bookmarks["GName"] != null)
  14623. {
  14624. string guestName = "";
  14625. string[] clients = new string[] { };
  14626. if (hr.GuestName.Contains(","))
  14627. {
  14628. clients = hr.GuestName.Split(",");
  14629. }
  14630. else
  14631. {
  14632. clients = new string[] { hr.GuestName };
  14633. }
  14634. List<int> clientIds_int = new List<int>();
  14635. if (clients.Length > 0)
  14636. {
  14637. foreach (var item in clients)
  14638. {
  14639. if (item.IsNumeric())
  14640. {
  14641. clientIds_int.Add(int.Parse(item));
  14642. }
  14643. }
  14644. }
  14645. if (clientIds_int.Count > 0)
  14646. {
  14647. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14648. foreach (var client in _clientDatas)
  14649. {
  14650. //男
  14651. if (client.Sex == 0) guestName += $"Mr.";
  14652. //女
  14653. else if (client.Sex == 1) guestName += $"Ms.";
  14654. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14655. {
  14656. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14657. }
  14658. //guestName += $"{client.Pinyin},";
  14659. }
  14660. if (guestName.Length > 0)
  14661. {
  14662. guestName = guestName.Substring(0, guestName.Length - 1);
  14663. }
  14664. }
  14665. else
  14666. {
  14667. guestName = hr.GuestName;
  14668. }
  14669. Bookmark mark = doc.Range.Bookmarks["GName"];
  14670. mark.Text = guestName;
  14671. }
  14672. //房间介绍
  14673. if (doc.Range.Bookmarks["ROOM"] != null)
  14674. {
  14675. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14676. mark.Text = hr.RoomExplanation;
  14677. }
  14678. //报价描述
  14679. if (doc.Range.Bookmarks["NOTE"] != null)
  14680. {
  14681. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14682. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14683. if (ss != null)
  14684. mark.Text = ss.Name;
  14685. }
  14686. //入住时间
  14687. if (doc.Range.Bookmarks["CheckIn"] != null)
  14688. {
  14689. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14690. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14691. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14692. }
  14693. //退房时间
  14694. if (doc.Range.Bookmarks["CheckOut"] != null)
  14695. {
  14696. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14697. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14698. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14699. }
  14700. //日期
  14701. if (doc.Range.Bookmarks["DT"] != null)
  14702. {
  14703. Bookmark mark = doc.Range.Bookmarks["DT"];
  14704. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14705. }
  14706. //名称
  14707. if (doc.Range.Bookmarks["VName"] != null)
  14708. {
  14709. Bookmark mark = doc.Range.Bookmarks["VName"];
  14710. mark.Text = hr.HotelName;
  14711. }
  14712. //号码
  14713. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14714. {
  14715. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14716. mark.Text = hr.CheckNumber;
  14717. }
  14718. #endregion
  14719. strFileName += "VOUCHER.doc";
  14720. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14721. doc.Save(fileDir);
  14722. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14723. return Ok(JsonView(true, "操作成功!", Url));
  14724. }
  14725. else
  14726. {
  14727. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14728. }
  14729. }
  14730. else
  14731. {
  14732. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14733. }
  14734. }
  14735. catch (Exception ex)
  14736. {
  14737. return Ok(JsonView(false, ex.Message));
  14738. }
  14739. }
  14740. /// <summary>
  14741. /// 酒店预订
  14742. /// 生成VOUCHER
  14743. /// 2024.05.06 之后版本
  14744. /// </summary>
  14745. /// <param name="_dto"></param>
  14746. /// <returns></returns>
  14747. [HttpPost]
  14748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14749. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14750. {
  14751. #region 参数验证
  14752. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14753. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14754. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14755. #region 团组操作权限验证 76 酒店预定模块
  14756. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14757. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14758. #endregion
  14759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14760. #region 页面操作权限验证
  14761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14762. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14763. #endregion
  14764. #endregion
  14765. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14766. //判断数据是否完整
  14767. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14768. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14769. string strFileName = "HotelStatement/";
  14770. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14771. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14772. #region 数据处理
  14773. List<int> guestIds = new List<int>();
  14774. //int index = 0;
  14775. foreach (var item in hrDtas)
  14776. {
  14777. if (item.GuestName.Contains(","))
  14778. {
  14779. string[] guestIdArr = item.GuestName.Split(',');
  14780. foreach (var guestIdStr in guestIdArr)
  14781. {
  14782. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14783. if (guestBool)
  14784. {
  14785. guestIds.Add(guestId);
  14786. }
  14787. }
  14788. }
  14789. else guestNames += item.GuestName;
  14790. var voucherInfo = new HotelVoucherInfoView()
  14791. {
  14792. HotelName = item.HotelName,
  14793. CheckInDate = item.CheckInDate,
  14794. CheckOutDate = item.CheckOutDate,
  14795. ConfirmationNumber = item.DetermineNo.Trim(),
  14796. RoomType = item.RoomExplanation
  14797. };
  14798. vouchers.Add(voucherInfo);
  14799. }
  14800. if (guestIds.Count > 0)
  14801. {
  14802. guestIds = guestIds.Distinct().ToList();
  14803. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14804. if (guestDatas.Count > 0)
  14805. {
  14806. guestNames = "";
  14807. foreach (var guest in guestDatas)
  14808. {
  14809. string guestName = "";
  14810. if (guest.Sex == 0) guestName += @"MR.";
  14811. else if (guest.Sex == 1) guestName += @"MS.";
  14812. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14813. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14814. guestNames += @$"{guestName.Trim()}、";
  14815. }
  14816. if (guestNames.Length > 0)
  14817. {
  14818. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14819. }
  14820. }
  14821. }
  14822. #endregion
  14823. //载入模板
  14824. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14825. Document doc = new Document(sss);
  14826. DocumentBuilder builder = new DocumentBuilder(doc);
  14827. if (doc.Range.Bookmarks["GuestName"] != null)
  14828. {
  14829. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14830. mark.Text = guestNames;
  14831. }
  14832. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14833. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14834. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14835. for (int i = 1; i <= vouchers.Count; i++)
  14836. {
  14837. HotelVoucherInfoView hviv = vouchers[i - 1];
  14838. builder.MoveToCell(0, i, 0, 0);
  14839. builder.Write(hviv.HotelName);
  14840. builder.MoveToCell(0, i, 1, 0);
  14841. builder.Write(hviv.CheckInDate);
  14842. builder.MoveToCell(0, i, 2, 0);
  14843. builder.Write(hviv.CheckOutDate);
  14844. builder.MoveToCell(0, i, 3, 0);
  14845. builder.Write(hviv.RoomType);
  14846. builder.MoveToCell(0, i, 4, 0);
  14847. builder.Write(hviv.ConfirmationNumber);
  14848. }
  14849. //删除多余行
  14850. int currRowIndex = vouchers.Count + 1;
  14851. int delRows = 21 - currRowIndex;
  14852. if (delRows > 0)
  14853. {
  14854. for (int i = 0; i < delRows; i++)
  14855. {
  14856. table.Rows.RemoveAt(currRowIndex);
  14857. //cultivateRowIndex++;
  14858. }
  14859. }
  14860. strFileName += "VOUCHER.docx";
  14861. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14862. doc.Save(fileDir);
  14863. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14864. return Ok(JsonView(true, "操作成功!", Url));
  14865. }
  14866. /// <summary>
  14867. /// 酒店预订
  14868. /// 生成VOUCHER 批量生成
  14869. /// New
  14870. /// </summary>
  14871. /// <param name="_dto"></param>
  14872. /// <returns></returns>
  14873. [HttpPost]
  14874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14875. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14876. {
  14877. #region 参数验证
  14878. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14879. if (_dto.PageId < 1) _dto.PageId = 28;
  14880. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14881. #region 团组操作权限验证 76 酒店预定模块
  14882. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14883. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14884. #endregion
  14885. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14886. #region 页面操作权限验证
  14887. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14888. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14889. #endregion
  14890. #endregion
  14891. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14892. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14893. .OrderBy(x => x.CheckInDate)
  14894. .ToListAsync();
  14895. //判断数据是否完整
  14896. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14897. string strFileName = "HotelStatement/";
  14898. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14899. if (dele != null)
  14900. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14901. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14902. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14903. .Where(it => it.IsDel == 0)
  14904. .ToListAsync();
  14905. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14906. for (int i = 0; i < hrDtas.Count; i++)
  14907. {
  14908. string guestNames = string.Empty;
  14909. List<int> guestIds = new List<int>();
  14910. var item = hrDtas[i];
  14911. //处理客户姓名
  14912. if (item.GuestName.Contains(","))
  14913. {
  14914. string[] guestIdArr = item.GuestName.Split(',');
  14915. foreach (var guestIdStr in guestIdArr)
  14916. if (int.TryParse(guestIdStr, out int guestId))
  14917. guestIds.Add(guestId);
  14918. }
  14919. else
  14920. {
  14921. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14922. if (guestIdBool)
  14923. {
  14924. guestIds.Add(guestId);
  14925. }
  14926. //NaN
  14927. if (item.GuestName.Contains("NaN"))
  14928. {
  14929. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14930. }
  14931. }
  14932. if (guestIds.Count > 0)
  14933. {
  14934. guestIds = guestIds.Distinct().ToList();
  14935. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14936. if (guestDatas1.Count > 0)
  14937. {
  14938. guestNames = "";
  14939. foreach (var guest in guestDatas1)
  14940. {
  14941. string guestName = "";
  14942. if (guest.Sex == 0) guestName += @"MR.";
  14943. else if (guest.Sex == 1) guestName += @"MS.";
  14944. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14945. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14946. guestNames += @$"{guestName.Trim()}、";
  14947. }
  14948. if (guestNames.Length > 0)
  14949. {
  14950. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14951. }
  14952. }
  14953. }
  14954. //if (!string.IsNullOrEmpty(guestNames))
  14955. //{
  14956. hrDtas[i].GuestName = guestNames;
  14957. //}
  14958. }
  14959. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14960. Document doc = new Document();
  14961. DocumentBuilder builder = new DocumentBuilder(doc);
  14962. try
  14963. {
  14964. builder.MoveToDocumentStart();
  14965. foreach (var item in hrDtas)
  14966. {
  14967. //标题
  14968. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14969. builder.ParagraphFormat.LineSpacing = 1;
  14970. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14971. builder.ParagraphFormat.Style.Font.Size = 9;
  14972. builder.ParagraphFormat.Style.Font.Bold = true;
  14973. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14974. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14975. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14976. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14977. builder.ParagraphFormat.LineSpacing = 1;
  14978. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14979. builder.ParagraphFormat.Style.Font.Size = 9;
  14980. builder.ParagraphFormat.Style.Font.Bold = true;
  14981. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14982. builder.StartTable();
  14983. // 设置边框颜色
  14984. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14985. //设置边框样式
  14986. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14987. //表格
  14988. #region 第一行
  14989. builder.InsertCell();
  14990. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14991. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14992. //builder.CellFormat.AllowAutoFit = false;
  14993. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14994. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14995. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14996. builder.CellFormat.WrapText = true; //自动换行
  14997. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14998. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14999. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15000. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15001. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15002. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15003. builder.Write("TOUR NO:");
  15004. builder.InsertCell();
  15005. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15006. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15007. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15008. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15009. builder.ParagraphFormat.Style.Font.Bold = false;
  15010. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15011. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15012. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15013. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15014. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15015. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15016. builder.Write($"{dele?.TourCode ?? "-"}");
  15017. builder.InsertCell();
  15018. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15019. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15020. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15021. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15022. builder.ParagraphFormat.Style.Font.Bold = false;
  15023. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15024. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15025. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15026. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15027. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15028. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15029. builder.Write($"CITY:");
  15030. builder.InsertCell();
  15031. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15032. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15033. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15034. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15035. builder.ParagraphFormat.Style.Font.Bold = false;
  15036. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15037. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15038. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15039. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15040. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15041. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15042. builder.Write($"{item.City}");
  15043. builder.EndRow();
  15044. #endregion
  15045. #region 第二行
  15046. builder.InsertCell();
  15047. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15048. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15049. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15050. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15051. builder.ParagraphFormat.Style.Font.Bold = false;
  15052. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15053. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15054. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15055. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15056. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15057. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15058. builder.Write("CONFIRMATION NO:");
  15059. builder.InsertCell();
  15060. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15061. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15062. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15063. builder.ParagraphFormat.Style.Font.Bold = false;
  15064. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15065. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15066. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15067. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15068. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15069. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15070. builder.CellFormat.VerticalMerge = CellMerge.None;
  15071. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15072. builder.Write($"{item.DetermineNo}");
  15073. builder.InsertCell();
  15074. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15075. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15076. builder.InsertCell();
  15077. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15078. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15079. builder.EndRow();
  15080. #endregion
  15081. #region 第三行
  15082. builder.InsertCell();
  15083. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15084. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15085. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15086. builder.ParagraphFormat.Style.Font.Bold = false;
  15087. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15088. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15089. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15090. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15091. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15092. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15093. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15094. builder.Write($"HOTEL NAME:");
  15095. builder.InsertCell();
  15096. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15097. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15098. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15099. builder.ParagraphFormat.Style.Font.Bold = false;
  15100. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15101. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15102. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15103. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15104. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15105. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15106. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15107. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15108. builder.Write($"{item.HotelName}");
  15109. builder.InsertCell();
  15110. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15111. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15112. builder.InsertCell();
  15113. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15114. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15115. builder.EndRow();
  15116. #endregion
  15117. #region 第四行
  15118. builder.InsertCell();
  15119. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15120. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15121. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15122. builder.ParagraphFormat.Style.Font.Bold = false;
  15123. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15124. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15125. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15126. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15127. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15128. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15129. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15130. builder.Write($"HOTEL ADDRESS:");
  15131. builder.InsertCell();
  15132. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15133. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15134. builder.ParagraphFormat.Style.Font.Size = 8;
  15135. builder.ParagraphFormat.Style.Font.Bold = false;
  15136. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15137. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15138. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15139. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15140. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15141. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15142. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15143. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15144. builder.Write($"{item.HotelAddress}");
  15145. builder.InsertCell();
  15146. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15147. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15148. builder.InsertCell();
  15149. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15150. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15151. builder.EndRow();
  15152. #endregion
  15153. #region 第五行
  15154. builder.InsertCell();
  15155. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15156. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15157. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15158. builder.ParagraphFormat.Style.Font.Bold = false;
  15159. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15160. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15161. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15162. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15163. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15164. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15165. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15166. builder.Write("TEL:");
  15167. builder.InsertCell();
  15168. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15169. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15170. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15171. builder.ParagraphFormat.Style.Font.Bold = false;
  15172. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15173. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15174. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15175. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15176. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15177. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15178. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15179. builder.Write($"{item.HotelTel}");
  15180. builder.InsertCell();
  15181. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15182. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15183. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15184. builder.ParagraphFormat.Style.Font.Bold = false;
  15185. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15186. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15187. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15188. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15189. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15190. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15191. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15192. builder.Write($"FAX:");
  15193. builder.InsertCell();
  15194. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15195. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15196. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15197. builder.ParagraphFormat.Style.Font.Bold = false;
  15198. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15199. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15200. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15201. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15202. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15203. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15204. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15205. builder.Write($"{item.HotelFax}");
  15206. builder.EndRow();
  15207. #endregion
  15208. #region 第六行
  15209. builder.InsertCell();
  15210. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15211. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15212. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15213. builder.ParagraphFormat.Style.Font.Bold = false;
  15214. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15215. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15216. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15217. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15218. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15219. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15220. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15221. builder.Write("CHECK IN:");
  15222. builder.InsertCell();
  15223. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15224. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15225. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15226. builder.ParagraphFormat.Style.Font.Bold = false;
  15227. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15228. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15229. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15230. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15231. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15232. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15233. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15234. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15235. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15236. builder.Write($"{checkInStr}");
  15237. builder.InsertCell();
  15238. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15239. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15240. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15241. builder.ParagraphFormat.Style.Font.Bold = false;
  15242. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15243. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15244. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15245. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15246. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15247. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15248. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15249. builder.Write($"CHECK OUT:");
  15250. builder.InsertCell();
  15251. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15252. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15253. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15254. builder.ParagraphFormat.Style.Font.Bold = false;
  15255. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15256. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15257. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15258. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15259. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15260. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15261. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15262. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15263. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15264. builder.Write($"{checkOutStr}");
  15265. builder.EndRow();
  15266. #endregion
  15267. #region 第七行
  15268. builder.InsertCell();
  15269. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15270. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15271. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15272. builder.ParagraphFormat.Style.Font.Bold = false;
  15273. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15274. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15275. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15276. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15277. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15278. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15279. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15280. builder.Write($"GUEST NAME:");
  15281. builder.InsertCell();
  15282. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15283. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15284. builder.ParagraphFormat.Style.Font.Size = 8;
  15285. builder.ParagraphFormat.Style.Font.Bold = false;
  15286. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15287. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15288. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15289. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15290. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15291. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15292. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15293. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15294. builder.Write($"{item.GuestName}");
  15295. builder.InsertCell();
  15296. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15297. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15298. builder.InsertCell();
  15299. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15300. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15301. builder.EndRow();
  15302. #endregion
  15303. #region 第八行
  15304. builder.InsertCell();
  15305. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15306. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15307. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15308. builder.ParagraphFormat.Style.Font.Bold = false;
  15309. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15310. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15311. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15312. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15313. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15314. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15315. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15316. builder.Write($"ROOM TYPE:");
  15317. builder.InsertCell();
  15318. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15319. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15320. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15321. builder.ParagraphFormat.Style.Font.Bold = false;
  15322. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15323. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15324. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15325. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15326. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15327. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15328. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15329. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15330. builder.Write($"{item.RoomExplanation}");
  15331. builder.InsertCell();
  15332. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15333. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15334. builder.InsertCell();
  15335. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15336. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15337. builder.EndRow();
  15338. #endregion
  15339. #region 第九行
  15340. builder.InsertCell();
  15341. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15342. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15343. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15344. builder.ParagraphFormat.Style.Font.Bold = false;
  15345. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15346. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15347. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15348. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15349. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15350. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15351. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15352. builder.Write($"NOTE:");
  15353. builder.InsertCell();
  15354. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15355. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15356. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15357. builder.ParagraphFormat.Style.Font.Bold = false;
  15358. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15359. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15360. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15361. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15362. 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.");
  15363. builder.InsertCell();
  15364. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15365. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15366. builder.InsertCell();
  15367. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15368. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15369. builder.EndRow();
  15370. #endregion
  15371. builder.EndTable();
  15372. //换行
  15373. builder.Writeln("");
  15374. builder.Writeln("");
  15375. }
  15376. #region 获取文档中的所有表格 设置文字自适应
  15377. // 获取文档中的所有表格。
  15378. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15379. {
  15380. // 遍历表格中的所有行。
  15381. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15382. {
  15383. foreach (Cell cell in row.Cells)
  15384. {
  15385. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15386. cellFormat.Width = 0;
  15387. }
  15388. }
  15389. }
  15390. #endregion
  15391. #region 设置页眉
  15392. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15393. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15394. if (System.IO.File.Exists(voucherHeaderPath))
  15395. {
  15396. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15397. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15398. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15399. Shape shape = builder.InsertImage(imageBytes);
  15400. // 调整图片位置
  15401. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15402. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15403. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15404. shape.Left = 0; // 将图片距离页面左边缘的距离
  15405. shape.Width = 81; // 设置图片宽度
  15406. shape.Height = 36; // 设置图片高度
  15407. }
  15408. //靠右
  15409. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15410. //// 设置页脚上下边距
  15411. //builder.PageSetup.HeaderDistance = 42;
  15412. // 添加页眉线
  15413. Aspose.Words.Border borderHeader = null;
  15414. try
  15415. {
  15416. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15417. }
  15418. catch (Exception e)
  15419. {
  15420. // TODO Auto-generated catch block
  15421. //e.printStackTrace();
  15422. }
  15423. borderHeader.Shadow = true;
  15424. borderHeader.DistanceFromText = 2;
  15425. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15426. #endregion
  15427. }
  15428. catch (Exception ex)
  15429. {
  15430. }
  15431. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15432. doc.Save(fileDir);
  15433. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15434. return Ok(JsonView(true, "操作成功!", Url));
  15435. }
  15436. /// <summary>
  15437. /// 酒店预订
  15438. /// 生成 预定成本 Excel
  15439. /// </summary>
  15440. /// <param name="_dto"></param>
  15441. /// <returns></returns>
  15442. [HttpPost]
  15443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15444. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15445. {
  15446. #region 参数验证
  15447. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15448. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15449. if (!vadalitorRes.IsValid)
  15450. {
  15451. var errors = new StringBuilder();
  15452. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15453. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15454. }
  15455. #region 团组操作权限验证 76 酒店预定模块
  15456. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15457. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15458. #endregion
  15459. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15460. #region 页面操作权限验证
  15461. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15462. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15463. #endregion
  15464. #endregion
  15465. decimal _rate = 1.00M;
  15466. string _currency = string.Empty;
  15467. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15468. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15469. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15470. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15471. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15472. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15473. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15474. if (_GroupCostParameter == null)
  15475. {
  15476. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15477. bool isIntType = int.TryParse(_currency, out int currId);
  15478. if (isIntType)
  15479. {
  15480. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15481. }
  15482. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15483. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15484. if (currInfo == null)
  15485. {
  15486. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15487. }
  15488. else _rate = currInfo.Rate;
  15489. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15490. {
  15491. _rate = _GroupCostParameter.Rate;
  15492. }
  15493. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15494. //string strFileName = "HotelStatement/";
  15495. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15496. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15497. var rateDatas = new List<dynamic>();
  15498. #region 数据处理
  15499. foreach (var item in hrDtas)
  15500. {
  15501. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15502. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15503. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15504. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15505. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15506. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15507. {
  15508. continue;
  15509. }
  15510. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15511. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15512. string singleRoomFeeStr = string.Empty,
  15513. doubleRoomFeeStr = string.Empty,
  15514. suiteRoomFeeStr = string.Empty,
  15515. otherRoomFeeStr = string.Empty,
  15516. payMoneyStr = string.Empty,
  15517. cardPriceStr = string.Empty;
  15518. if (roomCurr.Equals("CNY"))
  15519. {
  15520. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15521. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15522. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15523. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15524. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15525. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15526. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15527. }
  15528. else
  15529. {
  15530. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15531. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15532. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15533. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15534. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15535. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15536. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15537. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15538. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15539. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15540. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15541. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15542. if (ccpPaymentCurrency.Equals("CNY"))
  15543. {
  15544. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15545. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15546. }
  15547. else
  15548. {
  15549. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15550. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15551. }
  15552. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15553. if (hotelcardPriceCurrency.Equals("CNY"))
  15554. {
  15555. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15556. }
  15557. else
  15558. {
  15559. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15560. }
  15561. }
  15562. string breakfastPriceStr = string.Empty,
  15563. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15564. governmentRentStr = string.Empty,
  15565. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15566. cityTaxStr = string.Empty,
  15567. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15568. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15569. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15570. {
  15571. if (breakfastCurrency1.Equals("CNY"))
  15572. {
  15573. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15574. }
  15575. else
  15576. {
  15577. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15578. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15579. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15580. }
  15581. }
  15582. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15583. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15584. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15585. {
  15586. if (governmentRentCurrency.Equals("CNY"))
  15587. {
  15588. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15589. }
  15590. else
  15591. {
  15592. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15593. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15594. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15595. }
  15596. }
  15597. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15598. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15599. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15600. {
  15601. if (cityTaxStrCurrency1.Equals("CNY"))
  15602. {
  15603. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15604. }
  15605. else
  15606. {
  15607. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15608. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15609. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15610. }
  15611. }
  15612. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15613. int payDId = roomInfo?.PayDId ?? 0;
  15614. pcfds.Add(new HotelReservations_PCFD_View()
  15615. {
  15616. City = item.City,
  15617. HotelName = item.HotelName,
  15618. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15619. // SingleRoomCount = item.SingleRoomCount,
  15620. SingleRoomPrice = singleRoomFeeStr,
  15621. // DoubleRoomCount = item.DoubleRoomCount,
  15622. DoubleRoomPrice = doubleRoomFeeStr,
  15623. //SuiteRoomCount = item.SuiteRoomCount,
  15624. SuiteRoomPrice = suiteRoomFeeStr,
  15625. OtherRoomPrice = otherRoomFeeStr,
  15626. //OtherRoomCount = item.OtherRoomCount,
  15627. BreakfastPrice = breakfastPriceStr,
  15628. GovernmentRent = governmentRentStr,
  15629. CityTax = cityTaxStr,
  15630. RoomExplanation = item.RoomExplanation,
  15631. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15632. PayTime = roomInfo?.ConsumptionDate,
  15633. BankNo = roomInfo?.BankNo,
  15634. PayMoney = payMoneyStr,
  15635. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15636. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15637. CardPrice = cardPriceStr,
  15638. Remark = ccpInfo.Remark
  15639. });
  15640. }
  15641. #endregion
  15642. //载入模板
  15643. WorkbookDesigner designer = new WorkbookDesigner();
  15644. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15645. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15646. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15647. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15648. var rateDatas1 = rateDatas.Distinct();
  15649. var rateStr = string.Empty;
  15650. foreach (var item in rateDatas1)
  15651. {
  15652. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15653. }
  15654. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15655. designer.SetDataSource("Opertor", userInfo.CnName);
  15656. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15657. dt.TableName = "ViewMyHotelReservations";
  15658. designer.SetDataSource(dt);
  15659. designer.Process();
  15660. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15661. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15662. designer.Workbook.Save(serverPath);
  15663. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15664. #region 删除指定行
  15665. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15666. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15667. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15668. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15669. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15670. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15671. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15672. cssIndex = dt.Columns["CityTax"].Ordinal,
  15673. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15674. remarkIndex = dt.Columns["Remark"].Ordinal;
  15675. //删除指定列
  15676. foreach (DataRow item in dt.Rows)
  15677. {
  15678. string singleStr = item["SingleRoomPrice"].ToString();
  15679. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15680. if (containsDigitButNotZero1) singleDel = false;
  15681. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15682. string doubleStr = item["DoubleRoomPrice"].ToString();
  15683. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15684. if (containsDigitButNotZero2) doubleDel = false;
  15685. string suiteStr = item["SuiteRoomPrice"].ToString();
  15686. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15687. if (containsDigitButNotZero3) suiteDel = false;
  15688. string otherStr = item["OtherRoomPrice"].ToString();
  15689. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15690. if (containsDigitButNotZero4) otherDel = false;
  15691. string zcStr = item["BreakfastPrice"].ToString();
  15692. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15693. if (containsDigitButNotZero5) zcDel = false;
  15694. string dsStr = item["GovernmentRent"].ToString();
  15695. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15696. if (containsDigitButNotZero6) dsDel = false;
  15697. string cssStr = item["CityTax"].ToString();
  15698. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15699. if (containsDigitButNotZero7) cssDel = false;
  15700. string cpStr = item["ConsumptionPatterns"].ToString();
  15701. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15702. string remarkStr = item["Remark"].ToString();
  15703. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15704. }
  15705. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15706. DeleteColumn(serverPath, cpIndex, cpDel);
  15707. DeleteColumn(serverPath, dsIndex, dsDel);
  15708. DeleteColumn(serverPath, cssIndex, cssDel);
  15709. DeleteColumn(serverPath, zcIndex, zcDel);
  15710. DeleteColumn(serverPath, otherIndex, otherDel);
  15711. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15712. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15713. DeleteColumn(serverPath, singleIndex, singleDel);
  15714. #endregion
  15715. //只保留第一个表格
  15716. DeleteSheet(serverPath);
  15717. return Ok(JsonView(true, "操作成功", url = rst));
  15718. }
  15719. else
  15720. {
  15721. _currency = _GroupCostParameter.Currency;
  15722. bool isIntType = int.TryParse(_currency, out int currId);
  15723. if (isIntType)
  15724. {
  15725. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15726. }
  15727. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15728. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15729. if (currInfo == null)
  15730. {
  15731. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15732. }
  15733. if (!_currency.ToUpper().Equals("CNY"))
  15734. {
  15735. _rate = _GroupCostParameter.Rate;
  15736. }
  15737. _rate = currInfo.Rate;
  15738. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15739. //string strFileName = "HotelStatement/";
  15740. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15741. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15742. #region 数据处理
  15743. foreach (var item in hrDtas)
  15744. {
  15745. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15746. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15747. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15748. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15749. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15750. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15751. string singleRoomFeeStr = string.Empty,
  15752. doubleRoomFeeStr = string.Empty,
  15753. suiteRoomFeeStr = string.Empty,
  15754. otherRoomFeeStr = string.Empty,
  15755. payMoneyStr = string.Empty,
  15756. cardPriceStr = string.Empty;
  15757. if (roomCurr.Equals(_currency))
  15758. {
  15759. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15760. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15761. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15762. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15763. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15764. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15765. }
  15766. else
  15767. {
  15768. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15769. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15770. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15771. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15772. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15773. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15774. }
  15775. string breakfastPriceStr = string.Empty,
  15776. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15777. governmentRentStr = string.Empty,
  15778. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15779. cityTaxStrStr = string.Empty,
  15780. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15781. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15782. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15783. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15784. int payDId = roomInfo?.PayDId ?? 0;
  15785. pcfds.Add(new HotelReservations_PCFD_View()
  15786. {
  15787. City = item.City,
  15788. HotelName = item.HotelName,
  15789. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15790. // SingleRoomCount = item.SingleRoomCount,
  15791. SingleRoomPrice = singleRoomFeeStr,
  15792. // DoubleRoomCount = item.DoubleRoomCount,
  15793. DoubleRoomPrice = doubleRoomFeeStr,
  15794. //SuiteRoomCount = item.SuiteRoomCount,
  15795. SuiteRoomPrice = suiteRoomFeeStr,
  15796. OtherRoomPrice = otherRoomFeeStr,
  15797. //OtherRoomCount = item.OtherRoomCount,
  15798. BreakfastPrice = breakfastPriceStr,
  15799. GovernmentRent = governmentRentStr,
  15800. CityTax = cityTaxStrStr,
  15801. RoomExplanation = item.RoomExplanation,
  15802. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15803. PayTime = roomInfo?.ConsumptionDate,
  15804. BankNo = roomInfo?.BankNo,
  15805. PayMoney = payMoneyStr,
  15806. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15807. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15808. CardPrice = cardPriceStr,
  15809. Remark = ccpInfo.Remark
  15810. });
  15811. }
  15812. #endregion
  15813. //载入模板
  15814. WorkbookDesigner designer = new WorkbookDesigner();
  15815. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15816. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15817. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15818. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15819. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15820. designer.SetDataSource("Opertor", userInfo.CnName);
  15821. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15822. dt.TableName = "ViewMyHotelReservations";
  15823. designer.SetDataSource(dt);
  15824. designer.Process();
  15825. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15826. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15827. designer.Workbook.Save(serverPath);
  15828. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15829. #region 删除指定行
  15830. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15831. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15832. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15833. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15834. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15835. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15836. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15837. cssIndex = dt.Columns["CityTax"].Ordinal,
  15838. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15839. remarkIndex = dt.Columns["Remark"].Ordinal;
  15840. //删除指定列
  15841. foreach (DataRow item in dt.Rows)
  15842. {
  15843. string singleStr = item["SingleRoomPrice"].ToString();
  15844. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15845. if (containsDigitButNotZero1) singleDel = false;
  15846. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15847. string doubleStr = item["DoubleRoomPrice"].ToString();
  15848. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15849. if (containsDigitButNotZero2) doubleDel = false;
  15850. string suiteStr = item["SuiteRoomPrice"].ToString();
  15851. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15852. if (containsDigitButNotZero3) suiteDel = false;
  15853. string otherStr = item["OtherRoomPrice"].ToString();
  15854. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15855. if (containsDigitButNotZero4) otherDel = false;
  15856. string zcStr = item["BreakfastPrice"].ToString();
  15857. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15858. if (containsDigitButNotZero5) zcDel = false;
  15859. string dsStr = item["GovernmentRent"].ToString();
  15860. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15861. if (containsDigitButNotZero6) dsDel = false;
  15862. string cssStr = item["CityTax"].ToString();
  15863. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15864. if (containsDigitButNotZero7) cssDel = false;
  15865. string cpStr = item["ConsumptionPatterns"].ToString();
  15866. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15867. string remarkStr = item["Remark"].ToString();
  15868. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15869. }
  15870. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15871. DeleteColumn(serverPath, cpIndex, cpDel);
  15872. DeleteColumn(serverPath, dsIndex, dsDel);
  15873. DeleteColumn(serverPath, cssIndex, cssDel);
  15874. DeleteColumn(serverPath, zcIndex, zcDel);
  15875. DeleteColumn(serverPath, otherIndex, otherDel);
  15876. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15877. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15878. DeleteColumn(serverPath, singleIndex, singleDel);
  15879. #endregion
  15880. //只保留第一个表格
  15881. DeleteSheet(serverPath);
  15882. return Ok(JsonView(true, "操作成功", url = rst));
  15883. }
  15884. //return Ok(JsonView(false));
  15885. }
  15886. /// <summary>
  15887. /// 删除指定列
  15888. /// </summary>
  15889. /// <param name="file"></param>
  15890. /// <param name="columnIndex"></param>
  15891. /// <param name="isDel"></param>
  15892. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15893. {
  15894. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15895. //wb.Save(file);
  15896. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15897. if (sheet1 != null)
  15898. {
  15899. if (isDel)
  15900. {
  15901. Cells cells = sheet1.Cells;
  15902. cells.DeleteColumn(columnIndex);
  15903. }
  15904. }
  15905. wb.Save(file);
  15906. }
  15907. /// <summary>
  15908. /// 删除sheet
  15909. /// </summary>
  15910. /// <param name="file"></param>
  15911. /// <param name="sheetName"></param>
  15912. private void DeleteSheet(string file, string sheetName = "")
  15913. {
  15914. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15915. //wb.Save(file);
  15916. List<string> sheets = new List<string>();
  15917. foreach (var item in wb.Worksheets)
  15918. {
  15919. sheets.Add(item.Name);
  15920. }
  15921. if (sheets.Count > 0)
  15922. {
  15923. sheets.RemoveAt(0);//不删除第一个sheet
  15924. foreach (var item in sheets)
  15925. {
  15926. wb.Worksheets.RemoveAt(item);
  15927. }
  15928. }
  15929. wb.Save(file);
  15930. }
  15931. /// <summary>
  15932. /// 酒店预订
  15933. /// 确认单
  15934. /// </summary>
  15935. /// <param name="_dto"></param>
  15936. /// <returns></returns>
  15937. [HttpPost]
  15938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15939. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15940. {
  15941. try
  15942. {
  15943. #region 参数验证
  15944. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15945. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15946. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15947. #region 团组操作权限验证 76 酒店预定模块
  15948. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15949. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15950. #endregion
  15951. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15952. #region 页面操作权限验证
  15953. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15954. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15955. #endregion
  15956. #endregion
  15957. //团组信息
  15958. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15959. //酒店数据
  15960. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15961. if (listhoteldata.Count < 0)
  15962. {
  15963. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15964. }
  15965. //利datatable存储
  15966. DataTable dt = new DataTable();
  15967. dt.Columns.Add("CheckInDate", typeof(string));
  15968. dt.Columns.Add("City", typeof(string));
  15969. dt.Columns.Add("Hotel", typeof(string));
  15970. dt.Columns.Add("Room", typeof(string));
  15971. for (int i = 0; i < listhoteldata.Count; i++)
  15972. {
  15973. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15974. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15975. while (dayStart < dayEnd)
  15976. {
  15977. string temp = "";
  15978. DataRow row = dt.NewRow();
  15979. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15980. row["City"] = listhoteldata[i].City;
  15981. row["Hotel"] = listhoteldata[i].HotelName;
  15982. if (listhoteldata[i].SingleRoomCount > 0)
  15983. {
  15984. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15985. }
  15986. if (listhoteldata[i].DoubleRoomCount > 0)
  15987. {
  15988. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15989. }
  15990. if (listhoteldata[i].SuiteRoomCount > 0)
  15991. {
  15992. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15993. }
  15994. if (listhoteldata[i].OtherRoomCount > 0)
  15995. {
  15996. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15997. }
  15998. row["Room"] = temp;
  15999. dt.Rows.Add(row);
  16000. dayStart = dayStart.AddDays(1);
  16001. }
  16002. }
  16003. Dictionary<string, string> dic = new Dictionary<string, string>();
  16004. dic.Add("Dele", di.TeamName);
  16005. dic.Add("City", di.VisitCountry);
  16006. //模板路径
  16007. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16008. //载入模板
  16009. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16010. DocumentBuilder builder = new DocumentBuilder(doc);
  16011. foreach (var key in dic.Keys)
  16012. {
  16013. builder.MoveToBookmark(key);
  16014. builder.Write(dic[key]);
  16015. }
  16016. //获取word里所有表格
  16017. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16018. //获取所填表格的序数
  16019. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16020. var rowStart = tableOne.Rows[0]; //获取第1行
  16021. //循环赋值
  16022. for (int i = 0; i < dt.Rows.Count; i++)
  16023. {
  16024. builder.MoveToCell(0, i + 1, 0, 0);
  16025. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16026. builder.MoveToCell(0, i + 1, 1, 0);
  16027. builder.Write(dt.Rows[i]["City"].ToString());
  16028. builder.MoveToCell(0, i + 1, 2, 0);
  16029. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16030. builder.MoveToCell(0, i + 1, 3, 0);
  16031. builder.Write(dt.Rows[i]["Room"].ToString());
  16032. }
  16033. //删除多余行
  16034. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16035. {
  16036. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16037. }
  16038. string strFileName = di.TeamName + "酒店确认单.doc";
  16039. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16040. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16041. return Ok(JsonView(true, "成功", url));
  16042. }
  16043. catch (Exception ex)
  16044. {
  16045. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16046. }
  16047. }
  16048. #endregion
  16049. #region 团组状态
  16050. /// <summary>
  16051. /// 团组状态列表 Page
  16052. /// </summary>
  16053. /// <param name="dto">团组列表请求dto</param>
  16054. /// <returns></returns>
  16055. [HttpPost]
  16056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16057. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16058. {
  16059. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16060. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16061. {
  16062. string sqlWhere = string.Empty;
  16063. if (dto.IsSure == 0) //未完成
  16064. {
  16065. sqlWhere += string.Format(@" And IsSure = 0");
  16066. }
  16067. else if (dto.IsSure == 1) //已完成
  16068. {
  16069. sqlWhere += string.Format(@" And IsSure = 1");
  16070. }
  16071. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16072. {
  16073. string tj = dto.SearchCriteria;
  16074. 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}%')",
  16075. tj, tj, tj, tj, tj);
  16076. }
  16077. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16078. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16079. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16080. From (
  16081. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16082. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16083. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16084. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16085. From Grp_DelegationInfo gdi
  16086. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16087. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16088. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16089. Where gdi.IsDel = 0 {0}
  16090. ) temp ", sqlWhere);
  16091. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16092. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16093. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16094. }
  16095. else
  16096. {
  16097. return Ok(JsonView(false, "查询失败"));
  16098. }
  16099. }
  16100. /// <summary>
  16101. /// 团组状态
  16102. /// 设置操作完成
  16103. /// </summary>
  16104. /// <param name="dto">团组列表请求dto</param>
  16105. /// <returns></returns>
  16106. [HttpPost]
  16107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16108. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16109. {
  16110. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16111. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16112. {
  16113. Id = dto.Id,
  16114. IsSure = 1
  16115. };
  16116. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16117. .UpdateColumns(it => new { it.IsSure })
  16118. .WhereColumns(it => new { it.Id })
  16119. .ExecuteCommandAsync();
  16120. if (result > 0)
  16121. {
  16122. return Ok(JsonView(true, "操作完成!"));
  16123. }
  16124. return Ok(JsonView(false, "操作失败!"));
  16125. }
  16126. #endregion
  16127. #region 保险费用录入
  16128. /// <summary>
  16129. /// 根据团组Id查询保险费用列表
  16130. /// </summary>
  16131. /// <param name="dto"></param>
  16132. /// <returns></returns>
  16133. [HttpPost]
  16134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16135. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16136. {
  16137. Result groupData = await _customersRep.CustomersByDiId(dto);
  16138. if (groupData.Code != 0)
  16139. {
  16140. return Ok(JsonView(false, groupData.Msg));
  16141. }
  16142. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16143. }
  16144. /// <summary>
  16145. /// 根据保险费用Id查询保险费用详细
  16146. /// </summary>
  16147. /// <param name="dto"></param>
  16148. /// <returns></returns>
  16149. [HttpPost]
  16150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16151. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16152. {
  16153. try
  16154. {
  16155. Result groupData = await _customersRep.CustomersById(dto);
  16156. if (groupData.Code != 0)
  16157. {
  16158. return Ok(JsonView(false, groupData.Msg));
  16159. }
  16160. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16161. }
  16162. catch (Exception ex)
  16163. {
  16164. return Ok(JsonView(false, ex.Message));
  16165. }
  16166. }
  16167. /// <summary>
  16168. /// 保险费用录入页面初始化绑定
  16169. /// </summary>
  16170. /// <param name="dto"></param>
  16171. /// <returns></returns>
  16172. [HttpPost]
  16173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16174. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16175. {
  16176. try
  16177. {
  16178. Result groupData = await _customersRep.CustomersInitialize(dto);
  16179. if (groupData.Code != 0)
  16180. {
  16181. return Ok(JsonView(false, groupData.Msg));
  16182. }
  16183. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16184. }
  16185. catch (Exception ex)
  16186. {
  16187. return Ok(JsonView(false, ex.Message));
  16188. }
  16189. }
  16190. /// <summary>
  16191. /// 保险费用操作(Status:1.新增,2.修改)
  16192. /// </summary>
  16193. /// <param name="dto"></param>
  16194. /// <returns></returns>
  16195. [HttpPost]
  16196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16197. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16198. {
  16199. Result groupData = await _customersRep.OpCustomers(dto);
  16200. if (groupData.Code != 0)
  16201. {
  16202. return Ok(JsonView(false, groupData.Msg));
  16203. }
  16204. #region 应用推送
  16205. try
  16206. {
  16207. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16208. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16209. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16210. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16211. //自动审核
  16212. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16213. //2024-10-21 新增LZ UID
  16214. var userIds = new List<int>() { 21 };
  16215. string title = $"系统通知";
  16216. var diId = dto.DiId;
  16217. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16218. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16219. string content = "";
  16220. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16221. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16222. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16223. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16224. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16225. }
  16226. catch (Exception ex)
  16227. {
  16228. }
  16229. #endregion
  16230. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16231. }
  16232. /// <summary>
  16233. /// 保险文件上传
  16234. /// </summary>
  16235. /// <param name="file"></param>
  16236. /// <returns></returns>
  16237. [HttpPost]
  16238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16239. public async Task<IActionResult> UploadCus(IFormFile file)
  16240. {
  16241. try
  16242. {
  16243. if (file != null)
  16244. {
  16245. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16246. //文件名称
  16247. string projectFileName = file.FileName;
  16248. //上传的文件的路径
  16249. string filePath = "";
  16250. if (!Directory.Exists(fileDir))
  16251. {
  16252. Directory.CreateDirectory(fileDir);
  16253. }
  16254. //上传的文件的路径
  16255. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16256. using (FileStream fs = System.IO.File.Create(filePath))
  16257. {
  16258. file.CopyTo(fs);
  16259. fs.Flush();
  16260. }
  16261. return Ok(JsonView(true, "上传成功!", projectFileName));
  16262. }
  16263. else
  16264. {
  16265. return Ok(JsonView(false, "上传失败!"));
  16266. }
  16267. }
  16268. catch (Exception ex)
  16269. {
  16270. return Ok(JsonView(false, "程序错误!"));
  16271. throw;
  16272. }
  16273. }
  16274. /// <summary>
  16275. /// 保险删除指定文件
  16276. /// </summary>
  16277. /// <param name="dto"></param>
  16278. /// <returns></returns>
  16279. [HttpPost]
  16280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16281. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16282. {
  16283. try
  16284. {
  16285. string filePath = "";
  16286. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16287. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16288. //int id = 0;
  16289. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16290. // 删除该文件
  16291. try
  16292. {
  16293. System.IO.File.Delete(filePath);
  16294. 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()
  16295. {
  16296. Attachment = "",
  16297. }).ExecuteCommandAsync();
  16298. if (result != 0)
  16299. {
  16300. return Ok(JsonView(true, "成功!"));
  16301. }
  16302. else
  16303. {
  16304. return Ok(JsonView(false, "失败!"));
  16305. }
  16306. }
  16307. catch (Exception)
  16308. {
  16309. 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()
  16310. {
  16311. Attachment = "",
  16312. }).ExecuteCommandAsync();
  16313. if (result != 0)
  16314. {
  16315. return Ok(JsonView(true, "成功!"));
  16316. }
  16317. else
  16318. {
  16319. return Ok(JsonView(false, "失败!"));
  16320. }
  16321. }
  16322. }
  16323. catch (Exception ex)
  16324. {
  16325. return Ok(JsonView(false, "程序错误!"));
  16326. throw;
  16327. }
  16328. }
  16329. /// <summary>
  16330. /// 保险费用操作(删除)
  16331. /// </summary>
  16332. /// <param name="dto"></param>
  16333. /// <returns></returns>
  16334. [HttpPost]
  16335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16336. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16337. {
  16338. try
  16339. {
  16340. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16341. if (!res)
  16342. {
  16343. return Ok(JsonView(false, "删除失败"));
  16344. }
  16345. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16346. {
  16347. IsDel = 1,
  16348. DeleteUserId = dto.DeleteUserId,
  16349. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16350. }).ExecuteCommandAsync();
  16351. return Ok(JsonView(true, "删除成功!"));
  16352. }
  16353. catch (Exception ex)
  16354. {
  16355. return Ok(JsonView(false, "程序错误!"));
  16356. throw;
  16357. }
  16358. }
  16359. #endregion
  16360. #region 接团客户名单 PageId 104
  16361. /// <summary>
  16362. /// 接团客户名单
  16363. /// 迁移数据(慎用!)
  16364. /// </summary>
  16365. /// <returns></returns>
  16366. [HttpPost]
  16367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16368. public async Task<IActionResult> PostTourClientListChange()
  16369. {
  16370. try
  16371. {
  16372. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16373. //var groupClinetData1
  16374. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16375. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16376. int updateCount = 0;
  16377. if (oldOAClientList.Count > 0)
  16378. {
  16379. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16380. _sqlSugar.BeginTran();
  16381. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16382. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16383. foreach (var item in oldOAClientList)
  16384. {
  16385. int comId = 0;
  16386. string format = "yyyy-MM-dd HH:mm:ss";
  16387. string data11 = "1990-01-01 00:00";
  16388. var data1 = IsValidDate(item.OPdate, format);
  16389. if (data1) data11 = item.OPdate;
  16390. //客户公司验证
  16391. if (!string.IsNullOrEmpty(item.Company))
  16392. {
  16393. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16394. if (clientComInfo == null) // add
  16395. {
  16396. var addInfo = new Crm_CustomerCompany()
  16397. {
  16398. CompanyAbbreviation = "",
  16399. CompanyFullName = item.Company,
  16400. Address = "",
  16401. PostCodes = "",
  16402. LastedOpUserId = item.OPer,
  16403. LastedOpDt = Convert.ToDateTime(data11),
  16404. CreateUserId = item.OPer,
  16405. CreateTime = Convert.ToDateTime(data11),
  16406. IsDel = 0
  16407. };
  16408. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16409. if (comId1 > 0) comId = comId1;
  16410. }
  16411. else comId = clientComInfo.Id;
  16412. }
  16413. //客户人员验证
  16414. int clientId = 0;
  16415. string name = item.LastName + item.Name;
  16416. if (!string.IsNullOrEmpty(name))
  16417. {
  16418. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16419. if (clientInfo == null)
  16420. {
  16421. DateTime? dateTime = null;
  16422. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16423. if (isDt) dateTime = birthDayDt;
  16424. var addInfo1 = new Crm_DeleClient()
  16425. {
  16426. CrmCompanyId = comId,
  16427. DiId = -1,
  16428. LastName = item.LastName,
  16429. FirstName = item.Name,
  16430. OldName = "",
  16431. Pinyin = item.Pinyin,
  16432. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16433. Marriage = 0,
  16434. Phone = item.Phone,
  16435. Job = item.Job,
  16436. BirthDay = dateTime
  16437. };
  16438. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16439. if (clientId1 > 0) clientId = clientId1;
  16440. }
  16441. else clientId = clientInfo.Id;
  16442. }
  16443. if (clientId < 1)
  16444. {
  16445. continue;
  16446. }
  16447. int airType = 0;
  16448. if (item.AirType == "超经舱") airType = 459;
  16449. else if (item.AirType == "公务舱") airType = 458;
  16450. else if (item.AirType == "经济舱") airType = 460;
  16451. else if (item.AirType == "其他") airType = 565;
  16452. else if (item.AirType == "头等舱") airType = 457;
  16453. var _TourClientListEntity = new Grp_TourClientList()
  16454. {
  16455. DiId = item.Diid,
  16456. ClientId = clientId,
  16457. CreateUserId = item.OPer,
  16458. CreateTime = Convert.ToDateTime(data11),
  16459. Remark = item.Remark,
  16460. IsDel = item.Isdel,
  16461. ShippingSpaceTypeId = airType,
  16462. ShippingSpaceSpecialNeeds = item.AirRemark,
  16463. HotelSpecialNeeds = item.RoomType
  16464. };
  16465. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16466. if (_TourClientList > 0)
  16467. {
  16468. updateCount++;
  16469. }
  16470. }
  16471. _sqlSugar.CommitTran();
  16472. }
  16473. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16474. }
  16475. catch (Exception ex)
  16476. {
  16477. _sqlSugar.RollbackTran();
  16478. return Ok(JsonView(false, ex.Message));
  16479. }
  16480. //return Ok(JsonView(true));
  16481. }
  16482. private bool IsValidDate(string dateString, string format)
  16483. {
  16484. DateTime dateValue;
  16485. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16486. return valid;
  16487. }
  16488. /// <summary>
  16489. /// 接团客户名单
  16490. /// 根据团组Id查询List
  16491. /// </summary>
  16492. /// <param name="_dto"></param>
  16493. /// <returns></returns>
  16494. [HttpPost]
  16495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16496. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16497. {
  16498. #region 参数验证
  16499. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16500. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16501. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16502. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16503. #region 页面操作权限验证
  16504. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16505. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16506. #endregion
  16507. #endregion
  16508. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16509. if (viewData.Code != 0)
  16510. {
  16511. return Ok(JsonView(false, viewData.Msg));
  16512. }
  16513. return Ok(JsonView(viewData.Data));
  16514. }
  16515. /// <summary>
  16516. /// 接团客户名单
  16517. /// 基础数据 Init
  16518. /// </summary>
  16519. /// <param name="_dto"></param>
  16520. /// <returns></returns>
  16521. [HttpPost]
  16522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16523. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16524. {
  16525. #region 参数验证
  16526. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16527. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16528. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16529. #region 页面操作权限验证
  16530. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16531. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16532. #endregion
  16533. #endregion
  16534. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16535. }
  16536. /// <summary>
  16537. /// 接团客户名单
  16538. /// 根据 Id查询 Details
  16539. /// </summary>
  16540. /// <param name="_dto"></param>
  16541. /// <returns></returns>
  16542. [HttpPost]
  16543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16544. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16545. {
  16546. #region 参数验证
  16547. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16548. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16549. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16550. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16551. #region 页面操作权限验证
  16552. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16553. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16554. #endregion
  16555. #endregion
  16556. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16557. if (viewData.Code != 0)
  16558. {
  16559. return Ok(JsonView(false, viewData.Msg));
  16560. }
  16561. return Ok(JsonView(viewData.Data));
  16562. }
  16563. /// <summary>
  16564. /// 接团客户名单
  16565. /// Add Or Edit
  16566. /// </summary>
  16567. /// <param name="_dto"></param>
  16568. /// <returns></returns>
  16569. [HttpPost]
  16570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16571. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16572. {
  16573. #region 参数验证
  16574. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16575. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16576. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16577. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16578. #region 页面操作权限验证
  16579. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16580. if (_dto.Id == 0) //添加
  16581. {
  16582. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16583. }
  16584. else if (_dto.Id >= 0) //修改
  16585. {
  16586. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16587. }
  16588. #endregion
  16589. #endregion
  16590. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16591. if (viewData.Code != 0)
  16592. {
  16593. return Ok(JsonView(false, viewData.Msg));
  16594. }
  16595. return Ok(JsonView(true));
  16596. }
  16597. /// <summary>
  16598. /// 接团客户名单
  16599. /// json字符串 AddMultiple(添加多个)
  16600. /// </summary>
  16601. /// <param name="_dto"></param>
  16602. /// <returns></returns>
  16603. [HttpPost]
  16604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16605. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16606. {
  16607. #region 参数验证
  16608. string jsonLabel = _dto.JsonLabel;
  16609. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16610. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16611. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16612. #region 页面操作权限验证
  16613. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16614. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16615. #endregion
  16616. #endregion
  16617. var request = new TourClientListAddMultipleDto();
  16618. request.DiId = _dto.DiId;
  16619. request.UserId = _dto.UserId;
  16620. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16621. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16622. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16623. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16624. var infos = new List<TourClientListInfo>();
  16625. foreach (var data in datas)
  16626. {
  16627. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16628. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16629. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16630. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16631. {
  16632. continue;
  16633. }
  16634. infos.Add(new TourClientListInfo()
  16635. {
  16636. IsAccompany = 1,
  16637. LastName = lastName,
  16638. FirstName = firstName,
  16639. Pinyin = lastNameEn + @"/" + firstNameEn,
  16640. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16641. CompanyFullName = data.CompanyFullName,
  16642. Job = data.Job
  16643. });
  16644. }
  16645. if (infos.Any())
  16646. {
  16647. var viewData = await _tourClientListRep._AddMultiple(request);
  16648. if (viewData.Code != 0)
  16649. {
  16650. return Ok(JsonView(false, viewData.Msg));
  16651. }
  16652. return Ok(JsonView(true));
  16653. }
  16654. return Ok(JsonView(false));
  16655. }
  16656. /// <summary>
  16657. /// 接团客户名单
  16658. /// AddMultiple(添加多个)
  16659. /// </summary>
  16660. /// <param name="_dto"></param>
  16661. /// <returns></returns>
  16662. [HttpPost]
  16663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16664. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16665. {
  16666. #region 参数验证
  16667. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16668. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16669. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16670. #region 页面操作权限验证
  16671. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16672. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16673. #endregion
  16674. #endregion
  16675. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16676. if (viewData.Code != 0)
  16677. {
  16678. return Ok(JsonView(false, viewData.Msg));
  16679. }
  16680. return Ok(JsonView(true));
  16681. }
  16682. /// <summary>
  16683. /// 接团客户名单
  16684. /// Del
  16685. /// </summary>
  16686. /// <param name="_dto"></param>
  16687. /// <returns></returns>
  16688. [HttpPost]
  16689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16690. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16691. {
  16692. #region 参数验证
  16693. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16694. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16695. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16696. #region 页面操作权限验证
  16697. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16698. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16699. #endregion
  16700. #endregion
  16701. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16702. if (viewData.Code != 0)
  16703. {
  16704. return Ok(JsonView(false, viewData.Msg));
  16705. }
  16706. return Ok(JsonView(true));
  16707. }
  16708. /// <summary>
  16709. /// 接团客户名单
  16710. /// 文件下载 客户名单
  16711. /// </summary>
  16712. /// <param name="_dto"></param>
  16713. /// <returns></returns>
  16714. [HttpPost]
  16715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16716. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16717. {
  16718. #region 参数验证
  16719. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16720. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16721. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16722. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16723. #region 页面操作权限验证
  16724. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16725. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16726. #endregion
  16727. #endregion
  16728. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16729. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16730. From Grp_TourClientList tcl
  16731. Left Join
  16732. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16733. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16734. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16735. From Crm_DeleClient dc
  16736. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16737. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16738. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16739. Where dc.IsDel = 0) temp
  16740. On temp.DcId =tcl.ClientId
  16741. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16742. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16743. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16744. //载入模板
  16745. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16746. if (_dto.Language == 1)
  16747. {
  16748. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16749. }
  16750. //载入模板
  16751. var doc = new Document(tempPath);
  16752. DocumentBuilder builder = new DocumentBuilder(doc);
  16753. //获取word里所有表格
  16754. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16755. //获取所填表格的序数
  16756. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16757. var rowStart = tableOne.Rows[0]; //获取第1行
  16758. if (_dto.Language == 0)
  16759. {
  16760. //循环赋值
  16761. for (int i = 0; i < DcList.Count; i++)
  16762. {
  16763. EncryptionProcessor.DecryptProperties(DcList[i]);
  16764. builder.MoveToCell(0, i + 1, 0, 0);
  16765. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16766. builder.MoveToCell(0, i + 1, 1, 0);
  16767. int sex = DcList[i].Sex;
  16768. string sexStr = string.Empty;
  16769. if (sex == 0) sexStr = "男";
  16770. else if (sex == 1) sexStr = "女";
  16771. else sexStr = "未设置";
  16772. builder.Write(sexStr);
  16773. builder.MoveToCell(0, i + 1, 2, 0);
  16774. string birthDay = DcList[i].BirthDay;
  16775. string birthDayStr = string.Empty;
  16776. if (!string.IsNullOrEmpty(birthDay))
  16777. {
  16778. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16779. }
  16780. builder.Write(birthDayStr);
  16781. builder.MoveToCell(0, i + 1, 3, 0);
  16782. string company = "";
  16783. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16784. {
  16785. company = DcList[i].CompanyFullName.ToString();
  16786. }
  16787. builder.Write(company);
  16788. builder.MoveToCell(0, i + 1, 4, 0);
  16789. builder.Write(DcList[i].Job);
  16790. }
  16791. }
  16792. else if (_dto.Language == 1)
  16793. {
  16794. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16795. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16796. List<string> transArrayStr = new List<string>();
  16797. string transStrRes1 = "";
  16798. for (int i = 0; i < DcList.Count; i++)
  16799. {
  16800. var dc = DcList[i];
  16801. EncryptionProcessor.DecryptProperties(dc);
  16802. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16803. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16804. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16805. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16806. else transStrRes1 += $"{str1}|";
  16807. }
  16808. //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";
  16809. string transStrRes = "";
  16810. if (transStrRes1.Length > 0)
  16811. {
  16812. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16813. }
  16814. //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
  16815. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16816. //List<string> transArray = new List<string> { };
  16817. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16818. if (transStrRes.Contains("|"))
  16819. {
  16820. string[] transArray1 = transStrRes.Split('|');
  16821. if (transArray1.Length > 0)
  16822. {
  16823. foreach (var item in transArray1)
  16824. {
  16825. if (item.Contains("&"))
  16826. {
  16827. string[] transArray2 = item.Split('&');
  16828. int index = 0;
  16829. string companyName = "", job = "";
  16830. if (transArray2.Length > 0)
  16831. {
  16832. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16833. if (1 < transArray2.Length) companyName = transArray2[1];
  16834. if (2 < transArray2.Length) job = transArray2[2];
  16835. }
  16836. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16837. }
  16838. }
  16839. }
  16840. }
  16841. //循环赋值
  16842. for (int i = 0; i < DcList.Count; i++)
  16843. {
  16844. string PYName = "";
  16845. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16846. {
  16847. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16848. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16849. PYName = PY_First + " " + PY_Last;
  16850. }
  16851. else
  16852. {
  16853. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16854. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16855. PYName = PY_First + " " + PY_Last;
  16856. }
  16857. builder.MoveToCell(0, i + 1, 0, 0);
  16858. builder.Write(PYName);
  16859. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16860. builder.MoveToCell(0, i + 1, 1, 0);
  16861. builder.Write(sex);
  16862. DateTime birthDt;
  16863. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16864. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16865. builder.MoveToCell(0, i + 1, 2, 0);
  16866. builder.Write(birthday);
  16867. string company = string.Empty, job = string.Empty;
  16868. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16869. if (dcTransInfo != null)
  16870. {
  16871. company = dcTransInfo.CompanyName;
  16872. job = dcTransInfo.Job;
  16873. }
  16874. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16875. {
  16876. //查询对照表
  16877. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16878. if (tempCec != null)
  16879. {
  16880. company = tempCec.enName;
  16881. }
  16882. //翻译
  16883. else
  16884. {
  16885. }
  16886. }
  16887. builder.MoveToCell(0, i + 1, 3, 0);
  16888. builder.Write(company);
  16889. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16890. {
  16891. //查询对照表
  16892. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16893. if (tempPec != null)
  16894. {
  16895. job = tempPec.enName;
  16896. }
  16897. //翻译
  16898. else
  16899. {
  16900. }
  16901. }
  16902. builder.MoveToCell(0, i + 1, 4, 0);
  16903. builder.Write(job);
  16904. }
  16905. }
  16906. //删除多余行
  16907. while (tableOne.Rows.Count > DcList.Count + 1)
  16908. {
  16909. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16910. }
  16911. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16912. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16913. doc.Save(fileDir);
  16914. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16915. return Ok(JsonView(true, "操作成功!", Url));
  16916. }
  16917. private class TranslateInfo
  16918. {
  16919. public int Index { get; set; }
  16920. public string CompanyName { get; set; }
  16921. public string Job { get; set; }
  16922. }
  16923. #endregion
  16924. #region 团组倒推表
  16925. /// <summary>
  16926. /// 倒推表基础数据
  16927. /// Init
  16928. /// </summary>
  16929. /// <returns></returns>
  16930. [HttpPost]
  16931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16932. public async Task<IActionResult> PostInvertedListInit()
  16933. {
  16934. var viewData = await _invertedListRep._Init();
  16935. if (viewData.Code != 0)
  16936. {
  16937. return Ok(JsonView(false, viewData.Msg));
  16938. }
  16939. return Ok(JsonView(viewData.Data));
  16940. }
  16941. /// <summary>
  16942. /// 倒推表
  16943. /// Info
  16944. /// </summary>
  16945. /// <param name="dto"></param>
  16946. /// <returns></returns>
  16947. [HttpPost]
  16948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16949. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16950. {
  16951. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16952. if (viewData.Code != 0)
  16953. {
  16954. return Ok(JsonView(false, viewData.Msg));
  16955. }
  16956. return Ok(JsonView(viewData.Data));
  16957. }
  16958. /// <summary>
  16959. /// 倒推表
  16960. /// Create
  16961. /// </summary>
  16962. /// <param name="dto"></param>
  16963. /// <returns></returns>
  16964. [HttpPost]
  16965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16966. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16967. {
  16968. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16969. if (viewData.Code != 0)
  16970. {
  16971. return Ok(JsonView(false, viewData.Msg));
  16972. }
  16973. return Ok(JsonView(viewData.Data));
  16974. }
  16975. /// <summary>
  16976. /// 倒推表
  16977. /// Update
  16978. /// </summary>
  16979. /// <param name="dto"></param>
  16980. /// <returns></returns>
  16981. [HttpPost]
  16982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16983. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16984. {
  16985. var viewData = await _invertedListRep._Update(dto);
  16986. if (viewData.Code != 0)
  16987. {
  16988. return Ok(JsonView(false, viewData.Msg));
  16989. }
  16990. return Ok(JsonView(viewData.Data));
  16991. }
  16992. /// <summary>
  16993. /// 倒推表
  16994. /// File Download
  16995. /// </summary>
  16996. /// <param name="dto"></param>
  16997. /// <returns></returns>
  16998. [HttpPost]
  16999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17000. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17001. {
  17002. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17003. if (info2.Code != 0)
  17004. {
  17005. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17006. }
  17007. var info1 = info2.Data as InvertedListInfoView;
  17008. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17009. string teamName = "";
  17010. if (info != null) teamName = info.TeamName;
  17011. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17012. var doc = new Document();
  17013. var builder = new DocumentBuilder(doc);
  17014. #region old insert
  17015. ////载入模板
  17016. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17017. //Document doc = new Document(tempPath);
  17018. //DocumentBuilder builder = new DocumentBuilder(doc);
  17019. //利用键值对存放数据
  17020. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17021. //dic.Add("TeamName", teamName);
  17022. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17023. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17024. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17025. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17026. //dic.Add("SQRemark", info1.ApprovalRemark);
  17027. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17028. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17029. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17030. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17031. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17032. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17033. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17034. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17035. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17036. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17037. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17038. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17039. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17040. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17041. //#region 填充word模板书签内容
  17042. //foreach (var key in dic.Keys)
  17043. //{
  17044. // builder.MoveToBookmark(key);
  17045. // builder.Write(dic[key]);
  17046. //}
  17047. //#endregion
  17048. #endregion
  17049. #region New Insert
  17050. string titleFont = $"仿宋",
  17051. contentFont = $"仿宋";
  17052. var fontColor = Color.FromArgb(64, 64, 64);
  17053. //设置标题 团组名称
  17054. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17055. builder.Font.Name = titleFont;
  17056. builder.Font.Color = fontColor;
  17057. builder.Font.Size = 12;
  17058. builder.Font.Bold = true;
  17059. builder.Writeln(teamName);
  17060. //设置副标题 团组出访时间
  17061. builder.Font.Size = 12;
  17062. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17063. builder.Writeln();
  17064. var backgroundColor = Color.FromArgb(199, 199, 199);
  17065. var table = builder.StartTable();
  17066. builder.InsertCell();
  17067. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17068. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17069. builder.CellFormat.Borders.LineWidth = 1;
  17070. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17071. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17072. builder.RowFormat.Height = 40;
  17073. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17074. builder.Font.Name = contentFont;
  17075. builder.Font.Size = 12;
  17076. builder.Font.Bold = true;
  17077. builder.Font.Color = fontColor;
  17078. builder.Write("时间");
  17079. builder.InsertCell();
  17080. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17081. builder.Write("流程");
  17082. builder.InsertCell();
  17083. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17084. builder.Write("说明");
  17085. builder.EndRow();
  17086. //报批资料准备
  17087. if (info1.IsSelectedAirportd)
  17088. {
  17089. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17090. }
  17091. //报批/提供送签资料
  17092. if (info1.IsSelectedApprovalData)
  17093. {
  17094. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17095. }
  17096. //出批件护照办理
  17097. if (info1.IsSelectedIssueApproval)
  17098. {
  17099. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17100. }
  17101. //签证资料准备
  17102. if (info1.IsSelectedVisaInfo)
  17103. {
  17104. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17105. }
  17106. //送签
  17107. if (info1.IsSelectedSendVisa)
  17108. {
  17109. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17110. }
  17111. //出签
  17112. if (info1.IsSelectedIssueVisa)
  17113. {
  17114. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17115. }
  17116. //机票
  17117. if (info1.IsSelectedAirTicket)
  17118. {
  17119. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17120. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17121. }
  17122. //酒店
  17123. if (info1.IsSelectedHotel)
  17124. {
  17125. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17126. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17127. }
  17128. //开行前会
  17129. if (info1.IsSelectedPreTripMeeting)
  17130. {
  17131. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17132. }
  17133. //送机
  17134. if (info1.IsSelectedAirportdDropOff)
  17135. {
  17136. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17137. }
  17138. builder.EndTable();
  17139. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17140. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17141. for (int i = 0; i < table.Rows.Count; i++)
  17142. {
  17143. var row = table.Rows[i];
  17144. //设置宽度
  17145. row.Cells[0].CellFormat.Width = 20.00;
  17146. row.Cells[1].CellFormat.Width = 30.00;
  17147. row.Cells[2].CellFormat.Width = 50.00;
  17148. if (i != 0)
  17149. {
  17150. //边框设置
  17151. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17152. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17153. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17154. }
  17155. }
  17156. #region 页脚插入图片
  17157. // 创建页脚
  17158. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17159. doc.FirstSection.HeadersFooters.Add(footer);
  17160. Paragraph para = new Paragraph(doc);
  17161. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17162. footer.AppendChild(para);
  17163. builder.MoveTo(para);
  17164. string imagePath = "./Images/FMGJ_Log.png";
  17165. builder.InsertImage(imagePath);
  17166. #endregion
  17167. #endregion
  17168. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17169. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17170. string filePath = fileDir + $@"InvertedList/{fileName}";
  17171. doc.Save(filePath);
  17172. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17173. return Ok(JsonView(true, "操作成功!", Url));
  17174. }
  17175. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  17176. {
  17177. var fontColor = Color.FromArgb(64, 64, 64);
  17178. builder.InsertCell();
  17179. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17180. builder.RowFormat.Height = 40;
  17181. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17182. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17183. builder.Font.Name = fontName;
  17184. builder.Font.Size = 8;
  17185. builder.Font.Bold = true;
  17186. builder.Font.Color = fontColor;
  17187. builder.Write(dateTime);
  17188. builder.InsertCell();
  17189. builder.Font.Size = 9;
  17190. builder.Font.Bold = true;
  17191. builder.Font.Color = fontColor;
  17192. builder.Write(content);
  17193. builder.InsertCell();
  17194. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17195. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17196. builder.Font.Size = 9;
  17197. builder.Font.Bold = false;
  17198. builder.Font.Color = fontColor;
  17199. builder.Write(reamrk);
  17200. builder.EndRow();
  17201. }
  17202. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  17203. {
  17204. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17205. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17206. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17207. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17208. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17209. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17210. }
  17211. #endregion
  17212. #region 会务倒推表
  17213. /// <summary>
  17214. /// 会务倒推表
  17215. /// Init
  17216. /// </summary>
  17217. /// <returns></returns>
  17218. [HttpPost]
  17219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17220. public async Task<IActionResult> InforRetrogressTableInit()
  17221. {
  17222. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17223. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17224. return Ok(JsonView(false, groupData.Msg));
  17225. }
  17226. /// <summary>
  17227. /// 会务倒推表
  17228. /// ExcelDownload
  17229. /// </summary>
  17230. /// <param name="dto"></param>
  17231. /// <returns></returns>
  17232. [HttpPost]
  17233. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17235. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17236. {
  17237. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17238. var validatorRes = await validator.ValidateAsync(dto);
  17239. if (!validatorRes.IsValid)
  17240. {
  17241. StringBuilder sb = new StringBuilder();
  17242. foreach (var item in validatorRes.Errors)
  17243. {
  17244. sb.AppendLine(item.ErrorMessage);
  17245. }
  17246. return Ok(JsonView(false, sb.ToString()));
  17247. }
  17248. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17249. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17250. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17251. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17252. #region Excel
  17253. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17254. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17255. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17256. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17257. var fileNamePrefix = string.Empty;
  17258. if (days >= 30)
  17259. {
  17260. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17261. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17262. }
  17263. else if (days < 30 && days > 7)
  17264. {
  17265. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17266. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17267. }
  17268. else if (days <= 7)
  17269. {
  17270. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17271. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17272. }
  17273. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17274. fileName = CommonFun.ValidFileName(fileName);
  17275. //载入模板
  17276. WorkbookDesigner designer = new WorkbookDesigner();
  17277. designer.Workbook = new Workbook(tempPath);
  17278. designer.Process();
  17279. if (!Directory.Exists(savePath))
  17280. {
  17281. Directory.CreateDirectory(savePath);
  17282. }
  17283. string serverPath = $"{savePath}{fileName}";
  17284. designer.Workbook.Save(serverPath);
  17285. string rst = $"{servicePath}{ftpPath}{fileName}";
  17286. #endregion
  17287. return Ok(JsonView(new { url = rst }));
  17288. }
  17289. #endregion
  17290. #region 三公签证费用(签证费、代办费)
  17291. /// <summary>
  17292. /// 三公签证费用(签证费、代办费)
  17293. /// List
  17294. /// </summary>
  17295. /// <returns></returns>
  17296. [HttpPost]
  17297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17298. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17299. {
  17300. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17301. if (_view.Code != 0)
  17302. {
  17303. return Ok(JsonView(false, _view.Msg));
  17304. }
  17305. return Ok(JsonView(true, "操作成功!", _view.Data));
  17306. }
  17307. /// <summary>
  17308. /// 三公签证费用(签证费、代办费)
  17309. /// Add Or Update
  17310. /// </summary>
  17311. /// <returns></returns>
  17312. [HttpPost]
  17313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17314. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17315. {
  17316. var _view = await _visaFeeInfoRep._Update(_dto);
  17317. if (_view.Code != 0)
  17318. {
  17319. return Ok(JsonView(false, _view.Msg));
  17320. }
  17321. return Ok(JsonView(true, _view.Msg));
  17322. }
  17323. #endregion
  17324. #region 酒店询价
  17325. /// <summary>
  17326. /// 酒店询价
  17327. /// Init
  17328. /// </summary>
  17329. /// <returns></returns>
  17330. [HttpPost]
  17331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17332. public async Task<IActionResult> PostHotelInquiryInit()
  17333. {
  17334. var res = await _hotelInquiryRep._Init();
  17335. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17336. return Ok(JsonView(true, res.Msg, res.Data));
  17337. }
  17338. /// <summary>
  17339. /// 酒店询价
  17340. /// page Item
  17341. /// </summary>
  17342. /// <param name="_dto"></param>
  17343. /// <returns></returns>
  17344. [HttpPost]
  17345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17346. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17347. {
  17348. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17349. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17350. var view = res.Data as PageDataViewBase;
  17351. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17352. }
  17353. /// <summary>
  17354. /// 酒店询价
  17355. /// info
  17356. /// </summary>
  17357. /// <param name="_dto"></param>
  17358. /// <returns></returns>
  17359. [HttpPost]
  17360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17361. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17362. {
  17363. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17364. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17365. return Ok(JsonView(true, res.Msg, res.Data));
  17366. }
  17367. /// <summary>
  17368. /// 酒店询价
  17369. /// Add Or Edit
  17370. /// </summary>
  17371. /// <param name="_dto"></param>
  17372. /// <returns></returns>
  17373. [HttpPost]
  17374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17375. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17376. {
  17377. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17378. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17379. return Ok(JsonView(true, res.Msg, res.Data));
  17380. }
  17381. /// <summary>
  17382. /// 酒店询价
  17383. /// Del
  17384. /// </summary>
  17385. /// <param name="_dto"></param>
  17386. /// <returns></returns>
  17387. [HttpPost]
  17388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17389. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17390. {
  17391. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17392. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17393. return Ok(JsonView(true, res.Msg, res.Data));
  17394. }
  17395. #endregion
  17396. #region 下载匹配op行程单
  17397. /// <summary>
  17398. /// 匹配op行程单
  17399. /// Init
  17400. /// </summary>
  17401. /// <param name="dto">团组列表请求dto</param>
  17402. /// <returns></returns>
  17403. [HttpPost]
  17404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17405. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17406. {
  17407. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17408. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17409. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17410. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17411. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17412. .Where(it => it.IsDel == 0)
  17413. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17414. .OrderByDescending(it => it.VisitStartDate)
  17415. .ToList();
  17416. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17417. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17418. var diids = groupInfos.Select(it => it.Id).ToList();
  17419. List<string> countrys = new List<string>();
  17420. foreach (var item in country)
  17421. {
  17422. var data = _groupRepository.FormartTeamName(item);
  17423. var dataArray = _groupRepository.GroupSplitCountry(data);
  17424. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17425. }
  17426. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17427. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17428. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17429. foreach (var item in areaItem)
  17430. {
  17431. string areaStr = item.Value;
  17432. if (!string.IsNullOrEmpty(areaStr))
  17433. {
  17434. string[] str1 = areaStr.Split("-");
  17435. if (str1.Length > 0)
  17436. {
  17437. areaArray.AddRange(str1);
  17438. }
  17439. }
  17440. }
  17441. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17442. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17443. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17444. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17445. .ToList();
  17446. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17447. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17448. .Where(it => countriesIds.Contains(it.Id))
  17449. .Select(it => new { it.Id, Name = it.Name_CN })
  17450. .ToList();
  17451. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17452. .Select(it => it.TeamName).ToList();
  17453. stopwatch.Stop();
  17454. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17455. }
  17456. ///// <summary>
  17457. ///// 匹配op行程单
  17458. ///// Init 查询区域数据
  17459. ///// </summary>
  17460. ///// <param name="dto">团组列表请求dto</param>
  17461. ///// <returns></returns>
  17462. //[HttpPost]
  17463. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17464. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17465. //{
  17466. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17467. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17468. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17469. // if (string.IsNullOrEmpty(countriesDataStr))
  17470. // {
  17471. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17472. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17473. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17474. // }
  17475. // else
  17476. // {
  17477. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17478. // }
  17479. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17480. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17481. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17482. // List<dynamic> childList = new List<dynamic>();
  17483. // int parentId = dto.CountriesId;
  17484. // if (provinceData.Count > 1)
  17485. // {
  17486. // foreach (var item1 in provinceData)
  17487. // {
  17488. // List<dynamic> childList1 = new List<dynamic>();
  17489. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17490. // foreach (var item2 in citiesData1)
  17491. // {
  17492. // List<dynamic> childList2 = new List<dynamic>();
  17493. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17494. // foreach (var item3 in countiesData1)
  17495. // {
  17496. // childList2.Add(new
  17497. // {
  17498. // id = item3.Id,
  17499. // parentId = item2.Id,
  17500. // level = "district",
  17501. // name = item3.Name_CN,
  17502. // });
  17503. // }
  17504. // childList1.Add(new
  17505. // {
  17506. // id = item2.Id,
  17507. // parentId = item1.Id,
  17508. // level = "city",
  17509. // name = item2.Name_CN,
  17510. // childList = childList2
  17511. // });
  17512. // }
  17513. // childList.Add(new
  17514. // {
  17515. // id = item1.Id,
  17516. // parentId = parentId,
  17517. // level = "province",
  17518. // name = item1.Name_CN,
  17519. // childList = childList1
  17520. // });
  17521. // }
  17522. // //城市
  17523. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17524. // foreach (var item2 in citiesData2)
  17525. // {
  17526. // List<dynamic> childList22 = new List<dynamic>();
  17527. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17528. // foreach (var item3 in countiesData1)
  17529. // {
  17530. // childList22.Add(new
  17531. // {
  17532. // id = item3.Id,
  17533. // parentId = item2.Id,
  17534. // level = "district",
  17535. // name = item3.Name_CN,
  17536. // });
  17537. // }
  17538. // childList.Add(new
  17539. // {
  17540. // id = item2.Id,
  17541. // parentId = parentId,
  17542. // level = "city",
  17543. // name = item2.Name_CN,
  17544. // childList = childList22
  17545. // });
  17546. // }
  17547. // }
  17548. // else
  17549. // {
  17550. // foreach (var item2 in citiesData)
  17551. // {
  17552. // string cname = item2.Name_CN;
  17553. // List<dynamic> childList1 = new List<dynamic>();
  17554. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17555. // foreach (var item3 in countiesData1)
  17556. // {
  17557. // childList1.Add(new
  17558. // {
  17559. // Id = item3.Id,
  17560. // parentId = item2.Id,
  17561. // level = "district",
  17562. // name = item3.Name_CN
  17563. // });
  17564. // }
  17565. // childList.Add(new
  17566. // {
  17567. // id = item2.Id,
  17568. // parentId = parentId,
  17569. // level = "city",
  17570. // name = item2.Name_CN,
  17571. // childList = childList1
  17572. // });
  17573. // }
  17574. // }
  17575. // stopwatch.Stop();
  17576. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17577. //}
  17578. /// <summary>
  17579. /// 匹配op行程单
  17580. /// 接团信息列表 Page
  17581. /// </summary>
  17582. /// <param name="dto">团组列表请求dto</param>
  17583. /// <returns></returns>
  17584. [HttpPost]
  17585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17586. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17587. {
  17588. var swatch = new Stopwatch();
  17589. swatch.Start();
  17590. #region 参数验证
  17591. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17592. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17593. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17594. #region 页面操作权限验证
  17595. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17596. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17597. #endregion
  17598. #endregion
  17599. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17600. {
  17601. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17602. //string sqlWhere = "";
  17603. if (!string.IsNullOrEmpty(dto.Country))
  17604. {
  17605. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17606. }
  17607. if (!string.IsNullOrEmpty(dto.Area))
  17608. {
  17609. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17610. }
  17611. if (!string.IsNullOrEmpty(dto.TeamName))
  17612. {
  17613. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17614. }
  17615. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17616. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17617. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17618. swatch.Stop();
  17619. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17620. }
  17621. else
  17622. {
  17623. return Ok(JsonView(false, "查询失败"));
  17624. }
  17625. }
  17626. /// <summary>
  17627. /// 匹配op行程单
  17628. /// 行程单下载
  17629. /// </summary>
  17630. /// <param name="dto">团组列表请求dto</param>
  17631. /// <returns></returns>
  17632. [HttpPost]
  17633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17634. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17635. {
  17636. #region 参数验证
  17637. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17638. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17639. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17640. #region 页面操作权限验证
  17641. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17642. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17643. #endregion
  17644. #endregion
  17645. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17646. {
  17647. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17648. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17649. }
  17650. else
  17651. {
  17652. return Ok(JsonView(false, "下载失败!"));
  17653. }
  17654. }
  17655. #endregion
  17656. #region 国家信息 数据 注释
  17657. //[HttpPost]
  17658. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17659. //{
  17660. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17661. // foreach (var item in dto)
  17662. // {
  17663. // infos.Add(new Grp_GroupsTaskAssignment()
  17664. // {
  17665. // DIId = item,
  17666. // CTId = 82,
  17667. // UId = 248,
  17668. // IsEnable = 1,
  17669. // CreateUserId = 233,
  17670. // CreateTime = DateTime.Now,
  17671. // IsDel = 0
  17672. // });
  17673. // infos.Add(new Grp_GroupsTaskAssignment()
  17674. // {
  17675. // DIId = item,
  17676. // CTId = 82,
  17677. // UId = 286,
  17678. // IsEnable = 1,
  17679. // CreateUserId = 233,
  17680. // CreateTime = DateTime.Now,
  17681. // IsDel = 0
  17682. // });
  17683. // }
  17684. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17685. // return Ok("操作成功");
  17686. //}
  17687. //public class paramJsonDto
  17688. //{
  17689. // public List<CountriesInfo> str { get; set; }
  17690. //}
  17691. //[HttpPost]
  17692. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17693. //{
  17694. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17695. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17696. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17697. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17698. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17699. // _sqlSugar.BeginTran();
  17700. // int countitiesIndex = 0;
  17701. // foreach (var item in dto.str)
  17702. // {
  17703. // dynamic data = item.c;
  17704. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17705. // if (data != null)
  17706. // {
  17707. // countitiesIndex++;
  17708. // foreach (var item1 in data)
  17709. // {
  17710. // string cnname = item1.cn;
  17711. // string enname = item1.en;
  17712. // Sys_Cities provinceInfo = new Sys_Cities()
  17713. // {
  17714. // CountriesId = countriesId,
  17715. // Name_CN = cnname,
  17716. // Name_EN = enname,
  17717. // ParentId = 0,
  17718. // IsCapital = 1,
  17719. // CreateUserId = 208,
  17720. // CreateTime = DateTime.Now,
  17721. // IsDel = 0
  17722. // };
  17723. // if (item1.lv == "province") //省份
  17724. // {
  17725. // provinceInfo.Level = 1;
  17726. // int provinceId = 0;
  17727. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17728. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17729. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17730. // var data1 = item1.c;
  17731. // foreach (var item2 in data1)
  17732. // {
  17733. // if (item2.lv == "city")
  17734. // {
  17735. // string citycnname = item2.cn;
  17736. // string cityenname = item2.en;
  17737. // Sys_Cities cityInfo = new Sys_Cities()
  17738. // {
  17739. // CountriesId = countriesId,
  17740. // ParentId = provinceId,
  17741. // Level = 2,
  17742. // Name_CN = citycnname,
  17743. // Name_EN = cityenname,
  17744. // IsCapital = 1,
  17745. // CreateUserId = 208,
  17746. // CreateTime = DateTime.Now,
  17747. // IsDel = 0
  17748. // };
  17749. // if (item2.c != null)
  17750. // {
  17751. // int cityId = 0;
  17752. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17753. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17754. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17755. // foreach (var item3 in item2.c)
  17756. // {
  17757. // if (item3.lv == "district")
  17758. // {
  17759. // var districtInfo = new Sys_Cities()
  17760. // {
  17761. // CountriesId = countriesId,
  17762. // Name_CN = item3.cn,
  17763. // Name_EN = item3.en,
  17764. // Level = 3,
  17765. // ParentId = cityId,
  17766. // IsCapital = 1,
  17767. // CreateUserId = 208,
  17768. // CreateTime = DateTime.Now,
  17769. // IsDel = 0
  17770. // };
  17771. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17772. // //{
  17773. // districts.Add(districtInfo);
  17774. // //}
  17775. // }
  17776. // }
  17777. // }
  17778. // else
  17779. // {
  17780. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17781. // //{
  17782. // cities.Add(cityInfo);
  17783. // //}
  17784. // }
  17785. // }
  17786. // }
  17787. // }
  17788. // else if (item1.lv == "city")//城市
  17789. // {
  17790. // provinceInfo.Level = 2;
  17791. // if (item1.c != null)
  17792. // {
  17793. // int cityId = 0;
  17794. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17795. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17796. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17797. // foreach (var item3 in item1.c)
  17798. // {
  17799. // if (item3.lv == "district")
  17800. // {
  17801. // var districtInfo = new Sys_Cities()
  17802. // {
  17803. // CountriesId = countriesId,
  17804. // Name_CN = item3.cn,
  17805. // Name_EN = item3.en,
  17806. // Level = 3,
  17807. // ParentId = cityId,
  17808. // IsCapital = 1,
  17809. // CreateUserId = 208,
  17810. // CreateTime = DateTime.Now,
  17811. // IsDel = 0
  17812. // };
  17813. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17814. // //{
  17815. // districts.Add(districtInfo);
  17816. // //}
  17817. // }
  17818. // }
  17819. // }
  17820. // else
  17821. // {
  17822. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17823. // //{
  17824. // cities.Add(provinceInfo);
  17825. // //}
  17826. // }
  17827. // }
  17828. // }
  17829. // }
  17830. // }
  17831. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17832. // cities = cities.Distinct().ToList();
  17833. // districts = districts.Distinct().ToList();
  17834. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17835. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17836. // cities.AddRange(districts);
  17837. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17838. // //_sqlSugar.RollbackTran();
  17839. // _sqlSugar.CommitTran();
  17840. // return Ok(JsonView(false, "操作成功!"));
  17841. //}
  17842. //[HttpPost]
  17843. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17844. //{
  17845. // List<CountitiesInfo> infos = dto.MyProperty;
  17846. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17847. // _sqlSugar.BeginTran();
  17848. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17849. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17850. // foreach (var item in infos)
  17851. // {
  17852. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17853. // if (countryInfo != null)
  17854. // {
  17855. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17856. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17857. // if (cityInfo1 != null)
  17858. // {
  17859. // cityInfo1.IsCapital = 0;
  17860. // cityInfos.Add(cityInfo1);
  17861. // }
  17862. // }
  17863. // }
  17864. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17865. // .UpdateColumns(it => it.IsCapital)
  17866. // .WhereColumns(it => it.Id)
  17867. // .ExecuteCommand();
  17868. // //_sqlSugar.RollbackTran();
  17869. // _sqlSugar.CommitTran();
  17870. // return Ok(JsonView(false, "操作成功!"));
  17871. //}
  17872. //public class CounrtiesDto
  17873. //{
  17874. // public List<CountitiesInfo> MyProperty { get; set; }
  17875. //}
  17876. //public class CountitiesInfo
  17877. //{
  17878. // /// <summary>
  17879. // /// 圣约翰
  17880. // /// </summary>
  17881. // public string capital_name_chinese { get; set; }
  17882. // /// <summary>
  17883. // ///
  17884. // /// </summary>
  17885. // public string capital_name { get; set; }
  17886. // /// <summary>
  17887. // ///
  17888. // /// </summary>
  17889. // public string country_type { get; set; }
  17890. // /// <summary>
  17891. // /// 安提瓜和巴布达
  17892. // /// </summary>
  17893. // public string country_name_chinese { get; set; }
  17894. // /// <summary>
  17895. // /// 安提瓜和巴布达
  17896. // /// </summary>
  17897. // public string country_name_chinese_short { get; set; }
  17898. // /// <summary>
  17899. // /// 安提瓜和巴布达
  17900. // /// </summary>
  17901. // public string country_name_chinese_UN { get; set; }
  17902. // /// <summary>
  17903. // ///
  17904. // /// </summary>
  17905. // public string country_name_english_abbreviation { get; set; }
  17906. // /// <summary>
  17907. // ///
  17908. // /// </summary>
  17909. // public string country_name_english_formal { get; set; }
  17910. // /// <summary>
  17911. // ///
  17912. // /// </summary>
  17913. // public string country_name_english_UN { get; set; }
  17914. // /// <summary>
  17915. // ///
  17916. // /// </summary>
  17917. // public string continent_name { get; set; }
  17918. // /// <summary>
  17919. // ///
  17920. // /// </summary>
  17921. // public string subregion_name { get; set; }
  17922. // /// <summary>
  17923. // ///
  17924. // /// </summary>
  17925. // public string country_code2 { get; set; }
  17926. // /// <summary>
  17927. // ///
  17928. // /// </summary>
  17929. // public string country_code3 { get; set; }
  17930. // /// <summary>
  17931. // ///
  17932. // /// </summary>
  17933. // public string phone_code { get; set; }
  17934. //}
  17935. //public class CountriesInfo : BasicInfo
  17936. //{
  17937. // public List<CitiesInfo> c { get; set; }
  17938. //}
  17939. //public class CitiesInfo : BasicInfo
  17940. //{
  17941. // public List<AreaInfo> c { get; set; }
  17942. //}
  17943. //public class AreaInfo : BasicInfo
  17944. //{
  17945. // public List<AreaInfo> c { get; set; }
  17946. //}
  17947. //public class BasicInfo
  17948. //{
  17949. // public string code { get; set; }
  17950. // public string cn { get; set; }
  17951. // public string lv { get; set; }
  17952. // public string en { get; set; }
  17953. //}
  17954. #endregion
  17955. #region 查看邀请方
  17956. /// <summary>
  17957. /// 查看邀请方
  17958. /// 邀请方信息 Init
  17959. /// </summary>
  17960. /// <param name="dto"></param>
  17961. /// <returns></returns>
  17962. [HttpPost]
  17963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17964. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17965. {
  17966. string sqlWhere = string.Empty;
  17967. if (!string.IsNullOrEmpty(dto.Search))
  17968. {
  17969. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17970. }
  17971. string sql = string.Format($@"Select
  17972. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17973. Id,
  17974. UnitName
  17975. From Res_InvitationOfficialActivityData
  17976. Where IsDel = 0
  17977. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17978. RefAsync<int> total = 0;
  17979. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17980. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17981. }
  17982. /// <summary>
  17983. /// 查看邀请方
  17984. /// 国家信息 Init
  17985. /// </summary>
  17986. /// <param name="dto"></param>
  17987. /// <returns></returns>
  17988. [HttpPost]
  17989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17990. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17991. {
  17992. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17993. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17994. var diids = groupInfos.Select(it => it.Id).ToList();
  17995. List<string> countrys = new List<string>();
  17996. foreach (var item in country)
  17997. {
  17998. var data = _groupRepository.FormartTeamName(item);
  17999. var dataArray = _groupRepository.GroupSplitCountry(data);
  18000. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18001. }
  18002. countrys = countrys.Distinct().ToList();
  18003. for (int i = 0; i < countrys.Count; i++)
  18004. {
  18005. string item = countrys[i];
  18006. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18007. {
  18008. countrys.Remove(item);
  18009. i--;
  18010. }
  18011. }
  18012. RefAsync<int> total = 0;
  18013. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18014. .Where(it => countrys.Contains(it.Name_CN))
  18015. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18016. .Select(it => new { id = it.Id, name = it.Name_CN })
  18017. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18018. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18019. }
  18020. /// <summary>
  18021. /// 查看邀请方
  18022. /// 城市信息 Init
  18023. /// </summary>
  18024. /// <param name="dto"></param>
  18025. /// <returns></returns>
  18026. [HttpPost]
  18027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18028. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18029. {
  18030. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18031. RefAsync<int> total = 0;
  18032. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18033. .Where(it => it.CountriesId == dto.CountiesId)
  18034. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18035. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18036. .Select(it => new { id = it.Id, name = it.Name_CN })
  18037. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18038. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18039. }
  18040. /// <summary>
  18041. /// 查看邀请方
  18042. /// 团组名称 Init
  18043. /// </summary>
  18044. /// <param name="dto"></param>
  18045. /// <returns></returns>
  18046. [HttpPost]
  18047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18048. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18049. {
  18050. var watch = new Stopwatch();
  18051. watch.Start();
  18052. RefAsync<int> total = 0;
  18053. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18054. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18055. .Where((oa, di) => oa.IsDel == 0)
  18056. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18057. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18058. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18059. .Distinct()
  18060. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18061. watch.Stop();
  18062. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18063. }
  18064. /// <summary>
  18065. /// 查看邀请方
  18066. /// 团组 & 邀请方信息
  18067. /// </summary>
  18068. /// <param name="dto"></param>
  18069. /// <returns></returns>
  18070. [HttpPost]
  18071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18072. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18073. {
  18074. var watch = new Stopwatch();
  18075. watch.Start();
  18076. RefAsync<int> total = 0;
  18077. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18078. .AS("Grp_DelegationInfo")
  18079. .Includes(x => x.InvitingInfos)
  18080. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18081. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18082. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18083. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18084. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18085. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18086. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18087. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18088. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18089. infos.ForEach(x =>
  18090. {
  18091. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18092. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18093. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18094. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18095. });
  18096. watch.Stop();
  18097. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18098. }
  18099. #endregion
  18100. #region 报批行程
  18101. /// <summary>
  18102. /// 报批行程初始化
  18103. /// </summary>
  18104. /// <param name="dto"></param>
  18105. /// <returns></returns>
  18106. [HttpPost]
  18107. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18108. {
  18109. const int chiNumber = 5;
  18110. var jw = JsonView(false);
  18111. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18112. var group = groupList.First();
  18113. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18114. group = groupList.First(x => x.Id == diid);
  18115. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18116. .Where(x => x.DiId == diid && x.IsDel == 0)
  18117. .ToArray();
  18118. var count = 1;
  18119. foreach (var item in blackCodeList)
  18120. {
  18121. if (string.IsNullOrWhiteSpace(item.Title))
  18122. {
  18123. item.Title = "未设置名称数据" + count;
  18124. }
  18125. count++;
  18126. };
  18127. if (group == null)
  18128. {
  18129. jw.Msg = "暂无团组!";
  18130. return Ok(jw);
  18131. }
  18132. var data = new
  18133. {
  18134. groupList = groupList.Select(x => new
  18135. {
  18136. x.TeamName,
  18137. x.Id
  18138. }),
  18139. content = new ArrayList(),
  18140. groupInfo = new
  18141. {
  18142. group.VisitDays,
  18143. group.TourCode,
  18144. group.VisitPNumber,
  18145. group.TeamName,
  18146. group.Id,
  18147. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18148. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18149. },
  18150. blackCodeList = blackCodeList.Select(x => new
  18151. {
  18152. x.Title,
  18153. x.Id
  18154. }),
  18155. FileTempList = new ArrayList()
  18156. {
  18157. new { Index = 1,FileName = "旧模板" },
  18158. new { Index = 2,FileName = "省外办" },
  18159. new { Index = 3,FileName = "市外办" },
  18160. }
  18161. };
  18162. var resultArr = new ArrayList();
  18163. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18164. #region 默认不生成行程
  18165. //if (content.Count == 0)
  18166. //{
  18167. // var stay = "-";
  18168. // var cityPath = "-";
  18169. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18170. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18171. // .ToList();
  18172. // //添加城市路径以及住宿地
  18173. // //黑屏代码数据
  18174. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18175. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18176. // {
  18177. // jw = JsonView(true, "黑屏代码有误!", data);
  18178. // return Ok(jw);
  18179. // }
  18180. // data = data with
  18181. // {
  18182. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18183. // {
  18184. // x.Title,
  18185. // x.Id,
  18186. // }).ToArray())
  18187. // };
  18188. // foreach (DataRow row in dtBlack.Rows)
  18189. // {
  18190. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18191. // {
  18192. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18193. // return Ok(jw);
  18194. // }
  18195. // }
  18196. // //黑屏代码获取时间区间
  18197. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18198. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18199. // _sqlSugar.BeginTran();
  18200. // for (int i = 0; i < timeArr.Count; i++)
  18201. // {
  18202. // stay = "-";
  18203. // cityPath = "-";
  18204. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18205. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18206. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18207. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18208. // if (tbSelect.Length > 0)
  18209. // {
  18210. // List<string> threeCodeStr = new List<string>();
  18211. // foreach (var item in tbSelect)
  18212. // {
  18213. // var threeCode = item["Three"].ToString() ?? "";
  18214. // if (threeCode.Length == 6)
  18215. // {
  18216. // var start = threeCode.Substring(0, 3);
  18217. // var end = threeCode.Substring(3, 3);
  18218. // if (threeCodeStr.Count == 0)
  18219. // {
  18220. // threeCodeStr.Add(start);
  18221. // threeCodeStr.Add(end);
  18222. // }
  18223. // else
  18224. // {
  18225. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18226. // {
  18227. // threeCodeStr.Add(end);
  18228. // }
  18229. // else
  18230. // {
  18231. // threeCodeStr.Add(start);
  18232. // threeCodeStr.Add(end);
  18233. // }
  18234. // }
  18235. // }
  18236. // }
  18237. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18238. // var last = threeCodeStr.Last();
  18239. // foreach (var item in threeCodeStr)
  18240. // {
  18241. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18242. // if (item.Equals(last))
  18243. // {
  18244. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18245. // }
  18246. // }
  18247. // cityPath = cityPath.Trim('-');
  18248. // }
  18249. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18250. // appro.Diid = diid ?? -1;
  18251. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18252. // appro.Id = thisId;
  18253. // appro.CreateUserId = dto.UserId;
  18254. // appro.CreateTime = DateTime.Now;
  18255. // content.Add(appro);
  18256. // }
  18257. // _sqlSugar.CommitTran();
  18258. //}
  18259. #endregion
  18260. foreach (var x in content)
  18261. {
  18262. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18263. if (chiList.Count < chiNumber)
  18264. {
  18265. for (int i = chiList.Count; i < chiNumber; i++)
  18266. {
  18267. chiList.Add(new Grp_ApprovalTravelDetails());
  18268. }
  18269. }
  18270. resultArr.Add(new
  18271. {
  18272. x.Id,
  18273. x.Date,
  18274. x.Diid,
  18275. chiList = chiList.Select(x1 => new
  18276. {
  18277. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18278. x1.Details,
  18279. x1.ParentId,
  18280. x1.Id
  18281. })
  18282. });
  18283. }
  18284. data = data with
  18285. {
  18286. content = resultArr,
  18287. };
  18288. jw = JsonView(true, "获取成功!", data);
  18289. return Ok(jw);
  18290. }
  18291. /// <summary>
  18292. /// 报批行程删除
  18293. /// </summary>
  18294. /// <param name="dto"></param>
  18295. /// <returns></returns>
  18296. [HttpPost]
  18297. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18298. {
  18299. var jw = JsonView(false);
  18300. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18301. if (group == null)
  18302. {
  18303. jw.Msg = "团组参数有误!";
  18304. return Ok(jw);
  18305. }
  18306. try
  18307. {
  18308. _sqlSugar.BeginTran();
  18309. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18310. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18311. {
  18312. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18313. DeleteUserId = dto.uesrId,
  18314. IsDel = 1
  18315. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18316. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18317. {
  18318. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18319. DeleteUserId = dto.uesrId,
  18320. IsDel = 1
  18321. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18322. _sqlSugar.CommitTran();
  18323. jw = JsonView(true, "删除成功");
  18324. }
  18325. catch (Exception ex)
  18326. {
  18327. jw = JsonView(false, ex.Message);
  18328. }
  18329. return Ok(jw);
  18330. }
  18331. /// <summary>
  18332. /// 报批行程保存
  18333. /// </summary>
  18334. /// <param name="dto"></param>
  18335. /// <returns></returns>
  18336. [HttpPost]
  18337. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18338. {
  18339. var jw = JsonView(false);
  18340. var Find = dto.Arr.Find(x => x.id == 0);
  18341. if (Find != null)
  18342. {
  18343. jw.Msg = "生成的ID为0!";
  18344. return Ok(jw);
  18345. }
  18346. foreach (var item in dto.Arr)
  18347. {
  18348. foreach (var chi in item.chiList)
  18349. {
  18350. if (chi.parentId == 0)
  18351. {
  18352. chi.parentId = item.id;
  18353. }
  18354. }
  18355. }
  18356. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18357. _sqlSugar.BeginTran();
  18358. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18359. {
  18360. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18361. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18362. {
  18363. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18364. DeleteUserId = dto.UserId,
  18365. IsDel = 1
  18366. }).ExecuteCommand();
  18367. }
  18368. try
  18369. {
  18370. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18371. {
  18372. CreateTime = DateTime.Now,
  18373. CreateUserId = dto.UserId,
  18374. Details = x.details,
  18375. ParentId = x.parentId,
  18376. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18377. Remark = "",
  18378. IsDel = 0
  18379. }).ToList()).ExecuteCommand();
  18380. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18381. {
  18382. Id = x.id,
  18383. Details = x.details,
  18384. ParentId = x.parentId,
  18385. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18386. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18387. {
  18388. Details = x.Details,
  18389. ParentId = x.ParentId,
  18390. Time = x.Time
  18391. }).ExecuteCommand();
  18392. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18393. {
  18394. Id = x.id,
  18395. Date = x.date,
  18396. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18397. {
  18398. Date = x.Date
  18399. }).ExecuteCommand();
  18400. _sqlSugar.CommitTran();
  18401. jw = JsonView(true, "保存成功!");
  18402. }
  18403. catch (Exception ex)
  18404. {
  18405. _sqlSugar.RollbackTran();
  18406. jw = JsonView(false, "保存失败!" + ex.Message);
  18407. }
  18408. return Ok(jw);
  18409. }
  18410. /// <summary>
  18411. /// 报批行程生成
  18412. /// </summary>
  18413. /// <param name="dto"></param>
  18414. /// <returns></returns>
  18415. [HttpPost]
  18416. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18417. {
  18418. var jw = JsonView(false);
  18419. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18420. if (group == null)
  18421. {
  18422. jw.Msg = "暂无该团组!";
  18423. return Ok(jw);
  18424. }
  18425. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18426. //黑屏代码数据
  18427. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18428. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18429. {
  18430. jw.Msg = "黑屏代码有误!";
  18431. return Ok(jw);
  18432. }
  18433. foreach (DataRow row in dtBlack.Rows)
  18434. {
  18435. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18436. {
  18437. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18438. return Ok(jw);
  18439. }
  18440. }
  18441. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18442. var resultArr = new ArrayList();
  18443. //if (officialActivitiesArr.Count == 0)
  18444. //{
  18445. // jw.Msg = "暂无公务出访信息!";
  18446. // return Ok(jw);
  18447. //}
  18448. try
  18449. {
  18450. _sqlSugar.BeginTran();
  18451. DeleteApprovalJourney(new
  18452. Domain.Dtos.Groups.DeleteApprovalJourney
  18453. {
  18454. Diid = dto.Diid,
  18455. uesrId = dto.Userid
  18456. });
  18457. var stay = "-";
  18458. var cityPath = "-";
  18459. //添加城市路径以及住宿地
  18460. //黑屏代码获取时间区间
  18461. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18462. var empty = "【未收入该三字码!请机票同事录入】";
  18463. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18464. for (int i = 0; i < timeArr.Count; i++)
  18465. {
  18466. stay = "-";
  18467. cityPath = "-";
  18468. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18469. DateTime NewData = DateTime.Parse(timeArr[i]);
  18470. //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();
  18471. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18472. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18473. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18474. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18475. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18476. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18477. if (tbSelect.Length > 0)
  18478. {
  18479. List<string> threeCodeStr = new List<string>();
  18480. bool isTrade = false;
  18481. string trip = string.Empty;
  18482. var rowLast = tbSelect.Last();
  18483. var rowFirst = tbSelect.First();
  18484. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18485. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18486. var takeOffTime = DateTime.Parse(timeArr[i]);
  18487. var fallToTime = DateTime.Parse(timeArr[i]);
  18488. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18489. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18490. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18491. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18492. foreach (var item in tbSelect)
  18493. {
  18494. var start = string.Empty;
  18495. var end = string.Empty;
  18496. var threeCode = item["Three"].ToString() ?? "";
  18497. if (threeCode.Length == 6)
  18498. {
  18499. start = threeCode.Substring(0, 3);
  18500. end = threeCode.Substring(3, 3);
  18501. if (threeCodeStr.Count == 0)
  18502. {
  18503. threeCodeStr.Add(start);
  18504. threeCodeStr.Add(end);
  18505. }
  18506. else
  18507. {
  18508. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18509. {
  18510. threeCodeStr.Add(end);
  18511. }
  18512. else
  18513. {
  18514. threeCodeStr.Add(start);
  18515. threeCodeStr.Add(end);
  18516. }
  18517. }
  18518. }
  18519. //处理机票信息
  18520. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18521. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18522. if (start_Object == null)
  18523. {
  18524. start_Object = new Res_ThreeCode()
  18525. {
  18526. AirPort = empty,
  18527. AirPort_En = empty,
  18528. City = empty,
  18529. Country = empty,
  18530. Four = empty,
  18531. Three = empty,
  18532. };
  18533. }
  18534. if (end_Object == null)
  18535. {
  18536. end_Object = new Res_ThreeCode()
  18537. {
  18538. AirPort = empty,
  18539. AirPort_En = empty,
  18540. City = empty,
  18541. Country = empty,
  18542. Four = empty,
  18543. Three = empty,
  18544. };
  18545. }
  18546. //机型判断
  18547. string airModel = item["AirModel"].ToString();
  18548. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18549. string flightTime = item["FlightTime"].ToString();
  18550. if (flightTime!.Contains(":"))
  18551. {
  18552. flightTime = flightTime.Replace(":", "小时");
  18553. flightTime += "分钟";
  18554. }
  18555. if (flightTime.Contains("H"))
  18556. {
  18557. flightTime = flightTime.Replace("H", "小时");
  18558. }
  18559. if (flightTime.Contains("M"))
  18560. {
  18561. flightTime = flightTime.Replace("M", "分钟");
  18562. }
  18563. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18564. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18565. {
  18566. flightTime = flightDataTime.Hour > 0
  18567. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18568. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18569. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18570. }
  18571. //航班号
  18572. string flightcode = item["Fliagtcode"].ToString();
  18573. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18574. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18575. if (aircompany == null)
  18576. {
  18577. aircompany = new Res_AirCompany
  18578. {
  18579. CnName = hsEmpty,
  18580. EnName = hsEmpty,
  18581. ShortCode = hsEmpty,
  18582. };
  18583. }
  18584. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18585. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18586. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18587. if (isTrade)
  18588. {
  18589. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18590. }
  18591. else
  18592. {
  18593. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18594. }
  18595. }
  18596. chiarr.Add(new Grp_ApprovalTravelDetails
  18597. {
  18598. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18599. CreateTime = DateTime.Now,
  18600. CreateUserId = dto.Userid,
  18601. ParentId = 0,
  18602. Details = trip
  18603. });
  18604. //添加乘车语句
  18605. chiarr.Add(new Grp_ApprovalTravelDetails
  18606. {
  18607. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18608. CreateTime = DateTime.Now,
  18609. CreateUserId = dto.Userid,
  18610. ParentId = 0,
  18611. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18612. });
  18613. if (i != timeArr.Count - 1)
  18614. {
  18615. fallToTime = fallToTime.AddHours(2.5);
  18616. foreach (var item in Times)
  18617. {
  18618. //排列公务时间
  18619. if (fallToTime.Hour < item.Item1)
  18620. {
  18621. chiarr.Add(new Grp_ApprovalTravelDetails
  18622. {
  18623. Time = $"{item.Item2} - {item.Item3}",
  18624. CreateTime = DateTime.Now,
  18625. CreateUserId = dto.Userid,
  18626. ParentId = 0,
  18627. Details = "公务活动"
  18628. });
  18629. }
  18630. }
  18631. }
  18632. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18633. var last = threeCodeStr.Last();
  18634. foreach (var item in threeCodeStr)
  18635. {
  18636. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18637. if (item.Equals(last))
  18638. {
  18639. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18640. }
  18641. }
  18642. cityPath = cityPath.Trim('-');
  18643. }
  18644. else
  18645. {
  18646. foreach (var item in Times)
  18647. {
  18648. chiarr.Add(new Grp_ApprovalTravelDetails
  18649. {
  18650. Time = $"{item.Item2} - {item.Item3}",
  18651. CreateTime = DateTime.Now,
  18652. CreateUserId = dto.Userid,
  18653. ParentId = 0,
  18654. Details = "公务活动"
  18655. });
  18656. }
  18657. }
  18658. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18659. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18660. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18661. appro.Diid = dto.Diid;
  18662. appro.CreateUserId = dto.Userid;
  18663. appro.CreateTime = DateTime.Now;
  18664. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18665. appro.Id = thisId;
  18666. //foreach (var item in gwinfo)
  18667. //{
  18668. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18669. // chi.Details = "拜访" + item.Client;
  18670. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18671. // {
  18672. // chi.Details += "," + item.ReqSample;
  18673. // }
  18674. // chi.ParentId = thisId;
  18675. // chi.Time = item.Time;
  18676. // chiarr.Add(chi);
  18677. //}
  18678. if (chiarr.Count < 6)
  18679. {
  18680. for (int j = chiarr.Count; j < 6; j++)
  18681. {
  18682. chiarr.Add(new
  18683. Grp_ApprovalTravelDetails());
  18684. }
  18685. }
  18686. resultArr.Add(new
  18687. {
  18688. appro.Id,
  18689. appro.Date,
  18690. appro.Diid,
  18691. chiList = chiarr.Select(x1 => new
  18692. {
  18693. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18694. x1.Details,
  18695. x1.ParentId,
  18696. x1.Id
  18697. })
  18698. });
  18699. }
  18700. _sqlSugar.CommitTran();
  18701. jw = JsonView(true, "生成成功!", resultArr);
  18702. }
  18703. catch (Exception ex)
  18704. {
  18705. jw.Code = 400;
  18706. jw.Msg = "生成失败!" + ex.Message;
  18707. }
  18708. return Ok(jw);
  18709. }
  18710. /// <summary>
  18711. /// 报批行程word导出
  18712. /// </summary>
  18713. /// <param name="dto"></param>
  18714. /// <returns></returns>
  18715. [HttpPost]
  18716. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18717. {
  18718. var jw = JsonView(false);
  18719. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18720. if (group == null)
  18721. {
  18722. jw.Msg = "暂无该团组!";
  18723. return Ok(jw);
  18724. }
  18725. //模板路径
  18726. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18727. var fileName = string.Empty;
  18728. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18729. bool bold = false;
  18730. if (dto.FileIndex == 1)
  18731. {
  18732. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18733. }
  18734. else if (dto.FileIndex == 2)
  18735. {
  18736. fileName = "省外办-报批.docx";
  18737. bold = false;
  18738. titleFont = "方正黑体简体";
  18739. timeFont = "Times New Roman";
  18740. contentFont = "方正仿宋_GBK";
  18741. }
  18742. else if (dto.FileIndex == 3)
  18743. {
  18744. fileName = "市外办-报批.docx";
  18745. titleFont = "方正黑体简体";
  18746. timeFont = "Times New Roman";
  18747. contentFont = "方正仿宋简体";
  18748. }
  18749. tempPath = tempPath + fileName;
  18750. //载入模板
  18751. Document doc = new Document(tempPath);
  18752. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18753. //获取所填表格的序数
  18754. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18755. Aspose.Words.Tables.Row titleRowClone = null;
  18756. Aspose.Words.Tables.Row CenterRowClone = null;
  18757. int index = 0;
  18758. int indexChi = 0;
  18759. int SetIndex = 0;
  18760. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18761. //获取数据,放到datatable
  18762. foreach (var item in ApprovalTravelArr)
  18763. {
  18764. if (index > 0)
  18765. {
  18766. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18767. tableOne.AppendChild(titleRowClone);
  18768. }
  18769. var textTime = item.Date;
  18770. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18771. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18772. SetIndex++;
  18773. if (ChiRep.Count > 0)
  18774. {
  18775. foreach (var itemChi in ChiRep)
  18776. {
  18777. var txtTime = itemChi.Time;
  18778. var txtDetail = itemChi.Details;
  18779. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18780. {
  18781. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  18782. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18783. //indexChi++;
  18784. //SetIndex++;
  18785. break;
  18786. }
  18787. if (indexChi > 0)
  18788. {
  18789. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18790. tableOne.AppendChild(CenterRowClone);
  18791. }
  18792. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  18793. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  18794. indexChi++;
  18795. SetIndex++;
  18796. }
  18797. }
  18798. //else
  18799. //{
  18800. // if (indexChi > 0)
  18801. // {
  18802. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18803. // tableOne.AppendChild(CenterRowClone);
  18804. // }
  18805. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  18806. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18807. // indexChi++;
  18808. // SetIndex++;
  18809. //}
  18810. index++;
  18811. }
  18812. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  18813. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18814. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18815. jw.Code = 200;
  18816. jw.Msg = "";
  18817. return Ok(jw);
  18818. }
  18819. private string intToString(int numberVal)
  18820. {
  18821. string numberval = numberVal.ToString();
  18822. Dictionary<char, string> Number = new Dictionary<char, string>();
  18823. Number.Add('1', "一");
  18824. Number.Add('2', "二");
  18825. Number.Add('3', "三");
  18826. Number.Add('4', "四");
  18827. Number.Add('5', "五");
  18828. Number.Add('6', "六");
  18829. Number.Add('7', "七");
  18830. Number.Add('8', "八");
  18831. Number.Add('9', "九");
  18832. string stringNumberVal = string.Empty;
  18833. for (int i = 0; i < numberval.Length; i++)
  18834. {
  18835. if (i == 0)
  18836. {
  18837. stringNumberVal += Number[numberval[i]];
  18838. }
  18839. else if (i >= 1)
  18840. {
  18841. if (numberval[i] == '0')
  18842. {
  18843. stringNumberVal = "十";
  18844. }
  18845. else
  18846. {
  18847. stringNumberVal += "十" + Number[numberval[i]];
  18848. }
  18849. }
  18850. }
  18851. return stringNumberVal;
  18852. }
  18853. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  18854. {
  18855. //获取table中的某个单元格,从0开始
  18856. Cell lshCell = table.Rows[rows].Cells[cells];
  18857. //将单元格中段落移除
  18858. foreach (Paragraph item in lshCell.Paragraphs)
  18859. {
  18860. lshCell.Paragraphs.Remove(item);
  18861. }
  18862. if (val.Contains("\r\n"))
  18863. {
  18864. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18865. foreach (var item in spArr)
  18866. {
  18867. //新建一个段落
  18868. Paragraph p = new Paragraph(doc);
  18869. var r = new Run(doc, item);
  18870. //设置字体
  18871. if (!string.IsNullOrEmpty(font))
  18872. {
  18873. r.Font.Name = font;
  18874. }
  18875. r.Font.Bold = bold;
  18876. //把设置的值赋给之前新建的段落
  18877. p.AppendChild(r);
  18878. //将此段落加到单元格内
  18879. lshCell.AppendChild(p);
  18880. }
  18881. }
  18882. else
  18883. {
  18884. //新建一个段落
  18885. Paragraph p = new Paragraph(doc);
  18886. var r = new Run(doc, val);
  18887. //设置字体
  18888. if (!string.IsNullOrEmpty(font))
  18889. {
  18890. r.Font.Name = font;
  18891. }
  18892. r.Font.Bold = bold;
  18893. //把设置的值赋给之前新建的段落
  18894. p.AppendChild(r);
  18895. //将此段落加到单元格内
  18896. lshCell.AppendChild(p);
  18897. }
  18898. }
  18899. [HttpPost]
  18900. public async Task<IActionResult> ServerHttp(string paramStr)
  18901. {
  18902. paramStr = paramStr.TrimEnd('\'');
  18903. paramStr = paramStr.TrimStart('\'');
  18904. JsonView jw = JsonView(false);
  18905. JObject param = JObject.Parse(paramStr);
  18906. if (!param.ContainsKey("url"))
  18907. {
  18908. jw.Msg = "url null";
  18909. return Ok(jw);
  18910. }
  18911. string url = param["url"]!.ToString();
  18912. var methon = "get";
  18913. Dictionary<string, string> headValues = null;
  18914. string bodyStr = string.Empty;
  18915. if (param.ContainsKey("methon"))
  18916. {
  18917. methon = param["methon"]!.ToString().ToLower();
  18918. }
  18919. if (param.ContainsKey("header"))
  18920. {
  18921. var header = param["header"]!.ToString();
  18922. JObject headerJobject = JObject.Parse(header);
  18923. headValues = new Dictionary<string, string>();
  18924. foreach (JProperty item in headerJobject.Properties())
  18925. {
  18926. var value = item.Value.ToString();
  18927. var head = item.Path;
  18928. headValues.Add(head, value);
  18929. }
  18930. }
  18931. HttpClient client = new HttpClient();
  18932. string responseString = string.Empty;
  18933. StringContent content = null;
  18934. if (headValues != null)
  18935. {
  18936. foreach (var item in headValues.Keys)
  18937. {
  18938. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18939. {
  18940. if (param.ContainsKey("body"))
  18941. {
  18942. bodyStr = param["body"]!.ToString();
  18943. }
  18944. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18945. }
  18946. else
  18947. {
  18948. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18949. }
  18950. }
  18951. }
  18952. try
  18953. {
  18954. if (methon == "get")
  18955. {
  18956. responseString = await client.GetStringAsync(url);
  18957. }
  18958. else if (methon == "post")
  18959. {
  18960. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18961. {
  18962. Content = content
  18963. };
  18964. var response = await client.SendAsync(request);
  18965. try
  18966. {
  18967. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18968. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18969. {
  18970. using (StreamReader reader = new StreamReader(gzipStream))
  18971. {
  18972. responseString = await reader.ReadToEndAsync();
  18973. }
  18974. }
  18975. }
  18976. catch (Exception)
  18977. {
  18978. responseString = await response.Content.ReadAsStringAsync();
  18979. }
  18980. }
  18981. else
  18982. {
  18983. responseString = "methon error";
  18984. }
  18985. jw = JsonView(true, "success", responseString);
  18986. }
  18987. catch (Exception ex)
  18988. {
  18989. jw.Msg = "error " + ex.Message;
  18990. jw.Data = ex.StackTrace;
  18991. }
  18992. finally
  18993. {
  18994. client.Dispose();
  18995. }
  18996. return Ok(jw);
  18997. }
  18998. #endregion
  18999. #region 团组接待意见调查
  19000. /// <summary>
  19001. /// 团组接待意见调查 - 信息管理
  19002. /// 基础数据(团组)
  19003. /// </summary>
  19004. /// <returns></returns>
  19005. [HttpGet]
  19006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19007. public async Task<IActionResult> OpinionaireInit()
  19008. {
  19009. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19010. .Select(x => new
  19011. {
  19012. x.Id,
  19013. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19014. })
  19015. .OrderByDescending(x => x.Id)
  19016. .ToListAsync();
  19017. return Ok(JsonView(groupData, groupData.Count));
  19018. }
  19019. /// <summary>
  19020. /// 团组接待意见调查 - 信息管理
  19021. /// 列表
  19022. /// </summary>
  19023. /// <param name="groupId"></param>
  19024. /// <returns></returns>
  19025. [HttpGet("{groupId}")]
  19026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19027. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19028. {
  19029. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19030. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19031. .Select(x => new
  19032. {
  19033. x.Id,
  19034. x.TourGuideName,
  19035. x.CityName,
  19036. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19037. x.CreateTime
  19038. })
  19039. .OrderBy(x => x.Id)
  19040. .ToListAsync();
  19041. return Ok(JsonView(data));
  19042. }
  19043. /// <summary>
  19044. /// 团组接待意见调查 - 信息管理
  19045. /// 保存
  19046. /// </summary>
  19047. /// <param name="dto"></param>
  19048. /// <returns></returns>
  19049. [HttpPost]
  19050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19051. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19052. {
  19053. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19054. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19055. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19056. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19057. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19058. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19059. _opinionaireRep.BeginTran();
  19060. if (addData != null && addData.Count > 0)
  19061. {
  19062. foreach (var item in addData)
  19063. {
  19064. item.CreateUserId = currUserInfo.UserId;
  19065. item.DiId = dto.DiId;
  19066. }
  19067. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19068. }
  19069. if (updData != null && updData.Count > 0)
  19070. {
  19071. var upd = await _opinionaireRep._sqlSugar
  19072. .Updateable(updData)
  19073. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19074. .WhereColumns(x => new { x.Id })
  19075. .ExecuteCommandAsync();
  19076. }
  19077. _opinionaireRep.CommitTran();
  19078. return Ok(JsonView("操作成功!"));
  19079. }
  19080. /// <summary>
  19081. /// 团组接待意见调查 - 信息管理
  19082. /// 删除
  19083. /// </summary>
  19084. /// <param name="id"></param>
  19085. /// <returns></returns>
  19086. [HttpDelete("{id}")]
  19087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19088. public async Task<IActionResult> OpinionaireManageDel(int id)
  19089. {
  19090. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19091. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19092. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19093. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19094. if (!del) return Ok(JsonView("操作失败!"));
  19095. return Ok(JsonView("操作成功!"));
  19096. }
  19097. /// <summary>
  19098. /// 团组接待意见调查 - 用户
  19099. /// 列表
  19100. /// </summary>
  19101. /// <param name="diId"></param>
  19102. /// <returns></returns>
  19103. [HttpGet("{diId}")]
  19104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19105. public async Task<IActionResult> OpinionaireUserList(int diId)
  19106. {
  19107. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19108. var sql = string.Format(@"
  19109. SELECT
  19110. o.Id,
  19111. o.DiId,
  19112. di.TeamName AS 'GroupName',
  19113. di.VisitPNumber AS 'PeopleNumber',
  19114. di.ClientName AS 'LeadGroup',
  19115. di.VisitCountry AS 'Travel',
  19116. di.VisitDays AS 'Days',
  19117. o.CityName,
  19118. o.TourGuideName,
  19119. o.Catering,
  19120. o.CateringReason,
  19121. o.Stay,
  19122. o.StayReason,
  19123. o.[Route],
  19124. o.RouteReason,
  19125. o.OfficialActivity,
  19126. o.OfficialActivityReason,
  19127. o.TourGuide,
  19128. o.TourGuideReason,
  19129. o.[Translate],
  19130. o.TranslateReason,
  19131. o.Trip,
  19132. o.TripReason,
  19133. o.ESFileName,
  19134. o.SignatureDate,
  19135. o.Remark
  19136. FROM
  19137. Grp_Opinionaire o
  19138. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19139. WHERE
  19140. o.IsDel = 0
  19141. AND o.DiId = {0}
  19142. ORDER BY
  19143. o.Id ASC", diId);
  19144. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19145. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19146. return Ok(JsonView(data));
  19147. }
  19148. /// <summary>
  19149. /// 团组接待意见调查 - 用户
  19150. /// 保存
  19151. /// </summary>
  19152. /// <param name="dto"></param>
  19153. /// <returns></returns>
  19154. [HttpPost]
  19155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19156. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19157. {
  19158. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19159. foreach (var item in dto)
  19160. {
  19161. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19162. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19163. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19164. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19165. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19166. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19167. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19168. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19169. }
  19170. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19171. if (!Directory.Exists(filePathBase))
  19172. {
  19173. Directory.CreateDirectory(filePathBase);
  19174. }
  19175. #region 上传文件
  19176. var filePaths = new List<string>();
  19177. foreach (var item in dto)
  19178. {
  19179. var file = item.File;
  19180. // 将文件保存到指定位置
  19181. var filePath = Path.Combine(filePathBase, file.FileName);
  19182. using (var stream = new FileStream(filePath, FileMode.Create))
  19183. {
  19184. await file.CopyToAsync(stream);
  19185. }
  19186. //验证文件是否上传成功
  19187. if (!System.IO.File.Exists(filePath))
  19188. {
  19189. foreach (var filePathStr in filePaths)
  19190. {
  19191. System.IO.File.Delete(filePathStr);
  19192. }
  19193. return Ok(JsonView(false, "文件上传失败!"));
  19194. }
  19195. item.ESFileName = file.FileName;
  19196. }
  19197. #endregion
  19198. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19199. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19200. .UpdateColumns(x => new
  19201. {
  19202. x.Catering,
  19203. x.CateringReason,
  19204. x.Stay,
  19205. x.StayReason,
  19206. x.Route,
  19207. x.RouteReason,
  19208. x.OfficialActivity,
  19209. x.OfficialActivityReason,
  19210. x.TourGuide,
  19211. x.TourGuideReason,
  19212. x.Translate,
  19213. x.TranslateReason,
  19214. x.Trip,
  19215. x.TripReason,
  19216. x.ESFileName,
  19217. x.SignatureDate,
  19218. x.Remark
  19219. })
  19220. .WhereColumns(x => new { x.Id })
  19221. .ExecuteCommandAsync();
  19222. if (upd < 1)
  19223. {
  19224. foreach (var filePathStr in filePaths)
  19225. {
  19226. System.IO.File.Delete(filePathStr);
  19227. }
  19228. return Ok(JsonView(false));
  19229. }
  19230. return Ok(JsonView(true));
  19231. }
  19232. #endregion
  19233. #region 团组餐厅相关信息
  19234. /// <summary>
  19235. /// 团组相关餐厅信息
  19236. /// 基础数据(团组)
  19237. /// </summary>
  19238. /// <returns></returns>
  19239. [HttpGet]
  19240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19241. public async Task<IActionResult> RestaurantInit()
  19242. {
  19243. return Ok(await _restaurantRep.InitAsync());
  19244. }
  19245. /// <summary>
  19246. /// 团组相关餐厅信息
  19247. /// Item
  19248. /// </summary>
  19249. /// <param name="dto"></param>
  19250. /// <returns></returns>
  19251. [HttpPost]
  19252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19253. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19254. {
  19255. int portType = dto.PortType,
  19256. groupId = dto.GroupId;
  19257. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19258. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19259. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19260. }
  19261. /// <summary>
  19262. /// 团组相关餐厅信息
  19263. /// List
  19264. /// </summary>
  19265. /// <param name="dto"></param>
  19266. /// <returns></returns>
  19267. [HttpPost]
  19268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19269. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19270. {
  19271. int portType = dto.PortType,
  19272. groupId = dto.GroupId;
  19273. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19274. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19275. var sql = string.Format(@" SELECT
  19276. ri.Id,
  19277. ri.GroupId,
  19278. ri.Date,
  19279. ri.StartTime,
  19280. ri.EndTime,
  19281. CASE WHEN ri.Type = 1 THEN '早餐'
  19282. WHEN ri.Type = 2 THEN '午餐'
  19283. WHEN ri.Type = 3 THEN '晚餐'
  19284. ELSE '其他'
  19285. END AS 'Type',
  19286. ri.Name,
  19287. ri.Address,
  19288. ri.Tel,
  19289. ri.Remark,
  19290. ri.CreateTime,
  19291. u.CnName AS CreateUserName
  19292. FROM
  19293. Grp_RestaurantInfo ri
  19294. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19295. WHERE
  19296. ri.IsDel = 0
  19297. AND ri.GroupId = {0}
  19298. ORDER BY
  19299. ri.Date ASC
  19300. ", groupId);
  19301. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19302. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19303. return Ok(JsonView(infos));
  19304. }
  19305. /// <summary>
  19306. /// 团组相关餐厅信息
  19307. /// Info
  19308. /// </summary>
  19309. /// <param name="dto"></param>
  19310. /// <returns></returns>
  19311. [HttpPost]
  19312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19313. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19314. {
  19315. int portType = dto.PortType,
  19316. id = dto.Id;
  19317. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19318. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19319. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19320. }
  19321. /// <summary>
  19322. /// 团组相关餐厅信息
  19323. /// Op
  19324. /// </summary>
  19325. /// <param name="dto"></param>
  19326. /// <returns></returns>
  19327. [HttpPost]
  19328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19329. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19330. {
  19331. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19332. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19333. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19334. return Ok(await _restaurantRep.OpAsync(dto));
  19335. }
  19336. /// <summary>
  19337. /// 团组相关餐厅信息
  19338. /// Del
  19339. /// </summary>
  19340. /// <param name="dto"></param>
  19341. /// <returns></returns>
  19342. [HttpPost]
  19343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19344. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19345. {
  19346. int userId = dto.DeleteUserId;
  19347. var id = dto.Id;
  19348. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19349. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19350. return Ok(await _restaurantRep.DelAsync(dto));
  19351. }
  19352. #endregion
  19353. // /// <summary>
  19354. // ///
  19355. // /// </summary>
  19356. // /// <param name="_dto"></param>
  19357. // /// <returns></returns>
  19358. // [HttpPost]
  19359. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19360. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19361. // {
  19362. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19363. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19364. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19365. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19366. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19367. // dic_psg.Add("客人", 974);
  19368. // dic_psg.Add("司机", 975);
  19369. // dic_psg.Add("导游", 976);
  19370. // dic_psg.Add("公司内部人员", 977);
  19371. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19372. // foreach (var item in list_visa)
  19373. // {
  19374. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19375. // temp.Id = item.Id;
  19376. // temp.DIId = item.DIId;
  19377. // temp.VisaClient = item.VisaClient;
  19378. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19379. // temp.VisaCurrency = item.VisaCurrency;
  19380. // temp.IsThird = item.IsThird;
  19381. // if (dic_psg.ContainsKey(item.PassengerType))
  19382. // {
  19383. // temp.PassengerType = dic_psg[item.PassengerType];
  19384. // }
  19385. // else {
  19386. // temp.PassengerType = -1;
  19387. // }
  19388. // temp.VisaNumber = item.VisaNumber;
  19389. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19390. // temp.CreateUserId = item.Operators;
  19391. // DateTime dt_ct;
  19392. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19393. // if (b_ct)
  19394. // {
  19395. // temp.CreateTime = dt_ct;
  19396. // }
  19397. // else
  19398. // {
  19399. // temp.CreateTime = DateTime.Now;
  19400. // }
  19401. // temp.DeleteTime = "";
  19402. // temp.DeleteUserId = 0;
  19403. // temp.Remark = item.Remark;
  19404. // if (string.IsNullOrEmpty(temp.Remark)) {
  19405. // temp.Remark = "";
  19406. // }
  19407. // temp.IsDel = item.IsDel;
  19408. // temp.VisaDescription = item.VisaAttachment;
  19409. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19410. //([Id]
  19411. // ,[DIId]
  19412. // ,[VisaClient]
  19413. // ,[VisaPrice]
  19414. // ,[VisaCurrency]
  19415. // ,[IsThird]
  19416. // ,[PassengerType]
  19417. // ,[VisaNumber]
  19418. // ,[VisaFreeNumber]
  19419. // ,[CreateUserId]
  19420. // ,[CreateTime]
  19421. // ,[DeleteTime]
  19422. // ,[DeleteUserId]
  19423. // ,[Remark]
  19424. // ,[IsDel]
  19425. // ,[visaDescription])
  19426. // VALUES
  19427. // ({0},{1},'{2}',{3},{4}
  19428. //,{5},{6},{7},{8},{9}
  19429. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19430. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19431. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19432. //);
  19433. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19434. // }
  19435. // return Ok(JsonView(true, "操作成功!"));
  19436. // }
  19437. /// <summary>
  19438. /// 123132123
  19439. /// </summary>
  19440. /// <param name="_dto"></param>
  19441. /// <returns></returns>
  19442. [HttpPost]
  19443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19444. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19445. {
  19446. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19447. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19448. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19449. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19450. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19451. dicDetail.Add(789, 1034);
  19452. dicDetail.Add(790, 1035);
  19453. dicDetail.Add(791, 1036);
  19454. dicDetail.Add(792, 1037);
  19455. dicDetail.Add(793, 1038);
  19456. dicDetail.Add(794, 1039);
  19457. dicDetail.Add(795, 1040);
  19458. dicDetail.Add(796, 1041);
  19459. dicDetail.Add(797, 1042);
  19460. dicDetail.Add(798, 1043);
  19461. dicDetail.Add(801, 1044);
  19462. dicDetail.Add(802, 1045);
  19463. dicDetail.Add(803, 1046);
  19464. Dictionary<int, int> dic = new Dictionary<int, int>();
  19465. dic.Add(806, 1027);
  19466. dic.Add(807, 1028);
  19467. dic.Add(808, 1029);
  19468. dic.Add(809, 1030);
  19469. dic.Add(810, 1031);
  19470. dic.Add(811, 1032);
  19471. dic.Add(812, 1033);
  19472. foreach (var item in list_visa)
  19473. {
  19474. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19475. temp.Coefficient = item.coefficient;
  19476. DateTime dtCrt;
  19477. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19478. if (b1)
  19479. {
  19480. temp.CreateTime = dtCrt;
  19481. }
  19482. else
  19483. {
  19484. temp.CreateTime = DateTime.Now;
  19485. }
  19486. temp.CreateUserId = item.Operators;
  19487. temp.DeleteTime = "";
  19488. temp.DeleteUserId = 0;
  19489. temp.DiId = int.Parse(item.DIID);
  19490. temp.FilePath = item.FilePath;
  19491. temp.IsDel = item.IsDel;
  19492. temp.Price = item.Price;
  19493. temp.PriceCount = 1;
  19494. temp.PriceCurrency = item.Currency;
  19495. int detailId = 0;
  19496. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19497. {
  19498. detailId = dicDetail[item.PriceTypeDetail];
  19499. }
  19500. temp.PriceDetailType = detailId;
  19501. temp.PriceDt = DateTime.Now;
  19502. temp.PriceName = item.PriceName;
  19503. temp.PriceSum = item.Price;
  19504. int tid = 0;
  19505. if (dic.ContainsKey(item.PriceType))
  19506. {
  19507. tid = dic[item.PriceType];
  19508. }
  19509. temp.PriceType = tid;
  19510. temp.Remark = item.Remark;
  19511. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19512. }
  19513. return Ok(JsonView(true, "操作成功!"));
  19514. }
  19515. [HttpPost]
  19516. public IActionResult TimeTest()
  19517. {
  19518. var jw = JsonView(false, "error");
  19519. _sqlSugar.BeginTran();
  19520. try
  19521. {
  19522. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19523. .Select(x => new Crm_NewClientData
  19524. {
  19525. Id = x.Id,
  19526. Client = x.Client,
  19527. Contact = x.Contact,
  19528. Location = x.Location,
  19529. })
  19530. .ToList();
  19531. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19532. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19533. Stopwatch stopwatch = new Stopwatch();
  19534. // 开始计时
  19535. stopwatch.Start();
  19536. foreach (var item in clientList)
  19537. {
  19538. EncryptionProcessor.DecryptProperties(item);
  19539. }
  19540. stopwatch.Stop();
  19541. jw.Code = 200;
  19542. jw.Data = stopwatch.ElapsedMilliseconds;
  19543. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19544. }
  19545. catch (Exception ex)
  19546. {
  19547. jw.Code = 400;
  19548. jw.Msg = ex.Message;
  19549. }
  19550. return Ok(jw);
  19551. }
  19552. }
  19553. }