GroupsController.cs 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761
  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 NPOI.HSSF.UserModel;
  8. using NPOI.SS.UserModel;
  9. using NPOI.SS.Util;
  10. using NPOI.XSSF.UserModel;
  11. using OASystem.API.Middlewares;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.APNs;
  14. using OASystem.API.OAMethodLib.File;
  15. using OASystem.API.OAMethodLib.Hub.HubClients;
  16. using OASystem.API.OAMethodLib.Hub.Hubs;
  17. using OASystem.API.OAMethodLib.JuHeAPI;
  18. using OASystem.API.OAMethodLib.KiMiApi;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.AesEncryption;
  21. using OASystem.Domain.Attributes;
  22. using OASystem.Domain.Dtos.CRM;
  23. using OASystem.Domain.Dtos.FileDto;
  24. using OASystem.Domain.Dtos.Financial;
  25. using OASystem.Domain.Dtos.Groups;
  26. using OASystem.Domain.Entities.Customer;
  27. using OASystem.Domain.Entities.Financial;
  28. using OASystem.Domain.Entities.Groups;
  29. using OASystem.Domain.ViewModels.Financial;
  30. using OASystem.Domain.ViewModels.Groups;
  31. using OASystem.Domain.ViewModels.OCR;
  32. using OASystem.Infrastructure.Repositories.CRM;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using Quartz.Util;
  36. using SqlSugar.Extensions;
  37. using System.Collections;
  38. using System.Data;
  39. using System.Diagnostics;
  40. using System.Globalization;
  41. using System.IO.Compression;
  42. using System.Web;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using Bookmark = Aspose.Words.Bookmark;
  46. using Cell = Aspose.Words.Tables.Cell;
  47. using Table = Aspose.Words.Tables.Table;
  48. namespace OASystem.API.Controllers
  49. {
  50. /// <summary>
  51. /// 团组相关
  52. /// </summary>
  53. //[Authorize]
  54. [Route("api/[controller]/[action]")]
  55. public class GroupsController : ControllerBase
  56. {
  57. private readonly ILogger<GroupsController> _logger;
  58. private readonly GrpScheduleRepository _grpScheduleRep;
  59. private readonly IMapper _mapper;
  60. private readonly DelegationInfoRepository _groupRepository;
  61. private readonly TaskAssignmentRepository _taskAssignmentRep;
  62. private readonly AirTicketResRepository _airTicketResRep;
  63. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  64. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  65. private readonly DelegationEnDataRepository _delegationEnDataRep;
  66. private readonly DelegationVisaRepository _delegationVisaRep;
  67. private readonly VisaPriceRepository _visaPriceRep;
  68. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  69. private readonly HotelPriceRepository _hotelPriceRep;
  70. private readonly CustomersRepository _customersRep;
  71. private readonly MessageRepository _message;
  72. private readonly SqlSugarClient _sqlSugar;
  73. private readonly TourClientListRepository _tourClientListRep;
  74. private readonly TeamRateRepository _teamRateRep;
  75. #region 成本相关
  76. private readonly CheckBoxsRepository _checkBoxs;
  77. private readonly GroupCostRepository _GroupCostRepository;
  78. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  79. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  80. #endregion
  81. private readonly SetDataRepository _setDataRep;
  82. private string url;
  83. private string path;
  84. private readonly EnterExitCostRepository _enterExitCostRep;
  85. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  86. private readonly UsersRepository _usersRep;
  87. private readonly IJuHeApiService _juHeApi;
  88. private readonly InvertedListRepository _invertedListRep;
  89. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  90. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  91. private readonly ThreeCodeRepository _threeCodeRepository;
  92. private readonly HotelInquiryRepository _hotelInquiryRep;
  93. private readonly FeeAuditRepository _feeAuditRep;
  94. private readonly VisaCommissionRepository _visaCommissionRep;
  95. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  96. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  97. private readonly List<CurrencyInfo> _currencyInit;
  98. private readonly List<int> _portTypeData;
  99. private readonly TableOperationRecordRepository _tableorRep;
  100. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  101. private readonly RestaurantRepository _restaurantRep;
  102. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  103. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  104. /// <summary>
  105. /// 构造函数
  106. /// </summary>
  107. /// <param name="logger"></param>
  108. /// <param name="mapper"></param>
  109. /// <param name="hubContext"></param>
  110. /// <param name="sqlSugar"></param>
  111. /// <param name="grpScheduleRep"></param>
  112. /// <param name="groupRepository"></param>
  113. /// <param name="taskAssignmentRep"></param>
  114. /// <param name="airTicketResRep"></param>
  115. /// <param name="decreasePaymentsRep"></param>
  116. /// <param name="InvitationOfficialActivitiesRep"></param>
  117. /// <param name="delegationEnDataRep"></param>
  118. /// <param name="enterExitCostRep"></param>
  119. /// <param name="delegationVisaRep"></param>
  120. /// <param name="message"></param>
  121. /// <param name="visaPriceRep"></param>
  122. /// <param name="carTouristGuideGroundRep"></param>
  123. /// <param name="checkBoxs"></param>
  124. /// <param name="GroupCostRepository"></param>
  125. /// <param name="CostTypeHotelNumberRepository"></param>
  126. /// <param name="GroupCostParameterRepository"></param>
  127. /// <param name="hotelPriceRep"></param>
  128. /// <param name="customersRep"></param>
  129. /// <param name="setDataRep"></param>
  130. /// <param name="tourClientListRep"></param>
  131. /// <param name="teamRateRep"></param>
  132. /// <param name="usersRep"></param>
  133. /// <param name="juHeApi"></param>
  134. /// <param name="invertedListRep"></param>
  135. /// <param name="visaFeeInfoRep"></param>
  136. /// <param name="ticketBlackCodeRep"></param>
  137. /// <param name="hotelInquiryRep"></param>
  138. /// <param name="threeCodeRepository"></param>
  139. /// <param name="feeAuditRep"></param>
  140. /// <param name="visaCommissionRep"></param>
  141. /// <param name="ffrRep"></param>
  142. /// <param name="opinionaireRep"></param>
  143. /// <param name="tableorRep"></param>
  144. /// <param name="enterExitCostDraftRep"></param>
  145. /// <param name="restaurantRep"></param>
  146. /// <param name="enterExitCostQuoteRep"></param>
  147. /// <param name="grpOrderPreInfoRep"></param>
  148. public GroupsController(
  149. ILogger<GroupsController> logger,
  150. IMapper mapper,
  151. IHubContext<ChatHub, IChatClient> hubContext,
  152. SqlSugarClient sqlSugar,
  153. GrpScheduleRepository grpScheduleRep,
  154. DelegationInfoRepository groupRepository,
  155. TaskAssignmentRepository taskAssignmentRep,
  156. AirTicketResRepository airTicketResRep,
  157. DecreasePaymentsRepository decreasePaymentsRep,
  158. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  159. DelegationEnDataRepository delegationEnDataRep,
  160. EnterExitCostRepository enterExitCostRep,
  161. DelegationVisaRepository delegationVisaRep,
  162. MessageRepository message,
  163. VisaPriceRepository visaPriceRep,
  164. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  165. CheckBoxsRepository checkBoxs,
  166. GroupCostRepository GroupCostRepository,
  167. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  168. GroupCostParameterRepository GroupCostParameterRepository,
  169. HotelPriceRepository hotelPriceRep,
  170. CustomersRepository customersRep,
  171. SetDataRepository setDataRep,
  172. TourClientListRepository tourClientListRep,
  173. TeamRateRepository teamRateRep,
  174. UsersRepository usersRep,
  175. IJuHeApiService juHeApi,
  176. InvertedListRepository invertedListRep,
  177. VisaFeeInfoRepository visaFeeInfoRep,
  178. TicketBlackCodeRepository ticketBlackCodeRep,
  179. HotelInquiryRepository hotelInquiryRep,
  180. ThreeCodeRepository threeCodeRepository,
  181. FeeAuditRepository feeAuditRep,
  182. VisaCommissionRepository visaCommissionRep,
  183. ForeignReceivablesRepository ffrRep,
  184. OpinionaireRepository opinionaireRep,
  185. TableOperationRecordRepository tableorRep,
  186. EnterExitCostDraftRepository enterExitCostDraftRep,
  187. RestaurantRepository restaurantRep,
  188. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  189. GroupOrderPreInfoRepository grpOrderPreInfoRep
  190. )
  191. {
  192. _logger = logger;
  193. _mapper = mapper;
  194. _grpScheduleRep = grpScheduleRep;
  195. _groupRepository = groupRepository;
  196. _taskAssignmentRep = taskAssignmentRep;
  197. _airTicketResRep = airTicketResRep;
  198. _sqlSugar = sqlSugar;
  199. url = AppSettingsHelper.Get("ExcelBaseUrl");
  200. path = AppSettingsHelper.Get("ExcelBasePath");
  201. if (!System.IO.Directory.Exists(path))
  202. {
  203. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  204. }
  205. _decreasePaymentsRep = decreasePaymentsRep;
  206. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  207. _delegationEnDataRep = delegationEnDataRep;
  208. _enterExitCostRep = enterExitCostRep;
  209. _delegationVisaRep = delegationVisaRep;
  210. _message = message;
  211. _visaPriceRep = visaPriceRep;
  212. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  213. _checkBoxs = checkBoxs;
  214. _GroupCostRepository = GroupCostRepository;
  215. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  216. _GroupCostParameterRepository = GroupCostParameterRepository;
  217. _hotelPriceRep = hotelPriceRep;
  218. _customersRep = customersRep;
  219. _setDataRep = setDataRep;
  220. _tourClientListRep = tourClientListRep;
  221. _teamRateRep = teamRateRep;
  222. _hubContext = hubContext;
  223. _usersRep = usersRep;
  224. _juHeApi = juHeApi;
  225. _invertedListRep = invertedListRep;
  226. _visaFeeInfoRep = visaFeeInfoRep;
  227. _ticketBlackCodeRep = ticketBlackCodeRep;
  228. _hotelInquiryRep = hotelInquiryRep;
  229. _threeCodeRepository = threeCodeRepository;
  230. _feeAuditRep = feeAuditRep;
  231. _visaCommissionRep = visaCommissionRep;
  232. _ffrRep = ffrRep;
  233. _opinionaireRep = opinionaireRep;
  234. _currencyInit = new List<CurrencyInfo>()
  235. {
  236. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  237. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  238. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  239. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  240. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  241. };
  242. _portTypeData = new List<int>() { 2, 3 };
  243. _tableorRep = tableorRep;
  244. _enterExitCostDraftRep = enterExitCostDraftRep;
  245. _restaurantRep = restaurantRep;
  246. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  247. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  248. }
  249. #region 流程管控
  250. /// <summary>
  251. /// 获取团组流程管控信息
  252. /// </summary>
  253. /// <param name="_jsonDto">查询参数</param>
  254. /// <returns></returns>
  255. [HttpPost]
  256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  257. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  258. {
  259. if (string.IsNullOrEmpty(_jsonDto.Paras))
  260. {
  261. return Ok(JsonView(false, "参数为空"));
  262. }
  263. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  264. if (_ScheduleDto != null)
  265. {
  266. if (_ScheduleDto.SearchType == 2)//获取列表
  267. {
  268. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  269. return Ok(JsonView(_grpScheduleViewList));
  270. }
  271. else//获取对象
  272. {
  273. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  274. if (_grpScheduleView != null)
  275. {
  276. return Ok(JsonView(_grpScheduleView));
  277. }
  278. }
  279. }
  280. else
  281. {
  282. return Ok(JsonView(false, "参数反序列化失败"));
  283. }
  284. return Ok(JsonView(false, "暂无数据!"));
  285. }
  286. /// <summary>
  287. /// 修改团组流程管控详细表数据
  288. /// </summary>
  289. /// <param name="dto"></param>
  290. /// <returns></returns>
  291. [HttpPost]
  292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  293. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  294. {
  295. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  296. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  297. .SetColumns(it => it.Duty == _detail.Duty)
  298. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  299. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  300. .SetColumns(it => it.JobContent == _detail.JobContent)
  301. .SetColumns(it => it.Remark == _detail.Remark)
  302. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  303. .Where(s => s.Id == dto.Id)
  304. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  305. .ExecuteCommandAsync();
  306. if (result > 0)
  307. {
  308. return Ok(JsonView(true, "保存成功!"));
  309. }
  310. return Ok(JsonView(false, "保存失败!"));
  311. }
  312. /// <summary>
  313. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  314. /// </summary>
  315. /// <param name="dto"></param>
  316. /// <returns></returns>
  317. [HttpPost]
  318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  319. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  320. {
  321. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  322. _detail.IsDel = 1;
  323. _detail.DeleteUserId = dto.Duty;
  324. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  325. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  326. .SetColumns(it => it.IsDel == _detail.IsDel)
  327. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  328. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  329. .Where(it => it.Id == dto.Id)
  330. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  331. //.WhereColumns(s => s.Id == dto.Id)
  332. .ExecuteCommandAsync();
  333. if (result > 0)
  334. {
  335. return Ok(JsonView(true, "删除成功!"));
  336. }
  337. return Ok(JsonView(false, "删除失败!"));
  338. }
  339. /// <summary>
  340. /// 增加团组流程管控详细表数据
  341. /// </summary>
  342. /// <param name="dto"></param>
  343. /// <returns></returns>
  344. [HttpPost]
  345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  346. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  347. {
  348. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  349. if (DateTime.Now < _detail.ExpectBeginDt)
  350. {
  351. _detail.StepStatus = 0;
  352. }
  353. else
  354. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  355. _detail.StepStatus = 1;
  356. }
  357. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  358. if (result > 0)
  359. {
  360. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  361. return Ok(JsonView(true, "添加成功!", _result));
  362. }
  363. return Ok(JsonView(false, "添加失败!"));
  364. }
  365. #endregion
  366. #region 团组前期信息
  367. /// <summary>
  368. /// 团组前期信息 List
  369. /// </summary>
  370. /// <returns></returns>
  371. [HttpPost]
  372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  373. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  374. {
  375. var search = dto.Search;
  376. int[] nameTempIds = new int[] { 1, 12, 28 },
  377. countryTempIds = new int[] { 2, 13, 29 },
  378. daysTempIds = new int[] { 4, 15, 31 },
  379. ppNumTempIds = new int[] { 6 };
  380. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  381. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  382. .Where((opi, u) => opi.IsDel == 0)
  383. .OrderByDescending((opi, u) => opi.CreateTime)
  384. .Select((opi, u) => new GroupOrderPreInfoListView()
  385. {
  386. Id = opi.Id,
  387. Name = opi.Name,
  388. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  389. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  390. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  391. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  392. Operator = u.CnName,
  393. OperationTime = opi.CreateTime
  394. })
  395. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  396. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  397. .ToListAsync();
  398. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  399. int total = list.Count;
  400. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  401. var listPageData1 = listPageData
  402. .Skip((dto.PageIndex - 1) * dto.PageSize)
  403. .Take(dto.PageSize)
  404. .ToList();
  405. var infoIds = listPageData1.Select(x => x.Id).ToList();
  406. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  407. .Where(x => x.IsDel == 0 && x.STid == 109)
  408. .ToArrayAsync();
  409. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  410. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  411. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  412. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  413. .ToListAsync();
  414. foreach (var item in listPageData1)
  415. {
  416. var typeDatas1 = typeDatas.Select(x => new
  417. {
  418. Id = x.Id,
  419. Name = x.Name,
  420. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  421. }).ToArray();
  422. item.VersionDetails = typeDatas1;
  423. }
  424. return Ok(JsonView(listPageData1, listPageData1.Count));
  425. }
  426. /// <summary>
  427. /// 团组前期信息 Init
  428. /// </summary>
  429. /// <returns></returns>
  430. [HttpGet("{userId}")]
  431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  432. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  433. {
  434. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  435. }
  436. /// <summary>
  437. /// 国家数据源
  438. /// </summary>
  439. /// <param name="pageIndex">当前页码</param>
  440. /// <param name="pageSize">每页条数</param>
  441. /// <param name="search">查询条件</param>
  442. /// <returns></returns>
  443. [HttpGet]
  444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  445. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  446. {
  447. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  448. if (pageIndex == 0 && pageSize == 0)
  449. {
  450. //所有数据
  451. return Ok(JsonView(countrys, countrys.Count));
  452. }
  453. //分页
  454. int skip = (pageIndex - 1) * pageSize;
  455. int take = pageSize;
  456. if (!string.IsNullOrEmpty(search))
  457. {
  458. IEnumerable<char> charSequence = search.Select(c => c);
  459. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  460. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  461. return Ok(JsonView(pageData, pageResult1.Count));
  462. }
  463. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  464. return Ok(JsonView(pageResult2, countrys.Count));
  465. }
  466. /// <summary>
  467. /// 城市数据源
  468. /// </summary>
  469. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  470. /// <param name="pageIndex">当前页码</param>
  471. /// <param name="pageSize">每页条数</param>
  472. /// <param name="search">查询条件</param>
  473. /// <returns></returns>
  474. [HttpGet("{countryLabel}")]
  475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  476. public async Task<IActionResult> CityByCountry(
  477. string countryLabel,
  478. [FromQuery] int pageIndex,
  479. [FromQuery] int pageSize,
  480. [FromQuery] string search)
  481. {
  482. countryLabel = HttpUtility.UrlDecode(countryLabel);
  483. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  484. var citys = Array.Empty<string?>();
  485. if (countryList.Any())
  486. {
  487. var cityDatas = await _sqlSugar
  488. .Queryable<Grp_NationalTravelFee>()
  489. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  490. .ToArrayAsync();
  491. foreach (var item in cityDatas)
  492. {
  493. if (item.City.Contains("城市"))
  494. {
  495. item.City = item.Country + "-所有城市";
  496. }
  497. }
  498. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  499. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  500. }
  501. if (pageIndex == 0 && pageSize == 0)
  502. {
  503. //所有数据
  504. return Ok(JsonView(citys, citys?.Length ?? 0));
  505. }
  506. //分页
  507. int skip = (pageIndex - 1) * pageSize;
  508. int take = pageSize;
  509. if (!string.IsNullOrEmpty(search))
  510. {
  511. IEnumerable<char> charSequence = search.Select(c => c);
  512. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  513. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  514. return Ok(JsonView(pageData, pageResult1.Count()));
  515. }
  516. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  517. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  518. }
  519. /// <summary>
  520. /// 团组前期信息 Info
  521. /// </summary>
  522. /// <param name="dto">Id</param>
  523. /// <param name="portType">Id</param>
  524. /// <returns></returns>
  525. [HttpGet("{Id}/{TempId}")]
  526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  527. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto, int portType = 1)
  528. {
  529. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  530. }
  531. /// <summary>
  532. /// 团组前期信息 移动端 Info
  533. /// </summary>
  534. /// <param name="dto">Id</param>
  535. /// <returns></returns>
  536. [HttpGet("{Id}/{TempId}")]
  537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  538. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  539. {
  540. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  541. }
  542. /// <summary>
  543. /// 团组前期信息 Save
  544. /// </summary>
  545. /// <param name="dto">Id</param>
  546. /// <returns></returns>
  547. [HttpPost]
  548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  549. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  550. {
  551. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  552. }
  553. /// <summary>
  554. /// 团组前期信息 Del
  555. /// </summary>
  556. /// <param name="dto">Id</param>
  557. /// <returns></returns>
  558. [HttpPost]
  559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  560. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  561. {
  562. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  563. }
  564. /// <summary>
  565. /// 团组前期信息 文件下载
  566. /// </summary>
  567. /// <param name="dto">Id</param>
  568. /// <returns></returns>
  569. [HttpGet("{Id}/{TempId}")]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  572. {
  573. int id = dto.Id, tempId = dto.TempId;
  574. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  575. var data = view.Data as GrpOrderPreInfoView;
  576. #region Excel
  577. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  578. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  579. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  580. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  581. var fileNamePrefix = string.Empty;
  582. if (tempId == 1405)
  583. {
  584. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  585. fileNamePrefix = $"{data.Name}_无商邀版";
  586. }
  587. else if (tempId == 1406)
  588. {
  589. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  590. fileNamePrefix = $"{data.Name}_有商邀版";
  591. }
  592. else
  593. {
  594. //tempId == 1404 默认下载
  595. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  596. fileNamePrefix = $"{data.Name}_单接送机";
  597. }
  598. foreach (var item in data.Items)
  599. {
  600. var obj = item.NewValue;
  601. if (obj == null) item.OriginVal = "";
  602. else if (obj.Equals("有") || obj.Equals("无"))
  603. {
  604. item.OriginVal = obj.ToString();
  605. }
  606. else if (obj is object[] objArray)
  607. {
  608. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  609. item.OriginVal = string.Join("、", stringArray);
  610. }
  611. else if (obj is string[] stringArray)
  612. {
  613. item.OriginVal = string.Join("、", stringArray);
  614. }
  615. else if (obj.Equals("-"))
  616. {
  617. item.OriginVal = "";
  618. }
  619. }
  620. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  621. fileName = CommonFun.ValidFileName(fileName);
  622. //载入模板
  623. WorkbookDesigner designer = new WorkbookDesigner();
  624. designer.Workbook = new Workbook(tempPath);
  625. if (tempId == 1406)
  626. {
  627. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  628. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  629. for (int i = 1; i <= view2.Length; i++)
  630. {
  631. view2[i - 1].Index = i;
  632. }
  633. designer.SetDataSource("View1", view1);
  634. designer.SetDataSource("View2", view2);
  635. }
  636. else
  637. {
  638. designer.SetDataSource("View", data.Items);
  639. }
  640. designer.Process();
  641. if (!Directory.Exists(savePath))
  642. {
  643. Directory.CreateDirectory(savePath);
  644. }
  645. string serverPath = $"{savePath}{fileName}";
  646. designer.Workbook.Save(serverPath);
  647. string rst = $"{servicePath}{ftpPath}{fileName}";
  648. #endregion
  649. return Ok(JsonView(new { url = rst }));
  650. }
  651. #endregion
  652. #region 团组基本信息
  653. /// <summary>
  654. /// 接团信息列表
  655. /// </summary>
  656. /// <param name="dto">团组列表请求dto</param>
  657. /// <returns></returns>
  658. [HttpPost]
  659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  660. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  661. {
  662. var groupData = await _groupRepository.GetGroupList(dto);
  663. if (groupData.Code != 0)
  664. {
  665. return Ok(JsonView(false, groupData.Msg));
  666. }
  667. return Ok(JsonView(groupData.Data));
  668. }
  669. /// <summary>
  670. /// 分页查询团组列表
  671. /// </summary>
  672. /// <param name="dto"></param>
  673. /// <returns></returns>
  674. [HttpPost]
  675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  676. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  677. {
  678. var watch = new Stopwatch();
  679. watch.Start();
  680. RefAsync<int> total = 0;
  681. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  682. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  683. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  684. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  685. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  686. .Distinct()
  687. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  688. watch.Stop();
  689. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  690. }
  691. /// <summary>
  692. /// 接团信息列表 Page Init
  693. /// </summary>
  694. /// <returns></returns>
  695. [HttpPost]
  696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  697. public async Task<IActionResult> PostGroupPageListInit()
  698. {
  699. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  700. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  701. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  702. var _view = new
  703. {
  704. depData = depDatas,
  705. rankData = rankDatas
  706. };
  707. return Ok(JsonView(true, "查询成功!", _view));
  708. }
  709. /// <summary>
  710. /// 接团信息列表 Page
  711. /// </summary>
  712. /// <param name="dto">团组列表请求dto</param>
  713. /// <returns></returns>
  714. [HttpPost]
  715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  716. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  717. {
  718. #region 参数验证
  719. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  720. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  721. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  722. #region 页面操作权限验证
  723. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  724. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  725. #endregion
  726. #endregion
  727. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  728. {
  729. string sqlWhere = string.Empty;
  730. if (dto.IsSure == 0) //未完成
  731. {
  732. sqlWhere += string.Format(@" And IsSure = 0");
  733. }
  734. else if (dto.IsSure == 1) //已完成
  735. {
  736. sqlWhere += string.Format(@" And IsSure = 1");
  737. }
  738. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  739. {
  740. string tj = dto.SearchCriteria;
  741. 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}%')",
  742. tj, tj, tj, tj, tj);
  743. }
  744. if (int.TryParse(dto.Rank, out int rankId))
  745. {
  746. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  747. }
  748. string sqlWhere1 = string.Empty;
  749. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  750. {
  751. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  752. }
  753. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  754. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  755. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  756. JietuanOperator,IsSure,CreateTime,IsBid
  757. From (
  758. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  759. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  760. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  761. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  762. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  763. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  764. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  765. From Grp_DelegationInfo gdi
  766. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  767. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  768. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  769. Where gdi.IsDel = 0 {0}
  770. ) temp {1}", sqlWhere, sqlWhere1);
  771. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  772. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  773. var _view = new
  774. {
  775. PageFuncAuth = pageFunAuthView,
  776. Data = _DelegationList
  777. };
  778. return Ok(JsonView(true, "查询成功!", _view, total));
  779. }
  780. else
  781. {
  782. return Ok(JsonView(false, "查询失败"));
  783. }
  784. }
  785. /// <summary>
  786. /// 团组列表
  787. /// </summary>
  788. /// <returns></returns>
  789. [HttpPost]
  790. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  791. {
  792. #region 参数验证
  793. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  794. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  795. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  796. #region 页面操作权限验证
  797. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  798. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  799. #endregion
  800. #endregion
  801. if (dto.PortType != 1 && dto.PortType != 2)
  802. {
  803. return Ok(JsonView(false, "查询失败!"));
  804. }
  805. string orderbyStr = "order by gdi.CreateTime Desc";
  806. string sqlWhere = string.Empty;
  807. if (dto.IsSure == 0) //未完成
  808. {
  809. sqlWhere += string.Format(@" And IsSure = 0");
  810. }
  811. else if (dto.IsSure == 1) //已完成
  812. {
  813. sqlWhere += string.Format(@" And IsSure = 1");
  814. }
  815. //团组类型
  816. if (dto.TeamDid > 0)
  817. {
  818. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  819. }
  820. //团组名称
  821. if (!string.IsNullOrEmpty(dto.TeamName))
  822. {
  823. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  824. }
  825. //客户名称
  826. if (!string.IsNullOrEmpty(dto.ClientName))
  827. {
  828. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  829. }
  830. //客户单位
  831. if (!string.IsNullOrEmpty(dto.ClientUnit))
  832. {
  833. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  834. }
  835. //出访时间
  836. if (!string.IsNullOrEmpty(dto.visitDataTime))
  837. {
  838. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  839. orderbyStr = "order by gdi.VisitDate";
  840. }
  841. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  842. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  843. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  844. JietuanOperator,IsSure,CreateTime
  845. From (
  846. Select row_number() over({0}) as Row_Number,
  847. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  848. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  849. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  850. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  851. From Grp_DelegationInfo gdi
  852. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  853. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  854. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  855. Where gdi.IsDel = 0 {1}
  856. ) temp ", orderbyStr, sqlWhere);
  857. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  858. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  859. #region 处理所属部门
  860. /*
  861. * 1.sq 和 gyy 等显示 市场部
  862. * 2.王鸽和主管及张总还有管理员号统一国交部
  863. * 2-1. 4 管理员 ,21 张海麟
  864. */
  865. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  866. List<int> userIds1 = new List<int>() { 4, 21 };
  867. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  868. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  869. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  870. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  871. .ToList();
  872. foreach (var item in _DelegationList)
  873. {
  874. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  875. }
  876. #endregion
  877. var _view = new
  878. {
  879. PageFuncAuth = pageFunAuthView,
  880. Data = _DelegationList
  881. };
  882. return Ok(JsonView(true, "查询成功!", _view, total));
  883. }
  884. /// <summary>
  885. /// 接团信息详情
  886. /// </summary>
  887. /// <param name="dto">团组info请求dto</param>
  888. /// <returns></returns>
  889. [HttpPost]
  890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  891. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  892. {
  893. var groupData = await _groupRepository.GetGroupInfo(dto);
  894. if (groupData.Code != 0)
  895. {
  896. return Ok(JsonView(false, groupData.Msg));
  897. }
  898. return Ok(JsonView(groupData.Data));
  899. }
  900. /// <summary>
  901. /// 接团信息 编辑添加
  902. /// 基础信息数据源
  903. /// </summary>
  904. /// <param name="dto"></param>
  905. /// <returns></returns>
  906. [HttpPost]
  907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  908. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  909. {
  910. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  911. if (groupData.Code != 0)
  912. {
  913. return Ok(JsonView(false, groupData.Msg));
  914. }
  915. return Ok(JsonView(groupData.Data));
  916. }
  917. /// <summary>
  918. /// 成本修改团组信息
  919. /// </summary>
  920. /// <param name="dto"></param>
  921. /// <returns></returns>
  922. [HttpPost]
  923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  924. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  925. {
  926. var jw = JsonView(false, "操作失败");
  927. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  928. if (di == null)
  929. {
  930. jw.Msg = "参数有误!";
  931. return Ok(jw);
  932. }
  933. #region 添加出访起止时间
  934. var startTime = new DateTime();
  935. var endTime = new DateTime();
  936. if (DateTime.TryParse(dto.VisitDate, out startTime))
  937. {
  938. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  939. }
  940. else
  941. {
  942. jw.Msg = "参数有误!";
  943. return Ok(jw);
  944. }
  945. #endregion
  946. di.VisitDate = startTime;
  947. di.VisitPNumber = dto.VisitPNumber;
  948. di.VisitDays = dto.VisitDays;
  949. di.VisitStartDate = startTime;
  950. di.VisitEndDate = endTime;
  951. var count = _sqlSugar.Updateable(di)
  952. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  953. .ExecuteCommand();
  954. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  955. }
  956. /// <summary>
  957. /// 接团信息 编辑添加
  958. /// 省份-城市 基础信息数据源
  959. /// </summary>
  960. /// <param name="dto"></param>
  961. /// <returns></returns>
  962. [HttpPost]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  965. {
  966. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  967. string search = dto.Search;
  968. var data = await _groupRepository.CityBasicSource();
  969. int total = data.Length;
  970. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  971. .Skip((pageIndex - 1) * pageSize)
  972. .Take(pageSize)
  973. .ToArray();
  974. return Ok(JsonView(data, total));
  975. }
  976. /// <summary>
  977. /// 接团信息 操作(增改)
  978. /// </summary>
  979. /// <param name="dto"></param>
  980. /// <returns></returns>
  981. [HttpPost]
  982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  983. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  984. {
  985. // 创建 Stopwatch 实例
  986. Stopwatch stopwatch = Stopwatch.StartNew();
  987. decimal ffrPrice = 0.00M;
  988. DateTime? visitDt = null;
  989. if (dto.Status == 2)
  990. {
  991. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  992. if (groupInfo != null)
  993. {
  994. ffrPrice = groupInfo.PaymentMoney;
  995. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  996. }
  997. }
  998. var groupData = await _groupRepository.GroupOperation(dto);
  999. if (groupData.Code != 0)
  1000. {
  1001. return Ok(JsonView(false, groupData.Msg));
  1002. }
  1003. int diId = 0;
  1004. try
  1005. {
  1006. //添加时 默认加入团组汇率
  1007. if (dto.Status == 1) //添加
  1008. {
  1009. diId = groupData.Data;
  1010. //添加默认币种
  1011. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1012. //默认分配权限
  1013. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1014. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1015. var _managerIds = new List<int>() { 22, 32, 21 };
  1016. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1017. if (userIds.Count > 0)
  1018. {
  1019. userIds.Add(208);
  1020. //创建团组管控
  1021. GroupStepForDelegation.CreateWorkStep(diId);
  1022. //发送消息
  1023. string groupName = dto.TeamName;
  1024. string createGroupUser = string.Empty;
  1025. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1026. if (userInfo != null) createGroupUser = userInfo.CnName;
  1027. string title = $"系统通知";
  1028. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1029. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1030. }
  1031. //默认创建倒推表
  1032. await _invertedListRep._Create(dto.UserId, diId);
  1033. }
  1034. else if (dto.Status == 2)
  1035. {
  1036. diId = dto.Id;
  1037. }
  1038. #region 签证人员团组时间通知
  1039. #region 计算出访起止时间
  1040. var startTime = new DateTime();
  1041. var endTime = new DateTime();
  1042. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1043. {
  1044. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1045. }
  1046. #endregion
  1047. #endregion
  1048. #region 团组操作默认添加/修改收款账单
  1049. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1050. {
  1051. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1052. .Where(x => x.IsDel == 0 &&
  1053. x.Diid == diId &&
  1054. x.Remark.Equals("预付款")
  1055. )
  1056. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1057. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1058. .FirstAsync();
  1059. ffrInfo = new Fin_ForeignReceivables()
  1060. {
  1061. Diid = diId,
  1062. PriceName = dto.ClientUnit,
  1063. Price = dto.PaymentMoney,
  1064. Count = 1,
  1065. Unit = $"元",
  1066. ItemSumPrice = dto.PaymentMoney,
  1067. Rate = 1.0000M,
  1068. Currency = 836,
  1069. AddingWay = 0,
  1070. CreateUserId = dto.UserId,
  1071. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1072. Remark = $"预付款"
  1073. };
  1074. if (ffrInfo == null) //Add
  1075. {
  1076. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1077. }
  1078. else //修改
  1079. {
  1080. await _sqlSugar.Updateable(ffrInfo)
  1081. .UpdateColumns(x => new
  1082. {
  1083. x.PriceName,
  1084. x.Price,
  1085. x.ItemSumPrice,
  1086. x.CreateTime,
  1087. x.CreateUserId
  1088. })
  1089. .WhereColumns(x => x.Id)
  1090. .ExecuteCommandAsync();
  1091. }
  1092. }
  1093. #endregion
  1094. if (diId > 0)
  1095. {
  1096. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1097. }
  1098. // 停止计时
  1099. stopwatch.Stop();
  1100. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1101. }
  1102. catch (Exception ex)
  1103. {
  1104. // 停止计时
  1105. stopwatch.Stop();
  1106. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1107. Logs(ex.Message);
  1108. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1109. }
  1110. // 停止计时
  1111. stopwatch.Stop();
  1112. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1113. }
  1114. /// <summary>
  1115. /// 接团流程操作(增改)
  1116. /// 安卓端使用 建团时添加客户名单
  1117. /// </summary>
  1118. /// <param name="dto"></param>
  1119. /// <returns></returns>
  1120. [HttpPost]
  1121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1122. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1123. {
  1124. #region 参数验证
  1125. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1126. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1127. #region 页面操作权限验证
  1128. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1129. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1130. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1131. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1132. #endregion
  1133. #endregion
  1134. try
  1135. {
  1136. //_sqlSugar.BeginTran();
  1137. decimal ffrPrice = 0.00M;
  1138. DateTime? visitDt = null;
  1139. if (dto.Status == 2)
  1140. {
  1141. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1142. if (groupInfo != null)
  1143. {
  1144. ffrPrice = groupInfo.PaymentMoney;
  1145. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1146. }
  1147. }
  1148. var _dto = new GroupOperationDto();
  1149. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1150. var groupData = await _groupRepository.GroupOperation(_dto);
  1151. if (groupData.Code != 0)
  1152. {
  1153. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1154. }
  1155. int diId = 0;
  1156. //添加时 默认加入团组汇率
  1157. if (dto.Status == 1) //添加
  1158. {
  1159. diId = groupData.Data;
  1160. //添加默认币种
  1161. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1162. //默认分配权限
  1163. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1164. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1165. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1166. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1167. if (userIds.Count > 0)
  1168. {
  1169. userIds.Add(208);
  1170. //创建团组管控
  1171. GroupStepForDelegation.CreateWorkStep(diId);
  1172. //发送消息
  1173. string groupName = dto.TeamName;
  1174. string createGroupUser = string.Empty;
  1175. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1176. if (userInfo != null) createGroupUser = userInfo.CnName;
  1177. string title = $"系统通知";
  1178. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1179. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1180. }
  1181. #region 应用推送
  1182. try
  1183. {
  1184. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1185. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1186. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1187. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1188. {
  1189. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1190. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1191. }
  1192. }
  1193. catch (Exception ex)
  1194. {
  1195. }
  1196. #endregion
  1197. //默认创建倒推表
  1198. await _invertedListRep._Create(dto.UserId, diId);
  1199. }
  1200. if (dto.Status == 2)
  1201. {
  1202. diId = dto.Id;
  1203. if (diId == 0)
  1204. {
  1205. //_sqlSugar.RollbackTran();
  1206. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1207. }
  1208. }
  1209. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1210. if (viewData.Code != 0)
  1211. {
  1212. //_sqlSugar.RollbackTran();
  1213. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1214. }
  1215. #region 团组操作默认添加/修改收款账单
  1216. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1217. {
  1218. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1219. .Where(x => x.IsDel == 0 &&
  1220. x.Diid == diId &&
  1221. x.Remark.Equals("预付款")
  1222. )
  1223. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1224. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1225. .FirstAsync();
  1226. ffrInfo = new Fin_ForeignReceivables()
  1227. {
  1228. Diid = diId,
  1229. PriceName = dto.ClientUnit,
  1230. Price = dto.PaymentMoney,
  1231. Count = 1,
  1232. Unit = $"元",
  1233. ItemSumPrice = dto.PaymentMoney,
  1234. Rate = 1.0000M,
  1235. Currency = 836,
  1236. AddingWay = 0,
  1237. CreateUserId = dto.UserId,
  1238. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1239. Remark = $"预付款"
  1240. };
  1241. if (ffrInfo == null) //Add
  1242. {
  1243. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1244. }
  1245. else //修改
  1246. {
  1247. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1248. .UpdateColumns(x => new
  1249. {
  1250. x.PriceName,
  1251. x.Price,
  1252. x.ItemSumPrice,
  1253. x.CreateTime,
  1254. x.CreateUserId
  1255. })
  1256. .WhereColumns(x => x.Id)
  1257. .ExecuteCommandAsync();
  1258. }
  1259. }
  1260. #endregion
  1261. #region 签证人员团组时间通知
  1262. #region 计算出访起止时间
  1263. var startTime = new DateTime();
  1264. var endTime = new DateTime();
  1265. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1266. {
  1267. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1268. }
  1269. #endregion
  1270. if (diId > 0)
  1271. {
  1272. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1273. }
  1274. #endregion
  1275. //_sqlSugar.CommitTran();
  1276. return Ok(JsonView(true, "添加成功"));
  1277. }
  1278. catch (Exception ex)
  1279. {
  1280. _sqlSugar.RollbackTran();
  1281. return Ok(JsonView(false, ex.Message));
  1282. }
  1283. }
  1284. /// <summary>
  1285. /// 接团流程操作(增改)
  1286. /// 安卓端使用 建团时添加客户名单
  1287. /// </summary>
  1288. /// <param name="dto"></param>
  1289. /// <returns></returns>
  1290. [HttpPost]
  1291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1292. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1293. {
  1294. #region 参数验证
  1295. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1296. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1297. #region 页面操作权限验证
  1298. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1299. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1300. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1301. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1302. #endregion
  1303. #endregion
  1304. _sqlSugar.BeginTran();
  1305. decimal ffrPrice = 0.00M;
  1306. DateTime? visitDt = null;
  1307. if (dto.Status == 2)
  1308. {
  1309. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1310. if (groupInfo != null)
  1311. {
  1312. ffrPrice = groupInfo.PaymentMoney;
  1313. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1314. }
  1315. }
  1316. var _dto = new GroupOperationDto();
  1317. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1318. var groupData = await _groupRepository.GroupOperation(_dto);
  1319. if (groupData.Code != 0)
  1320. {
  1321. _sqlSugar.RollbackTran();
  1322. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1323. }
  1324. try
  1325. {
  1326. int diId = 0;
  1327. //添加时 默认加入团组汇率
  1328. if (dto.Status == 1) //添加
  1329. {
  1330. diId = groupData.Data;
  1331. //添加默认币种
  1332. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1333. //默认分配权限
  1334. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1335. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1336. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1337. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1338. if (userIds.Count > 0)
  1339. {
  1340. userIds.Add(208);
  1341. //创建团组管控
  1342. GroupStepForDelegation.CreateWorkStep(diId);
  1343. //发送消息
  1344. string groupName = dto.TeamName;
  1345. string createGroupUser = string.Empty;
  1346. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1347. if (userInfo != null) createGroupUser = userInfo.CnName;
  1348. string title = $"系统通知";
  1349. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1350. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1351. }
  1352. #region 应用推送
  1353. try
  1354. {
  1355. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1356. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1357. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1358. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1359. {
  1360. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1361. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1362. }
  1363. }
  1364. catch (Exception ex)
  1365. {
  1366. _sqlSugar.CommitTran();
  1367. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1368. }
  1369. #endregion
  1370. //默认创建倒推表
  1371. await _invertedListRep._Create(dto.UserId, diId);
  1372. }
  1373. else if (dto.Status == 2)
  1374. {
  1375. diId = dto.Id;
  1376. if (diId == 0)
  1377. {
  1378. _sqlSugar.RollbackTran();
  1379. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1380. }
  1381. }
  1382. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1383. if (viewData.Code != 0)
  1384. {
  1385. _sqlSugar.RollbackTran();
  1386. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1387. }
  1388. #region 团组操作默认添加/修改收款账单
  1389. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1390. {
  1391. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1392. .Where(x => x.IsDel == 0 &&
  1393. x.Diid == diId &&
  1394. x.Remark.Equals("预付款")
  1395. )
  1396. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1397. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1398. .FirstAsync();
  1399. ffrInfo = new Fin_ForeignReceivables()
  1400. {
  1401. Diid = diId,
  1402. PriceName = dto.ClientUnit,
  1403. Price = dto.PaymentMoney,
  1404. Count = 1,
  1405. Unit = $"元",
  1406. ItemSumPrice = dto.PaymentMoney,
  1407. Rate = 1.0000M,
  1408. Currency = 836,
  1409. AddingWay = 0,
  1410. CreateUserId = dto.UserId,
  1411. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1412. Remark = $"预付款"
  1413. };
  1414. if (ffrInfo == null) //Add
  1415. {
  1416. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1417. }
  1418. else //修改
  1419. {
  1420. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1421. .UpdateColumns(x => new
  1422. {
  1423. x.PriceName,
  1424. x.Price,
  1425. x.ItemSumPrice,
  1426. x.CreateTime,
  1427. x.CreateUserId
  1428. })
  1429. .WhereColumns(x => x.Id)
  1430. .ExecuteCommandAsync();
  1431. }
  1432. }
  1433. #endregion
  1434. #region 签证人员团组时间通知
  1435. #region 计算出访起止时间
  1436. var startTime = new DateTime();
  1437. var endTime = new DateTime();
  1438. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1439. {
  1440. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1441. }
  1442. #endregion
  1443. if (diId > 0)
  1444. {
  1445. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1446. }
  1447. #endregion
  1448. _sqlSugar.CommitTran();
  1449. return Ok(JsonView(true));
  1450. }
  1451. catch (Exception ex)
  1452. {
  1453. _sqlSugar.RollbackTran();
  1454. return Ok(JsonView(false, ex.Message));
  1455. }
  1456. }
  1457. /// <summary>
  1458. /// 接团信息 操作(删除)
  1459. /// </summary>
  1460. /// <param name="dto"></param>
  1461. /// <returns></returns>
  1462. [HttpPost]
  1463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1464. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1465. {
  1466. var diId = dto.Id;
  1467. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1468. #region 删除 验证
  1469. /*
  1470. * 1、收款账单数据:0 条
  1471. * 2、收款退还数据:0 条
  1472. * 3、机票费用数据:0 条
  1473. * 4、签证费用数据:0 条
  1474. * 5、保险费用数据:0 条
  1475. * 6、酒店费用数据:0 条
  1476. * 7、公务出访数据:1 条
  1477. * 8、邀请公务活动费用数据:1 条
  1478. * 9、OP费用数据:5 条
  1479. * 10、其他费用数据:0 条
  1480. * 11、团组日付报销费用数据:0 条
  1481. *
  1482. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1483. */
  1484. //收款账单
  1485. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1486. //收款退还
  1487. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1488. //机票费用
  1489. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1490. //签证费用
  1491. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1492. //保险费用
  1493. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1494. //酒店费用
  1495. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1496. //公务出访
  1497. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1498. //邀请公务活动费用
  1499. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1500. //OP费用
  1501. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1502. //其他费用
  1503. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1504. //团组日付报销费用
  1505. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1506. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1507. if (feeCount > 0)
  1508. {
  1509. var delMsgTips = new StringBuilder();
  1510. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1511. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1512. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1513. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1514. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1515. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1516. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1517. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1518. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1519. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1520. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1521. delMsgTips.AppendLine($"");
  1522. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1523. return Ok(JsonView(false, delMsgTips.ToString()));
  1524. }
  1525. #endregion
  1526. var groupData = await _groupRepository.GroupDel(dto);
  1527. if (groupData.Code != 0)
  1528. {
  1529. return Ok(JsonView(false, groupData.Msg));
  1530. }
  1531. return Ok(JsonView(true));
  1532. }
  1533. /// <summary>
  1534. /// 获取团组销售报价号
  1535. /// 团组添加时 使用
  1536. /// </summary>
  1537. /// <returns></returns>
  1538. [HttpPost]
  1539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1540. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1541. {
  1542. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1543. if (groupData.Code != 0)
  1544. {
  1545. return Ok(JsonView(false, groupData.Msg));
  1546. }
  1547. object salesQuoteNo = new
  1548. {
  1549. SalesQuoteNo = groupData.Data
  1550. };
  1551. return Ok(JsonView(salesQuoteNo));
  1552. }
  1553. /// <summary>
  1554. /// 设置确认出团
  1555. /// </summary>
  1556. /// <param name="dto"></param>
  1557. /// <returns></returns>
  1558. [HttpPost]
  1559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1560. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1561. {
  1562. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1563. if (groupData.Code != 0)
  1564. {
  1565. return Ok(JsonView(false, groupData.Msg));
  1566. }
  1567. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1568. #region OA消息推送
  1569. try
  1570. {
  1571. string groupName = groupInfo.TeamName;
  1572. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1573. string title = $"系统通知";
  1574. string content = $"团组[{groupName}]已确认出团!";
  1575. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1576. }
  1577. catch (Exception ex)
  1578. {
  1579. }
  1580. #endregion
  1581. #region 应用推送
  1582. try
  1583. {
  1584. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1585. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1586. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1587. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1588. {
  1589. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1590. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1591. }
  1592. }
  1593. catch (Exception ex)
  1594. {
  1595. }
  1596. #endregion
  1597. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1598. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1599. }
  1600. /// <summary>
  1601. /// 获取团组名称data And 签证国别Data
  1602. /// </summary>
  1603. /// <param name="dto"></param>
  1604. /// <returns></returns>
  1605. [HttpPost]
  1606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1607. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1608. {
  1609. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1610. if (groupData.Code != 0)
  1611. {
  1612. return Ok(JsonView(false, groupData.Msg));
  1613. }
  1614. return Ok(JsonView(groupData.Data));
  1615. }
  1616. /// <summary>
  1617. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1618. /// </summary>
  1619. /// <returns></returns>
  1620. [HttpPost]
  1621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1622. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1623. {
  1624. try
  1625. {
  1626. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1627. if (groupData.Code != 0)
  1628. {
  1629. return Ok(JsonView(false, groupData.Msg));
  1630. }
  1631. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1632. }
  1633. catch (Exception ex)
  1634. {
  1635. return Ok(JsonView(false, "程序错误!"));
  1636. throw;
  1637. }
  1638. }
  1639. /// <summary>
  1640. /// 团组清单 Excel
  1641. /// </summary>
  1642. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1643. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1644. /// <returns></returns>
  1645. [HttpGet]
  1646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1647. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1648. {
  1649. DateTime _beginDt, _endDt;
  1650. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1651. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1652. if (!beginBool && !endBool)
  1653. {
  1654. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1655. }
  1656. string sql = string.Format(@"
  1657. SELECT
  1658. ROW_NUMBER,
  1659. Id,
  1660. SalesQuoteNo,
  1661. TourCode,
  1662. TeamTypeId,
  1663. TeamType,
  1664. TeamLevId,
  1665. TeamLev,
  1666. TeamName,
  1667. ClientName,
  1668. ClientUnit,
  1669. VisitDate,
  1670. VisitDays,
  1671. VisitPNumber,
  1672. JietuanOperatorId,
  1673. JietuanOperator,
  1674. IsSure,
  1675. CreateUserName,
  1676. IsBid
  1677. FROM
  1678. (
  1679. SELECT
  1680. ROW_NUMBER() OVER(
  1681. ORDER BY
  1682. gdi.VisitDate Desc
  1683. ) AS ROW_NUMBER,
  1684. gdi.Id,
  1685. SalesQuoteNo,
  1686. TourCode,
  1687. ssd.Id TeamTypeId,
  1688. ssd.Name TeamType,
  1689. ssd1.Id TeamLevId,
  1690. ssd1.Name TeamLev,
  1691. TeamName,
  1692. ClientName,
  1693. ClientUnit,
  1694. VisitDate,
  1695. VisitDays,
  1696. VisitPNumber,
  1697. JietuanOperator JietuanOperatorId,
  1698. su.CnName JietuanOperator,
  1699. IsSure,
  1700. gdi.CreateTime,
  1701. su1.CnName As CreateUserName,
  1702. gdi.IsBid
  1703. FROM
  1704. Grp_DelegationInfo gdi
  1705. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1706. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1707. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1708. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1709. WHERE
  1710. gdi.IsDel = 0
  1711. AND gdi.IsBid = 0
  1712. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1713. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1714. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1715. #region 处理所属部门
  1716. /*
  1717. * 1.sq 和 gyy 等显示 市场部
  1718. * 2.王鸽和主管及张总还有管理员号统一国交部
  1719. * 2-1. 4 管理员 ,21 张海麟
  1720. */
  1721. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1722. List<int> userIds1 = new List<int>() { 4, 21 };
  1723. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1724. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1725. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1726. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1727. .ToListAsync();
  1728. var droupIds = groupList.Select(it => it.Id).ToList();
  1729. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1730. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1731. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1732. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1733. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1734. {
  1735. DiId = tcl.DiId,
  1736. LastName = dc.LastName,
  1737. FirstName = dc.FirstName,
  1738. Sex = dc.Sex,
  1739. Birthday = dc.BirthDay,
  1740. Company = cc.CompanyFullName,
  1741. Job = dc.Job,
  1742. CreateTime = tcl.CreateTime,
  1743. })
  1744. .ToList();
  1745. foreach (var item in groupList)
  1746. {
  1747. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1748. string groupFirstName = "";
  1749. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1750. if (currDatas.Any())
  1751. {
  1752. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1753. }
  1754. item.GroupFirst = groupFirstName;
  1755. }
  1756. #endregion
  1757. #region Excel
  1758. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1759. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1760. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1761. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1762. var fileName = $"团组清单({beginDt}{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1763. //载入模板
  1764. WorkbookDesigner designer = new WorkbookDesigner();
  1765. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1766. designer.SetDataSource("Titel", $"团组清单({beginDt}{endDt})");
  1767. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1768. dt.TableName = "GroupList";
  1769. designer.SetDataSource(dt);
  1770. designer.Process();
  1771. if (!Directory.Exists(savePath))
  1772. {
  1773. Directory.CreateDirectory(savePath);
  1774. }
  1775. string serverPath = $"{savePath}{fileName}";
  1776. designer.Workbook.Save(serverPath);
  1777. string rst = $"{servicePath}{ftpPath}{fileName}";
  1778. #endregion
  1779. return Ok(JsonView(true, "操作成功!", rst));
  1780. }
  1781. /// <summary>
  1782. /// 团组合同下载(1.付款80% 2.付全款)
  1783. /// </summary>
  1784. /// <param name="dto"></param>
  1785. /// <returns></returns>
  1786. /// <exception cref="Exception"></exception>
  1787. [HttpPost]
  1788. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1789. {
  1790. var jw = JsonView(false);
  1791. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1792. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1793. if (di == null)
  1794. {
  1795. jw.Msg = "团组Id有误!";
  1796. return Ok(jw);
  1797. }
  1798. #region 权限校验
  1799. var allDownFile = new List<int>() { 21 };
  1800. try
  1801. {
  1802. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1803. .First(x => x.Id == 1418 && x.IsDel == 0);
  1804. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1805. }
  1806. catch (Exception)
  1807. { }
  1808. var guojiaoDownFile = new List<int>() { 330 };
  1809. var shichangDownFile = new List<int>() { 95 };
  1810. if (allDownFile.Contains(dto.UserId))
  1811. {
  1812. }
  1813. else if (guojiaoDownFile.Contains(dto.UserId))
  1814. {
  1815. var guojiaobuDi = new List<int>() { 4, 21 };
  1816. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1817. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1818. .Where((d, u) => u.Id == di.JietuanOperator)
  1819. .Select((d, u) => d.DepName)
  1820. .First();
  1821. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1822. {
  1823. jw.Msg = "暂无下载权限!";
  1824. return Ok(jw);
  1825. }
  1826. }
  1827. else if (shichangDownFile.Contains(dto.UserId))
  1828. {
  1829. var dic = new Dictionary<int, int[]>()
  1830. {
  1831. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1832. };
  1833. try
  1834. {
  1835. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1836. if (sqSetting != null)
  1837. {
  1838. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1839. foreach (var item in result.Keys)
  1840. {
  1841. if (dic.Keys.Contains(item))
  1842. {
  1843. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1844. Array.Copy(dic[item], dilatation, dic[item].Length);
  1845. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1846. dic[item] = dilatation;
  1847. }
  1848. else
  1849. {
  1850. dic.Add(item, result[item]);
  1851. }
  1852. }
  1853. }
  1854. if (!dic[95].Contains(di.CreateUserId))
  1855. {
  1856. jw.Msg = "暂无下载权限!";
  1857. return Ok(jw);
  1858. }
  1859. }
  1860. catch (Exception)
  1861. { }
  1862. }
  1863. else if (dto.UserId == di.CreateUserId)
  1864. {
  1865. }
  1866. else
  1867. {
  1868. jw.Msg = "暂无下载权限!";
  1869. return Ok(jw);
  1870. }
  1871. #endregion
  1872. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1873. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1874. .ToListAsync();
  1875. if (!blackCodeList.Any())
  1876. {
  1877. jw.Msg = "该团无机票行程代码!";
  1878. return Ok(jw);
  1879. }
  1880. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1881. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1882. if (groupEnterExitCost == null)
  1883. {
  1884. jw.Msg = "暂无三公费用信息!";
  1885. return Ok(jw);
  1886. }
  1887. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1888. rateList ??= new List<CurrencyInfo>();
  1889. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1890. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1891. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1892. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1893. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1894. .Select((x, a, b) => new
  1895. {
  1896. x.Index,
  1897. itemName = a.Name,
  1898. CurrencyStr = b.Name,
  1899. x.Cost,
  1900. x.SubTotal,
  1901. x.Remark
  1902. })
  1903. .OrderBy((x) => x.Index)
  1904. .ToList();
  1905. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1906. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1907. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1908. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1909. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1910. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1911. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1912. decimal subJJC = 0.00M,
  1913. subGWC = 0.00M,
  1914. subTDC = 0.00M;
  1915. //经济舱
  1916. if (groupEnterExitCost.SumJJC == 1)
  1917. {
  1918. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1919. }
  1920. //公务舱
  1921. if (groupEnterExitCost.SumGWC == 1)
  1922. {
  1923. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1924. }
  1925. //头等舱
  1926. if (groupEnterExitCost.SumTDC == 1)
  1927. {
  1928. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1929. }
  1930. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1931. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1932. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1933. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1934. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1935. .Select((x, s, dc, cc) => new groupClints
  1936. {
  1937. Id = x.Id,
  1938. Name = s.Name,
  1939. IsAccompany = x.IsAccompany,
  1940. CompanyFullName = cc.CompanyFullName
  1941. })
  1942. .ToListAsync();
  1943. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1944. //获取舱位人数
  1945. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1946. .GroupBy(x => x.Name)
  1947. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1948. .ToList();
  1949. string cityPath = string.Empty;
  1950. string startCity = string.Empty;
  1951. string endCity = string.Empty;
  1952. foreach (var item in blackCodeList)
  1953. {
  1954. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1955. cityPath += city + "\r\n";
  1956. if (item.Equals(blackCodeList.First()))
  1957. {
  1958. var sp = city.Split('-');
  1959. startCity = sp[0];
  1960. endCity = sp[sp.Length - 1];
  1961. }
  1962. }
  1963. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1964. bookMarkDic.Add("ClientUnit", di.ClientUnit);
  1965. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1966. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1967. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1968. bookMarkDic.Add("CityPath", cityPath);
  1969. bookMarkDic.Add("StartCity", startCity);
  1970. bookMarkDic.Add("EndCity", endCity);
  1971. bookMarkDic.Add("StayDays", $"{di.VisitDays}{di.VisitDays - 1}晚");
  1972. Document doc = null;
  1973. var percentage = 0.8M;
  1974. var fileNameadd = "预付";
  1975. if (dto.FileType == 1)
  1976. {
  1977. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1978. }
  1979. else if (dto.FileType == 2)
  1980. {
  1981. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1982. percentage = 1;
  1983. fileNameadd = "全款";
  1984. }
  1985. else
  1986. {
  1987. throw new Exception("FileType有误!");
  1988. }
  1989. DocumentBuilder builder = new DocumentBuilder(doc);
  1990. decimal totalPrice = 0.00M;
  1991. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1992. if (firstTable != null)
  1993. {
  1994. // 遍历表格的行和单元格
  1995. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1996. {
  1997. for (int i = 0; i < row.Cells.Count; i++)
  1998. {
  1999. var cell = row.Cells[i];
  2000. // 读取单元格内容
  2001. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2002. if (cellTextFirst.Contains("舱位"))
  2003. {
  2004. break;
  2005. }
  2006. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2007. {
  2008. if (i == 2)
  2009. {
  2010. if (cellTextFirst == "经济舱")
  2011. {
  2012. // 设置单元格内容
  2013. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2014. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2015. }
  2016. else
  2017. {
  2018. // 设置单元格内容
  2019. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2020. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2021. }
  2022. }
  2023. if (i == 3)
  2024. {
  2025. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2026. if (count != null)
  2027. {
  2028. // 设置单元格内容
  2029. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2030. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2031. }
  2032. }
  2033. if (i == 4)
  2034. {
  2035. var rowPrice = 0.00M;
  2036. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2037. count ??= 0;
  2038. if (cellTextFirst == "经济舱")
  2039. {
  2040. rowPrice = subJJC * (int)count;
  2041. }
  2042. else
  2043. {
  2044. rowPrice = subGWC * (int)count;
  2045. }
  2046. totalPrice += rowPrice;
  2047. // 设置单元格内容
  2048. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2049. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2050. }
  2051. }
  2052. }
  2053. }
  2054. }
  2055. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2056. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2057. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2058. //--合同表格部分
  2059. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2060. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2061. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2062. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2063. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2064. bookMarkDic.Add("CityPath1", cityPath);
  2065. bookMarkDic.Add("CityPath2", cityPath);
  2066. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2067. if (contractTable != null)
  2068. {
  2069. //数据源
  2070. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2071. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2072. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2073. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2074. .Select((it, y, s) => new
  2075. {
  2076. it.Cost,
  2077. it.SubTotal,
  2078. it.Type,
  2079. y.Id,
  2080. y.City,
  2081. s.Name,
  2082. CurrencyCodeCn = s.Remark
  2083. })
  2084. .ToList()
  2085. .Select(x => new
  2086. {
  2087. CurrencyCode = x.Name,
  2088. CityId = x.Id,
  2089. x.City,
  2090. VisitPNumber = di.VisitPNumber,
  2091. x.Type,
  2092. x.Cost,
  2093. x.SubTotal,
  2094. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2095. x.CurrencyCodeCn,
  2096. });
  2097. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2098. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2099. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2100. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2101. List<tableSetting> tableSettings = new List<tableSetting>()
  2102. {
  2103. new tableSetting{ Index = 1 , Property = "City"},
  2104. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  2105. new tableSetting{ Index = 3 , Property = "Cost"},
  2106. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  2107. //new tableSetting{ Index = 5 , Property = ""},
  2108. //new tableSetting{ Index = 6 , Property = ""},
  2109. new tableSetting{ Index = 7 , Property = "Rate"},
  2110. //new tableSetting{ Index = 8 , Property = ""},
  2111. };
  2112. //1.住宿费
  2113. int cloneRow = 8;
  2114. int startDayPrice = 8; //写入index
  2115. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2116. foreach (var dac in dac1)
  2117. {
  2118. var first = dac.First();
  2119. var dayCount = dac.Count();
  2120. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2121. for (int i = 1; i < row.Cells.Count; i++)
  2122. {
  2123. var cell = row.Cells[i];
  2124. var findProperty = tableSettings.Find(x => x.Index == i);
  2125. if (findProperty != null)
  2126. {
  2127. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2128. // 设置单元格内容
  2129. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2130. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2131. }
  2132. else
  2133. {
  2134. switch (i)
  2135. {
  2136. case 5:
  2137. cell.FirstParagraph.Runs.Clear();
  2138. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2139. break;
  2140. case 6:
  2141. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2142. cell.FirstParagraph.Runs.Clear();
  2143. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2144. break;
  2145. case 8:
  2146. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2147. cell.FirstParagraph.Runs.Clear();
  2148. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2149. ZSPriceSum += xiaojiRMB;
  2150. break;
  2151. default:
  2152. break;
  2153. }
  2154. }
  2155. }
  2156. startDayPrice++;
  2157. if (!dac1.Last().Equals(dac))
  2158. {
  2159. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2160. // 将克隆的行追加到原行后面
  2161. contractTable.Rows.Insert(startDayPrice, newRow);
  2162. }
  2163. else
  2164. {
  2165. cloneRow += dac1.Count() + 1;
  2166. startDayPrice = cloneRow;
  2167. }
  2168. }
  2169. //2.伙食费
  2170. foreach (var dac in dac2)
  2171. {
  2172. var first = dac.First();
  2173. var dayCount = dac.Count();
  2174. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2175. for (int i = 1; i < row.Cells.Count; i++)
  2176. {
  2177. var cell = row.Cells[i];
  2178. var findProperty = tableSettings.Find(x => x.Index == i);
  2179. if (findProperty != null)
  2180. {
  2181. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2182. // 设置单元格内容
  2183. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2184. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2185. }
  2186. else
  2187. {
  2188. switch (i)
  2189. {
  2190. case 5:
  2191. cell.FirstParagraph.Runs.Clear();
  2192. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2193. break;
  2194. case 6:
  2195. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2196. cell.FirstParagraph.Runs.Clear();
  2197. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2198. break;
  2199. case 8:
  2200. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2201. cell.FirstParagraph.Runs.Clear();
  2202. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2203. HSPriceSum += xiaojiRMB;
  2204. break;
  2205. default:
  2206. break;
  2207. }
  2208. }
  2209. }
  2210. startDayPrice++;
  2211. if (!dac2.Last().Equals(dac))
  2212. {
  2213. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2214. // 将克隆的行追加到原行后面
  2215. contractTable.Rows.Insert(startDayPrice, newRow);
  2216. }
  2217. else
  2218. {
  2219. cloneRow += dac2.Count() + 1;
  2220. startDayPrice = cloneRow;
  2221. }
  2222. }
  2223. //3.公杂费
  2224. foreach (var dac in dac3)
  2225. {
  2226. var first = dac.First();
  2227. var dayCount = dac.Count();
  2228. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2229. for (int i = 1; i < row.Cells.Count; i++)
  2230. {
  2231. var cell = row.Cells[i];
  2232. var findProperty = tableSettings.Find(x => x.Index == i);
  2233. if (findProperty != null)
  2234. {
  2235. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2236. // 设置单元格内容
  2237. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2238. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2239. }
  2240. else
  2241. {
  2242. switch (i)
  2243. {
  2244. case 5:
  2245. cell.FirstParagraph.Runs.Clear();
  2246. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2247. break;
  2248. case 6:
  2249. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2250. cell.FirstParagraph.Runs.Clear();
  2251. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2252. break;
  2253. case 8:
  2254. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2255. cell.FirstParagraph.Runs.Clear();
  2256. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2257. GZPriceSum += xiaojiRMB;
  2258. break;
  2259. default:
  2260. break;
  2261. }
  2262. }
  2263. }
  2264. startDayPrice++;
  2265. if (!dac3.Last().Equals(dac))
  2266. {
  2267. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2268. // 将克隆的行追加到原行后面
  2269. contractTable.Rows.Insert(startDayPrice, newRow);
  2270. }
  2271. else
  2272. {
  2273. cloneRow += dac3.Count() + 1;
  2274. startDayPrice = cloneRow;
  2275. }
  2276. }
  2277. //合并单元格
  2278. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2279. {
  2280. var currentRow = contractTable.Rows[i];
  2281. var nextRow = contractTable.Rows[i + 1];
  2282. // 获取当前行和下一行的第一个单元格
  2283. Cell currentCell = currentRow.Cells[0];
  2284. Cell nextCell = nextRow.Cells[0];
  2285. // 检查单元格内容是否一致(去除尾部的换行符)
  2286. string currentText = currentCell.GetText().Trim();
  2287. string nextText = nextCell.GetText().Trim();
  2288. if (currentText == nextText)
  2289. {
  2290. // 如果当前单元格已经被合并,找到合并的起始单元格
  2291. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2292. {
  2293. // 找到合并的起始单元格
  2294. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2295. // 将下一行的单元格设置为合并的后续单元格
  2296. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2297. }
  2298. else
  2299. {
  2300. // 如果当前单元格是合并的起始单元格
  2301. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2302. // 将下一行的单元格设置为合并的后续单元格
  2303. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2304. }
  2305. }
  2306. else
  2307. {
  2308. // 如果内容不一致,重置当前单元格的合并属性
  2309. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2310. {
  2311. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2312. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2313. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2314. }
  2315. else
  2316. {
  2317. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2318. }
  2319. }
  2320. }
  2321. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2322. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2323. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2324. }
  2325. foreach (var bookmarkName in bookMarkDic.Keys)
  2326. {
  2327. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2328. if (bookmark != null)
  2329. {
  2330. if (bookmarkName == "ClientUnit")
  2331. {
  2332. // 移动到书签位置
  2333. builder.MoveTo(bookmark.BookmarkStart);
  2334. // 设置字体样式为下划线
  2335. builder.Font.Underline = Aspose.Words.Underline.Single;
  2336. // 插入书签值
  2337. builder.Write(bookMarkDic[bookmarkName]);
  2338. // 清除字体格式,避免影响后续文本
  2339. builder.Font.ClearFormatting();
  2340. }
  2341. else
  2342. {
  2343. builder.MoveToBookmark(bookmarkName);
  2344. builder.Write(bookMarkDic[bookmarkName]);
  2345. }
  2346. }
  2347. }
  2348. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2349. doc.Save(savePaht);
  2350. jw.Msg = "生成成功!";
  2351. jw.Code = 200;
  2352. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2353. return Ok(jw);
  2354. }
  2355. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2356. {
  2357. int index = rowIndex;
  2358. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2359. {
  2360. index--;
  2361. }
  2362. return index;
  2363. }
  2364. #endregion
  2365. #region 团组&签证
  2366. /// <summary>
  2367. /// 根据团组Id获取签证客户信息List
  2368. /// </summary>
  2369. /// <param name="dto">请求dto</param>
  2370. /// <returns></returns>
  2371. [HttpPost]
  2372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2373. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2374. {
  2375. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2376. if (groupData.Code != 0)
  2377. {
  2378. return Ok(JsonView(false, groupData.Msg));
  2379. }
  2380. return Ok(JsonView(groupData.Data));
  2381. }
  2382. /// <summary>
  2383. /// IOS获取团组签证拍照上传进度01(团组列表)
  2384. /// </summary>
  2385. /// <param name="dto">请求dto</param>
  2386. /// <returns></returns>
  2387. [HttpPost]
  2388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2389. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2390. {
  2391. if (dto == null)
  2392. {
  2393. return Ok(JsonView(false, "参数为空"));
  2394. }
  2395. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2396. return Ok(JsonView(visaList));
  2397. }
  2398. /// <summary>
  2399. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2400. /// </summary>
  2401. /// <returns></returns>
  2402. [HttpPost]
  2403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2404. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2405. {
  2406. if (dto == null)
  2407. {
  2408. return Ok(JsonView(false, "请求错误:"));
  2409. }
  2410. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2411. return Ok(JsonView(list));
  2412. }
  2413. /// <summary>
  2414. /// IOS获取团组签证拍照上传进度03(相册)
  2415. /// </summary>
  2416. /// <returns></returns>
  2417. [HttpPost]
  2418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2419. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2420. {
  2421. if (dto == null)
  2422. {
  2423. return Ok(JsonView(false, "请求错误:"));
  2424. }
  2425. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2426. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2427. list.ForEach(s => s.url = url);
  2428. return Ok(JsonView(list));
  2429. }
  2430. /// <summary>
  2431. /// IOS获取团组签证拍照上传进度04(图片上传)
  2432. /// </summary>
  2433. /// <param name="dto"></param>
  2434. /// <returns></returns>
  2435. [HttpPost]
  2436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2437. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2438. {
  2439. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2440. //if (!string.IsNullOrEmpty(result))
  2441. //{
  2442. //}
  2443. //else {
  2444. // return Ok(JsonView(false, "上传失败"));
  2445. //}
  2446. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2447. int sucNum = 0;
  2448. try
  2449. {
  2450. foreach (var item in dto.base64DataList)
  2451. {
  2452. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2453. string result = DecodeBase64ToImage(item, imageName);
  2454. if (!string.IsNullOrEmpty(result))
  2455. {
  2456. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2457. pic.CreateUserId = dto.CreateUserId;
  2458. pic.PicName = imageName;
  2459. pic.PicPath = result;
  2460. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2461. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2462. if (insertResult > 0)
  2463. {
  2464. sucNum++;
  2465. }
  2466. }
  2467. }
  2468. }
  2469. catch (Exception ex)
  2470. {
  2471. return Ok(JsonView(false, ex.Message));
  2472. }
  2473. string msg = string.Format(@"成功上传{0}张", sucNum);
  2474. return Ok(JsonView(true, msg));
  2475. }
  2476. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2477. {
  2478. string filename = "";//声明一个string类型的相对路径
  2479. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2480. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2481. try//会有异常抛出,try,catch一下
  2482. {
  2483. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2484. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2485. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2486. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2487. //文件名称
  2488. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2489. //上传的文件的路径
  2490. string filePath = "";
  2491. if (!Directory.Exists(fileDir))
  2492. {
  2493. Directory.CreateDirectory(fileDir);
  2494. }
  2495. //上传的文件的路径
  2496. filePath = fileDir + filename;
  2497. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2498. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2499. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2500. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2501. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2502. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2503. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2504. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2505. bitmap.Dispose();
  2506. }
  2507. catch (Exception e)
  2508. {
  2509. string massage = e.Message;
  2510. Logs("IOS图片上传Error:" + massage);
  2511. //filename = e.Message;
  2512. }
  2513. return filename;//返回相对路径
  2514. }
  2515. /// <summary>
  2516. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2517. /// </summary>
  2518. /// <param name="dto"></param>
  2519. /// <returns></returns>
  2520. [HttpPost]
  2521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2522. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2523. {
  2524. if (dto == null)
  2525. {
  2526. return Ok(JsonView(false, "请求错误:"));
  2527. }
  2528. string msg = "参数错误";
  2529. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2530. {
  2531. try
  2532. {
  2533. //_delegationVisaRep.BeginTran();
  2534. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2535. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2536. .Where(s => s.Id == dto.visaProgressCustomerId)
  2537. .ExecuteCommandAsync();
  2538. if (updCount > 0 && dto.publishCode == 1)
  2539. {
  2540. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2541. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2542. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2543. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2544. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2545. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2546. if (groupData == null)
  2547. {
  2548. _delegationVisaRep.RollbackTran();
  2549. }
  2550. string title = string.Format(@"[签证进度更新]");
  2551. string content = string.Format(@"测试文本");
  2552. bool rst = await _message.AddMsg(new MessageDto()
  2553. {
  2554. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2555. IssuerId = dto.publisher,
  2556. Title = title,
  2557. Content = content,
  2558. ReleaseTime = DateTime.Now,
  2559. UIdList = new List<int> {
  2560. 234
  2561. }
  2562. });
  2563. if (rst)
  2564. {
  2565. return Ok(JsonView(true, "发送通知成功"));
  2566. }
  2567. }
  2568. //_delegationVisaRep.CommitTran();
  2569. }
  2570. catch (Exception)
  2571. {
  2572. //_delegationVisaRep.RollbackTran();
  2573. }
  2574. }
  2575. return Ok(JsonView(true, msg));
  2576. }
  2577. #endregion
  2578. #region 团组任务分配
  2579. /// <summary>
  2580. /// 团组任务分配初始化
  2581. /// </summary>
  2582. /// <returns></returns>
  2583. [HttpPost]
  2584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2585. public async Task<IActionResult> GetTaskAssignmen()
  2586. {
  2587. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2588. if (groupData.Code != 0)
  2589. {
  2590. return Ok(JsonView(false, groupData.Msg));
  2591. }
  2592. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2593. }
  2594. /// <summary>
  2595. /// 团组任务分配查询
  2596. /// </summary>
  2597. /// <param name="dto"></param>
  2598. /// <returns></returns>
  2599. [HttpPost]
  2600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2601. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2602. {
  2603. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2604. if (groupData.Code != 0)
  2605. {
  2606. return Ok(JsonView(false, groupData.Msg));
  2607. }
  2608. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2609. }
  2610. /// <summary>
  2611. /// 团组任务分配操作
  2612. /// </summary>
  2613. /// <param name="dto"></param>
  2614. /// <returns></returns>
  2615. [HttpPost]
  2616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2617. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2618. {
  2619. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2620. if (groupData.Code != 0)
  2621. {
  2622. return Ok(JsonView(false, groupData.Msg));
  2623. }
  2624. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2625. }
  2626. /// <summary>
  2627. /// 团组任务分配
  2628. /// 批量分配
  2629. /// 查询团组
  2630. /// </summary>
  2631. /// <param name="dto"></param>
  2632. /// <returns></returns>
  2633. [HttpPost]
  2634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2635. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2636. {
  2637. //参数验证
  2638. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2639. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2640. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2641. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2642. }
  2643. /// <summary>
  2644. /// 团组任务分配
  2645. /// 批量分配
  2646. /// </summary>
  2647. /// <param name="dto"></param>
  2648. /// <returns></returns>
  2649. [HttpPost]
  2650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2651. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2652. {
  2653. //参数验证
  2654. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2655. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2656. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2657. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2658. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2659. }
  2660. #endregion
  2661. #region 团组费用审核
  2662. /// <summary>
  2663. /// 费用审核
  2664. /// 团组列表 Page
  2665. /// </summary>
  2666. /// <param name="_dto">团组列表请求dto</param>
  2667. /// <returns></returns>
  2668. [HttpPost]
  2669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2670. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2671. {
  2672. #region 参数验证
  2673. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2674. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2675. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2676. #region 页面操作权限验证
  2677. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2678. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2679. #endregion
  2680. #endregion
  2681. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2682. {
  2683. string sqlWhere = string.Empty;
  2684. if (_dto.IsSure == 0) //未完成
  2685. {
  2686. sqlWhere += string.Format(@" And IsSure = 0");
  2687. }
  2688. else if (_dto.IsSure == 1) //已完成
  2689. {
  2690. sqlWhere += string.Format(@" And IsSure = 1");
  2691. }
  2692. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2693. {
  2694. string tj = _dto.SearchCriteria;
  2695. 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}%')",
  2696. tj, tj, tj, tj, tj);
  2697. }
  2698. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2699. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2700. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2701. From (
  2702. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2703. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2704. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2705. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2706. From Grp_DelegationInfo gdi
  2707. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2708. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2709. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2710. Where gdi.IsDel = 0 {0}
  2711. ) temp ", sqlWhere);
  2712. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2713. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2714. var _view = new
  2715. {
  2716. PageFuncAuth = pageFunAuthView,
  2717. Data = _DelegationList
  2718. };
  2719. return Ok(JsonView(true, "查询成功!", _view, total));
  2720. }
  2721. else
  2722. {
  2723. return Ok(JsonView(false, "查询失败"));
  2724. }
  2725. }
  2726. /// <summary>
  2727. /// 获取团组费用审核
  2728. /// </summary>
  2729. /// <param name="_dto"></param>
  2730. /// <returns></returns>
  2731. [HttpPost]
  2732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2733. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2734. {
  2735. try
  2736. {
  2737. #region 参数验证
  2738. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2739. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2740. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2741. #region 页面操作权限验证
  2742. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2743. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2744. #endregion
  2745. #endregion
  2746. var _view = new Grp_CreditCardPaymentView();
  2747. var clientNameList = getSimplClientList(_dto.DiId);
  2748. #region 费用清单
  2749. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2750. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2751. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2752. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2753. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2754. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2755. /*
  2756. * 76://酒店预订
  2757. */
  2758. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2759. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2760. /*
  2761. * 79://车/导游地接
  2762. */
  2763. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2764. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2765. /*
  2766. * 80: //签证
  2767. */
  2768. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2769. /*
  2770. *81: //邀请/公务活动
  2771. */
  2772. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2773. /*
  2774. * 82: //团组客户保险
  2775. */
  2776. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2777. /*
  2778. * Lable = 85 机票预订
  2779. */
  2780. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2781. /*
  2782. * 85 机票预定
  2783. */
  2784. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2785. /*
  2786. * 98 其他款项
  2787. */
  2788. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2789. /*
  2790. * 285:收款退还
  2791. */
  2792. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2793. /*
  2794. * 1015: //超支费用
  2795. */
  2796. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2797. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2798. /*
  2799. * 币种信息
  2800. */
  2801. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2802. /*
  2803. * 车/导游地接 费用类型
  2804. */
  2805. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2806. /*
  2807. * 车/导游地接 费用类型
  2808. */
  2809. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2810. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2811. /*
  2812. * 用户信息
  2813. */
  2814. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2815. /*
  2816. * 费用模块
  2817. */
  2818. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2819. string priceModule = string.Empty;
  2820. if (sdPriceName != null)
  2821. {
  2822. priceModule = sdPriceName.Name;
  2823. }
  2824. /*
  2825. * 成本信息
  2826. */
  2827. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2828. decimal _groupRate = 0.0000M;
  2829. string _groupCurrencyCode = "-";
  2830. if (groupCost != null)
  2831. {
  2832. _groupRate = groupCost.Rate;
  2833. if (int.TryParse(groupCost.Currency, out int _currency))
  2834. {
  2835. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2836. }
  2837. else _groupCurrencyCode = groupCost.Currency;
  2838. }
  2839. string costContentSql = $"Select * From Grp_GroupCost";
  2840. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2841. //处理日期为空的天数
  2842. for (int i = 0; i < groupCostDetails.Count; i++)
  2843. if (i != 0)
  2844. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2845. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2846. /*
  2847. * 处理详情数据
  2848. */
  2849. foreach (var entity in entityList)
  2850. {
  2851. var _detail = new Grp_CreditCardPaymentDetailView();
  2852. _detail.Id = entity.Id;
  2853. _detail.PriceName = priceModule;
  2854. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2855. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2856. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2857. //处理金额
  2858. if (entity.CTable == 1015)
  2859. {
  2860. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2861. if (czInfo != null)
  2862. {
  2863. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2864. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2865. }
  2866. }
  2867. /*
  2868. * 应付款金额
  2869. */
  2870. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2871. string PaymentCurrency_WaitPay = "Unknown";
  2872. string hotelCurrncyCode = "Unknown";
  2873. string hotelCurrncyName = "Unknown";
  2874. if (sdPaymentCurrency_WaitPay != null)
  2875. {
  2876. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2877. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2878. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2879. if (hotelCurrncyCode.Equals("CNY"))
  2880. {
  2881. entity.DayRate = 1.0000M;
  2882. }
  2883. }
  2884. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2885. /*
  2886. * 此次付款金额
  2887. */
  2888. decimal CurrPayStr = 0.00M,
  2889. OriginalCurrPay = 0.00M;
  2890. if (entity.PayPercentage == 0)
  2891. {
  2892. if (entity.PayThenMoney != 0)
  2893. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2894. }
  2895. else
  2896. {
  2897. if (entity.PayMoney != 0)
  2898. {
  2899. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2900. }
  2901. }
  2902. //if (_dto.Label == 79)
  2903. //{
  2904. // string original = string.Empty;
  2905. // if (hotelCurrncyCode.Equals("CNY"))
  2906. // {
  2907. // OriginalCurrPay = CurrPayStr;
  2908. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2909. // }
  2910. // else
  2911. // {
  2912. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2913. // //760 EUR(7600.00 CNY)
  2914. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2915. // }
  2916. //}
  2917. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2918. string original = string.Empty;
  2919. if (hotelCurrncyCode.Equals("CNY"))
  2920. {
  2921. OriginalCurrPay = CurrPayStr;
  2922. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2923. }
  2924. else
  2925. {
  2926. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2927. //760 EUR(7600.00 CNY)
  2928. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2929. }
  2930. /*
  2931. * 剩余尾款
  2932. */
  2933. decimal BalanceStr = 0;
  2934. if (CurrPayStr != 0)
  2935. {
  2936. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2937. BalanceStr = 0;
  2938. else
  2939. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2940. }
  2941. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2942. /*
  2943. * Bus名称
  2944. */
  2945. _detail.BusName = "待增加";
  2946. /*
  2947. *费用所属
  2948. */
  2949. switch (entity.CTable)
  2950. {
  2951. case 76://酒店预订
  2952. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2953. if (hotelReservations != null)
  2954. {
  2955. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2956. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2957. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2958. string roomFeeStr = "", roomFeestr1 = "";
  2959. //是否比较房型价格
  2960. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2961. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2962. roomFeeStr += $"<br/>";
  2963. var roomTotal = 0.00M;
  2964. if (hotelReservations.SingleRoomPrice > 0)
  2965. {
  2966. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  2967. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2968. //__isSingle = true;
  2969. roomTotal += fee;
  2970. }
  2971. if (hotelReservations.DoubleRoomPrice > 0)
  2972. {
  2973. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  2974. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2975. // __isDouble = true;
  2976. roomTotal += fee;
  2977. }
  2978. if (hotelReservations.SuiteRoomPrice > 0)
  2979. {
  2980. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  2981. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2982. //__isSuite = true;
  2983. roomTotal += fee;
  2984. }
  2985. if (hotelReservations.OtherRoomPrice > 0)
  2986. {
  2987. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  2988. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2989. //__isOther = true;
  2990. roomTotal += fee;
  2991. }
  2992. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  2993. else roomFeeStr += " 0.00 * 0";
  2994. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2995. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2996. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2997. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2998. /*
  2999. * 费用类型
  3000. * 1:房费
  3001. * 2:早餐
  3002. * 3:地税
  3003. * 4:城市税
  3004. * </summary>
  3005. */
  3006. //地税
  3007. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3008. if (governmentRentData != null)
  3009. {
  3010. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3011. governmentRentFee = governmentRentData.Price;
  3012. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3013. if (governmentRentCurrData != null)
  3014. {
  3015. governmentRentCode = governmentRentCurrData.Name;
  3016. governmentRentName = $"({governmentRentCurrData.Remark})";
  3017. }
  3018. }
  3019. //城市税
  3020. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3021. if (cityTaxData != null)
  3022. {
  3023. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3024. cityTaxFee = cityTaxData.Price;
  3025. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3026. if (cityTaxCurrData != null)
  3027. {
  3028. cityTaxCode = cityTaxCurrData.Name;
  3029. cityTaxName = $"({cityTaxCurrData.Remark})";
  3030. }
  3031. }
  3032. //酒店早餐
  3033. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3034. if (breakfastData != null)
  3035. {
  3036. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3037. breakfastFee = breakfastData.Price;
  3038. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3039. if (breakfastCurrData != null)
  3040. {
  3041. breakfastCode = breakfastCurrData.Name;
  3042. breakfastName = $"({breakfastCurrData.Remark})";
  3043. }
  3044. }
  3045. //房间费用
  3046. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3047. if (roomData != null)
  3048. {
  3049. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3050. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3051. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3052. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3053. roomFee = roomData.Price;
  3054. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3055. if (roomCurrData != null)
  3056. {
  3057. roomCode = roomCurrData.Name;
  3058. roomName = $"({roomCurrData.Remark})";
  3059. }
  3060. }
  3061. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3062. string hotelCostStr = "";
  3063. decimal hotelCsotTotal = 0.00M;
  3064. if (groupCost != null)
  3065. {
  3066. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3067. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3068. }
  3069. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3070. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3071. string hotelCost_day = "";
  3072. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3073. foreach (var item in hotelCostDetails1)
  3074. {
  3075. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3076. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3077. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3078. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3079. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3080. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3081. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3082. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3083. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3084. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3085. hotelCost_day += @$"<br/>";
  3086. }
  3087. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3088. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3089. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3090. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3091. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3092. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3093. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3094. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3095. $"房间说明: {hotelReservations.Remark} <br/>" +
  3096. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3097. $"{hotelBreakfastStr}" +
  3098. $"{hotelGovernmentRentStr}" +
  3099. $"{hotelCityTaxStr}";
  3100. _detail.PriceNameContent = hotelReservations.HotelName;
  3101. }
  3102. break;
  3103. case 79://车/导游地接
  3104. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3105. if (touristGuideGroundReservations != null)
  3106. {
  3107. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3108. {
  3109. _detail.BusName = touristGuideGroundReservations.BusName;
  3110. }
  3111. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3112. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3113. //if (isInt)
  3114. //{
  3115. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3116. // if (cityInfo != null)
  3117. // {
  3118. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3119. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3120. // if (carFeeItem != null)
  3121. // {
  3122. // nameContent += $@"({carFeeItem.Name})";
  3123. // }
  3124. // _detail.PriceNameContent = nameContent;
  3125. // }
  3126. //}
  3127. //else
  3128. //{
  3129. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3130. //}
  3131. var touristGuideGroundReservationsContents =
  3132. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3133. var opContent_sb = new StringBuilder();
  3134. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3135. opContent_sb.AppendLine(contetTitle);
  3136. foreach (var item in touristGuideGroundReservationsContents)
  3137. {
  3138. string typeName = "Unknown";
  3139. string carCurrencyCode = "Unknown";
  3140. string carCurrencyName = "Unknown";
  3141. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3142. if (carTypeData != null) typeName = carTypeData.Name;
  3143. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3144. if (currencyData != null)
  3145. {
  3146. carCurrencyCode = currencyData.Name;
  3147. carCurrencyName = currencyData.Remark;
  3148. }
  3149. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3150. bool IsCurrencyAgreement = false;
  3151. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3152. string opCostStr = string.Empty;
  3153. decimal opCostTypePrice = 0.00M;
  3154. #region 处理成本各项费用
  3155. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3156. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3157. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3158. costOPFeeCNY = 0.00M, //团组成本 op费用
  3159. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3160. if (opCost.Count > 0)
  3161. {
  3162. switch (item.SId)
  3163. {
  3164. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3165. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3166. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3167. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3168. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3169. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3170. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3171. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3172. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3173. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3174. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3175. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3176. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3177. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3178. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3179. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3180. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3181. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3182. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3183. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3184. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3185. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3186. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3187. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3188. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3189. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3190. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3191. }
  3192. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3193. costOPFeeCNY = opCostTypePrice * _groupRate;
  3194. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3195. }
  3196. #endregion
  3197. string opTypeStr = $"{typeName}{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3198. aduitOPFeeCNY = item.Price * entity.DayRate;
  3199. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3200. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3201. $"{opTypeStr} {opCostStr}<br/>" +
  3202. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3203. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3204. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3205. {
  3206. if (IsCurrencyAgreement)
  3207. {
  3208. if (item.Price > opCostTypePrice)
  3209. {
  3210. opContent_sb.Append("<span style='color:red;'>");
  3211. opContent_sb.Append(opContent);
  3212. opContent_sb.Append("</span>");
  3213. opContent_sb.AppendLine();
  3214. }
  3215. else
  3216. {
  3217. opContent_sb.Append(opContent);
  3218. opContent_sb.AppendLine();
  3219. }
  3220. }
  3221. else
  3222. {
  3223. //验证是否超成本 按付款比例计算
  3224. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3225. {
  3226. opContent_sb.Append("<span style='color:red;'>");
  3227. opContent_sb.Append(opContent);
  3228. opContent_sb.Append("</span>");
  3229. opContent_sb.AppendLine();
  3230. }
  3231. else
  3232. {
  3233. opContent_sb.Append(opContent);
  3234. opContent_sb.AppendLine();
  3235. }
  3236. }
  3237. }
  3238. else
  3239. {
  3240. opContent_sb.Append(opContent);
  3241. opContent_sb.AppendLine();
  3242. }
  3243. }
  3244. _detail.PriceMsgContent = opContent_sb.ToString();
  3245. }
  3246. break;
  3247. case 80: //签证
  3248. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3249. if (visaInfo != null)
  3250. {
  3251. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3252. _detail.PriceNameContent = visaInfo.VisaDescription;
  3253. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3254. }
  3255. break;
  3256. case 81: //邀请/公务活动
  3257. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3258. if (_ioa != null)
  3259. {
  3260. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3261. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3262. sendCurrName = "Unknown", //快递费用币种 Name
  3263. sendCurrCode = "Unknown", //快递费用币种 Code
  3264. eventsCurrName = "Unknown", //公务活动费币种 Name
  3265. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3266. translateCurrName = "Unknown", //公务翻译费 Name
  3267. translateCurrCode = "Unknown"; //公务翻译费 Code
  3268. #region 处理费用币种
  3269. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3270. if (inviteCurrData != null)
  3271. {
  3272. inviteCurrName = inviteCurrData.Remark;
  3273. inviteCurrCode = inviteCurrData.Name;
  3274. }
  3275. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3276. if (sendCurrData != null)
  3277. {
  3278. sendCurrName = sendCurrData.Remark;
  3279. sendCurrCode = sendCurrData.Name;
  3280. }
  3281. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3282. if (eventsCurrData != null)
  3283. {
  3284. eventsCurrName = eventsCurrData.Remark;
  3285. eventsCurrCode = eventsCurrData.Name;
  3286. }
  3287. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3288. if (translateCurrData != null)
  3289. {
  3290. translateCurrName = translateCurrData.Remark;
  3291. translateCurrCode = translateCurrData.Name;
  3292. }
  3293. #endregion
  3294. _detail.PriceNameContent = _ioa.InviterArea;
  3295. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3296. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3297. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3298. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3299. $@"备注:" + _ioa.Remark + "<br/>";
  3300. }
  3301. break;
  3302. case 82: //团组客户保险
  3303. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3304. if (customers != null)
  3305. {
  3306. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3307. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3308. }
  3309. break;
  3310. case 85: //机票预订
  3311. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3312. if (jpRes != null)
  3313. {
  3314. string FlightsDescription = jpRes.FlightsDescription;
  3315. string PriceDescription = jpRes.PriceDescription;
  3316. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3317. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3318. }
  3319. break;
  3320. case 98://其他款项
  3321. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3322. if (gdpRes != null)
  3323. {
  3324. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3325. _detail.PriceNameContent = gdpRes.PriceName;
  3326. }
  3327. break;
  3328. case 285://收款退还
  3329. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3330. if (refundAndOtherMoney != null)
  3331. {
  3332. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3333. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3334. }
  3335. break;
  3336. case 751://酒店早餐
  3337. break;
  3338. case 1015://超支费用
  3339. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3340. if (groupExtraCost != null)
  3341. {
  3342. _detail.PriceNameContent = groupExtraCost.PriceName;
  3343. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3344. }
  3345. break;
  3346. default:
  3347. break;
  3348. }
  3349. /*
  3350. * 申请人
  3351. */
  3352. string operatorName = " - ";
  3353. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3354. if (_opUser != null)
  3355. {
  3356. operatorName = _opUser.CnName;
  3357. }
  3358. _detail.OperatorName = operatorName;
  3359. /*
  3360. * 审核人
  3361. */
  3362. string auditOperatorName = "Unknown";
  3363. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3364. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3365. else
  3366. {
  3367. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3368. if (_adUser != null)
  3369. {
  3370. auditOperatorName = _adUser.CnName;
  3371. }
  3372. }
  3373. _detail.AuditOperatorName = auditOperatorName;
  3374. /*
  3375. * 超预算比例
  3376. */
  3377. string overBudgetStr = "";
  3378. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3379. else if (entity.ExceedBudget == 0)
  3380. {
  3381. if (entity.CTable == 76 || entity.CTable == 79)
  3382. {
  3383. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3384. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3385. }
  3386. else
  3387. {
  3388. overBudgetStr = "未超预算";
  3389. }
  3390. }
  3391. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3392. _detail.OverBudget = overBudgetStr;
  3393. decimal auditFee = 0.00M; //已审核金额 人名币
  3394. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3395. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3396. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3397. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3398. {
  3399. auditedFeeOriginal = entity.PayMoney;
  3400. auditFee = CurrPayStr;
  3401. }
  3402. else if (entity.IsAuditGM == 0)
  3403. {
  3404. unAuditFeeCNY = CurrPayStr;
  3405. unAuditFeeOriginal = OriginalCurrPay;
  3406. OriginalCurrPay = 0.00M;
  3407. }
  3408. /*
  3409. * 费用总计
  3410. */
  3411. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3412. {
  3413. CurrencyId = entity.PaymentCurrency,
  3414. CurrencyName = PaymentCurrency_WaitPay,
  3415. AmountPayable = entity.PayMoney,
  3416. ThisPayment = OriginalCurrPay,
  3417. BalancePayment = BalanceStr,
  3418. AuditedFunds = auditFee,
  3419. AuditedFundsOriginal = auditedFeeOriginal,
  3420. UnAuditFundsCNY = unAuditFeeCNY,
  3421. UnAuditFundsOriginal = unAuditFeeOriginal
  3422. });
  3423. _detail.IsAuditGM = entity.IsAuditGM;
  3424. detailList.Add(_detail);
  3425. }
  3426. #endregion
  3427. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3428. /*
  3429. * 下方描述处理
  3430. */
  3431. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3432. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3433. if (ccpCurrencyPrice != null)
  3434. {
  3435. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3436. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3437. }
  3438. else
  3439. {
  3440. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3441. }
  3442. string amountPayableStr = string.Format(@"应付款总金额: ");
  3443. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3444. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3445. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3446. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3447. foreach (var item in nonDuplicat)
  3448. {
  3449. var currencyName = item.CurrencyName;
  3450. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3451. if (strs.Count > 0)
  3452. {
  3453. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3454. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3455. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3456. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3457. //单独处理此次付款金额
  3458. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3459. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3460. //单独处理已审核费用
  3461. //if (item.CurrencyId == 836) //人民币
  3462. //{
  3463. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3464. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3465. //}
  3466. //else
  3467. //{
  3468. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3469. //}
  3470. if (currencyName.Equals("CNY"))
  3471. {
  3472. //已审核费用
  3473. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3474. //未审核费用
  3475. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3476. }
  3477. else
  3478. {
  3479. //已审核费用
  3480. 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"));
  3481. //未审核费用
  3482. 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"));
  3483. }
  3484. }
  3485. }
  3486. _view.TotalStr1 = amountPayableStr[..^1];
  3487. _view.TotalStr2 = thisPaymentStr[..^1];
  3488. _view.TotalStr3 = balancePaymentStr[..^1];
  3489. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3490. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3491. var _view1 = new
  3492. {
  3493. PageFuncAuth = pageFunAuthView,
  3494. Data = _view
  3495. };
  3496. return Ok(JsonView(_view1));
  3497. }
  3498. catch (Exception ex)
  3499. {
  3500. return Ok(JsonView(false, ex.Message));
  3501. }
  3502. }
  3503. /// <summary>
  3504. /// 费用审核
  3505. /// 修改团组费用审核状态
  3506. /// </summary>
  3507. /// <param name="_dto">参数Json字符串</param>
  3508. /// <returns></returns>
  3509. [HttpPost]
  3510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3511. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3512. {
  3513. #region 参数验证
  3514. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3515. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3516. #endregion
  3517. #region 页面操作权限验证
  3518. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3519. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3520. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3521. #endregion
  3522. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3523. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3524. DateTime dtNow = DateTime.Now;
  3525. _groupRepository.BeginTran();
  3526. int rst = 0;
  3527. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3528. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3529. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3530. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3531. List<dynamic> msgDatas = new List<dynamic>();
  3532. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3533. foreach (var item in idList)
  3534. {
  3535. int CreditId = int.Parse(item);
  3536. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3537. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3538. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3539. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3540. .Where(s => s.Id == CreditId)
  3541. .ExecuteCommandAsync();
  3542. if (result < 1)
  3543. {
  3544. rst = -1;
  3545. _groupRepository.RollbackTran();
  3546. return Ok(JsonView(false, "操作失败并回滚!"));
  3547. }
  3548. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3549. if (creditData != null)
  3550. {
  3551. #region 应用通知配置
  3552. try
  3553. {
  3554. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3555. }
  3556. catch (Exception ex)
  3557. {
  3558. }
  3559. #endregion
  3560. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3561. string groupNameStr = string.Empty;
  3562. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3563. if (groupData != null) groupNameStr = groupData.TeamName;
  3564. string creditTypeStr = string.Empty;
  3565. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3566. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3567. string creditCurrency = string.Empty;
  3568. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3569. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3570. if (creditCurrency.Equals("CNY"))
  3571. {
  3572. creditData.DayRate = 1.0000M;
  3573. }
  3574. if (creditData.PayPercentage == 0.00M)
  3575. {
  3576. creditData.PayPercentage = 100M;
  3577. }
  3578. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3579. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3580. string msgContent = "";
  3581. if (creditCurrency.Equals("CNY"))
  3582. {
  3583. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3584. }
  3585. else
  3586. {
  3587. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3588. }
  3589. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3590. }
  3591. }
  3592. if (rst == 0)
  3593. {
  3594. _groupRepository.CommitTran();
  3595. foreach (var item in msgDatas)
  3596. {
  3597. //发送消息
  3598. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3599. }
  3600. #region 应用推送
  3601. try
  3602. {
  3603. foreach (var ccpId in dic_ccp_user.Keys)
  3604. {
  3605. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3606. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3607. }
  3608. }
  3609. catch (Exception)
  3610. {
  3611. }
  3612. #endregion
  3613. return Ok(JsonView(true, "操作成功!"));
  3614. }
  3615. return Ok(JsonView(false, "操作失败!"));
  3616. }
  3617. #endregion
  3618. #region 机票费用录入
  3619. /// <summary>
  3620. /// 机票录入当前登录人可操作团组
  3621. /// </summary>
  3622. /// <param name="dto"></param>
  3623. /// <returns></returns>
  3624. [HttpPost]
  3625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3626. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3627. {
  3628. try
  3629. {
  3630. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3631. if (groupData.Code != 0)
  3632. {
  3633. return Ok(JsonView(false, groupData.Msg));
  3634. }
  3635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3636. }
  3637. catch (Exception ex)
  3638. {
  3639. return Ok(JsonView(false, "程序错误!"));
  3640. throw;
  3641. }
  3642. }
  3643. /// <summary>
  3644. /// 机票费用录入列表
  3645. /// </summary>
  3646. /// <param name="dto"></param>
  3647. /// <returns></returns>
  3648. [HttpPost]
  3649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3650. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3651. {
  3652. try
  3653. {
  3654. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3655. if (groupData.Code != 0)
  3656. {
  3657. return Ok(JsonView(false, groupData.Msg));
  3658. }
  3659. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3660. }
  3661. catch (Exception ex)
  3662. {
  3663. return Ok(JsonView(false, ex.Message));
  3664. throw;
  3665. }
  3666. }
  3667. /// <summary>
  3668. /// 根据id查询费用录入信息
  3669. /// </summary>
  3670. /// <param name="dto"></param>
  3671. /// <returns></returns>
  3672. [HttpPost]
  3673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3674. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3675. {
  3676. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3677. if (groupData.Code != 0)
  3678. {
  3679. return Ok(JsonView(false, groupData.Msg));
  3680. }
  3681. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3682. }
  3683. /// <summary>
  3684. /// 机票费用录入操作(Status:1.新增,2.修改)
  3685. /// </summary>
  3686. /// <param name="dto"></param>
  3687. /// <returns></returns>
  3688. [HttpPost]
  3689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3690. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3691. {
  3692. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3693. if (groupData.Code != 0)
  3694. {
  3695. return Ok(JsonView(false, groupData.Msg));
  3696. }
  3697. #region 应用推送
  3698. try
  3699. {
  3700. var diId = dto.AirTicketResOpData.DiId;
  3701. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3702. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3703. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3704. //自动审核
  3705. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId);
  3706. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3707. //2024-10-21 新增LZ UID
  3708. var userIds = new List<int>() { 21 };
  3709. string title = $"系统通知";
  3710. string content = "";
  3711. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3712. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3713. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3714. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3715. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3716. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3717. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3718. }
  3719. catch (Exception ex)
  3720. {
  3721. }
  3722. #endregion
  3723. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3724. }
  3725. /// <summary>
  3726. /// 机票费用录入
  3727. /// 自动审核测试
  3728. /// </summary>
  3729. /// <param name="groupId"></param>
  3730. /// <param name="Id"></param>
  3731. /// <returns></returns>
  3732. [HttpPost]
  3733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3734. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  3735. {
  3736. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(5, groupId, Id);
  3737. return Ok(JsonView(true, autoAdit.Msg, autoAdit.Data));
  3738. }
  3739. /// <summary>
  3740. /// 根据舱位类型查询接团客户名单信息
  3741. /// </summary>
  3742. /// <param name="dto"></param>
  3743. /// <returns></returns>
  3744. [HttpPost]
  3745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3746. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3747. {
  3748. try
  3749. {
  3750. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3751. if (crm_Groups.Count != 0)
  3752. {
  3753. List<dynamic> Customer = new List<dynamic>();
  3754. foreach (var item in crm_Groups)
  3755. {
  3756. var data = new
  3757. {
  3758. Id = item.Id,
  3759. Pinyin = item.Pinyin,
  3760. Name = item.LastName + item.FirstName
  3761. };
  3762. Customer.Add(data);
  3763. }
  3764. return Ok(JsonView(true, "查询成功!", Customer));
  3765. }
  3766. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3767. }
  3768. catch (Exception ex)
  3769. {
  3770. return Ok(JsonView(false, "程序错误!"));
  3771. throw;
  3772. }
  3773. }
  3774. /// <summary>
  3775. /// 根据团号获取客户信息
  3776. /// </summary>
  3777. /// <param name="dto"></param>
  3778. /// <returns></returns>
  3779. [HttpPost]
  3780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3781. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3782. {
  3783. var jw = JsonView(false);
  3784. if (dto.DIID < 1)
  3785. {
  3786. jw.Msg += "请输入正确的diid";
  3787. return Ok(jw);
  3788. }
  3789. var arr = getSimplClientList(dto.DIID);
  3790. jw = JsonView(true, "获取成功!", arr);
  3791. return Ok(jw);
  3792. }
  3793. private List<SimplClientInfo> getSimplClientList(int diId)
  3794. {
  3795. 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);
  3796. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3797. foreach (var item in arr)
  3798. {
  3799. EncryptionProcessor.DecryptProperties(item);
  3800. }
  3801. return arr;
  3802. }
  3803. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3804. {
  3805. string result = origin;
  3806. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3807. {
  3808. string[] temparr = origin.Split(',');
  3809. string fistrStr = temparr[0];
  3810. int count = temparr.Count();
  3811. int tempId;
  3812. bool success = int.TryParse(fistrStr, out tempId);
  3813. if (success)
  3814. {
  3815. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3816. if (tempInfo != null)
  3817. {
  3818. if (count > 1)
  3819. {
  3820. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3821. }
  3822. else
  3823. {
  3824. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3825. }
  3826. }
  3827. }
  3828. }
  3829. return result;
  3830. }
  3831. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3832. {
  3833. string result = origin;
  3834. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3835. {
  3836. string[] temparr = origin.Split(',');
  3837. result = "";
  3838. foreach (var item in temparr)
  3839. {
  3840. int tempId;
  3841. bool success = int.TryParse(item, out tempId);
  3842. if (success)
  3843. {
  3844. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3845. if (tempInfo != null)
  3846. {
  3847. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3848. }
  3849. }
  3850. }
  3851. }
  3852. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3853. return result;
  3854. }
  3855. /// <summary>
  3856. /// 机票费用录入,删除
  3857. /// </summary>
  3858. /// <param name="dto"></param>
  3859. /// <returns></returns>
  3860. [HttpPost]
  3861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3862. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3863. {
  3864. try
  3865. {
  3866. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3867. if (res)
  3868. {
  3869. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3870. {
  3871. IsDel = 1,
  3872. DeleteUserId = dto.DeleteUserId,
  3873. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3874. }).ExecuteCommandAsync();
  3875. return Ok(JsonView(true, "删除成功!"));
  3876. }
  3877. return Ok(JsonView(false, "删除失败!"));
  3878. }
  3879. catch (Exception ex)
  3880. {
  3881. return Ok(JsonView(false, "程序错误!"));
  3882. throw;
  3883. }
  3884. }
  3885. /// <summary>
  3886. /// 导出机票录入报表
  3887. /// </summary>
  3888. /// <param name="dto"></param>
  3889. /// <returns></returns>
  3890. [HttpPost]
  3891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3892. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3893. {
  3894. try
  3895. {
  3896. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3897. if (groupData.Code != 0)
  3898. {
  3899. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3900. }
  3901. else
  3902. {
  3903. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3904. if (AirTicketReservations.Count != 0)
  3905. {
  3906. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3907. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3908. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3909. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3910. WorkbookDesigner designer = new WorkbookDesigner();
  3911. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3912. decimal countCost = 0;
  3913. foreach (var item in AirTicketReservations)
  3914. {
  3915. #region 处理客人姓名
  3916. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3917. item.ClientName = clientNames;
  3918. #endregion
  3919. if (item.BankType == "其他")
  3920. {
  3921. item.BankNo = "--";
  3922. }
  3923. else
  3924. {
  3925. if (!string.IsNullOrEmpty(item.BankType))
  3926. {
  3927. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3928. }
  3929. }
  3930. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3931. item.Price = System.Decimal.Round(item.Price, 2);
  3932. countCost += Convert.ToDecimal(item.Price);
  3933. }
  3934. designer.SetDataSource("Export", AirTicketReservations);
  3935. designer.SetDataSource("ExportDiCode", diCode);
  3936. designer.SetDataSource("ExportDiName", diName);
  3937. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3938. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3939. designer.Process();
  3940. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3941. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3942. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3943. return Ok(JsonView(true, "成功", url = rst));
  3944. }
  3945. else
  3946. {
  3947. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3948. }
  3949. }
  3950. }
  3951. catch (Exception ex)
  3952. {
  3953. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3954. throw;
  3955. }
  3956. }
  3957. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3958. /// <summary>
  3959. /// 行程单导出
  3960. /// </summary>
  3961. /// <param name="dto"></param>
  3962. /// <returns></returns>
  3963. [HttpPost]
  3964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3965. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3966. {
  3967. try
  3968. {
  3969. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3970. if (groupData.Code != 0)
  3971. {
  3972. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3973. }
  3974. else
  3975. {
  3976. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3977. if (dto.Language == "CN")
  3978. {
  3979. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3980. DocumentBuilder builder = new DocumentBuilder(doc);
  3981. int tableIndex = 0;//表格索引
  3982. //得到文档中的第一个表格
  3983. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3984. foreach (var item in _AirTicketReservations)
  3985. {
  3986. #region 处理固定数据
  3987. string[] FlightsCode = item.FlightsCode.Split('/');
  3988. if (FlightsCode.Length != 0)
  3989. {
  3990. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3991. if (_AirCompany != null)
  3992. {
  3993. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3994. }
  3995. else
  3996. {
  3997. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3998. }
  3999. }
  4000. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4001. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4002. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4003. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4004. string name = "";
  4005. foreach (string clientName in nameArray)
  4006. {
  4007. if (!name.Contains(clientName))
  4008. {
  4009. name += clientName + ",";
  4010. }
  4011. }
  4012. if (!string.IsNullOrWhiteSpace(name))
  4013. {
  4014. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4015. }
  4016. else
  4017. {
  4018. table.Range.Bookmarks["ClientName"].Text = "--";
  4019. }
  4020. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4021. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4022. table.Range.Bookmarks["JointTicket"].Text = "--";
  4023. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4024. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4025. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4026. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4027. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4028. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4029. #endregion
  4030. #region 循环数据处理
  4031. List<AirInfo> airs = new List<AirInfo>();
  4032. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4033. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4034. for (int i = 0; i < FlightsCode.Length; i++)
  4035. {
  4036. AirInfo air = new AirInfo();
  4037. string[] tempstr = DayArray[i]
  4038. .Replace("\r\n", string.Empty)
  4039. .Replace("\\r\\n", string.Empty)
  4040. .TrimStart().TrimEnd()
  4041. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4042. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4043. string starCity = "";
  4044. if (star_Three != null)
  4045. {
  4046. starCity = star_Three.AirPort;
  4047. }
  4048. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4049. string EndCity = "";
  4050. if (End_Three != null)
  4051. {
  4052. EndCity = End_Three.AirPort;
  4053. }
  4054. air.Destination = starCity + "/" + EndCity;
  4055. air.Flight = FlightsCode[i];
  4056. air.SeatingClass = item.CTypeName;
  4057. string dateTime = tempstr[2];
  4058. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4059. air.FlightDate = DateTemp;
  4060. air.DepartureTime = tempstr[5];
  4061. air.LandingTime = tempstr[6];
  4062. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4063. air.TicketStatus = "--";
  4064. air.Luggage = "--";
  4065. air.DepartureTerminal = "--";
  4066. air.LandingTerminal = "--";
  4067. airs.Add(air);
  4068. }
  4069. int row = 13;
  4070. for (int i = 0; i < airs.Count; i++)
  4071. {
  4072. if (airs.Count > 2)
  4073. {
  4074. for (int j = 0; j < airs.Count - 2; j++)
  4075. {
  4076. var CopyRow = table.Rows[12].Clone(true);
  4077. table.Rows.Add(CopyRow);
  4078. }
  4079. }
  4080. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4081. int index = 0;
  4082. foreach (PropertyInfo property in properties)
  4083. {
  4084. string value = property.GetValue(airs[i]).ToString();
  4085. Cell ishcel0 = table.Rows[row].Cells[index];
  4086. Paragraph p = new Paragraph(doc);
  4087. string s = value;
  4088. p.AppendChild(new Run(doc, s));
  4089. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4090. ishcel0.AppendChild(p);
  4091. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4092. index++;
  4093. }
  4094. row++;
  4095. }
  4096. #endregion
  4097. Paragraph lastParagraph = new Paragraph(doc);
  4098. //第一个表格末尾加段落
  4099. table.ParentNode.InsertAfter(lastParagraph, table);
  4100. //复制第一个表格
  4101. Table cloneTable = (Table)table.Clone(true);
  4102. //在文档末尾段落后面加入复制的表格
  4103. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4104. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4105. {
  4106. int rownewsIndex = 13;
  4107. for (int i = 0; i < 2; i++)
  4108. {
  4109. var CopyRow = table.Rows[12].Clone(true);
  4110. table.Rows.RemoveAt(13);
  4111. table.Rows.Add(CopyRow);
  4112. rownewsIndex++;
  4113. }
  4114. }
  4115. else
  4116. {
  4117. table.Rows.RemoveAt(12);
  4118. }
  4119. cloneTable.Rows.RemoveAt(12);
  4120. }
  4121. if (_AirTicketReservations.Count != 0)
  4122. {
  4123. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4124. if (FlightsCode.Length != 0)
  4125. {
  4126. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4127. if (_AirCompany != null)
  4128. {
  4129. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4130. }
  4131. else
  4132. {
  4133. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4134. }
  4135. }
  4136. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4137. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4138. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4139. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4140. string name = "";
  4141. foreach (string clientName in nameArray)
  4142. {
  4143. if (!name.Contains(clientName))
  4144. {
  4145. name += clientName + ",";
  4146. }
  4147. }
  4148. if (!string.IsNullOrWhiteSpace(name))
  4149. {
  4150. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4151. }
  4152. else
  4153. {
  4154. table.Range.Bookmarks["ClientName"].Text = "--";
  4155. }
  4156. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4157. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4158. table.Range.Bookmarks["JointTicket"].Text = "--";
  4159. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4160. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4161. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4162. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4163. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4164. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4165. }
  4166. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4167. //保存合并后的文档
  4168. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4169. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4170. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4171. return Ok(JsonView(true, "成功!", rst));
  4172. }
  4173. else
  4174. {
  4175. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4176. DocumentBuilder builder = new DocumentBuilder(doc);
  4177. int tableIndex = 0;//表格索引
  4178. //得到文档中的第一个表格
  4179. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4180. List<string> texts = new List<string>();
  4181. foreach (var item in _AirTicketReservations)
  4182. {
  4183. string[] FlightsCode = item.FlightsCode.Split('/');
  4184. if (FlightsCode.Length != 0)
  4185. {
  4186. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4187. if (_AirCompany != null)
  4188. {
  4189. if (!transDic.ContainsKey(_AirCompany.CnName))
  4190. {
  4191. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4192. }
  4193. }
  4194. else
  4195. {
  4196. if (!transDic.ContainsKey("--"))
  4197. {
  4198. transDic.Add("--", "--");
  4199. }
  4200. }
  4201. }
  4202. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4203. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4204. string name = "";
  4205. foreach (string clientName in nameArray)
  4206. {
  4207. name += clientName + ",";
  4208. }
  4209. if (!texts.Contains(name))
  4210. {
  4211. texts.Add(name);
  4212. }
  4213. List<AirInfo> airs = new List<AirInfo>();
  4214. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4215. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4216. for (int i = 0; i < FlightsCode.Length; i++)
  4217. {
  4218. AirInfo air = new AirInfo();
  4219. string[] tempstr = DayArray[i]
  4220. .Replace("\r\n", string.Empty)
  4221. .Replace("\\r\\n", string.Empty)
  4222. .TrimStart().TrimEnd()
  4223. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4224. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4225. if (star_Three != null)
  4226. {
  4227. if (!transDic.ContainsKey(star_Three.AirPort))
  4228. {
  4229. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4230. }
  4231. }
  4232. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4233. if (End_Three != null)
  4234. {
  4235. if (!transDic.ContainsKey(End_Three.AirPort))
  4236. {
  4237. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4238. }
  4239. }
  4240. if (!texts.Contains(item.CTypeName))
  4241. {
  4242. texts.Add(item.CTypeName);
  4243. }
  4244. }
  4245. }
  4246. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4247. if (transData.Count > 0)
  4248. {
  4249. foreach (TranslateResult item in transData)
  4250. {
  4251. if (!transDic.ContainsKey(item.Query))
  4252. {
  4253. transDic.Add(item.Query, item.Translation);
  4254. }
  4255. }
  4256. }
  4257. foreach (var item in _AirTicketReservations)
  4258. {
  4259. #region 处理固定数据
  4260. string[] FlightsCode = item.FlightsCode.Split('/');
  4261. if (FlightsCode.Length != 0)
  4262. {
  4263. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4264. if (_AirCompany != null)
  4265. {
  4266. string str = "--";
  4267. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4268. if (!string.IsNullOrEmpty(translateResult))
  4269. {
  4270. str = translateResult;
  4271. str = _airTicketResRep.Processing(str);
  4272. }
  4273. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4274. }
  4275. else
  4276. {
  4277. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4278. }
  4279. }
  4280. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4281. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4282. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4283. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4284. string names = "";
  4285. foreach (string clientName in nameArray)
  4286. {
  4287. names += clientName + ",";
  4288. }
  4289. if (!string.IsNullOrWhiteSpace(names))
  4290. {
  4291. string str = "--";
  4292. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4293. if (!string.IsNullOrEmpty(translateResult))
  4294. {
  4295. str = translateResult;
  4296. str = _airTicketResRep.Processing(str);
  4297. }
  4298. table.Range.Bookmarks["ClientName"].Text = str;
  4299. }
  4300. else
  4301. {
  4302. table.Range.Bookmarks["ClientName"].Text = "--";
  4303. }
  4304. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4305. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4306. table.Range.Bookmarks["JointTicket"].Text = "--";
  4307. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4308. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4309. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4310. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4311. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4312. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4313. #endregion
  4314. #region 循环数据处理
  4315. List<AirInfo> airs = new List<AirInfo>();
  4316. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4317. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4318. for (int i = 0; i < FlightsCode.Length; i++)
  4319. {
  4320. AirInfo air = new AirInfo();
  4321. string[] tempstr = DayArray[i]
  4322. .Replace("\r\n", string.Empty)
  4323. .Replace("\\r\\n", string.Empty)
  4324. .TrimStart().TrimEnd()
  4325. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4326. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4327. string starCity = "";
  4328. if (star_Three != null)
  4329. {
  4330. string str2 = "--";
  4331. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4332. if (!string.IsNullOrEmpty(translateResult2))
  4333. {
  4334. str2 = translateResult2;
  4335. str2 = _airTicketResRep.Processing(str2);
  4336. }
  4337. starCity = str2;
  4338. }
  4339. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4340. string EndCity = "";
  4341. if (End_Three != null)
  4342. {
  4343. string str1 = "--";
  4344. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4345. if (!string.IsNullOrEmpty(translateResult1))
  4346. {
  4347. str1 = translateResult1;
  4348. str1 = _airTicketResRep.Processing(str1);
  4349. }
  4350. EndCity = str1;
  4351. }
  4352. air.Destination = starCity + "/" + EndCity;
  4353. air.Flight = FlightsCode[i];
  4354. string str = "--";
  4355. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4356. if (!string.IsNullOrEmpty(translateResult))
  4357. {
  4358. str = translateResult;
  4359. str = _airTicketResRep.Processing(str);
  4360. }
  4361. air.SeatingClass = str;
  4362. string dateTime = tempstr[2];
  4363. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4364. air.FlightDate = DateTemp;
  4365. air.DepartureTime = tempstr[5];
  4366. air.LandingTime = tempstr[6];
  4367. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4368. air.TicketStatus = "--";
  4369. air.Luggage = "--";
  4370. air.DepartureTerminal = "--";
  4371. air.LandingTerminal = "--";
  4372. airs.Add(air);
  4373. }
  4374. int row = 13;
  4375. for (int i = 0; i < airs.Count; i++)
  4376. {
  4377. if (airs.Count > 2)
  4378. {
  4379. for (int j = 0; j < airs.Count - 2; j++)
  4380. {
  4381. var CopyRow = table.Rows[12].Clone(true);
  4382. table.Rows.Add(CopyRow);
  4383. }
  4384. }
  4385. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4386. int index = 0;
  4387. foreach (PropertyInfo property in properties)
  4388. {
  4389. string value = property.GetValue(airs[i]).ToString();
  4390. Cell ishcel0 = table.Rows[row].Cells[index];
  4391. Paragraph p = new Paragraph(doc);
  4392. string s = value;
  4393. p.AppendChild(new Run(doc, s));
  4394. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4395. ishcel0.AppendChild(p);
  4396. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4397. //ishcel0.CellFormat.VerticalAlignment=
  4398. index++;
  4399. }
  4400. row++;
  4401. }
  4402. #endregion
  4403. Paragraph lastParagraph = new Paragraph(doc);
  4404. //第一个表格末尾加段落
  4405. table.ParentNode.InsertAfter(lastParagraph, table);
  4406. //复制第一个表格
  4407. Table cloneTable = (Table)table.Clone(true);
  4408. //在文档末尾段落后面加入复制的表格
  4409. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4410. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4411. {
  4412. int rownewsIndex = 13;
  4413. for (int i = 0; i < 2; i++)
  4414. {
  4415. var CopyRow = table.Rows[12].Clone(true);
  4416. table.Rows.RemoveAt(13);
  4417. table.Rows.Add(CopyRow);
  4418. rownewsIndex++;
  4419. }
  4420. }
  4421. else
  4422. {
  4423. table.Rows.RemoveAt(12);
  4424. }
  4425. cloneTable.Rows.RemoveAt(12);
  4426. }
  4427. if (_AirTicketReservations.Count != 0)
  4428. {
  4429. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4430. if (FlightsCode.Length != 0)
  4431. {
  4432. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4433. if (_AirCompany != null)
  4434. {
  4435. string str = "--";
  4436. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4437. if (!string.IsNullOrEmpty(translateResult))
  4438. {
  4439. str = translateResult;
  4440. str = _airTicketResRep.Processing(str);
  4441. }
  4442. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4443. }
  4444. else
  4445. {
  4446. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4447. }
  4448. }
  4449. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4450. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4451. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4452. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4453. string names = "";
  4454. foreach (string clientName in nameArray)
  4455. {
  4456. names += clientName + ",";
  4457. }
  4458. if (!string.IsNullOrWhiteSpace(names))
  4459. {
  4460. string str = "--";
  4461. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4462. if (!string.IsNullOrEmpty(translateResult))
  4463. {
  4464. str = translateResult;
  4465. str = _airTicketResRep.Processing(str);
  4466. }
  4467. table.Range.Bookmarks["ClientName"].Text = str;
  4468. }
  4469. else
  4470. {
  4471. table.Range.Bookmarks["ClientName"].Text = "--";
  4472. }
  4473. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4474. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4475. table.Range.Bookmarks["JointTicket"].Text = "--";
  4476. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4477. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4478. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4479. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4480. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4481. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4482. }
  4483. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4484. //保存合并后的文档
  4485. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4486. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4487. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4488. return Ok(JsonView(true, "成功!", rst));
  4489. }
  4490. }
  4491. }
  4492. catch (Exception ex)
  4493. {
  4494. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4495. throw;
  4496. }
  4497. }
  4498. #endregion
  4499. #region 团组增减款项 --> 其他款项
  4500. /// <summary>
  4501. /// 团组增减款项下拉框绑定
  4502. /// </summary>
  4503. /// <param name="dto"></param>
  4504. /// <returns></returns>
  4505. [HttpPost]
  4506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4507. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4508. {
  4509. #region 参数验证
  4510. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4511. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4512. #endregion
  4513. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4514. }
  4515. /// <summary>
  4516. /// 根据团组Id查询团组增减款项
  4517. /// </summary>
  4518. /// <param name="dto"></param>
  4519. /// <returns></returns>
  4520. [HttpPost]
  4521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4522. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4523. {
  4524. #region 参数验证
  4525. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4526. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4527. #endregion
  4528. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4529. }
  4530. /// <summary>
  4531. /// 团组增减款项操作(Status:1.新增,2.修改)
  4532. /// </summary>
  4533. /// <param name="dto"></param>
  4534. /// <returns></returns>
  4535. [HttpPost]
  4536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4537. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4538. {
  4539. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4540. if (groupData.Code != 200)
  4541. {
  4542. return Ok(JsonView(false, groupData.Msg));
  4543. }
  4544. #region 应用推送
  4545. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4546. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4547. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4548. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4549. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4550. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4551. //自动审核
  4552. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4553. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4554. //2024-10-21 新增LZ UID
  4555. var userIds = new List<int>() { 21 };
  4556. string title = $"系统通知";
  4557. string content = "";
  4558. var diId = dto.DiId;
  4559. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4560. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4561. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4562. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4563. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4564. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4565. #endregion
  4566. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4567. }
  4568. /// <summary>
  4569. /// 团组增减款项操作 删除
  4570. /// </summary>
  4571. /// <param name="dto"></param>
  4572. /// <returns></returns>
  4573. [HttpPost]
  4574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4575. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4576. {
  4577. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4578. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4579. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4580. if (res.Code == 0)
  4581. {
  4582. return Ok(JsonView(true, "删除成功!"));
  4583. }
  4584. return Ok(JsonView(false, "删除失败!"));
  4585. }
  4586. /// <summary>
  4587. /// 根据团组增减款项Id查询
  4588. /// </summary>
  4589. /// <param name="dto"></param>
  4590. /// <returns></returns>
  4591. [HttpPost]
  4592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4593. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4594. {
  4595. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4596. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4597. }
  4598. /// <summary>
  4599. /// 查询供应商名称
  4600. /// </summary>
  4601. /// <param name="dto"></param>
  4602. /// <returns></returns>
  4603. [HttpPost]
  4604. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4605. {
  4606. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4607. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4608. ?? new List<Grp_DecreasePayments>();
  4609. dbResult = dbResult.Distinct(new
  4610. ProductComparer()).ToList();
  4611. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4612. {
  4613. x.Id,
  4614. x.SupplierAddress,
  4615. x.SupplierArea,
  4616. x.SupplierContact,
  4617. x.SupplierContactNumber,
  4618. x.SupplierEmail,
  4619. x.SupplierName,
  4620. x.SupplierSocialAccount,
  4621. x.SupplierTypeId,
  4622. }).ToList());
  4623. return Ok(jw);
  4624. }
  4625. /// <summary>
  4626. /// 团组增减款项 OTA匹配
  4627. /// </summary>
  4628. /// <param name="file"></param>
  4629. /// <returns></returns>
  4630. [HttpPost]
  4631. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4632. {
  4633. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4634. string fileName = file.FileName;
  4635. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4636. {
  4637. return Ok(JsonView(false, "请上传Excel文件!"));
  4638. }
  4639. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4640. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4641. if (!Directory.Exists(path))
  4642. {
  4643. Directory.CreateDirectory(path);
  4644. }
  4645. var filePath = @$"{path}/{fileName}";
  4646. //保存文件
  4647. using (FileStream fs = System.IO.File.Create(filePath))
  4648. {
  4649. file.CopyTo(fs);
  4650. fs.Flush();
  4651. }
  4652. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4653. //读取ExcelFile
  4654. DataTable dt = ConvertExcelToDataTable(filePath);
  4655. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4656. dt.TableName = "TB";
  4657. //修改table列名
  4658. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4659. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4660. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4661. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4662. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4663. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4664. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4665. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4666. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4667. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4668. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4669. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4670. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4671. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4672. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4673. var otaOrderNos = new List<string>();
  4674. foreach (DataRow item in dt.Rows)
  4675. {
  4676. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4677. }
  4678. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4679. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4680. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4681. .Select((dp, di) => new
  4682. {
  4683. dp.PriceName,
  4684. dp.OTAOrderNo,
  4685. dp.FeeTotal,
  4686. di.TeamName,
  4687. })
  4688. .ToListAsync();
  4689. foreach (DataRow item in dt.Rows)
  4690. {
  4691. var otaOrderNo = item["OTAOrderNo"].ToString();
  4692. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4693. if (oaData == null) continue;
  4694. item["GroupName"] = oaData.TeamName;
  4695. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4696. }
  4697. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4698. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4699. List<DataTable> datas = new List<DataTable>();
  4700. datas.Add(dt);
  4701. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4702. return Ok(JsonView(true, "操作成功", new { url = url }));
  4703. }
  4704. #region
  4705. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4706. {
  4707. // 创建Workbook对象
  4708. Workbook workbook = new Workbook(excelFilePath);
  4709. // 获取第一个工作表
  4710. Worksheet worksheet = workbook.Worksheets[0];
  4711. // 将工作表转换为DataTable
  4712. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4713. return dataTable;
  4714. }
  4715. #endregion
  4716. #endregion
  4717. #region 文件上传、删除
  4718. /// <summary>
  4719. /// region 文件上传 可以带参数
  4720. /// </summary>
  4721. /// <param name="file"></param>
  4722. /// <returns></returns>
  4723. [HttpPost]
  4724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4725. public async Task<IActionResult> UploadProject(IFormFile file)
  4726. {
  4727. //var TypeName = Request.Headers["TypeName"].ToString();
  4728. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4729. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4730. ////文件名称
  4731. //string projectFileName = file.FileName;
  4732. ////上传的文件的路径
  4733. //string filePath = $"{fileDir}/{projectFileName}";
  4734. //if (TypeName == "A")//A代表团组增减款项
  4735. //{
  4736. // filePath = fileDir + $@"\团组增减款项相关文件";
  4737. // if (!Directory.Exists(filePath))
  4738. // {
  4739. // Directory.CreateDirectory(filePath);
  4740. // }
  4741. // //上传的文件的路径
  4742. // filePath += $@"\{projectFileName}";
  4743. //}
  4744. //else if (TypeName == "B")//B代表商邀相关文件
  4745. //{
  4746. // //上传的文件的路径
  4747. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4748. // if (!Directory.Exists(filePath))
  4749. // {
  4750. // Directory.CreateDirectory(filePath);
  4751. // }
  4752. // //上传的文件的路径
  4753. // filePath = $@"\{projectFileName}";
  4754. //}
  4755. //try
  4756. //{
  4757. // using (FileStream fs = System.IO.File.Create(filePath))
  4758. // {
  4759. // file.CopyTo(fs);
  4760. // fs.Flush();
  4761. // }
  4762. //}
  4763. //catch (Exception ex)
  4764. //{
  4765. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4766. //}
  4767. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4768. try
  4769. {
  4770. var TypeName = Request.Headers["TypeName"].ToString();
  4771. if (file != null)
  4772. {
  4773. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4774. //文件名称
  4775. string projectFileName = file.FileName;
  4776. //上传的文件的路径
  4777. string filePath = $"{fileDir}/{projectFileName}";
  4778. if (TypeName == "A")//A代表团组增减款项
  4779. {
  4780. if (!Directory.Exists(fileDir))
  4781. {
  4782. Directory.CreateDirectory(fileDir);
  4783. }
  4784. //上传的文件的路径
  4785. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4786. }
  4787. else if (TypeName == "B")//B代表商邀相关文件
  4788. {
  4789. if (!Directory.Exists(fileDir))
  4790. {
  4791. Directory.CreateDirectory(fileDir);
  4792. }
  4793. //上传的文件的路径
  4794. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4795. }
  4796. using (FileStream fs = System.IO.File.Create(filePath))
  4797. {
  4798. file.CopyTo(fs);
  4799. fs.Flush();
  4800. }
  4801. return Ok(JsonView(true, "上传成功!", projectFileName));
  4802. }
  4803. else
  4804. {
  4805. return Ok(JsonView(false, "上传失败!"));
  4806. }
  4807. }
  4808. catch (Exception ex)
  4809. {
  4810. return Ok(JsonView(false, "程序错误!"));
  4811. }
  4812. }
  4813. /// <summary>
  4814. /// 删除指定文件
  4815. /// </summary>
  4816. /// <param name="dto"></param>
  4817. /// <returns></returns>
  4818. [HttpPost]
  4819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4820. public async Task<IActionResult> DelFile(DelFileDto dto)
  4821. {
  4822. try
  4823. {
  4824. var TypeName = Request.Headers["TypeName"].ToString();
  4825. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4826. string filePath = "";
  4827. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4828. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4829. int id = 0;
  4830. if (TypeName == "A")
  4831. {
  4832. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4833. // 删除该文件
  4834. System.IO.File.Delete(filePath);
  4835. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4836. .Where(a => a.Id == dto.Id)
  4837. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4838. .ExecuteCommandAsync();
  4839. }
  4840. else if (TypeName == "B")
  4841. {
  4842. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4843. // 删除该文件
  4844. System.IO.File.Delete(filePath);
  4845. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4846. if (info != null)
  4847. {
  4848. string[] files = new string[] { };
  4849. if (!string.IsNullOrEmpty(info.Attachment))
  4850. {
  4851. try
  4852. {
  4853. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4854. }
  4855. catch (Exception)
  4856. {
  4857. files = new List<string>() { info.Attachment }.ToArray();
  4858. }
  4859. }
  4860. if (files.Length > 0)
  4861. {
  4862. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4863. string filePath2 = string.Empty;
  4864. if (files1.Length > 0)
  4865. {
  4866. filePath2 = JsonConvert.SerializeObject(files1);
  4867. }
  4868. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4869. .Where(a => a.Id == dto.Id)
  4870. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4871. .ExecuteCommandAsync();
  4872. }
  4873. }
  4874. }
  4875. if (id != 0)
  4876. {
  4877. return Ok(JsonView(true, "成功!"));
  4878. }
  4879. else
  4880. {
  4881. return Ok(JsonView(false, "失败!"));
  4882. }
  4883. }
  4884. catch (Exception ex)
  4885. {
  4886. return Ok(JsonView(false, "程序错误!"));
  4887. throw;
  4888. }
  4889. }
  4890. /// <summary>
  4891. /// 文件上传多个文件 可以带参数
  4892. /// </summary>
  4893. /// <param name="files"></param>
  4894. /// <returns></returns>
  4895. [HttpPost]
  4896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4897. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4898. {
  4899. try
  4900. {
  4901. var TypeName = Request.Headers["TypeName"].ToString();
  4902. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4903. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4904. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4905. var filePahts = new List<string>();
  4906. foreach (var file in files)
  4907. {
  4908. //文件名称
  4909. string projectFileName = file.FileName;
  4910. //上传的文件的路径
  4911. string filePath = $"{fileDir}/{projectFileName}";
  4912. if (TypeName == "A")//A代表团组增减款项
  4913. {
  4914. if (!Directory.Exists(fileDir))
  4915. {
  4916. Directory.CreateDirectory(fileDir);
  4917. }
  4918. //上传的文件的路径
  4919. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4920. }
  4921. else if (TypeName == "B")//B代表商邀相关文件
  4922. {
  4923. if (!Directory.Exists(fileDir))
  4924. {
  4925. Directory.CreateDirectory(fileDir);
  4926. }
  4927. //上传的文件的路径
  4928. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4929. }
  4930. using (FileStream fs = System.IO.File.Create(filePath))
  4931. {
  4932. file.CopyTo(fs);
  4933. fs.Flush();
  4934. }
  4935. filePahts.Add(projectFileName);
  4936. }
  4937. return Ok(JsonView(true, "上传成功!", filePahts));
  4938. }
  4939. catch (Exception ex)
  4940. {
  4941. return Ok(JsonView(false, "程序错误!"));
  4942. }
  4943. }
  4944. #endregion
  4945. #region 商邀费用录入
  4946. /// <summary>
  4947. /// 根据团组Id查询商邀费用列表
  4948. /// </summary>
  4949. /// <param name="dto"></param>
  4950. /// <returns></returns>
  4951. [HttpPost]
  4952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4953. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4954. {
  4955. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4956. if (groupData.Code != 0)
  4957. {
  4958. return Ok(JsonView(false, groupData.Msg));
  4959. }
  4960. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4961. }
  4962. /// <summary>
  4963. /// 商邀费用列表
  4964. /// 下载文件
  4965. /// </summary>
  4966. /// <param name="id"></param>
  4967. /// <returns></returns>
  4968. [HttpGet("{id}")]
  4969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4970. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4971. {
  4972. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4973. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4974. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4975. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4976. var filePaths = new List<string>();
  4977. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4978. try
  4979. {
  4980. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4981. }
  4982. catch (Exception ex)
  4983. {
  4984. filePaths.Add(info.Attachment);
  4985. }
  4986. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4987. for (int i = 0; i < filePaths.Count; i++)
  4988. {
  4989. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4990. }
  4991. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4992. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4993. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4994. {
  4995. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4996. {
  4997. foreach (string filePath in filePaths)
  4998. {
  4999. if (System.IO.File.Exists(filePath))
  5000. {
  5001. // 获取文件名
  5002. string fileName = Path.GetFileName(filePath);
  5003. // 将文件添加到ZIP归档中
  5004. zipArchive.CreateEntryFromFile(filePath, fileName);
  5005. }
  5006. }
  5007. }
  5008. }
  5009. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5010. }
  5011. /// <summary>
  5012. /// 商邀费用 Info Page 基础数据源
  5013. /// </summary>
  5014. /// <returns></returns>
  5015. [HttpPost]
  5016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5017. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5018. {
  5019. try
  5020. {
  5021. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  5022. if (groupData.Code != 0)
  5023. {
  5024. return Ok(JsonView(false, groupData.Msg));
  5025. }
  5026. return Ok(JsonView(true, "操作成功", groupData.Data));
  5027. }
  5028. catch (Exception ex)
  5029. {
  5030. return Ok(JsonView(false, ex.Message));
  5031. throw;
  5032. }
  5033. }
  5034. /// <summary>
  5035. /// 根据商邀费用ID查询C表和商邀费用数据
  5036. /// </summary>
  5037. /// <param name="dto"></param>
  5038. /// <returns></returns>
  5039. [HttpPost]
  5040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5041. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5042. {
  5043. try
  5044. {
  5045. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5046. if (groupData.Code != 0)
  5047. {
  5048. return Ok(JsonView(false, groupData.Msg));
  5049. }
  5050. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5051. }
  5052. catch (Exception ex)
  5053. {
  5054. return Ok(JsonView(false, ex.Message));
  5055. throw;
  5056. }
  5057. }
  5058. /// <summary>
  5059. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5060. /// </summary>
  5061. /// <param name="dto"></param>
  5062. /// <returns></returns>
  5063. [HttpPost]
  5064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5065. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5066. {
  5067. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5068. if (groupData.Code != 0)
  5069. {
  5070. return Ok(JsonView(false, groupData.Msg));
  5071. }
  5072. #region 应用推送
  5073. try
  5074. {
  5075. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5076. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5077. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5078. //2024-10-21 新增LZ UID
  5079. var userIds = new List<int>() { 21 };
  5080. string title = $"系统通知";
  5081. string content = "";
  5082. var diId = dto.DiId;
  5083. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5084. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5085. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5086. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5087. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5088. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5089. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5090. }
  5091. catch (Exception ex)
  5092. {
  5093. }
  5094. #endregion
  5095. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5096. }
  5097. /// <summary>
  5098. /// 商邀删除
  5099. /// </summary>
  5100. /// <param name="dto"></param>
  5101. /// <returns></returns>
  5102. [HttpPost]
  5103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5104. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5105. {
  5106. try
  5107. {
  5108. _sqlSugar.BeginTran();
  5109. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5110. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5111. {
  5112. IsDel = 1,
  5113. DeleteUserId = dto.DeleteUserId,
  5114. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5115. })
  5116. .Where(it => it.Id == dto.Id)
  5117. .ExecuteCommand();
  5118. if (res1 > 0)
  5119. {
  5120. int _diId = 0;
  5121. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5122. if (_ioaInfo != null)
  5123. {
  5124. _diId = _ioaInfo.DiId;
  5125. }
  5126. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5127. .SetColumns(a => new Grp_CreditCardPayment()
  5128. {
  5129. IsDel = 1,
  5130. DeleteUserId = dto.DeleteUserId,
  5131. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5132. })
  5133. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5134. .ExecuteCommand();
  5135. if (res2 > 0)
  5136. {
  5137. _sqlSugar.CommitTran();
  5138. return Ok(JsonView(true, "删除成功!"));
  5139. }
  5140. }
  5141. _sqlSugar.RollbackTran();
  5142. return Ok(JsonView(false, "删除失败"));
  5143. }
  5144. catch (Exception ex)
  5145. {
  5146. _sqlSugar.RollbackTran();
  5147. return Ok(JsonView(false, ex.Message));
  5148. }
  5149. }
  5150. #endregion
  5151. #region 票据上传
  5152. /// <summary>
  5153. /// 团组模块文件上传
  5154. /// </summary>
  5155. /// <param name="dto"></param>
  5156. /// <returns></returns>
  5157. [HttpPost]
  5158. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5159. {
  5160. var jw = JsonView(false);
  5161. long M = 1024 * 1024;
  5162. if (dto.Files == null || dto.Files.Count == 0)
  5163. {
  5164. jw.Msg = "无文件信息!";
  5165. return Ok(jw);
  5166. }
  5167. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5168. {
  5169. jw.Msg = "文件大小超过20M!";
  5170. return Ok(jw);
  5171. }
  5172. //var nameSp = dto.File.FileName.Split(".");
  5173. //if (nameSp.Length < 2)
  5174. //{
  5175. // jw.Msg = "拓展名称有误!";
  5176. // return Ok(jw);
  5177. //}
  5178. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5179. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5180. //{
  5181. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5182. // return Ok(jw);
  5183. //}
  5184. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5185. if (Ctable == null)
  5186. {
  5187. jw.Msg = "Ctable指向有误!";
  5188. return Ok(jw);
  5189. }
  5190. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5191. if (groupInfo == null)
  5192. {
  5193. jw.Msg = "团组信息不存在!";
  5194. return Ok(jw);
  5195. }
  5196. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5197. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5198. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5199. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5200. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5201. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5202. try
  5203. {
  5204. if (!Directory.Exists(fileBase))
  5205. {
  5206. Directory.CreateDirectory(fileBase);
  5207. }
  5208. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5209. foreach (var fileStream in dto.Files)
  5210. {
  5211. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5212. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5213. {
  5214. Cid = dto.Cid,
  5215. CreateTime = DateTime.Now,
  5216. CreateUserId = dto.Userid,
  5217. Ctable = dto.Ctable,
  5218. Diid = dto.Diid,
  5219. IsDel = 0,
  5220. FilePath = saveFilePath,
  5221. FileName = fileStream.FileName
  5222. };
  5223. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5224. {
  5225. fileStream.CopyTo(fs);
  5226. fs.Flush();
  5227. }
  5228. saveArr.Add(file);
  5229. }
  5230. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5231. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5232. jw = JsonView(true, "保存成功!", new
  5233. {
  5234. count = addResult,
  5235. filesName = saveArr.Select(x => x.FileName)
  5236. });
  5237. }
  5238. catch (Exception ex)
  5239. {
  5240. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5241. {
  5242. count = 0,
  5243. filesName = new string[0],
  5244. });
  5245. }
  5246. return Ok(jw);
  5247. }
  5248. /// <summary>
  5249. /// 查询各模块已保存文件
  5250. /// </summary>
  5251. /// <param name="dto"></param>
  5252. /// <returns></returns>
  5253. [HttpPost]
  5254. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5255. {
  5256. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5257. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5258. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5259. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5260. {
  5261. expression = Expressionable.Create<Grp_GroupModelFile>()
  5262. .And(x => visaIds.Contains(x.CreateUserId));
  5263. }
  5264. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5265. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5266. .Where(expression.ToExpression())
  5267. .ToList();
  5268. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5269. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5270. {
  5271. x.FileName,
  5272. x.Id,
  5273. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5274. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5275. })));
  5276. }
  5277. /// <summary>
  5278. /// 下载该团组下的所有文件
  5279. /// </summary>
  5280. /// <param name="dto"></param>
  5281. /// <returns></returns>
  5282. [HttpPost]
  5283. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5284. {
  5285. var jw = JsonView(false);
  5286. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5287. if (groupInfo == null)
  5288. {
  5289. jw.Msg = "团组信息不存在!";
  5290. return Ok(jw);
  5291. }
  5292. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5293. var isModule = Convert.ToBoolean(dto.isModule);
  5294. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5295. IOOperatorHelper io = new IOOperatorHelper();
  5296. if (isModule)
  5297. {
  5298. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5299. foreach (var moduleArr in moduleGroup)
  5300. {
  5301. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5302. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5303. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5304. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5305. foreach (var item in moduleArr)
  5306. {
  5307. if (System.IO.File.Exists(item.FilePath))
  5308. {
  5309. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5310. {
  5311. byte[] bytes = new byte[fileStream.Length];
  5312. fileStream.Read(bytes, 0, bytes.Length);
  5313. fileStream.Close();
  5314. Stream stream = new MemoryStream(bytes);
  5315. chiZips.Add(item.FileName, stream);
  5316. }
  5317. }
  5318. }
  5319. if (chiZips.Count > 0)
  5320. {
  5321. var byts = io.ConvertZipStream(chiZips);
  5322. Stream stream = new MemoryStream(byts);
  5323. Zips.Add(key.Name + "_.zip", stream);
  5324. }
  5325. }
  5326. }
  5327. else
  5328. {
  5329. foreach (var item in dbQuery)
  5330. {
  5331. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5332. {
  5333. byte[] bytes = new byte[fileStream.Length];
  5334. fileStream.Read(bytes, 0, bytes.Length);
  5335. fileStream.Close();
  5336. Stream stream = new MemoryStream(bytes);
  5337. while (Zips.Keys.Contains(item.FileName))
  5338. {
  5339. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5340. }
  5341. Zips.Add(item.FileName, stream);
  5342. }
  5343. }
  5344. }
  5345. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5346. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5347. if (Zips.Count > 0)
  5348. {
  5349. var byts = io.ConvertZipStream(Zips);
  5350. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5351. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5352. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5353. }
  5354. else
  5355. {
  5356. jw.Msg = "暂无生成文件!";
  5357. }
  5358. return Ok(jw);
  5359. }
  5360. /// <summary>
  5361. /// 下载该团组下此模块的所有文件
  5362. /// </summary>
  5363. /// <param name="dto"></param>
  5364. /// <returns></returns>
  5365. [HttpPost]
  5366. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5367. {
  5368. var jw = JsonView(false);
  5369. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5370. if (groupInfo == null)
  5371. {
  5372. jw.Msg = "团组信息不存在!";
  5373. return Ok(jw);
  5374. }
  5375. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5376. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5377. && x.IsDel == 0);
  5378. if (key == null)
  5379. {
  5380. jw.Msg = "Ctable指向错误!";
  5381. return Ok(jw);
  5382. }
  5383. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5384. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5385. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5386. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5387. IOOperatorHelper io = new IOOperatorHelper();
  5388. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5389. foreach (var item in dbQuery)
  5390. {
  5391. if (System.IO.File.Exists(item.FilePath))
  5392. {
  5393. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5394. {
  5395. byte[] bytes = new byte[fileStream.Length];
  5396. fileStream.Read(bytes, 0, bytes.Length);
  5397. fileStream.Close();
  5398. Stream stream = new MemoryStream(bytes);
  5399. while (Zips.Keys.Contains(item.FileName))
  5400. {
  5401. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5402. }
  5403. Zips.Add(item.FileName, stream);
  5404. }
  5405. }
  5406. }
  5407. if (Zips.Count > 0)
  5408. {
  5409. var byts = io.ConvertZipStream(Zips);
  5410. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5411. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5412. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5413. }
  5414. else
  5415. {
  5416. jw.Msg = "暂无生成文件!";
  5417. }
  5418. return Ok(jw);
  5419. }
  5420. /// <summary>
  5421. /// 删除该团组下的指定文件
  5422. /// </summary>
  5423. /// <param name="dto"></param>
  5424. /// <returns></returns>
  5425. [HttpPost]
  5426. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5427. {
  5428. var jw = JsonView(false);
  5429. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5430. if (sing == null)
  5431. {
  5432. jw.Msg = "暂无";
  5433. return Ok(jw);
  5434. }
  5435. if (System.IO.File.Exists(sing.FilePath))
  5436. {
  5437. try
  5438. {
  5439. System.IO.File.Delete(sing.FilePath);
  5440. }
  5441. catch (Exception ex)
  5442. {
  5443. jw.Msg = "删除失败!" + ex.Message;
  5444. return Ok(jw);
  5445. }
  5446. }
  5447. sing.IsDel = 1;
  5448. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5449. sing.DeleteUserId = dto.UserId;
  5450. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5451. jw = JsonView(true, "删除成功!");
  5452. return Ok(jw);
  5453. }
  5454. #endregion
  5455. #region 共享文件上传
  5456. /// <summary>
  5457. /// 共享文件数据初始化
  5458. /// </summary>
  5459. /// <returns></returns>
  5460. [HttpGet]
  5461. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5462. {
  5463. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5464. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5465. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5466. .Select(x => x.Id)
  5467. .ToList()
  5468. .Contains(userid);
  5469. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5470. .Where(x => x.STid == 111 && x.IsDel == 0)
  5471. .Select(x => new
  5472. {
  5473. x.Name,
  5474. x.Id,
  5475. }).ToList();
  5476. if (isMarketingDepartment)
  5477. {
  5478. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5479. }
  5480. if (portType == 1)
  5481. {
  5482. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5483. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5484. .Where(x => x.IsDel == 0)
  5485. .OrderByDescending(x => x.VisitDate)
  5486. .Select(x => new
  5487. {
  5488. x.TeamName,
  5489. x.Id,
  5490. x.CityId,
  5491. })
  5492. .ToList()
  5493. .Select(x =>
  5494. {
  5495. var provinceId = x.CityId;
  5496. var isDefualtVal = true;
  5497. if (provinceId > 0)
  5498. {
  5499. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5500. if (parentId != null)
  5501. {
  5502. isDefualtVal = false;
  5503. provinceId = (int)parentId;
  5504. }
  5505. }
  5506. if (isDefualtVal)
  5507. {
  5508. provinceId = 122; //默认四川
  5509. }
  5510. return new
  5511. {
  5512. x.TeamName,
  5513. x.Id,
  5514. provinceId,
  5515. };
  5516. })
  5517. .ToList();
  5518. return Ok(JsonView(true, "SUCCESS!", new
  5519. {
  5520. dropDownType,
  5521. dropDownGroupList,
  5522. isMarketingDepartment
  5523. }));
  5524. }
  5525. else if (portType == 2 || portType == 3)
  5526. {
  5527. return Ok(JsonView(true, "SUCCESS!", new
  5528. {
  5529. dropDownType,
  5530. isMarketingDepartment
  5531. }));
  5532. }
  5533. else
  5534. {
  5535. return Ok(JsonView(false, "portType有误!"));
  5536. }
  5537. }
  5538. /// <summary>
  5539. /// 共享文件上传
  5540. /// </summary>
  5541. /// <param name="dto"></param>
  5542. /// <returns></returns>
  5543. [HttpPost]
  5544. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5545. {
  5546. var isGroup = new List<int> { 1412 };
  5547. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5548. {
  5549. return Ok(JsonView(false, "该文件需要关联团组!"));
  5550. }
  5551. if (dto.Files == null || dto.Files.Count == 0)
  5552. {
  5553. return Ok(JsonView(false, "无文件信息!"));
  5554. }
  5555. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5556. {
  5557. return Ok(JsonView(false, "文件大小超过20M!"));
  5558. }
  5559. if (dto.Userid < 1)
  5560. {
  5561. return Ok(JsonView(false, "请传入有效的Userid!"));
  5562. }
  5563. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5564. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5565. .Select((u, j) => new
  5566. {
  5567. u.CnName,
  5568. UserId = u.Id,
  5569. j.JobName,
  5570. })
  5571. .First();
  5572. if (jobInfo == null)
  5573. {
  5574. return Ok(JsonView(false, "请传入有效的Userid!"));
  5575. }
  5576. List<string> commonFileExtensions = new List<string>
  5577. {
  5578. // 文本文件
  5579. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5580. // 图片文件
  5581. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5582. // 视频文件
  5583. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5584. // 音频文件
  5585. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5586. // 压缩文件
  5587. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5588. // 数据文件
  5589. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5590. };
  5591. try
  5592. {
  5593. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5594. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5595. commonFileExtensions.AddRange(settingExtend);
  5596. }
  5597. catch (Exception)
  5598. { }
  5599. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5600. if (setdata == null)
  5601. {
  5602. return Ok(JsonView(false, "请传入有效的FileType!"));
  5603. }
  5604. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5605. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5606. if (!Directory.Exists(winPath))
  5607. {
  5608. Directory.CreateDirectory(winPath);
  5609. }
  5610. foreach (var item in dto.Files)
  5611. {
  5612. var houzui = Path.GetExtension(item.FileName);
  5613. if (!commonFileExtensions.Contains(houzui))
  5614. {
  5615. return Ok(JsonView(false, "未知后缀名称!"));
  5616. }
  5617. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5618. var saveFilePath = winPath + fileName;
  5619. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5620. {
  5621. item.CopyTo(fs);
  5622. fs.Flush();
  5623. }
  5624. var fileDetail = new Grp_GroupShareFile()
  5625. {
  5626. CreateUserId = dto.Userid,
  5627. CreateTime = DateTime.Now,
  5628. UploadJob = jobInfo.JobName,
  5629. FileName = fileName,
  5630. FileType = dto.FileType,
  5631. Diid = dto.Diid,
  5632. FilePath = winPath + fileName,
  5633. };
  5634. insertList.Add(fileDetail);
  5635. }
  5636. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5637. return Ok(JsonView(true, "保存成功!"));
  5638. }
  5639. /// <summary>
  5640. /// 查询共享文件列表
  5641. /// </summary>
  5642. /// <param name="dto"></param>
  5643. /// <returns></returns>
  5644. [HttpPost]
  5645. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5646. {
  5647. var isGroup = new List<int> { 1412 };
  5648. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5649. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5650. .And(x => x.Diid == dto.Diid)
  5651. .And(x => x.FileType == dto.FileType)
  5652. .And(x => x.IsDel == 0)
  5653. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5654. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5655. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5656. int totalCount = 0;
  5657. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5658. .Where(queryExpression.ToExpression())
  5659. .OrderBy(x => x.UploadJob)
  5660. .Select(x => new
  5661. {
  5662. x.Id,
  5663. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5664. x.FileName,
  5665. x.FileType,
  5666. x.CreateTime,
  5667. })
  5668. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5669. return Ok(JsonView(true, "SUCCESS!", new
  5670. {
  5671. FileList = dbQuery,
  5672. dto.PageSize,
  5673. dto.PageIndex,
  5674. totalCount
  5675. }));
  5676. }
  5677. /// <summary>
  5678. /// 删除共享文件模块下的指定文件
  5679. /// </summary>
  5680. /// <param name="dto"></param>
  5681. /// <returns></returns>
  5682. [HttpPost]
  5683. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5684. {
  5685. var jw = JsonView(false);
  5686. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5687. if (sing == null)
  5688. {
  5689. jw.Msg = "暂无文件信息!";
  5690. return Ok(jw);
  5691. }
  5692. if (sing.CreateUserId != dto.UserId)
  5693. {
  5694. jw.Msg = "只能删除自己上传的文件!";
  5695. return Ok(jw);
  5696. }
  5697. if (System.IO.File.Exists(sing.FilePath))
  5698. {
  5699. try
  5700. {
  5701. System.IO.File.Delete(sing.FilePath);
  5702. }
  5703. catch (Exception ex)
  5704. {
  5705. jw.Msg = "删除失败!" + ex.Message;
  5706. return Ok(jw);
  5707. }
  5708. }
  5709. sing.IsDel = 1;
  5710. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5711. sing.DeleteUserId = dto.UserId;
  5712. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5713. jw = JsonView(true, "删除成功!");
  5714. return Ok(jw);
  5715. }
  5716. #endregion
  5717. #region 团组英文资料
  5718. /// <summary>
  5719. /// 查询团组英文所有资料
  5720. /// </summary>
  5721. /// <param name="dto"></param>
  5722. /// <returns></returns>
  5723. [HttpPost]
  5724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5725. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5726. {
  5727. try
  5728. {
  5729. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5730. if (groupData.Code != 0)
  5731. {
  5732. return Ok(JsonView(false, groupData.Msg));
  5733. }
  5734. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5735. }
  5736. catch (Exception ex)
  5737. {
  5738. return Ok(JsonView(false, "程序错误!"));
  5739. throw;
  5740. }
  5741. }
  5742. /// <summary>
  5743. /// 团组英文资料操作(Status:1.新增,2.修改)
  5744. /// </summary>
  5745. /// <param name="dto"></param>
  5746. /// <returns></returns>
  5747. [HttpPost]
  5748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5749. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5750. {
  5751. try
  5752. {
  5753. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5754. if (groupData.Code != 0)
  5755. {
  5756. return Ok(JsonView(false, groupData.Msg));
  5757. }
  5758. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5759. }
  5760. catch (Exception ex)
  5761. {
  5762. return Ok(JsonView(false, "程序错误!"));
  5763. throw;
  5764. }
  5765. }
  5766. /// <summary>
  5767. /// 团组英文资料Id查询数据
  5768. /// </summary>
  5769. /// <param name="dto"></param>
  5770. /// <returns></returns>
  5771. [HttpPost]
  5772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5773. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5774. {
  5775. try
  5776. {
  5777. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5778. if (_DelegationEnData != null)
  5779. {
  5780. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5781. }
  5782. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5783. }
  5784. catch (Exception ex)
  5785. {
  5786. return Ok(JsonView(false, "程序错误!"));
  5787. throw;
  5788. }
  5789. }
  5790. /// <summary>
  5791. /// 团组英文资料删除
  5792. /// </summary>
  5793. /// <param name="dto"></param>
  5794. /// <returns></returns>
  5795. [HttpPost]
  5796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5797. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5798. {
  5799. try
  5800. {
  5801. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5802. if (!res)
  5803. {
  5804. return Ok(JsonView(false, "删除失败"));
  5805. }
  5806. return Ok(JsonView(true, "删除成功!"));
  5807. }
  5808. catch (Exception ex)
  5809. {
  5810. return Ok(JsonView(false, "程序错误!"));
  5811. throw;
  5812. }
  5813. }
  5814. #endregion
  5815. #region 导出邀请函
  5816. /// <summary>
  5817. /// 导出邀请函页面初始化
  5818. /// </summary>
  5819. /// <param name="dto"></param>
  5820. /// <returns></returns>
  5821. [HttpPost]
  5822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5823. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5824. {
  5825. try
  5826. {
  5827. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5828. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5829. if (dto.DiId == 0)
  5830. {
  5831. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5832. }
  5833. else
  5834. {
  5835. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5836. }
  5837. return Ok(JsonView(true, "查询成功!", new
  5838. {
  5839. deleClient = crm_Deles,
  5840. delegations = grp_Delegations
  5841. }));
  5842. }
  5843. catch (Exception ex)
  5844. {
  5845. return Ok(JsonView(false, "程序错误!"));
  5846. throw;
  5847. }
  5848. }
  5849. /// <summary>
  5850. /// 导出邀请函
  5851. /// </summary>
  5852. /// <param name="dto"></param>
  5853. /// <returns></returns>
  5854. [HttpPost]
  5855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5856. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5857. {
  5858. #region 参数验证
  5859. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5860. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5861. #endregion
  5862. try
  5863. {
  5864. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5865. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5866. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5867. From Grp_TourClientList tcl
  5868. Left Join
  5869. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5870. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5871. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5872. From Crm_DeleClient dc
  5873. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5874. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5875. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5876. Where dc.IsDel = 0) temp
  5877. On temp.DcId =tcl.ClientId
  5878. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5879. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5880. List<string> texts = new List<string>();
  5881. if (datas.Count != 0)
  5882. {
  5883. foreach (TourClientListDetailsView item in datas)
  5884. {
  5885. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5886. {
  5887. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5888. }
  5889. else
  5890. {
  5891. string name = item.LastName + item.FirstName;
  5892. texts.Add(name);
  5893. }
  5894. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5895. {
  5896. if (!transDic.ContainsKey(item.Job))
  5897. {
  5898. texts.Add(item.Job);
  5899. }
  5900. }
  5901. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5902. {
  5903. texts.Add(item.CompanyFullName);
  5904. }
  5905. }
  5906. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5907. if (transData.Count > 0)
  5908. {
  5909. foreach (TranslateResult item in transData)
  5910. {
  5911. if (!transDic.ContainsKey(item.Query))
  5912. {
  5913. transDic.Add(item.Query, item.Translation);
  5914. }
  5915. }
  5916. }
  5917. List<GuestList> list = new List<GuestList>();
  5918. foreach (TourClientListDetailsView dele in datas)
  5919. {
  5920. GuestList guestList = new GuestList();
  5921. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5922. {
  5923. guestList.Name = dele.Pinyin;
  5924. }
  5925. else
  5926. {
  5927. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5928. guestList.Name = Name;
  5929. }
  5930. if (dele.Sex == 0)
  5931. {
  5932. guestList.Sex = "Male";
  5933. }
  5934. else if (dele.Sex == 1)
  5935. {
  5936. guestList.Sex = "Female";
  5937. }
  5938. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5939. if (!string.IsNullOrEmpty(dele.Job))
  5940. {
  5941. guestList.Job = dele.Job;
  5942. }
  5943. list.Add(guestList);
  5944. }
  5945. //载入模板
  5946. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5947. DocumentBuilder builder = new DocumentBuilder(doc);
  5948. //获取word里所有表格
  5949. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5950. //获取所填表格的序数
  5951. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5952. var rowStart = tableOne.Rows[0]; //获取第1行
  5953. //循环赋值
  5954. for (int i = 0; i < list.Count; i++)
  5955. {
  5956. builder.MoveToCell(0, i + 1, 0, 0);
  5957. builder.Write(list[i].Name.ToString());
  5958. builder.MoveToCell(0, i + 1, 1, 0);
  5959. builder.Write(list[i].Sex.ToString());
  5960. builder.MoveToCell(0, i + 1, 2, 0);
  5961. builder.Write(list[i].DOB.ToString());
  5962. builder.MoveToCell(0, i + 1, 3, 0);
  5963. builder.Write(list[i].Job.ToString());
  5964. }
  5965. //删除多余行
  5966. while (tableOne.Rows.Count > list.Count + 1)
  5967. {
  5968. tableOne.Rows.RemoveAt(list.Count + 1);
  5969. }
  5970. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5971. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5972. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5973. doc.Save(filePath);
  5974. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5975. return Ok(JsonView(true, "操作成功!", Url));
  5976. }
  5977. else
  5978. {
  5979. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5980. }
  5981. }
  5982. catch (Exception ex)
  5983. {
  5984. return Ok(JsonView(false, ex.Message));
  5985. throw;
  5986. }
  5987. }
  5988. #endregion
  5989. #region 团组经理模块 出入境费用
  5990. /// <summary>
  5991. /// 团组模块 - 出入境费用 - 省份基础数据源
  5992. /// </summary>
  5993. /// <returns></returns>
  5994. [HttpGet]
  5995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5996. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5997. {
  5998. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5999. }
  6000. /// <summary>
  6001. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6002. /// </summary>
  6003. /// <returns></returns>
  6004. [HttpPost]
  6005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6006. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6007. {
  6008. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6009. var groupNamFirst = groupNameData.FirstOrDefault();
  6010. //SetDataInfoView
  6011. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6012. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6013. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6014. //验证城市归属并给默认值
  6015. int provinceId = 122;
  6016. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6017. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6018. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6019. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6020. return Ok(JsonView(true, "查询成功!", new
  6021. {
  6022. GroupNameData = groupNameData,
  6023. CurrencyData = _CurrencyData,
  6024. WordTypeData = wordTypeData,
  6025. ExcelTypeData = excelTypeData,
  6026. CurrencyInit = _currencyInfos,
  6027. ViewPermissionData = viewPermissionData
  6028. }));
  6029. }
  6030. /// <summary>
  6031. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6032. /// </summary>
  6033. /// <returns></returns>
  6034. [HttpGet("{provinceId}")]
  6035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6036. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6037. {
  6038. //验证城市归属并给默认值
  6039. if (provinceId < 1) provinceId = 122;
  6040. /*
  6041. * 122 四川
  6042. * 108 贵州
  6043. * 103 重庆
  6044. * 132 云南
  6045. */
  6046. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6047. return Ok(JsonView(true, "查询成功!", new
  6048. {
  6049. WordTypeData = wordTypeData,
  6050. ExcelTypeData = excelTypeData,
  6051. }));
  6052. }
  6053. /// <summary>
  6054. /// 团组模块 - 出入境费用
  6055. /// 实时汇率 tips
  6056. /// 签证费用 tips
  6057. /// 机票费用 tips
  6058. /// </summary>
  6059. /// <returns></returns>
  6060. [HttpPost]
  6061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6062. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6063. {
  6064. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6065. //默认币种显示
  6066. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6067. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6068. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6069. return Ok(JsonView(true, "查询成功!", new
  6070. {
  6071. //GroupNameData = groupNameData.Data,
  6072. visaData = visaData.Data,
  6073. airData = airData,
  6074. reteInfos = reteInfos
  6075. }));
  6076. }
  6077. /// <summary>
  6078. /// 团组模块 - 出入境费用 - Info
  6079. /// </summary>
  6080. /// <returns></returns>
  6081. [HttpPost]
  6082. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6084. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6085. {
  6086. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6087. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6088. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6089. }
  6090. /// <summary>
  6091. /// 团组模块 - 出入境费用 - 设置view权限
  6092. /// </summary>
  6093. /// <returns></returns>
  6094. [HttpPost]
  6095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6096. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6097. {
  6098. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6099. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6100. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6101. var permissions = new List<Grp_EnterExitCostPermission>();
  6102. foreach (var userId in dto.UserIds)
  6103. {
  6104. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6105. }
  6106. if (permissions.Any())
  6107. {
  6108. _sqlSugar.BeginTran();
  6109. try
  6110. {
  6111. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6112. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6113. if (result < 1)
  6114. {
  6115. _sqlSugar.RollbackTran();
  6116. return Ok(JsonView(false));
  6117. }
  6118. }
  6119. catch (Exception ex)
  6120. {
  6121. _sqlSugar.RollbackTran();
  6122. return Ok(JsonView(false, ex.Message));
  6123. }
  6124. _sqlSugar.CommitTran();
  6125. return Ok(JsonView(true));
  6126. }
  6127. return Ok(JsonView(false));
  6128. }
  6129. /// <summary>
  6130. /// 团组模块 - 出入境费用 - Add And Update
  6131. /// </summary>
  6132. /// <returns></returns>
  6133. [HttpPost]
  6134. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6136. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6137. {
  6138. try
  6139. {
  6140. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6141. if (dto.DayOtherPriceData.Any())
  6142. {
  6143. var inserList = dto.DayOtherPriceData
  6144. .Where(x => x.Id == 0)
  6145. .Select(x => new Grp_DayOtherPrice
  6146. {
  6147. Cost = x.Cost,
  6148. Id = x.Id,
  6149. CreateTime = DateTime.Now,
  6150. CreateUserId = dto.UserId,
  6151. Currency = x.Currency,
  6152. Diid = x.DiId,
  6153. Index = x.Index,
  6154. IsDel = 0,
  6155. SetDataId = x.SetDataId,
  6156. SubTotal = x.SubTotal,
  6157. Remark = x.Remark
  6158. })
  6159. .ToList();
  6160. var updateList = dto.DayOtherPriceData
  6161. .Where(x => x.Id != 0)
  6162. .Select(x => new Grp_DayOtherPrice
  6163. {
  6164. Cost = x.Cost,
  6165. Id = x.Id,
  6166. CreateTime = DateTime.Now,
  6167. CreateUserId = dto.UserId,
  6168. Currency = x.Currency,
  6169. Diid = x.DiId,
  6170. Index = x.Index,
  6171. IsDel = 0,
  6172. SetDataId = x.SetDataId,
  6173. SubTotal = x.SubTotal,
  6174. Remark = x.Remark
  6175. })
  6176. .ToList();
  6177. //添加
  6178. _sqlSugar.BeginTran();
  6179. if (inserList.Any())
  6180. {
  6181. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6182. }
  6183. if (updateList.Any())
  6184. {
  6185. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6186. }
  6187. _sqlSugar.CommitTran();
  6188. }
  6189. if (data.Code != 0)
  6190. {
  6191. return Ok(JsonView(false, data.Msg));
  6192. }
  6193. //生成默认文件pdf并且通知人员
  6194. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6195. {
  6196. DiId = dto.DiId,
  6197. ExportType = 1,
  6198. SubTypeId = 1005
  6199. }, "pdf");
  6200. //发送通知
  6201. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6202. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6203. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6204. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6205. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6206. //汇率信息记录
  6207. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6208. return Ok(JsonView(true, data.Msg, data.Data));
  6209. }
  6210. catch (Exception ex)
  6211. {
  6212. return Ok(JsonView(false, ex.Message));
  6213. }
  6214. }
  6215. /// <summary>
  6216. /// 团组模块 - 出入境费用 - Confirm 费用
  6217. /// </summary>
  6218. /// <returns></returns>
  6219. [HttpPost]
  6220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6221. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6222. {
  6223. //TODO:测试完毕需把对应的用户ID更改
  6224. //1、数据表添加字段
  6225. //2、更改字段接口()
  6226. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6227. //3、确认成功 给财务发送消息
  6228. if (_view.Code == 200)
  6229. {
  6230. if (dto.Type == 1)
  6231. {
  6232. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6233. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6234. }
  6235. }
  6236. return Ok(_view);
  6237. }
  6238. /// <summary>
  6239. /// 团组模块 - 出入境费用 - File download
  6240. /// </summary>
  6241. /// <param name="dto"></param>
  6242. /// <returns></returns>
  6243. [HttpPost]
  6244. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6246. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6247. {
  6248. try
  6249. {
  6250. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6251. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6252. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6253. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6254. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6255. 3 团组成员名单 1 团组成员名单", ""));
  6256. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6257. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6258. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6259. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6260. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6261. //数据源
  6262. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6263. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6264. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6265. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6266. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6267. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6268. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6269. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6270. .Select((x, a, b) => new
  6271. {
  6272. x.Index,
  6273. itemName = a.Name,
  6274. CurrencyStr = b.Name,
  6275. x.Cost,
  6276. x.SubTotal,
  6277. x.Remark
  6278. })
  6279. .OrderBy((x) => x.Index)
  6280. .ToList(); //其他款项费用
  6281. var peiceItemCurrencys = new List<string>();
  6282. if (_DayAndCosts.Any())
  6283. {
  6284. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6285. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6286. }
  6287. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6288. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6289. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6290. {
  6291. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6292. }
  6293. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6294. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6295. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6296. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6297. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6298. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6299. .Select((tcl, dc, cc) => new ClientInfo
  6300. {
  6301. LastName = dc.LastName,
  6302. FirstName = dc.FirstName,
  6303. Sex = dc.Sex,
  6304. Birthday = dc.BirthDay,
  6305. Company = cc.CompanyFullName,
  6306. Job = dc.Job
  6307. })
  6308. .ToList();
  6309. foreach (var item in DeleClientList)
  6310. {
  6311. EncryptionProcessor.DecryptProperties(item);
  6312. }
  6313. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6314. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6315. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6316. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6317. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6318. if (dto.ExportType == 1) //明细表
  6319. {
  6320. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6321. {
  6322. //获取模板
  6323. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6324. //载入模板
  6325. Document doc = new Document(tempPath);
  6326. DocumentBuilder builder = new DocumentBuilder(doc);
  6327. //利用键值对存放数据
  6328. Dictionary<string, string> dic = new Dictionary<string, string>();
  6329. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6330. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6331. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6332. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6333. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6334. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6335. //境内费用(其他费用)
  6336. if (_EnterExitCosts.ChoiceOne == 1)
  6337. {
  6338. string row1_1 = "";
  6339. if (_EnterExitCosts.Visa > 0)
  6340. {
  6341. //insidePayTotal += _EnterExitCosts.Visa;
  6342. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6343. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6344. //{
  6345. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6346. //}
  6347. }
  6348. string row1_2 = "";
  6349. if (_EnterExitCosts.YiMiao > 0)
  6350. {
  6351. //insidePayTotal += _EnterExitCosts.YiMiao;
  6352. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6353. }
  6354. if (_EnterExitCosts.HeSuan > 0)
  6355. {
  6356. //insidePayTotal += _EnterExitCosts.HeSuan;
  6357. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6358. }
  6359. if (_EnterExitCosts.Service > 0)
  6360. {
  6361. //insidePayTotal += _EnterExitCosts.Service;
  6362. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6363. }
  6364. string row1_3 = "";
  6365. if (_EnterExitCosts.Safe > 0)
  6366. {
  6367. //insidePayTotal += _EnterExitCosts.Safe;
  6368. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6369. }
  6370. if (_EnterExitCosts.Ticket > 0)
  6371. {
  6372. //insidePayTotal += _EnterExitCosts.Ticket;
  6373. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6374. }
  6375. string row1 = "";
  6376. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6377. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6378. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6379. row1 += $"备注:{_EnterExitCosts.Remark}";
  6380. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6381. dic.Add("Row1Str", row1);
  6382. }
  6383. string airTotalStr = string.Empty,
  6384. airPriceStr = string.Empty;
  6385. //经济舱
  6386. if (_EnterExitCosts.SumJJC == 1)
  6387. {
  6388. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6389. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6390. }
  6391. //公务舱
  6392. if (_EnterExitCosts.SumGWC == 1)
  6393. {
  6394. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6395. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6396. }
  6397. //头等舱
  6398. if (_EnterExitCosts.SumTDC == 1)
  6399. {
  6400. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6401. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6402. }
  6403. //汇率描述
  6404. string rateStr = "";
  6405. if (peiceItemCurrencyInfos.Any())
  6406. {
  6407. rateStr = "\r\n汇率描述:";
  6408. foreach (var item in peiceItemCurrencyInfos)
  6409. {
  6410. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6411. }
  6412. }
  6413. string twoItemRemark = "备注:";
  6414. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6415. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6416. dic.Add("AirTotalStr", airTotalStr);
  6417. dic.Add("AirPriceStr", airPriceStr);
  6418. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6419. dic.Add("TwoItemRemark", twoItemRemark);
  6420. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6421. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6422. int table1Row = 0,
  6423. table2Row = 0,
  6424. table3Row = 0,
  6425. table4Row = 0,
  6426. table5Row = 0;
  6427. //住宿费
  6428. if (_EnterExitCosts.ChoiceThree == 1)
  6429. {
  6430. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6431. table1Row = dac1.Count;
  6432. #region 填充word表格内容
  6433. for (int i = 0; i < dac1.Count; i++)
  6434. {
  6435. Grp_DayAndCost dac = dac1[i];
  6436. if (dac == null) continue;
  6437. builder.MoveToCell(0, i, 0, 0);
  6438. builder.Write("第" + dac.Days.ToString() + "晚:");
  6439. builder.MoveToCell(0, i, 1, 0);
  6440. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6441. //builder.Write(dac.Place == null ? "" : dac.Place);
  6442. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6443. builder.MoveToCell(0, i, 2, 0);
  6444. builder.Write("费用标准:");
  6445. string curr = "";
  6446. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6447. if (currData != null)
  6448. {
  6449. curr = currData.Name;
  6450. }
  6451. builder.MoveToCell(0, i, 3, 0);
  6452. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6453. builder.MoveToCell(0, i, 4, 0);
  6454. builder.Write("费用小计:");
  6455. builder.MoveToCell(0, i, 5, 0);
  6456. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6457. }
  6458. #endregion
  6459. }
  6460. else dic.Add("SubZS", "0.00");
  6461. //删除多余行
  6462. while (table1.Rows.Count > table1Row)
  6463. {
  6464. table1.Rows.RemoveAt(table1Row);
  6465. }
  6466. //伙食费
  6467. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6468. if (_EnterExitCosts.ChoiceFour == 1)
  6469. {
  6470. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6471. table2Row = dac2.Count;
  6472. #region 填充word表格内容
  6473. for (int i = 0; i < dac2.Count; i++)
  6474. {
  6475. Grp_DayAndCost dac = dac2[i];
  6476. if (dac == null) continue;
  6477. builder.MoveToCell(1, i, 0, 0);
  6478. builder.Write("第" + dac.Days.ToString() + "天:");
  6479. builder.MoveToCell(1, i, 1, 0);
  6480. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6481. builder.MoveToCell(1, i, 2, 0);
  6482. builder.Write("费用标准:");
  6483. string curr = "";
  6484. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6485. if (currData != null)
  6486. {
  6487. curr = currData.Name;
  6488. }
  6489. builder.MoveToCell(1, i, 3, 0);
  6490. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6491. builder.MoveToCell(1, i, 4, 0);
  6492. builder.Write("费用小计:");
  6493. builder.MoveToCell(1, i, 5, 0);
  6494. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6495. }
  6496. #endregion
  6497. }
  6498. else dic.Add("SubHS", "0.00");
  6499. //删除多余行
  6500. while (table2.Rows.Count > table2Row)
  6501. {
  6502. table2.Rows.RemoveAt(table2Row);
  6503. }
  6504. //公杂费
  6505. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6506. if (_EnterExitCosts.ChoiceFive == 1)
  6507. {
  6508. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6509. table3Row = dac3.Count;
  6510. #region 填充word表格内容
  6511. for (int i = 0; i < dac3.Count; i++)
  6512. {
  6513. Grp_DayAndCost dac = dac3[i];
  6514. if (dac == null) continue;
  6515. builder.MoveToCell(2, i, 0, 0);
  6516. builder.Write("第" + dac.Days.ToString() + "天:");
  6517. builder.MoveToCell(2, i, 1, 0);
  6518. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6519. builder.MoveToCell(2, i, 2, 0);
  6520. builder.Write("费用标准:");
  6521. string curr = "";
  6522. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6523. if (currData != null)
  6524. {
  6525. curr = currData.Name;
  6526. }
  6527. builder.MoveToCell(2, i, 3, 0);
  6528. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6529. builder.MoveToCell(2, i, 4, 0);
  6530. builder.Write("费用小计:");
  6531. builder.MoveToCell(2, i, 5, 0);
  6532. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6533. }
  6534. //删除多余行
  6535. while (table3.Rows.Count > table3Row)
  6536. {
  6537. table3.Rows.RemoveAt(table3Row);
  6538. }
  6539. #endregion
  6540. }
  6541. else dic.Add("SubGZF", "0.00");
  6542. //删除多余行
  6543. while (table3.Rows.Count > table3Row)
  6544. {
  6545. table3.Rows.RemoveAt(table3Row);
  6546. }
  6547. //培训费
  6548. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6549. if (_EnterExitCosts.ChoiceSix == 1)
  6550. {
  6551. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6552. dic.Add("SubPX", pxStr);
  6553. table4Row = dac4.Count;
  6554. #region 填充word表格内容
  6555. for (int i = 0; i < dac4.Count; i++)
  6556. {
  6557. Grp_DayAndCost dac = dac4[i];
  6558. if (dac == null) continue;
  6559. builder.MoveToCell(3, i, 0, 0);
  6560. builder.Write("第" + dac.Days.ToString() + "天:");
  6561. builder.MoveToCell(3, i, 1, 0);
  6562. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6563. builder.MoveToCell(3, i, 2, 0);
  6564. builder.Write("费用标准:");
  6565. string curr = "";
  6566. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6567. if (currData != null)
  6568. {
  6569. curr = currData.Name;
  6570. }
  6571. builder.MoveToCell(3, i, 3, 0);
  6572. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6573. builder.MoveToCell(3, i, 4, 0);
  6574. builder.Write("费用小计:");
  6575. builder.MoveToCell(3, i, 5, 0);
  6576. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6577. }
  6578. #endregion
  6579. }
  6580. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6581. //删除多余行
  6582. while (table4.Rows.Count > table4Row)
  6583. {
  6584. table4.Rows.RemoveAt(table4Row);
  6585. }
  6586. //其他费用
  6587. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6588. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6589. {
  6590. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6591. dic.Add("titleQi", qtStr);
  6592. table5Row = dac5.Count;
  6593. #region 填充word表格内容
  6594. for (int i = 0; i < dac5.Count; i++)
  6595. {
  6596. var dac = dac5[i];
  6597. if (dac == null) continue;
  6598. builder.MoveToCell(4, i, 0, 0);
  6599. builder.Write("第" + dac.Index.ToString() + "项:");
  6600. builder.MoveToCell(4, i, 1, 0);
  6601. builder.Write(dac.itemName);
  6602. builder.MoveToCell(4, i, 2, 0);
  6603. builder.Write("费用标准:");
  6604. builder.MoveToCell(4, i, 3, 0);
  6605. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6606. builder.MoveToCell(4, i, 4, 0);
  6607. builder.Write("费用小计:");
  6608. builder.MoveToCell(4, i, 5, 0);
  6609. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6610. builder.MoveToCell(4, i, 6, 0);
  6611. builder.Write("备注:");
  6612. builder.MoveToCell(4, i, 7, 0);
  6613. builder.Write(dac.Remark);
  6614. }
  6615. #endregion
  6616. }
  6617. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6618. //删除多余行
  6619. while (table5.Rows.Count > table5Row)
  6620. {
  6621. table5.Rows.RemoveAt(table5Row);
  6622. }
  6623. //加上其他费用
  6624. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6625. decimal subJJC = 0.00M,
  6626. subGWC = 0.00M,
  6627. subTDC = 0.00M;
  6628. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6629. string totalLabel = string.Format("全部费用总计:");
  6630. //经济舱
  6631. if (_EnterExitCosts.SumJJC == 1)
  6632. {
  6633. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6634. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6635. }
  6636. //公务舱
  6637. if (_EnterExitCosts.SumGWC == 1)
  6638. {
  6639. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6640. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6641. }
  6642. //头等舱
  6643. if (_EnterExitCosts.SumTDC == 1)
  6644. {
  6645. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6646. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6647. }
  6648. //TotalLabel
  6649. dic.Add("TotalLabel", totalLabel);
  6650. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6651. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6652. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6653. #region 填充word模板书签内容
  6654. foreach (var key in dic.Keys)
  6655. {
  6656. Bookmark bookmark = doc.Range.Bookmarks[key];
  6657. if (bookmark != null)
  6658. {
  6659. builder.MoveToBookmark(key);
  6660. builder.Write(dic[key]);
  6661. }
  6662. }
  6663. #endregion
  6664. #region 设置页眉
  6665. string userLabel = string.Empty;
  6666. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6667. if (currUserInfo != null)
  6668. {
  6669. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6670. if (userInfo != null)
  6671. {
  6672. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6673. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6674. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6675. }
  6676. }
  6677. //设置页脚
  6678. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6679. #endregion
  6680. //文件名
  6681. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6682. AsposeHelper.removewatermark_v2180();
  6683. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6684. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6685. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6686. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6687. }
  6688. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6689. {
  6690. //获取模板
  6691. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6692. //载入模板
  6693. Document doc = new Document(tempPath);
  6694. DocumentBuilder builder = new DocumentBuilder(doc);
  6695. Dictionary<string, string> dic = new Dictionary<string, string>();
  6696. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6697. {
  6698. List<string> list = new List<string>();
  6699. try
  6700. {
  6701. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6702. foreach (var item in spilitArr)
  6703. {
  6704. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6705. var depCode = spDotandEmpty[2].Substring(0, 3);
  6706. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6707. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6708. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6709. list.Add(depName);
  6710. list.Add(arrName);
  6711. }
  6712. list = list.Distinct().ToList();
  6713. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6714. }
  6715. catch (Exception)
  6716. {
  6717. dic.Add("ReturnCode", "行程录入不正确!");
  6718. }
  6719. }
  6720. else
  6721. {
  6722. dic.Add("ReturnCode", "未录入行程!");
  6723. }
  6724. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6725. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6726. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6727. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6728. {
  6729. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6730. dic.Add("Day", sp.Days.ToString());
  6731. }
  6732. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6733. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6734. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6735. //dic.Add("Names", Names);
  6736. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6737. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6738. decimal dac1totalPrice = 0.00M;
  6739. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6740. foreach (var dac in dac1)
  6741. {
  6742. if (dac.SubTotal == 0.00M)
  6743. {
  6744. continue;
  6745. }
  6746. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6747. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6748. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6749. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6750. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6751. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6752. builder.Write(currency);//币种
  6753. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6754. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6755. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6756. builder.Write("");//人数
  6757. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6758. builder.Write("");//天数
  6759. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6760. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6761. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6762. decimal rate = 0.00M;
  6763. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6764. builder.Write(rate.ToString("#0.0000"));//汇率
  6765. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6766. decimal rbmPrice = dac.SubTotal;
  6767. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6768. accommodationStartIndex++;
  6769. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6770. }
  6771. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6772. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6773. {
  6774. table1.Rows.RemoveAt(i - 1);
  6775. foodandotherStartIndex--;
  6776. }
  6777. if (dac2.Count == dac3.Count)//国家 币种 金额
  6778. {
  6779. for (int i = 0; i < dac2.Count; i++)
  6780. {
  6781. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6782. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6783. }
  6784. }
  6785. decimal dac2totalPrice = 0.00M;
  6786. foreach (var dac in dac2)
  6787. {
  6788. if (dac.SubTotal == 0)
  6789. {
  6790. continue;
  6791. }
  6792. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6793. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6794. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6795. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6796. builder.Write(currency);//币种
  6797. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6798. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6799. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6800. builder.Write("");//人数
  6801. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6802. builder.Write("");//天数
  6803. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6804. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6805. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6806. decimal rate = 0.00M;
  6807. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6808. builder.Write(rate.ToString("#0.0000"));//汇率
  6809. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6810. decimal rbmPrice = dac.SubTotal;
  6811. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6812. foodandotherStartIndex++;
  6813. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6814. }
  6815. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6816. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6817. {
  6818. table1.Rows.RemoveAt(i - 1);
  6819. }
  6820. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6821. string otherFeeStr = "";
  6822. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6823. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6824. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6825. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6826. foreach (var otherInfo in dac5)
  6827. {
  6828. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6829. }
  6830. #endregion
  6831. if (otherFeeStr.Length > 0)
  6832. {
  6833. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6834. otherFeeStr = $"({otherFeeStr})";
  6835. dic.Add("OtherFeeStr", otherFeeStr);
  6836. }
  6837. //总计
  6838. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6839. //国际旅费
  6840. string outsideAir = string.Empty;
  6841. string allPriceAir = string.Empty;
  6842. if (_EnterExitCosts.SumJJC == 1)
  6843. {
  6844. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6845. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6846. }
  6847. if (_EnterExitCosts.SumGWC == 1)
  6848. {
  6849. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6850. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6851. }
  6852. if (_EnterExitCosts.SumTDC == 1)
  6853. {
  6854. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6855. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6856. }
  6857. dic.Add("InTravelPrice", $"({outsideAir})");
  6858. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6859. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6860. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6861. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6862. foreach (var key in dic.Keys)
  6863. {
  6864. builder.MoveToBookmark(key);
  6865. builder.Write(dic[key]);
  6866. }
  6867. //模板文件名
  6868. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6869. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6870. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6871. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6872. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6873. }
  6874. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6875. {
  6876. //获取模板
  6877. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6878. //载入模板
  6879. WorkbookDesigner designer = new WorkbookDesigner();
  6880. designer.Workbook = new Workbook(tempPath);
  6881. Dictionary<string, string> dic = new Dictionary<string, string>();
  6882. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6883. {
  6884. List<string> list = new List<string>();
  6885. try
  6886. {
  6887. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6888. foreach (var item in spilitArr)
  6889. {
  6890. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6891. var depCode = spDotandEmpty[2].Substring(0, 3);
  6892. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6893. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6894. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6895. list.Add(depName);
  6896. list.Add(arrName);
  6897. }
  6898. list = list.Distinct().ToList();
  6899. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6900. }
  6901. catch (Exception)
  6902. {
  6903. dic.Add("ReturnCode", "行程录入不正确!");
  6904. }
  6905. }
  6906. else
  6907. {
  6908. dic.Add("ReturnCode", "未录入行程!");
  6909. }
  6910. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6911. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6912. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6913. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6914. {
  6915. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6916. dic.Add("Day", sp.Days.ToString());
  6917. }
  6918. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6919. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6920. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6921. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6922. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6923. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6924. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6925. designer.SetDataSource("Name", Names);
  6926. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6927. designer.SetDataSource("Day", dic["Day"] + "天");
  6928. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6929. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6930. int startIndex = 10;
  6931. const int startIndexcopy = 10;
  6932. if (dac2.Count == dac3.Count)//国家 币种 金额
  6933. {
  6934. for (int i = 0; i < dac2.Count; i++)
  6935. {
  6936. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6937. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6938. }
  6939. }
  6940. DataTable dtdac1 = new DataTable();
  6941. List<string> place = new List<string>();
  6942. dtdac1.Columns.AddRange(new DataColumn[] {
  6943. new DataColumn(){ ColumnName = "city"},
  6944. new DataColumn(){ ColumnName = "curr"},
  6945. new DataColumn(){ ColumnName = "criterion"},
  6946. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6947. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6948. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6949. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6950. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6951. });
  6952. DataTable dtdac2 = new DataTable();
  6953. dtdac2.Columns.AddRange(new DataColumn[] {
  6954. new DataColumn(){ ColumnName = "city"},
  6955. new DataColumn(){ ColumnName = "curr"},
  6956. new DataColumn(){ ColumnName = "criterion"},
  6957. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6958. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6959. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6960. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6961. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6962. });
  6963. dtdac1.TableName = "tb1";
  6964. dtdac2.TableName = "tb2";
  6965. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6966. foreach (var item in dac1)
  6967. {
  6968. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6969. if (place.Contains(item.Place))
  6970. {
  6971. continue;
  6972. }
  6973. DataRow row = dtdac1.NewRow();
  6974. row["city"] = item.Place;
  6975. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6976. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6977. row["curr"] = currency;
  6978. row["rate"] = rate.ToString("#0.0000");
  6979. row["criterion"] = item.Cost.ToString("#0.00");
  6980. row["number"] = 1;
  6981. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6982. //row["costRMB"] = rbmPrice;
  6983. dtdac1.Rows.Add(row);
  6984. place.Add(item.Place);
  6985. }
  6986. place = new List<string>();
  6987. foreach (var item in dac2)
  6988. {
  6989. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6990. if (place.Contains(item.Place))
  6991. {
  6992. continue;
  6993. }
  6994. DataRow row = dtdac2.NewRow();
  6995. row["city"] = item.Place;
  6996. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6997. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6998. row["curr"] = currency;
  6999. row["rate"] = rate.ToString("#0.0000");
  7000. row["criterion"] = item.Cost.ToString("#0.00");
  7001. row["number"] = 1;
  7002. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7003. //row["cost"] = item.SubTotal;
  7004. //row["costRMB"] = rbmPrice;
  7005. dtdac2.Rows.Add(row);
  7006. place.Add(item.Place);
  7007. //dac2totalPrice += rbmPrice;
  7008. }
  7009. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7010. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7011. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7012. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7013. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7014. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7015. string cell4Str1 = string.Empty;
  7016. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7017. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7018. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7019. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7020. string cellStr = $" 5.其他费用(";
  7021. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7022. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7023. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7024. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7025. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7026. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7027. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7028. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7029. foreach (var otherInfo in dac5)
  7030. {
  7031. cellStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7032. }
  7033. #endregion
  7034. if (cellStr.Length > 8)
  7035. {
  7036. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7037. }
  7038. cellStr += ")";
  7039. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7040. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7041. decimal pxFee = dac4.Sum(it => it.Cost);
  7042. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7043. string celllastStr1 = "";
  7044. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7045. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7046. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7047. celllastStr1 += $",国际旅费 元";
  7048. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7049. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7050. designer.SetDataSource("cell4Str", cell4Str);
  7051. designer.SetDataSource("cellStr", cellStr);
  7052. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7053. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7054. designer.SetDataSource("celllastStr", celllastStr);
  7055. Workbook wb = designer.Workbook;
  7056. var sheet = wb.Worksheets[0];
  7057. //绑定datatable数据集
  7058. designer.SetDataSource(dtdac1);
  7059. designer.SetDataSource(dtdac2);
  7060. designer.Process();
  7061. var rowStart = dtdac1.Rows.Count;
  7062. while (rowStart > 0)
  7063. {
  7064. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7065. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7066. startIndex++;
  7067. rowStart--;
  7068. }
  7069. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7070. startIndex += 1; //总计行
  7071. rowStart = dtdac2.Rows.Count;
  7072. while (rowStart > 0)
  7073. {
  7074. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7075. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7076. startIndex++;
  7077. rowStart--;
  7078. }
  7079. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7080. wb.CalculateFormula(true);
  7081. //模板文件名
  7082. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7083. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7084. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7085. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7086. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7087. }
  7088. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7089. {
  7090. //获取模板
  7091. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7092. //载入模板
  7093. Document doc = new Document(tempPath);
  7094. DocumentBuilder builder = new DocumentBuilder(doc);
  7095. Dictionary<string, string> dic = new Dictionary<string, string>();
  7096. dic.Add("GroupName", _DelegationInfo.TeamName);
  7097. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7098. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7099. string missionLeaderJob = "";//负责人job
  7100. //int groupNumber = 0; //团人数
  7101. if (DeleClientList.Count > 0)
  7102. {
  7103. missionLeader = DeleClientList[0]?.Name ?? "";
  7104. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7105. }
  7106. dic.Add("MissionLeader", missionLeader); //团负责人
  7107. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7108. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7109. #region MyRegion
  7110. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7111. //{
  7112. // List<string> list = new List<string>();
  7113. // try
  7114. // {
  7115. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7116. // foreach (var item in spilitArr)
  7117. // {
  7118. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7119. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7120. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7121. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7122. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7123. // list.Add(depName);
  7124. // list.Add(arrName);
  7125. // }
  7126. // list = list.Distinct().ToList();
  7127. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7128. // }
  7129. // catch (Exception)
  7130. // {
  7131. // dic.Add("ReturnCode", "行程录入不正确!");
  7132. // }
  7133. //}
  7134. //else
  7135. //{
  7136. // dic.Add("ReturnCode", "未录入行程!");
  7137. //}
  7138. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7139. dic.Add("ReturnCode", string.Join("、", countrys));
  7140. #endregion
  7141. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7142. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7143. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7144. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7145. //{
  7146. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7147. // dic.Add("Day", sp.Days.ToString());
  7148. //}
  7149. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7150. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7151. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7152. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7153. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7154. //培训人员名单
  7155. int cultivateRowIndex = 7;
  7156. foreach (var item in DeleClientList)
  7157. {
  7158. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7159. builder.Write(item.Name);
  7160. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7161. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7162. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7163. string birthDay = "";
  7164. if (item.Birthday != null)
  7165. {
  7166. DateTime dt = Convert.ToDateTime(item.Birthday);
  7167. birthDay = $"{dt.Year}.{dt.Month}";
  7168. }
  7169. builder.Write(birthDay);
  7170. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7171. builder.Write(item.Company);
  7172. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7173. builder.Write(item.Job);
  7174. cultivateRowIndex++;
  7175. }
  7176. //删除多余行
  7177. //cultivateRowIndex -= 2;
  7178. int delRows = 10 + 7 - cultivateRowIndex;
  7179. if (delRows > 0)
  7180. {
  7181. for (int i = 0; i < delRows; i++)
  7182. {
  7183. table1.Rows.RemoveAt(cultivateRowIndex);
  7184. //cultivateRowIndex++;
  7185. }
  7186. }
  7187. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7188. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7189. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7190. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7191. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7192. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7193. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7194. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7195. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7196. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7197. //其他费用
  7198. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7199. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7200. //其他费用合计
  7201. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7202. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7203. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7204. //公务舱合计
  7205. //国际旅费
  7206. //string outsideJJ = "";
  7207. //string allPriceJJ = "";
  7208. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7209. {
  7210. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7211. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7212. }
  7213. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7214. {
  7215. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7216. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7217. }
  7218. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7219. {
  7220. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7221. dic.Add("AirFeeTotal", airFeeTotalStr);
  7222. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7223. dic.Add("FeeTotal", feeTotalStr);
  7224. }
  7225. foreach (var key in dic.Keys)
  7226. {
  7227. builder.MoveToBookmark(key);
  7228. builder.Write(dic[key]);
  7229. }
  7230. //模板文件名
  7231. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7232. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7233. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7234. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7235. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7236. }
  7237. }
  7238. else if (dto.ExportType == 2) //表格
  7239. {
  7240. //利用键值对存放数据
  7241. Dictionary<string, string> dic = new Dictionary<string, string>();
  7242. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7243. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7244. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7245. dic.Add("Day", sp.Days.ToString());
  7246. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7247. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7248. {
  7249. //获取模板
  7250. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7251. //载入模板
  7252. Document doc = new Document(tempPath);
  7253. DocumentBuilder builder = new DocumentBuilder(doc);
  7254. dic.Add("TeamName", _DelegationInfo.TeamName);
  7255. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7256. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7257. string missionLeaderName = "",
  7258. missionLeaderJob = "";
  7259. if (DeleClientList.Count > 0)
  7260. {
  7261. missionLeaderName = DeleClientList[0].Name;
  7262. missionLeaderJob = DeleClientList[0].Job;
  7263. }
  7264. dic.Add("MissionLeaderName", missionLeaderName);
  7265. dic.Add("MissionLeaderJob", missionLeaderJob);
  7266. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7267. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7268. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7269. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7270. int rowCount = 10;//总人数行
  7271. int startRowIndex = 7; //起始行
  7272. for (int i = 0; i < DeleClientList.Count; i++)
  7273. {
  7274. builder.MoveToCell(0, startRowIndex, 0, 0);
  7275. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7276. builder.MoveToCell(0, startRowIndex, 1, 0);
  7277. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7278. builder.Write(sex);//性别
  7279. builder.MoveToCell(0, startRowIndex, 2, 0);
  7280. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7281. builder.MoveToCell(0, startRowIndex, 3, 0);
  7282. builder.Write(DeleClientList[i].Company);//工作单位
  7283. builder.MoveToCell(0, startRowIndex, 4, 0);
  7284. builder.Write(DeleClientList[i].Job);//职务及级别
  7285. builder.MoveToCell(0, startRowIndex, 5, 0);
  7286. builder.Write("");//人员属性
  7287. builder.MoveToCell(0, startRowIndex, 6, 0);
  7288. builder.Write("");//上次出国时间
  7289. startRowIndex++;
  7290. }
  7291. int nullRow = rowCount - DeleClientList.Count;//空行
  7292. for (int i = 0; i < nullRow; i++)
  7293. {
  7294. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7295. }
  7296. foreach (var key in dic.Keys)
  7297. {
  7298. builder.MoveToBookmark(key);
  7299. builder.Write(dic[key]);
  7300. }
  7301. //模板文件名
  7302. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7303. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7304. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7305. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7306. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7307. }
  7308. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7309. {
  7310. //获取模板
  7311. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7312. //载入模板
  7313. Document doc = new Document(tempPath);
  7314. DocumentBuilder builder = new DocumentBuilder(doc);
  7315. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7316. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7317. dic.Add("Names", Names);
  7318. int accommodationRows = 12;
  7319. //int foodandotherRows = 12;
  7320. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7321. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7322. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7323. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7324. int accommodationStartIndex = 6;
  7325. decimal dac1totalPrice = 0.00M;
  7326. foreach (var dac in dac1)
  7327. {
  7328. if (dac.SubTotal == 0)
  7329. {
  7330. continue;
  7331. }
  7332. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7333. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7334. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7335. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7336. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7337. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7338. builder.Write(currency);//币种
  7339. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7340. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7341. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7342. builder.Write("");//人数
  7343. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7344. builder.Write("");//天数
  7345. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7346. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7347. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7348. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7349. builder.Write(rate.ToString("#0.0000"));//汇率
  7350. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7351. decimal rbmPrice = rate * dac.SubTotal;
  7352. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7353. accommodationStartIndex++;
  7354. dac1totalPrice += rbmPrice;
  7355. }
  7356. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7357. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7358. builder.Write("小计");
  7359. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7360. builder.Write(dac1totalPrice.ToString("#0.00"));
  7361. accommodationStartIndex++;
  7362. int nullRow = accommodationRows - dac1.Count;
  7363. //删除空行
  7364. //if (nullRow > 0)
  7365. //{
  7366. // int rowIndex = accommodationStartIndex;
  7367. // for (int i = 0; i < nullRow; i++)
  7368. // {
  7369. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7370. // row.Remove();
  7371. // rowIndex++;
  7372. // }
  7373. //}
  7374. if (dac2.Count == dac3.Count)//国家 币种 金额
  7375. {
  7376. for (int i = 0; i < dac2.Count; i++)
  7377. {
  7378. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7379. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7380. }
  7381. }
  7382. int foodandotherStartIndex = 19;//
  7383. decimal dac2totalPrice = 0.00M;
  7384. foreach (var dac in dac2)
  7385. {
  7386. if (dac.SubTotal == 0)
  7387. {
  7388. continue;
  7389. }
  7390. //foodandotherStartIndex = 12;
  7391. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7392. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7393. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7394. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7395. builder.Write(currency);//币种
  7396. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7397. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7398. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7399. builder.Write("");//人数
  7400. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7401. builder.Write("");//天数
  7402. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7403. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7404. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7405. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7406. builder.Write(rate.ToString("#0.0000"));//汇率
  7407. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7408. decimal rbmPrice = rate * dac.SubTotal;
  7409. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7410. foodandotherStartIndex++;
  7411. dac2totalPrice += rbmPrice;
  7412. }
  7413. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7414. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7415. //删除空行
  7416. //if (dac2.Count < foodandotherRows)
  7417. //{
  7418. // while (table2.Rows.Count > dac2.Count)
  7419. // {
  7420. // table2.Rows.RemoveAt(dac2.Count);
  7421. // }
  7422. //}
  7423. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7424. string otherFeeStr = "";
  7425. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7426. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7427. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7428. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7429. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7430. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7431. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7432. foreach (var otherInfo in dac5)
  7433. {
  7434. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7435. }
  7436. #endregion
  7437. if (otherFeeStr.Length > 0)
  7438. {
  7439. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7440. otherFeeStr = $"({otherFeeStr})";
  7441. dic.Add("OtherFeeStr", otherFeeStr);
  7442. }
  7443. foreach (var key in dic.Keys)
  7444. {
  7445. builder.MoveToBookmark(key);
  7446. builder.Write(dic[key]);
  7447. }
  7448. //模板文件名
  7449. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7450. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7451. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7452. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7453. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7454. }
  7455. }
  7456. else if (dto.ExportType == 3)
  7457. {
  7458. if (dto.SubTypeId == 1) //团组成员名单
  7459. {
  7460. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7461. //获取模板
  7462. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7463. //载入模板
  7464. Document doc = new Document(tempPath);
  7465. DocumentBuilder builder = new DocumentBuilder(doc);
  7466. //获取word里所有表格
  7467. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7468. //获取所填表格的序数
  7469. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7470. var rowStart = tableOne.Rows[0]; //获取第1行
  7471. //循环赋值
  7472. for (int i = 0; i < DeleClientList.Count; i++)
  7473. {
  7474. builder.MoveToCell(0, i + 1, 0, 0);
  7475. builder.Write(DeleClientList[i].Name);
  7476. builder.MoveToCell(0, i + 1, 1, 0);
  7477. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7478. builder.Write(sex);
  7479. builder.MoveToCell(0, i + 1, 2, 0);
  7480. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7481. builder.MoveToCell(0, i + 1, 3, 0);
  7482. builder.Write(DeleClientList[i].Company);
  7483. builder.MoveToCell(0, i + 1, 4, 0);
  7484. builder.Write(DeleClientList[i].Job);
  7485. }
  7486. //删除多余行
  7487. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7488. {
  7489. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7490. }
  7491. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7492. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7493. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7494. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7495. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7496. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7497. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7498. }
  7499. }
  7500. return Ok(JsonView(400, "操作失败!", ""));
  7501. }
  7502. catch (Exception ex)
  7503. {
  7504. return Ok(JsonView(400, ex.Message, ""));
  7505. }
  7506. }
  7507. /// <summary>
  7508. /// 获取三公费用标准city
  7509. /// </summary>
  7510. /// <param name="placeData"></param>
  7511. /// <param name="nationalTravelFeeId"></param>
  7512. /// <returns></returns>
  7513. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7514. {
  7515. string _city = string.Empty;
  7516. if (placeData.Count < 1) return _city;
  7517. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7518. if (data == null) return _city;
  7519. string country = data.Country;
  7520. string city = data.City;
  7521. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7522. else _city = city;
  7523. return _city;
  7524. }
  7525. ///// <summary>
  7526. ///// 团组模块 - 出入境费用 - 明细表导出
  7527. ///// </summary>
  7528. ///// <returns></returns>
  7529. //[HttpPost]
  7530. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7531. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7532. //{
  7533. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7534. // if (data.Code != 0)
  7535. // {
  7536. // return Ok(JsonView(false, data.Msg));
  7537. // }
  7538. // return Ok(JsonView(true, data.Msg, data.Data));
  7539. //}
  7540. /// <summary>
  7541. /// 团组模块 - 出入境费用 - 一键清空
  7542. /// </summary>
  7543. /// <returns></returns>
  7544. [HttpPost]
  7545. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7547. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7548. {
  7549. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7550. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7551. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7552. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7553. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7554. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7555. .SetColumns(x => new Grp_DayOtherPrice
  7556. {
  7557. IsDel = 1,
  7558. DeleteUserId = dto.UserId,
  7559. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7560. })
  7561. .ExecuteCommandAsync();
  7562. if (_view.Code == 0)
  7563. {
  7564. return Ok(JsonView(true, "操作成功"));
  7565. }
  7566. return Ok(JsonView(false, "操作失败"));
  7567. }
  7568. /// <summary>
  7569. /// 团组模块 - 出入境费用 - 子项删除
  7570. /// </summary>
  7571. /// <returns></returns>
  7572. [HttpPost]
  7573. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7575. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7576. {
  7577. try
  7578. {
  7579. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7580. if (data.Code != 0)
  7581. {
  7582. return Ok(JsonView(false, data.Msg));
  7583. }
  7584. return Ok(JsonView(true, "操作成功!", data.Data));
  7585. }
  7586. catch (Exception ex)
  7587. {
  7588. return Ok(JsonView(false, ex.Message));
  7589. }
  7590. }
  7591. /// <summary>
  7592. /// 删除三公其他费用
  7593. /// </summary>
  7594. /// <param name="dto"></param>
  7595. /// <returns></returns>
  7596. [HttpPost]
  7597. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7598. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7599. {
  7600. var jw = JsonView(false, "删除失败!");
  7601. var data = new Grp_DayOtherPrice()
  7602. {
  7603. Id = dto.Id,
  7604. IsDel = 1,
  7605. DeleteUserId = dto.DeleteUserId,
  7606. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7607. };
  7608. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7609. if (del > 0)
  7610. {
  7611. jw.Code = 200;
  7612. jw.Msg = "删除成功!";
  7613. }
  7614. return Ok(jw);
  7615. }
  7616. /// <summary>
  7617. /// 团组模块 - 出入境国家费用标准 List
  7618. /// </summary>
  7619. /// <returns></returns>
  7620. [HttpPost]
  7621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7622. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7623. {
  7624. int provinceId = dto.ProvinceId;
  7625. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7626. var nftData = await _sqlSugar
  7627. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7628. JoinType.Left, ntf.Currency == sd1.Id,
  7629. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7630. JoinType.Left, ntf.ProvinceId == c.Id
  7631. ))
  7632. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7633. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7634. {
  7635. Id = ntf.Id,
  7636. ProvinceId = ntf.ProvinceId,
  7637. ProvinceName = c.Name_CN,
  7638. Continent = ntf.Continent,
  7639. Country = ntf.Country,
  7640. City = ntf.City,
  7641. Currency = ntf.Currency,
  7642. CurrencyCode = sd1.Name,
  7643. CurrencyName = sd1.Remark,
  7644. RoomCost = ntf.RoomCost,
  7645. FoodCost = ntf.FoodCost,
  7646. PublicCost = ntf.PublicCost,
  7647. LastUpdateUserId = ntf.LastUpdateUserId,
  7648. LastUpdateUserName = u.CnName,
  7649. LastUpdateTime = ntf.LastUpdateTime
  7650. })
  7651. .ToListAsync();
  7652. return Ok(JsonView(true, "查询成功!", nftData));
  7653. }
  7654. /// <summary>
  7655. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7656. /// </summary>
  7657. /// <returns></returns>
  7658. [HttpPost]
  7659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7660. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7661. {
  7662. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7663. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7664. List<string> countryData = new List<string>();
  7665. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7666. countryData = countryData.Distinct().ToList();
  7667. List<dynamic> dataSource = new List<dynamic>();
  7668. foreach (var item in countryData)
  7669. {
  7670. var cityData1 = new List<string>();
  7671. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7672. var countryData2 = new
  7673. {
  7674. CountryName = item,
  7675. CityData = cityData1
  7676. };
  7677. if (!dataSource.Contains(countryData2))
  7678. {
  7679. dataSource.Add(countryData2);
  7680. }
  7681. }
  7682. return Ok(JsonView(true, "查询成功!", dataSource));
  7683. }
  7684. /// <summary>
  7685. /// 团组模块 - 出入境国家费用标准 Page List
  7686. /// </summary>
  7687. /// <returns></returns>
  7688. [HttpPost]
  7689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7690. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7691. {
  7692. int portId = dto.PortType,
  7693. pageIndex = dto.PageIndex,
  7694. pageSize = dto.PageSize;
  7695. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7696. if (pageIndex == 0) pageIndex = 1;
  7697. if (pageSize == 0) pageSize = 10;
  7698. RefAsync<int> total = 0;
  7699. var nationalTravelFeeData = await _sqlSugar
  7700. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7701. JoinType.Left, ntf.Currency == sd1.Id,
  7702. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7703. JoinType.Left, ntf.ProvinceId == sd2.Id
  7704. ))
  7705. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7706. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7707. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7708. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7709. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7710. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7711. {
  7712. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7713. Id = ntf.Id,
  7714. ProvinceId = ntf.ProvinceId,
  7715. ProvinceName = sd2.Name_CN,
  7716. Continent = ntf.Continent,
  7717. Country = ntf.Country,
  7718. City = ntf.City,
  7719. Currency = ntf.Currency,
  7720. CurrencyCode = sd1.Name,
  7721. CurrencyName = sd1.Remark,
  7722. RoomCost = ntf.RoomCost,
  7723. FoodCost = ntf.FoodCost,
  7724. PublicCost = ntf.PublicCost,
  7725. LastUpdateUserId = ntf.LastUpdateUserId,
  7726. LastUpdateUserName = u.CnName,
  7727. LastUpdateTime = ntf.LastUpdateTime,
  7728. Remark = ntf.Remark
  7729. })
  7730. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7731. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7732. }
  7733. /// <summary>
  7734. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7735. /// </summary>
  7736. /// <returns></returns>
  7737. [HttpPost]
  7738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7739. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7740. {
  7741. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7742. int portId = dto.PortType;
  7743. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7744. string whereSql = string.Empty;
  7745. if (!string.IsNullOrEmpty(dto.Country))
  7746. {
  7747. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7748. }
  7749. if (!string.IsNullOrEmpty(dto.City))
  7750. {
  7751. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7752. }
  7753. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7754. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7755. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7756. From Grp_NationalTravelFee gntf
  7757. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7758. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7759. Where gntf.Isdel = 0 {0} ", whereSql);
  7760. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7761. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7762. }
  7763. /// <summary>
  7764. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7765. /// </summary>
  7766. /// <returns></returns>
  7767. [HttpPost]
  7768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7769. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7770. {
  7771. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7772. }
  7773. /// <summary>
  7774. /// 团组模块 - 出入境国家费用标准 - Del
  7775. /// </summary>
  7776. /// <returns></returns>
  7777. [HttpPost]
  7778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7779. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7780. {
  7781. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7782. {
  7783. Id = dto.Id,
  7784. DeleteUserId = dto.DeleteUserId,
  7785. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7786. IsDel = 1
  7787. };
  7788. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7789. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7790. .WhereColumns(it => new { it.Id })
  7791. .ExecuteCommandAsync();
  7792. if (delStatus <= 0)
  7793. {
  7794. return Ok(JsonView(false, "删除失败!"));
  7795. }
  7796. return Ok(JsonView(true, "操作成功!"));
  7797. }
  7798. /// <summary>
  7799. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7800. /// 注:Get 请求Headers 加 Token
  7801. /// </summary>
  7802. /// <param name="groupId"></param>
  7803. /// <returns></returns>
  7804. [HttpGet("{groupId}")]
  7805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7806. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7807. {
  7808. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7809. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7810. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7811. data.ForEach(x =>
  7812. {
  7813. x.CreateUserId = _currUserInfo.UserId;
  7814. });
  7815. if (data.Any())
  7816. {
  7817. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7818. if (add > 0)
  7819. {
  7820. return Ok(JsonView(true, "操作成功!"));
  7821. }
  7822. }
  7823. return Ok(JsonView(false, "未操作!"));
  7824. }
  7825. #endregion
  7826. #region 团组经理模块 出入境费用-草稿
  7827. /// <summary>
  7828. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7829. /// </summary>
  7830. /// <returns></returns>
  7831. [HttpGet]
  7832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7833. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7834. {
  7835. var provData = await _groupRepository.ProvinceBasicSource();
  7836. return Ok(JsonView(true, "查询成功!", provData));
  7837. }
  7838. /// <summary>
  7839. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7840. /// </summary>
  7841. /// <returns></returns>
  7842. [HttpGet("{provinceId}")]
  7843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7844. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7845. {
  7846. //验证城市归属并给默认值
  7847. if (provinceId < 1) provinceId = 122;
  7848. /*
  7849. * 122 四川
  7850. * 108 贵州
  7851. * 103 重庆
  7852. * 132 云南
  7853. */
  7854. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7855. return Ok(JsonView(true, "查询成功!", new
  7856. {
  7857. WordTypeData = wordTypeData,
  7858. ExcelTypeData = excelTypeData,
  7859. }));
  7860. }
  7861. /// <summary>
  7862. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7863. /// </summary>
  7864. /// <returns></returns>
  7865. [HttpPost]
  7866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7867. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7868. {
  7869. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7870. .Where(x => x.IsDel == 0)
  7871. .OrderByDescending(x => x.CreateTime)
  7872. .Select(x => new { x.Id, x.DraftName })
  7873. .ToListAsync();
  7874. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7875. //SetDataInfoView
  7876. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7877. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7878. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7879. int provinceId = dto.ProvinceId;
  7880. if (provinceId < 1) provinceId = 122;
  7881. /*
  7882. * 122 四川
  7883. * 108 贵州
  7884. * 103 重庆
  7885. * 132 云南
  7886. */
  7887. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7888. //默认币种显示
  7889. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7890. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7891. return Ok(JsonView(true, "查询成功!", new
  7892. {
  7893. DraftNameDatas = draftNameDatas,
  7894. CurrencyData = _CurrencyData,
  7895. WordTypeData = wordTypeData,
  7896. ExcelTypeData = excelTypeData,
  7897. CurrencyInit = _currencyInfos,
  7898. ViewPermissionData = viewPermissionData
  7899. }));
  7900. }
  7901. /// <summary>
  7902. /// 团组模块 - 出入境费用-草稿
  7903. /// 实时汇率 tips
  7904. /// 机票费用 tips
  7905. /// </summary>
  7906. /// <returns></returns>
  7907. [HttpPost]
  7908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7909. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7910. {
  7911. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7912. return Ok(JsonView(true, "查询成功!", new
  7913. {
  7914. //GroupNameData = groupNameData.Data,
  7915. //visaData = visaData.Data,
  7916. //airData = airData.Data,
  7917. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7918. }));
  7919. }
  7920. /// <summary>
  7921. /// 团组模块 - 出入境费用-草稿
  7922. /// 签证费用 tips
  7923. /// </summary>
  7924. /// <returns></returns>
  7925. [HttpPost]
  7926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7927. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7928. {
  7929. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7930. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7931. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7932. .Select(x => x.NationalTravelFeeId)
  7933. .Distinct()
  7934. .ToListAsync();
  7935. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7936. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7937. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7938. .Select(x => x.Country)
  7939. .Distinct()
  7940. .ToArrayAsync();
  7941. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7942. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7943. return Ok(JsonView(true, "查询成功!", new
  7944. {
  7945. totalAmt = totalAmt,
  7946. remark = remark
  7947. }));
  7948. }
  7949. /// <summary>
  7950. /// 团组模块 - 出入境费用-草稿 - Info
  7951. /// </summary>
  7952. /// <returns></returns>
  7953. [HttpPost]
  7954. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7956. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7957. {
  7958. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7959. }
  7960. /// <summary>
  7961. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7962. /// </summary>
  7963. /// <returns></returns>
  7964. [HttpPost]
  7965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7966. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7967. {
  7968. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7969. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7970. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7971. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7972. foreach (var userId in dto.UserIds)
  7973. {
  7974. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7975. }
  7976. if (permissions.Any())
  7977. {
  7978. _sqlSugar.BeginTran();
  7979. try
  7980. {
  7981. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7982. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7983. if (result < 1)
  7984. {
  7985. _sqlSugar.RollbackTran();
  7986. return Ok(JsonView(false));
  7987. }
  7988. }
  7989. catch (Exception ex)
  7990. {
  7991. _sqlSugar.RollbackTran();
  7992. return Ok(JsonView(false, ex.Message));
  7993. }
  7994. _sqlSugar.CommitTran();
  7995. return Ok(JsonView(true));
  7996. }
  7997. return Ok(JsonView(false));
  7998. }
  7999. /// <summary>
  8000. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8001. /// </summary>
  8002. /// <returns></returns>
  8003. [HttpPost]
  8004. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8006. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8007. {
  8008. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8009. if (data.Code != 0)
  8010. {
  8011. return Ok(JsonView(false, data.Msg));
  8012. }
  8013. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8014. //汇率信息记录
  8015. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8016. return Ok(JsonView(true, data.Msg, data.Data));
  8017. }
  8018. /// <summary>
  8019. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8020. /// </summary>
  8021. /// <param name="dto"></param>
  8022. /// <returns></returns>
  8023. [HttpPost]
  8024. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8026. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8027. {
  8028. try
  8029. {
  8030. var id = dto.Id;
  8031. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8032. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8033. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8034. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8035. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8036. 3 团组成员名单 1 团组成员名单", ""));
  8037. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8038. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8039. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8040. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8041. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8042. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8043. //数据源
  8044. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8045. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8046. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8047. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8048. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8049. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8050. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8051. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8052. .Select((x, a, b) => new
  8053. {
  8054. x.Index,
  8055. itemName = a.Name,
  8056. CurrencyStr = b.Name,
  8057. x.Cost,
  8058. x.SubTotal,
  8059. x.Remark
  8060. })
  8061. .OrderBy((x) => x.Index)
  8062. .ToList(); //其他款项费用
  8063. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8064. var peiceItemCurrencys = new List<string>();
  8065. if (_DayAndCosts.Any())
  8066. {
  8067. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8068. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8069. }
  8070. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8071. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8072. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8073. {
  8074. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8075. }
  8076. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8077. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8078. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8079. if (dto.ExportType == 1) //明细表
  8080. {
  8081. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8082. {
  8083. //获取模板
  8084. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8085. //载入模板
  8086. Document doc = new Document(tempPath);
  8087. DocumentBuilder builder = new DocumentBuilder(doc);
  8088. //利用键值对存放数据
  8089. Dictionary<string, string> dic = new Dictionary<string, string>();
  8090. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8091. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8092. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8093. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8094. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8095. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8096. //境内费用(其他费用)
  8097. if (_EnterExitCosts.ChoiceOne == 1)
  8098. {
  8099. string row1_1 = "";
  8100. if (_EnterExitCosts.Visa > 0)
  8101. {
  8102. //insidePayTotal += _EnterExitCosts.Visa;
  8103. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8104. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8105. //{
  8106. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8107. //}
  8108. }
  8109. string row1_2 = "";
  8110. if (_EnterExitCosts.YiMiao > 0)
  8111. {
  8112. //insidePayTotal += _EnterExitCosts.YiMiao;
  8113. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8114. }
  8115. if (_EnterExitCosts.HeSuan > 0)
  8116. {
  8117. //insidePayTotal += _EnterExitCosts.HeSuan;
  8118. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8119. }
  8120. if (_EnterExitCosts.Service > 0)
  8121. {
  8122. //insidePayTotal += _EnterExitCosts.Service;
  8123. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8124. }
  8125. string row1_3 = "";
  8126. if (_EnterExitCosts.Safe > 0)
  8127. {
  8128. //insidePayTotal += _EnterExitCosts.Safe;
  8129. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8130. }
  8131. if (_EnterExitCosts.Ticket > 0)
  8132. {
  8133. //insidePayTotal += _EnterExitCosts.Ticket;
  8134. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8135. }
  8136. string row1 = "";
  8137. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8138. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8139. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8140. row1 += $"备注:{_EnterExitCosts.Remark}";
  8141. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8142. dic.Add("Row1Str", row1);
  8143. }
  8144. string airTotalStr = string.Empty,
  8145. airPriceStr = string.Empty;
  8146. //经济舱
  8147. if (_EnterExitCosts.SumJJC == 1)
  8148. {
  8149. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8150. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8151. }
  8152. //公务舱
  8153. if (_EnterExitCosts.SumGWC == 1)
  8154. {
  8155. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8156. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8157. }
  8158. //头等舱
  8159. if (_EnterExitCosts.SumTDC == 1)
  8160. {
  8161. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8162. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8163. }
  8164. //汇率描述
  8165. string rateStr = "";
  8166. if (peiceItemCurrencyInfos.Any())
  8167. {
  8168. rateStr = "\r\n汇率描述:";
  8169. foreach (var item in peiceItemCurrencyInfos)
  8170. {
  8171. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8172. }
  8173. }
  8174. string twoItemRemark = "备注:";
  8175. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8176. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8177. dic.Add("AirTotalStr", airTotalStr);
  8178. dic.Add("AirPriceStr", airPriceStr);
  8179. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8180. dic.Add("TwoItemRemark", twoItemRemark);
  8181. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8182. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8183. int table1Row = 0,
  8184. table2Row = 0,
  8185. table3Row = 0,
  8186. table4Row = 0,
  8187. table5Row = 0;
  8188. //住宿费
  8189. if (_EnterExitCosts.ChoiceThree == 1)
  8190. {
  8191. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8192. table1Row = dac1.Count;
  8193. #region 填充word表格内容
  8194. for (int i = 0; i < dac1.Count; i++)
  8195. {
  8196. var dac = dac1[i];
  8197. if (dac == null) continue;
  8198. builder.MoveToCell(0, i, 0, 0);
  8199. builder.Write("第" + dac.Days.ToString() + "晚:");
  8200. builder.MoveToCell(0, i, 1, 0);
  8201. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8202. //builder.Write(dac.Place == null ? "" : dac.Place);
  8203. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8204. builder.MoveToCell(0, i, 2, 0);
  8205. builder.Write("费用标准:");
  8206. string curr = "";
  8207. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8208. if (currData != null)
  8209. {
  8210. curr = currData.Name;
  8211. }
  8212. builder.MoveToCell(0, i, 3, 0);
  8213. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8214. builder.MoveToCell(0, i, 4, 0);
  8215. builder.Write("费用小计:");
  8216. builder.MoveToCell(0, i, 5, 0);
  8217. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8218. }
  8219. #endregion
  8220. }
  8221. else dic.Add("SubZS", "0.00");
  8222. //删除多余行
  8223. while (table1.Rows.Count > table1Row)
  8224. {
  8225. table1.Rows.RemoveAt(table1Row);
  8226. }
  8227. //伙食费
  8228. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8229. if (_EnterExitCosts.ChoiceFour == 1)
  8230. {
  8231. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8232. table2Row = dac2.Count;
  8233. #region 填充word表格内容
  8234. for (int i = 0; i < dac2.Count; i++)
  8235. {
  8236. var dac = dac2[i];
  8237. if (dac == null) continue;
  8238. builder.MoveToCell(1, i, 0, 0);
  8239. builder.Write("第" + dac.Days.ToString() + "天:");
  8240. builder.MoveToCell(1, i, 1, 0);
  8241. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8242. builder.MoveToCell(1, i, 2, 0);
  8243. builder.Write("费用标准:");
  8244. string curr = "";
  8245. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8246. if (currData != null)
  8247. {
  8248. curr = currData.Name;
  8249. }
  8250. builder.MoveToCell(1, i, 3, 0);
  8251. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8252. builder.MoveToCell(1, i, 4, 0);
  8253. builder.Write("费用小计:");
  8254. builder.MoveToCell(1, i, 5, 0);
  8255. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8256. }
  8257. #endregion
  8258. }
  8259. else dic.Add("SubHS", "0.00");
  8260. //删除多余行
  8261. while (table2.Rows.Count > table2Row)
  8262. {
  8263. table2.Rows.RemoveAt(table2Row);
  8264. }
  8265. //公杂费
  8266. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8267. if (_EnterExitCosts.ChoiceFive == 1)
  8268. {
  8269. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8270. table3Row = dac3.Count;
  8271. #region 填充word表格内容
  8272. for (int i = 0; i < dac3.Count; i++)
  8273. {
  8274. var dac = dac3[i];
  8275. if (dac == null) continue;
  8276. builder.MoveToCell(2, i, 0, 0);
  8277. builder.Write("第" + dac.Days.ToString() + "天:");
  8278. builder.MoveToCell(2, i, 1, 0);
  8279. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8280. builder.MoveToCell(2, i, 2, 0);
  8281. builder.Write("费用标准:");
  8282. string curr = "";
  8283. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8284. if (currData != null)
  8285. {
  8286. curr = currData.Name;
  8287. }
  8288. builder.MoveToCell(2, i, 3, 0);
  8289. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8290. builder.MoveToCell(2, i, 4, 0);
  8291. builder.Write("费用小计:");
  8292. builder.MoveToCell(2, i, 5, 0);
  8293. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8294. }
  8295. //删除多余行
  8296. while (table3.Rows.Count > table3Row)
  8297. {
  8298. table3.Rows.RemoveAt(table3Row);
  8299. }
  8300. #endregion
  8301. }
  8302. else dic.Add("SubGZF", "0.00");
  8303. //删除多余行
  8304. while (table3.Rows.Count > table3Row)
  8305. {
  8306. table3.Rows.RemoveAt(table3Row);
  8307. }
  8308. //培训费
  8309. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8310. if (_EnterExitCosts.ChoiceSix == 1)
  8311. {
  8312. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8313. dic.Add("SubPX", pxStr);
  8314. table4Row = dac4.Count;
  8315. #region 填充word表格内容
  8316. for (int i = 0; i < dac4.Count; i++)
  8317. {
  8318. var dac = dac4[i];
  8319. if (dac == null) continue;
  8320. builder.MoveToCell(3, i, 0, 0);
  8321. builder.Write("第" + dac.Days.ToString() + "天:");
  8322. builder.MoveToCell(3, i, 1, 0);
  8323. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8324. builder.MoveToCell(3, i, 2, 0);
  8325. builder.Write("费用标准:");
  8326. string curr = "";
  8327. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8328. if (currData != null)
  8329. {
  8330. curr = currData.Name;
  8331. }
  8332. builder.MoveToCell(3, i, 3, 0);
  8333. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8334. builder.MoveToCell(3, i, 4, 0);
  8335. builder.Write("费用小计:");
  8336. builder.MoveToCell(3, i, 5, 0);
  8337. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8338. }
  8339. #endregion
  8340. }
  8341. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8342. //删除多余行
  8343. while (table4.Rows.Count > table4Row)
  8344. {
  8345. table4.Rows.RemoveAt(table4Row);
  8346. }
  8347. //其他费用
  8348. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8349. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8350. {
  8351. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8352. dic.Add("titleQi", qtStr);
  8353. table5Row = dac5.Count;
  8354. #region 填充word表格内容
  8355. for (int i = 0; i < dac5.Count; i++)
  8356. {
  8357. var dac = dac5[i];
  8358. if (dac == null) continue;
  8359. builder.MoveToCell(4, i, 0, 0);
  8360. builder.Write("第" + dac.Index.ToString() + "项:");
  8361. builder.MoveToCell(4, i, 1, 0);
  8362. builder.Write(dac.itemName);
  8363. builder.MoveToCell(4, i, 2, 0);
  8364. builder.Write("费用标准:");
  8365. builder.MoveToCell(4, i, 3, 0);
  8366. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8367. builder.MoveToCell(4, i, 4, 0);
  8368. builder.Write("费用小计:");
  8369. builder.MoveToCell(4, i, 5, 0);
  8370. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8371. builder.MoveToCell(4, i, 6, 0);
  8372. builder.Write("备注:");
  8373. builder.MoveToCell(4, i, 7, 0);
  8374. builder.Write(dac.Remark);
  8375. }
  8376. #endregion
  8377. }
  8378. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8379. //删除多余行
  8380. while (table5.Rows.Count > table5Row)
  8381. {
  8382. table5.Rows.RemoveAt(table5Row);
  8383. }
  8384. //加上其他费用
  8385. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8386. decimal subJJC = 0.00M,
  8387. subGWC = 0.00M,
  8388. subTDC = 0.00M;
  8389. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8390. string totalLabel = string.Format("全部费用总计:");
  8391. //经济舱
  8392. if (_EnterExitCosts.SumJJC == 1)
  8393. {
  8394. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8395. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8396. }
  8397. //公务舱
  8398. if (_EnterExitCosts.SumGWC == 1)
  8399. {
  8400. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8401. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8402. }
  8403. //头等舱
  8404. if (_EnterExitCosts.SumTDC == 1)
  8405. {
  8406. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8407. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8408. }
  8409. //TotalLabel
  8410. dic.Add("TotalLabel", totalLabel);
  8411. #region 填充word模板书签内容
  8412. foreach (var key in dic.Keys)
  8413. {
  8414. Bookmark bookmark = doc.Range.Bookmarks[key];
  8415. if (bookmark != null)
  8416. {
  8417. builder.MoveToBookmark(key);
  8418. builder.Write(dic[key]);
  8419. }
  8420. }
  8421. #endregion
  8422. //文件名
  8423. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8424. strFileName = CommonFun.ValidFileName(strFileName);
  8425. AsposeHelper.removewatermark_v2180();
  8426. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8427. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8428. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8429. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8430. }
  8431. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8432. {
  8433. //获取模板
  8434. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8435. //载入模板
  8436. Document doc = new Document(tempPath);
  8437. DocumentBuilder builder = new DocumentBuilder(doc);
  8438. Dictionary<string, string> dic = new Dictionary<string, string>();
  8439. string returnCodeLabel = string.Empty;
  8440. if (nationalTravelFeeData.Any())
  8441. {
  8442. List<string> list = new List<string>();
  8443. foreach (var item in nationalTravelFeeData)
  8444. {
  8445. list.Add($"{item.Country}({item.City})");
  8446. }
  8447. list = list.Distinct().ToList();
  8448. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8449. }
  8450. var countryLabel = string.Empty;
  8451. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8452. if (countryData.Any())
  8453. {
  8454. countryLabel = string.Join("、", countryData);
  8455. }
  8456. dic.Add("ReturnCodeAir", returnCodeLabel);
  8457. dic.Add("VisitStartDate", "-");
  8458. dic.Add("VisitEndDate", "-");
  8459. dic.Add("Day", "-");
  8460. dic.Add("VisitCountry", countryLabel);
  8461. dic.Add("ClientUnit", "-");
  8462. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8463. //dic.Add("Names", Names);
  8464. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8465. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8466. decimal dac1totalPrice = 0.00M;
  8467. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8468. foreach (var dac in dac1)
  8469. {
  8470. if (dac.SubTotal == 0.00M)
  8471. {
  8472. continue;
  8473. }
  8474. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8475. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8476. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8477. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8478. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8479. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8480. builder.Write(currency);//币种
  8481. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8482. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8483. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8484. builder.Write("");//人数
  8485. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8486. builder.Write("");//天数
  8487. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8488. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8489. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8490. decimal rate = 0.00M;
  8491. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8492. builder.Write(rate.ToString("#0.0000"));//汇率
  8493. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8494. decimal rbmPrice = dac.SubTotal;
  8495. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8496. accommodationStartIndex++;
  8497. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8498. }
  8499. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8500. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8501. {
  8502. table1.Rows.RemoveAt(i - 1);
  8503. foodandotherStartIndex--;
  8504. }
  8505. if (dac2.Count == dac3.Count)//国家 币种 金额
  8506. {
  8507. for (int i = 0; i < dac2.Count; i++)
  8508. {
  8509. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8510. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8511. }
  8512. }
  8513. decimal dac2totalPrice = 0.00M;
  8514. foreach (var dac in dac2)
  8515. {
  8516. if (dac.SubTotal == 0)
  8517. {
  8518. continue;
  8519. }
  8520. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8521. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8522. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8523. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8524. builder.Write(currency);//币种
  8525. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8526. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8527. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8528. builder.Write("");//人数
  8529. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8530. builder.Write("");//天数
  8531. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8532. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8533. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8534. decimal rate = 0.00M;
  8535. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8536. builder.Write(rate.ToString("#0.0000"));//汇率
  8537. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8538. decimal rbmPrice = dac.SubTotal;
  8539. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8540. foodandotherStartIndex++;
  8541. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8542. }
  8543. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8544. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8545. {
  8546. table1.Rows.RemoveAt(i - 1);
  8547. }
  8548. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8549. string otherFeeStr = "";
  8550. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8551. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8552. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8553. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8554. foreach (var otherInfo in dac5)
  8555. {
  8556. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8557. }
  8558. #endregion
  8559. if (otherFeeStr.Length > 0)
  8560. {
  8561. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8562. otherFeeStr = $"({otherFeeStr})";
  8563. dic.Add("OtherFeeStr", otherFeeStr);
  8564. }
  8565. //总计
  8566. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8567. //国际旅费
  8568. string outsideAir = string.Empty;
  8569. string allPriceAir = string.Empty;
  8570. if (_EnterExitCosts.SumJJC == 1)
  8571. {
  8572. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8573. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8574. }
  8575. if (_EnterExitCosts.SumGWC == 1)
  8576. {
  8577. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8578. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8579. }
  8580. if (_EnterExitCosts.SumTDC == 1)
  8581. {
  8582. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8583. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8584. }
  8585. dic.Add("InTravelPrice", $"({outsideAir})");
  8586. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8587. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8588. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8589. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8590. foreach (var key in dic.Keys)
  8591. {
  8592. builder.MoveToBookmark(key);
  8593. builder.Write(dic[key]);
  8594. }
  8595. //模板文件名
  8596. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8597. strFileName = CommonFun.ValidFileName(strFileName);
  8598. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8599. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8600. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8601. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8602. }
  8603. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8604. {
  8605. //获取模板
  8606. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8607. //载入模板
  8608. WorkbookDesigner designer = new WorkbookDesigner();
  8609. designer.Workbook = new Workbook(tempPath);
  8610. Dictionary<string, string> dic = new Dictionary<string, string>();
  8611. string returnCodeLabel = string.Empty;
  8612. if (nationalTravelFeeData.Any())
  8613. {
  8614. List<string> list = new List<string>();
  8615. foreach (var item in nationalTravelFeeData)
  8616. {
  8617. list.Add($"{item.Country}({item.City})");
  8618. }
  8619. list = list.Distinct().ToList();
  8620. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8621. }
  8622. var countryLabel = string.Empty;
  8623. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8624. if (countryData.Any())
  8625. {
  8626. countryLabel = string.Join("、", countryData);
  8627. }
  8628. dic.Add("ReturnCodeAir", returnCodeLabel);
  8629. dic.Add("VisitStartDate", "-");
  8630. dic.Add("VisitEndDate", "-");
  8631. dic.Add("Day", "0");
  8632. dic.Add("VisitCountry", countryLabel);
  8633. dic.Add("ClientUnit", "-");
  8634. designer.SetDataSource("ClientUnit", "-");
  8635. designer.SetDataSource("VisitCountry", countryLabel);
  8636. designer.SetDataSource("Group", "-");
  8637. designer.SetDataSource("ClientUnitTitle", "-");
  8638. designer.SetDataSource("Name", "-");
  8639. designer.SetDataSource("VisitStartDate", "-");
  8640. designer.SetDataSource("Day", "0");
  8641. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8642. designer.SetDataSource("ReturnCodeAir", "-");
  8643. int startIndex = 10;
  8644. const int startIndexcopy = 10;
  8645. if (dac2.Count == dac3.Count)//国家 币种 金额
  8646. {
  8647. for (int i = 0; i < dac2.Count; i++)
  8648. {
  8649. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8650. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8651. }
  8652. }
  8653. DataTable dtdac1 = new DataTable();
  8654. List<string> place = new List<string>();
  8655. dtdac1.Columns.AddRange(new DataColumn[] {
  8656. new DataColumn(){ ColumnName = "city"},
  8657. new DataColumn(){ ColumnName = "curr"},
  8658. new DataColumn(){ ColumnName = "criterion"},
  8659. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8660. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8661. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8662. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8663. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8664. });
  8665. DataTable dtdac2 = new DataTable();
  8666. dtdac2.Columns.AddRange(new DataColumn[] {
  8667. new DataColumn(){ ColumnName = "city"},
  8668. new DataColumn(){ ColumnName = "curr"},
  8669. new DataColumn(){ ColumnName = "criterion"},
  8670. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8671. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8672. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8673. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8674. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8675. });
  8676. dtdac1.TableName = "tb1";
  8677. dtdac2.TableName = "tb2";
  8678. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8679. foreach (var item in dac1)
  8680. {
  8681. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8682. if (place.Contains(item.Place))
  8683. {
  8684. continue;
  8685. }
  8686. DataRow row = dtdac1.NewRow();
  8687. row["city"] = item.Place;
  8688. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8689. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8690. row["curr"] = currency;
  8691. row["rate"] = rate.ToString("#0.0000");
  8692. row["criterion"] = item.Cost.ToString("#0.00");
  8693. row["number"] = 1;
  8694. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8695. //row["costRMB"] = rbmPrice;
  8696. dtdac1.Rows.Add(row);
  8697. place.Add(item.Place);
  8698. }
  8699. place = new List<string>();
  8700. foreach (var item in dac2)
  8701. {
  8702. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8703. if (place.Contains(item.Place))
  8704. {
  8705. continue;
  8706. }
  8707. DataRow row = dtdac2.NewRow();
  8708. row["city"] = item.Place;
  8709. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8710. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8711. row["curr"] = currency;
  8712. row["rate"] = rate.ToString("#0.0000");
  8713. row["criterion"] = item.Cost.ToString("#0.00");
  8714. row["number"] = 1;
  8715. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8716. //row["cost"] = item.SubTotal;
  8717. //row["costRMB"] = rbmPrice;
  8718. dtdac2.Rows.Add(row);
  8719. place.Add(item.Place);
  8720. //dac2totalPrice += rbmPrice;
  8721. }
  8722. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8723. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8724. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8725. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8726. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8727. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8728. string cell4Str1 = string.Empty;
  8729. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8730. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8731. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8732. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8733. string cellStr = $" 5.其他费用(";
  8734. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8735. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8736. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8737. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8738. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8739. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8740. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8741. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8742. foreach (var otherInfo in dac5)
  8743. {
  8744. cellStr += $"{otherInfo.itemName}{otherInfo.SubTotal:#0.00} 元,";
  8745. }
  8746. #endregion
  8747. if (cellStr.Length > 8)
  8748. {
  8749. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8750. }
  8751. cellStr += ")";
  8752. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8753. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8754. decimal pxFee = dac4.Sum(it => it.Cost);
  8755. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8756. string celllastStr1 = "";
  8757. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8758. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8759. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8760. celllastStr1 += $",国际旅费 元";
  8761. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8762. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8763. designer.SetDataSource("cell4Str", cell4Str);
  8764. designer.SetDataSource("cellStr", cellStr);
  8765. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8766. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8767. designer.SetDataSource("celllastStr", celllastStr);
  8768. Workbook wb = designer.Workbook;
  8769. var sheet = wb.Worksheets[0];
  8770. //绑定datatable数据集
  8771. designer.SetDataSource(dtdac1);
  8772. designer.SetDataSource(dtdac2);
  8773. designer.Process();
  8774. var rowStart = dtdac1.Rows.Count;
  8775. while (rowStart > 0)
  8776. {
  8777. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8778. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8779. startIndex++;
  8780. rowStart--;
  8781. }
  8782. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8783. startIndex += 1; //总计行
  8784. rowStart = dtdac2.Rows.Count;
  8785. while (rowStart > 0)
  8786. {
  8787. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8788. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8789. startIndex++;
  8790. rowStart--;
  8791. }
  8792. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8793. wb.CalculateFormula(true);
  8794. //模板文件名
  8795. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8796. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8797. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8798. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8799. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8800. }
  8801. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8802. {
  8803. //获取模板
  8804. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8805. //载入模板
  8806. Document doc = new Document(tempPath);
  8807. DocumentBuilder builder = new DocumentBuilder(doc);
  8808. Dictionary<string, string> dic = new Dictionary<string, string>();
  8809. dic.Add("GroupName", "-");
  8810. dic.Add("ClientUnit", "-");
  8811. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8812. //string missionLeaderJob = "";//负责人job
  8813. //int groupNumber = 0; //团人数
  8814. dic.Add("MissionLeader", "-"); //团负责人
  8815. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8816. dic.Add("GroupNumber", "0"); //团人数
  8817. dic.Add("Day", "0");
  8818. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8819. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8820. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8821. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8822. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8823. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8824. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8825. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8826. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8827. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8828. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8829. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8830. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8831. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8832. //其他费用
  8833. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8834. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8835. //其他费用合计
  8836. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8837. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8838. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8839. //公务舱合计
  8840. //国际旅费
  8841. //string outsideJJ = "";
  8842. //string allPriceJJ = "";
  8843. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8844. {
  8845. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8846. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8847. }
  8848. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8849. {
  8850. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8851. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8852. }
  8853. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8854. {
  8855. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8856. dic.Add("AirFeeTotal", airFeeTotalStr);
  8857. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8858. dic.Add("FeeTotal", feeTotalStr);
  8859. }
  8860. foreach (var key in dic.Keys)
  8861. {
  8862. builder.MoveToBookmark(key);
  8863. builder.Write(dic[key]);
  8864. }
  8865. //模板文件名
  8866. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8867. strFileName = CommonFun.ValidFileName(strFileName);
  8868. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8869. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8870. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8871. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8872. }
  8873. }
  8874. else if (dto.ExportType == 2) //表格
  8875. {
  8876. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8877. }
  8878. else if (dto.ExportType == 3)
  8879. {
  8880. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8881. }
  8882. return Ok(JsonView(400, "只可导出明细表!", ""));
  8883. }
  8884. catch (Exception ex)
  8885. {
  8886. return Ok(JsonView(400, ex.Message, ""));
  8887. }
  8888. }
  8889. /// <summary>
  8890. /// 获取三公费用标准city
  8891. /// </summary>
  8892. /// <param name="placeData"></param>
  8893. /// <param name="nationalTravelFeeId"></param>
  8894. /// <returns></returns>
  8895. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8896. {
  8897. string _city = string.Empty;
  8898. if (!placeData.Any()) return _city;
  8899. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8900. if (data == null) return _city;
  8901. string country = data.Country;
  8902. string city = data.City;
  8903. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8904. else _city = city;
  8905. return _city;
  8906. }
  8907. /// <summary>
  8908. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8909. /// </summary>
  8910. /// <returns></returns>
  8911. [HttpPost]
  8912. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8914. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8915. {
  8916. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8917. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8918. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8919. if (_view.Code == 0)
  8920. {
  8921. return Ok(JsonView(true, "操作成功"));
  8922. }
  8923. return Ok(JsonView(false, "操作失败"));
  8924. }
  8925. /// <summary>
  8926. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8927. /// </summary>
  8928. /// <returns></returns>
  8929. [HttpPost]
  8930. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8932. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8933. {
  8934. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8935. if (data.Code != 0)
  8936. {
  8937. return Ok(JsonView(false, data.Msg));
  8938. }
  8939. return Ok(JsonView(true, "操作成功!", data.Data));
  8940. }
  8941. /// <summary>
  8942. /// 三公其他费用草稿 删除
  8943. /// </summary>
  8944. /// <param name="dto"></param>
  8945. /// <returns></returns>
  8946. [HttpPost]
  8947. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8948. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8949. {
  8950. var jw = JsonView(false, "删除失败!");
  8951. var data = new Grp_DayOtherPriceDraft()
  8952. {
  8953. Id = dto.Id,
  8954. IsDel = 1,
  8955. DeleteUserId = dto.DeleteUserId,
  8956. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8957. };
  8958. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8959. if (del > 0)
  8960. {
  8961. jw.Code = 200;
  8962. jw.Msg = "删除成功!";
  8963. }
  8964. return Ok(jw);
  8965. }
  8966. /// <summary>
  8967. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8968. /// </summary>
  8969. /// <returns></returns>
  8970. [HttpPost]
  8971. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8972. {
  8973. var jw = JsonView(false);
  8974. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8975. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8976. jw.Code = StatusCodes.Status200OK;
  8977. jw.Msg = "操作成功!";
  8978. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8979. return Ok(jw);
  8980. }
  8981. /// <summary>
  8982. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8983. /// </summary>
  8984. /// <param name="dto"></param>
  8985. /// <returns></returns>
  8986. [HttpPost]
  8987. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8988. {
  8989. int userId = dto.UserId,
  8990. portId = dto.PortType,
  8991. groupId = dto.GroupId,
  8992. draftId = dto.DraftId;
  8993. _portTypeData.Add(1);
  8994. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8995. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8996. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8997. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8998. _sqlSugar.BeginTran();
  8999. try
  9000. {
  9001. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9002. if (draftDatas == null)
  9003. {
  9004. _sqlSugar.RollbackTran();
  9005. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9006. }
  9007. //验证可覆盖已有数据 两边创建人需为同一人;
  9008. int draftCreateUserId = draftDatas.CreateUserId,
  9009. formalCreateUserId = 0;
  9010. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9011. if (formalData != null)
  9012. {
  9013. formalCreateUserId = formalData.CreateUserId;
  9014. if (draftCreateUserId != formalCreateUserId)
  9015. {
  9016. _sqlSugar.RollbackTran();
  9017. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9018. }
  9019. }
  9020. //默认添加查看、编辑权限(创建人、自己)
  9021. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9022. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9023. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9024. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9025. newExterData.DiId = groupId;
  9026. newExterData.CreateUserId = userId;
  9027. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9028. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9029. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9030. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9031. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9032. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9033. //数据如果存在执行删除
  9034. if (enterExitCostInfo != null)
  9035. {
  9036. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9037. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9038. .Where(x => x.Id == enterExitCostInfo.Id)
  9039. .ExecuteCommand();
  9040. _sqlSugar.Updateable<Grp_DayAndCost>()
  9041. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9042. .Where(x => x.DiId == groupId)
  9043. .ExecuteCommand();
  9044. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9045. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9046. .Where(x => x.Diid == groupId)
  9047. .ExecuteCommand();
  9048. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9049. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9050. .Where(x => x.GroupId == groupId)
  9051. .ExecuteCommand();
  9052. }
  9053. //执行insert
  9054. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9055. if (insertId < 1)
  9056. {
  9057. _sqlSugar.RollbackTran();
  9058. return Ok(JsonView(false, "草稿数据导入失败!"));
  9059. }
  9060. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9061. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9062. #region 默认添加权限
  9063. #endregion
  9064. _sqlSugar.CommitTran();
  9065. //执行操作之后
  9066. //生成默认文件pdf并且通知人员
  9067. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9068. {
  9069. DiId = groupId,
  9070. ExportType = 1,
  9071. SubTypeId = 1005
  9072. }, "pdf");
  9073. //发送通知
  9074. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9075. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9076. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9077. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9078. //汇率信息记录
  9079. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9080. return Ok(JsonView(true));
  9081. }
  9082. catch (Exception ex)
  9083. {
  9084. _sqlSugar.RollbackTran();
  9085. return Ok(JsonView(false, ex.Message));
  9086. }
  9087. }
  9088. #endregion
  9089. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9090. /// <summary>
  9091. /// 获取币种基础数据(含逻辑处理)
  9092. /// </summary>
  9093. /// <returns></returns>
  9094. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9095. {
  9096. return await GeneralMethod.EnterExitCostInitRate();
  9097. }
  9098. /// <summary>
  9099. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9100. /// </summary>
  9101. /// <returns></returns>
  9102. [HttpPost]
  9103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9104. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9105. {
  9106. //验证城市归属并给默认值
  9107. int provinceId = dto.ProvinceId;
  9108. if (provinceId < 1) provinceId = 122;
  9109. var dataSource = await _sqlSugar
  9110. .Queryable<Sys_SetData>()
  9111. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9112. .ToListAsync();
  9113. var fileTypes = new List<EecSetDataInfoView>();
  9114. //三公费用-Word明细类型
  9115. var wordTypeData = dataSource
  9116. .Where(it => it.STid == 72)
  9117. .Select(x => new EecSetDataInfoView
  9118. {
  9119. ParentId = 1,
  9120. Id = x.Id,
  9121. Name = x.Name
  9122. })
  9123. .ToArray();
  9124. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9125. var excelTypeData = dataSource
  9126. .Where(it => it.STid == 73)
  9127. .Select(x => new EecSetDataInfoView
  9128. {
  9129. ParentId = 2,
  9130. Id = x.Id,
  9131. Name = x.Name
  9132. })
  9133. .ToArray();
  9134. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9135. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9136. fileTypes.Add(groupNameList);
  9137. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9138. //默认币种显示
  9139. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9140. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9141. return Ok(JsonView(true, "查询成功!", new
  9142. {
  9143. FileTypeData = fileTypes,
  9144. CurrencyInit = _currencyInfos,
  9145. viewPermissionData = viewPermissionData
  9146. }));
  9147. }
  9148. /// <summary>
  9149. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9150. /// </summary>
  9151. /// <returns></returns>
  9152. [HttpPost]
  9153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9154. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9155. {
  9156. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9157. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9158. RefAsync<int> total = 0;
  9159. int diId = 0;
  9160. var status = int.TryParse(dto.GroupName, out diId);
  9161. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9162. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9163. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9164. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9165. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9166. .OrderByDescending(x => x.VisitStartDate)
  9167. .Select(x => new EnterExitCostMobileGroupView()
  9168. {
  9169. Id = x.Id,
  9170. GroupName = x.TeamName,
  9171. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9172. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9173. ProvinceId = x.CityId
  9174. })
  9175. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9176. //处理省份Id
  9177. if (data.Any())
  9178. {
  9179. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9180. if (provCityDatas.Any())
  9181. {
  9182. foreach (var item in data)
  9183. {
  9184. var provinceId = item.ProvinceId;
  9185. var isDefualtVal = true;
  9186. if (provinceId > 0)
  9187. {
  9188. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9189. if (parentId != null)
  9190. {
  9191. isDefualtVal = false;
  9192. item.ProvinceId = (int)parentId;
  9193. }
  9194. }
  9195. if (isDefualtVal)
  9196. {
  9197. item.ProvinceId = 122; //默认四川
  9198. }
  9199. }
  9200. }
  9201. }
  9202. //处理是否显示
  9203. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9204. {
  9205. foreach (var item in data)
  9206. {
  9207. item.IsView = true;
  9208. }
  9209. }
  9210. return Ok(JsonView(true, "查询成功!", data, total));
  9211. }
  9212. /// <summary>
  9213. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9214. /// </summary>
  9215. /// <returns></returns>
  9216. [HttpPost]
  9217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9218. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9219. {
  9220. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9221. RefAsync<int> total = 0;
  9222. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9223. .Where(x => x.IsDel == 0 && x.STid == 66)
  9224. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9225. .Select(x => new
  9226. {
  9227. id = x.Id,
  9228. name = x.Name,
  9229. remark = x.Remark,
  9230. })
  9231. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9232. return Ok(JsonView(true, "查询成功!", data, total));
  9233. }
  9234. /// <summary>
  9235. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9236. /// </summary>
  9237. /// <returns></returns>
  9238. [HttpPost]
  9239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9240. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9241. {
  9242. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9243. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9244. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9245. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9246. var groupOtherRateData = groupRateData.TeamRates;
  9247. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9248. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9249. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9250. groupOtherRateData = groupOtherRateData
  9251. .Select(x => new TeamRateDescAddCurrencyIdView
  9252. {
  9253. CurrencyId = x.CurrencyId,
  9254. CurrencyName = x.CurrencyName,
  9255. CurrencyCode = x.CurrencyCode,
  9256. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9257. }).ToList();
  9258. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9259. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9260. }
  9261. /// <summary>
  9262. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9263. /// </summary>
  9264. /// <returns></returns>
  9265. [HttpPost]
  9266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9267. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9268. {
  9269. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9270. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9271. var tipsData = new List<int>() { 1, 2, 3 };
  9272. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9273. if (dto.TipsType == 1)
  9274. {
  9275. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9276. }
  9277. else if (dto.TipsType == 2)
  9278. {
  9279. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9280. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9281. }
  9282. else if (dto.TipsType == 3)
  9283. {
  9284. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9285. return Ok(JsonView(true, "查询成功!", airData));
  9286. }
  9287. return Ok(JsonView(false));
  9288. }
  9289. /// <summary>
  9290. /// 团组模块 - 出入境国家费用标准-移动端 List
  9291. /// </summary>
  9292. /// <returns></returns>
  9293. [HttpPost]
  9294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9295. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9296. {
  9297. Stopwatch sw = new Stopwatch();
  9298. sw.Start();
  9299. int provinceId = dto.ProvinceId;
  9300. if (provinceId < 1) provinceId = 122; // 默认四川
  9301. RefAsync<int> total = 0;
  9302. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9303. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9304. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9305. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9306. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9307. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9308. .Select((ntf, sd, u, sd1) => new
  9309. {
  9310. Id = ntf.Id,
  9311. Area = $"{ntf.Country}-{ntf.City}",
  9312. Currency = ntf.Currency,
  9313. CurrencyCode = sd.Name,
  9314. CurrencyName = sd.Remark,
  9315. RoomCost = ntf.RoomCost,
  9316. FoodCost = ntf.FoodCost,
  9317. PublicCost = ntf.PublicCost,
  9318. TrainCost = ntf.TrainCost,
  9319. LastUpdateUserId = ntf.LastUpdateUserId,
  9320. LastUpdateUserName = u.CnName,
  9321. LastUpdateTime = ntf.LastUpdateTime
  9322. })
  9323. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9324. sw.Stop();
  9325. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9326. }
  9327. /// <summary>
  9328. /// 团组模块 - 出入境费用-移动端 - Info
  9329. /// </summary>
  9330. /// <returns></returns>
  9331. [HttpPost]
  9332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9333. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9334. {
  9335. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9336. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9337. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9338. return Ok(data);
  9339. }
  9340. /// <summary>
  9341. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9342. /// </summary>
  9343. /// <returns></returns>
  9344. [HttpPost]
  9345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9346. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9347. {
  9348. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9349. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9350. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9351. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9352. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9353. mobileInfo.DiId = dto.DiId;
  9354. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9355. if (eecInfo == null) return Ok(mobileInfo);
  9356. //验证查看权限
  9357. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9358. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9359. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9360. mobileInfo.IsAssignPerm = isSet;
  9361. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9362. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9363. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9364. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9365. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9366. {
  9367. SubId = dac.Id,
  9368. DiId = dac.DiId,
  9369. Type = dac.Type,
  9370. Days = dac.Days,
  9371. NationalTravelFeeId = dac.NationalTravelFeeId,
  9372. Arae = $"{ntf.Country}-{ntf.City}",
  9373. Cost = dac.Cost,
  9374. Currency = dac.Currency,
  9375. CurrencyName = sd.Name,
  9376. SubTotal = dac.SubTotal,
  9377. })
  9378. .ToList();
  9379. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9380. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9381. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9382. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9383. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9384. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9385. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9386. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9387. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9388. //其他款项
  9389. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9390. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9391. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9392. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9393. .OrderBy((dop, sd1, sd2) => dop.Index)
  9394. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9395. {
  9396. SubId = dop.Id,
  9397. DiId = dop.Diid,
  9398. Index = dop.Index,
  9399. SetDataId = dop.SetDataId,
  9400. SetDataName = sd1.Name,
  9401. Cost = dop.Cost,
  9402. Currency = dop.Currency,
  9403. CurrencyName = sd2.Remark,
  9404. SubTotal = dop.SubTotal,
  9405. Remark = dop.Remark,
  9406. })
  9407. .ToArray();
  9408. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9409. return Ok(mobileInfo);
  9410. }
  9411. /// <summary>
  9412. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9413. /// </summary>
  9414. /// <returns></returns>
  9415. [HttpPost]
  9416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9417. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9418. {
  9419. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9420. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9421. //验证查看权限
  9422. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9423. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9424. var userIds = await _sqlSugar
  9425. .Queryable<Grp_EnterExitCostPermission>()
  9426. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9427. .Select(x => x.UserId)
  9428. .ToArrayAsync();
  9429. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9430. var perUsersView = new List<dynamic>();
  9431. foreach (var item in perUsers)
  9432. {
  9433. bool isView1 = false;
  9434. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9435. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9436. }
  9437. return Ok(JsonView(perUsersView));
  9438. }
  9439. /// <summary>
  9440. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9441. /// </summary>
  9442. /// <returns></returns>
  9443. [HttpPost]
  9444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9445. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9446. {
  9447. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9448. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9449. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9450. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9451. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9452. //验证查看权限
  9453. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9454. //if (!isView) return Ok(JsonView(false, msg));
  9455. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9456. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9457. var subType = dto.SubType;
  9458. if (subType == 1) //1:境内费用
  9459. {
  9460. var oneData = new ChoiceOneMobileSubInfoView()
  9461. {
  9462. Id = eecInfo.Id,
  9463. ChoiceOne = eecInfo.ChoiceOne,
  9464. ChoiceOneTotalCost = eecInfo.InsidePay,
  9465. Visa = eecInfo.Visa,
  9466. VisaRemark = eecInfo.VisaRemark,
  9467. YiMiao = eecInfo.YiMiao,
  9468. HeSuan = eecInfo.HeSuan,
  9469. Service = eecInfo.Service,
  9470. Ticket = eecInfo.Ticket,
  9471. Safe = eecInfo.Safe,
  9472. FirstItemRemark = eecInfo.FirstItemRemark
  9473. };
  9474. return Ok(JsonView(oneData));
  9475. }
  9476. else if (subType == 2) //2:国际旅费
  9477. {
  9478. var twoData = new ChoiceTwoMobileSubInfoView()
  9479. {
  9480. Id = eecInfo.Id,
  9481. ChoiceTwoJJ = eecInfo.SumJJC,
  9482. OutsideJJPay = eecInfo.OutsideJJPay,
  9483. ChoiceTwoGW = eecInfo.SumGWC,
  9484. OutsideGWPay = eecInfo.OutsideGWPay,
  9485. ChoiceTwoTD = eecInfo.SumTDC,
  9486. OutsideTDPay = eecInfo.OutsideTDPay,
  9487. AirJJ = eecInfo.AirJJ,
  9488. AirGW = eecInfo.AirGW,
  9489. AirTD = eecInfo.AirTD,
  9490. CityTranffic = eecInfo.CityTranffic,
  9491. TwoItemRemark = eecInfo.TwoItemRemark
  9492. };
  9493. return Ok(JsonView(twoData));
  9494. }
  9495. else if (subType == 3) //3:住宿费
  9496. {
  9497. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9498. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9499. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9500. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9501. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9502. {
  9503. SubId = dac.Id,
  9504. DiId = dac.DiId,
  9505. Type = dac.Type,
  9506. Days = dac.Days,
  9507. NationalTravelFeeId = dac.NationalTravelFeeId,
  9508. Arae = $"{ntf.Country}-{ntf.City}",
  9509. Cost = dac.Cost,
  9510. Currency = dac.Currency,
  9511. CurrencyName = sd.Name,
  9512. SubTotal = dac.SubTotal,
  9513. })
  9514. .ToArray();
  9515. var data = new ChoiceMobileSubInfo3To6View()
  9516. {
  9517. ParentId = eecInfo.Id,
  9518. Choice = eecInfo.ChoiceThree,
  9519. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9520. Details = dayAndCostDatas
  9521. };
  9522. return Ok(JsonView(data));
  9523. }
  9524. else if (subType == 4) //4:伙食费
  9525. {
  9526. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9527. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9528. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9529. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9530. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9531. {
  9532. SubId = dac.Id,
  9533. DiId = dac.DiId,
  9534. Type = dac.Type,
  9535. Days = dac.Days,
  9536. NationalTravelFeeId = dac.NationalTravelFeeId,
  9537. Arae = $"{ntf.Country}-{ntf.City}",
  9538. Cost = dac.Cost,
  9539. Currency = dac.Currency,
  9540. CurrencyName = sd.Name,
  9541. SubTotal = dac.SubTotal,
  9542. })
  9543. .ToArray();
  9544. var data = new ChoiceMobileSubInfo3To6View()
  9545. {
  9546. ParentId = eecInfo.Id,
  9547. Choice = eecInfo.ChoiceFour,
  9548. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9549. Details = dayAndCostDatas
  9550. };
  9551. return Ok(JsonView(data));
  9552. }
  9553. else if (subType == 5) //5:公杂费
  9554. {
  9555. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9556. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9557. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9558. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9559. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9560. {
  9561. SubId = dac.Id,
  9562. DiId = dac.DiId,
  9563. Type = dac.Type,
  9564. Days = dac.Days,
  9565. NationalTravelFeeId = dac.NationalTravelFeeId,
  9566. Arae = $"{ntf.Country}-{ntf.City}",
  9567. Cost = dac.Cost,
  9568. Currency = dac.Currency,
  9569. CurrencyName = sd.Name,
  9570. SubTotal = dac.SubTotal,
  9571. })
  9572. .ToArray();
  9573. var data = new ChoiceMobileSubInfo3To6View()
  9574. {
  9575. ParentId = eecInfo.Id,
  9576. Choice = eecInfo.ChoiceFive,
  9577. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9578. Details = dayAndCostDatas
  9579. };
  9580. return Ok(JsonView(data));
  9581. }
  9582. else if (subType == 6) //6:培训费
  9583. {
  9584. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9585. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9586. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9587. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9588. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9589. {
  9590. SubId = dac.Id,
  9591. DiId = dac.DiId,
  9592. Type = dac.Type,
  9593. Days = dac.Days,
  9594. NationalTravelFeeId = dac.NationalTravelFeeId,
  9595. Arae = $"{ntf.Country}-{ntf.City}",
  9596. Cost = dac.Cost,
  9597. Currency = dac.Currency,
  9598. CurrencyName = sd.Name,
  9599. SubTotal = dac.SubTotal,
  9600. })
  9601. .ToArray();
  9602. var data = new ChoiceMobileSubInfo3To6View()
  9603. {
  9604. ParentId = eecInfo.Id,
  9605. Choice = eecInfo.ChoiceSix,
  9606. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9607. Details = dayAndCostDatas
  9608. };
  9609. return Ok(JsonView(data));
  9610. }
  9611. else if (subType == 7) //7:其他
  9612. {
  9613. //其他款项
  9614. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9615. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9616. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9617. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9618. .OrderBy((dop, sd1, sd2) => dop.Index)
  9619. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9620. {
  9621. SubId = dop.Id,
  9622. DiId = dop.Diid,
  9623. Index = dop.Index,
  9624. SetDataId = dop.SetDataId,
  9625. SetDataName = sd1.Name,
  9626. Cost = dop.Cost,
  9627. Currency = dop.Currency,
  9628. CurrencyName = sd2.Name,
  9629. SubTotal = dop.SubTotal,
  9630. Remark = dop.Remark,
  9631. })
  9632. .ToArray();
  9633. var data = new ChoiceSevenMobileSubInfoView()
  9634. {
  9635. ParentId = eecInfo.Id,
  9636. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9637. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9638. Details = otherData
  9639. };
  9640. return Ok(JsonView(data));
  9641. }
  9642. return Ok(JsonView(false));
  9643. }
  9644. #region op
  9645. /// <summary>
  9646. /// 移动端更新费用消息通知
  9647. /// </summary>
  9648. /// <param name="diid"></param>
  9649. /// <param name="id"></param>
  9650. /// <param name="currUserId"></param>
  9651. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9652. {
  9653. try
  9654. {
  9655. ////生成默认文件pdf并且通知人员
  9656. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9657. //{
  9658. // DiId = diid,
  9659. // ExportType = 1,
  9660. // SubTypeId = 1005
  9661. //}, "pdf");
  9662. ////发送通知
  9663. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9664. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9665. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9666. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9667. ////汇率信息记录
  9668. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9669. }
  9670. catch (Exception ex)
  9671. {
  9672. //记录日志
  9673. throw;
  9674. }
  9675. }
  9676. /// <summary>
  9677. /// 验证出入境费用数据是否存在
  9678. /// 不存在添加
  9679. /// </summary>
  9680. /// <param name="diId"></param>
  9681. /// <param name="currUserId"></param>
  9682. /// <returns></returns>
  9683. /// <exception cref="CustomException"></exception>
  9684. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9685. {
  9686. var parentId = 0;
  9687. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9688. if (info != null)
  9689. {
  9690. parentId = info.Id;
  9691. }
  9692. else
  9693. {
  9694. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9695. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9696. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9697. parentId = addId;
  9698. }
  9699. return parentId;
  9700. }
  9701. /// <summary>
  9702. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9703. /// </summary>
  9704. /// <returns></returns>
  9705. [HttpPost]
  9706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9707. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9708. {
  9709. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9710. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9711. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9712. //验证编辑权限
  9713. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9714. //if (!isEdit) return Ok(JsonView(false, msg));
  9715. var permissions = new List<Grp_EnterExitCostPermission>();
  9716. foreach (var userId in dto.UserIds)
  9717. {
  9718. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9719. }
  9720. if (permissions.Any())
  9721. {
  9722. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9723. {
  9724. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9725. }
  9726. _sqlSugar.BeginTran();
  9727. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9728. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9729. if (result < 1)
  9730. {
  9731. _sqlSugar.RollbackTran();
  9732. return Ok(JsonView(false));
  9733. }
  9734. _sqlSugar.CommitTran();
  9735. return Ok(JsonView(true));
  9736. }
  9737. return Ok(JsonView(false));
  9738. }
  9739. /// <summary>
  9740. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9741. /// </summary>
  9742. /// <returns></returns>
  9743. [HttpPost]
  9744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9745. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9746. {
  9747. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9748. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9749. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9750. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9751. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9752. int id = dto.Id;
  9753. if (id <= 0) //add
  9754. {
  9755. //int provinceId = dto.ProvinceId;
  9756. int groupId = dto.DiId;
  9757. //if (provinceId < 1) provinceId = 122;
  9758. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9759. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9760. if (add < 1) return Ok(JsonView(false));
  9761. id = add;
  9762. }
  9763. else //update
  9764. {
  9765. ////验证编辑权限
  9766. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9767. //if (!isEdit) return Ok(JsonView(false, msg));
  9768. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9769. if (upd < 1) return Ok(JsonView(false));
  9770. }
  9771. #region 汇率变更时更改币种相关费用
  9772. var opDayCosts = new List<Grp_DayAndCost>();
  9773. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9774. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9775. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9776. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9777. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9778. .Select((dac, sd) => new
  9779. {
  9780. dac.Id,
  9781. dac.DiId,
  9782. CurrencyCode = sd.Name,
  9783. dac.Cost
  9784. })
  9785. .ToList();
  9786. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9787. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9788. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9789. .Select((dop, sd) => new
  9790. {
  9791. dop.Id,
  9792. dop.Diid,
  9793. CurrencyCode = sd.Name,
  9794. dop.Cost
  9795. })
  9796. .ToList();
  9797. if (dayCosts.Count > 0)
  9798. {
  9799. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9800. foreach (var dc in new_dayCosts)
  9801. {
  9802. var thisCurrency = dc.Key.ToUpper();
  9803. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9804. if (thisRate == 0.00M) continue;
  9805. foreach (var dcSub in dc)
  9806. {
  9807. opDayCosts.Add(new Grp_DayAndCost()
  9808. {
  9809. Id = dcSub.Id,
  9810. DiId = dcSub.DiId,
  9811. Cost = dcSub.Cost,
  9812. SubTotal = dcSub.Cost * thisRate,
  9813. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9814. });
  9815. }
  9816. }
  9817. if (opDayCosts.Count > 0)
  9818. {
  9819. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9820. }
  9821. }
  9822. if (dayOtherCosts.Count > 0)
  9823. {
  9824. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9825. foreach (var dc in new_dayOtherCosts)
  9826. {
  9827. var thisCurrency = dc.Key.ToUpper();
  9828. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9829. if (thisRate == 0.00M) continue;
  9830. foreach (var dcSub in dc)
  9831. {
  9832. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9833. {
  9834. Id = dcSub.Id,
  9835. Diid = dcSub.Diid,
  9836. Cost = dcSub.Cost,
  9837. SubTotal = dcSub.Cost * thisRate,
  9838. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9839. });
  9840. }
  9841. }
  9842. if (opDayOtherCosts.Count > 0)
  9843. {
  9844. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9845. }
  9846. }
  9847. #endregion
  9848. //消息通知
  9849. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9850. //汇率信息记录
  9851. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9852. return Ok(JsonView(new { parentId = id }));
  9853. }
  9854. /// <summary>
  9855. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9856. /// </summary>
  9857. /// <returns></returns>
  9858. [HttpPost]
  9859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9860. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9861. {
  9862. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9863. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9864. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9865. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9866. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9867. int id = dto.Id;
  9868. if (id <= 0) //add
  9869. {
  9870. checkboxInfo.CreateUserId = dto.CurrUserId;
  9871. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9872. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9873. if (add < 1) return Ok(JsonView(false));
  9874. }
  9875. else //update
  9876. {
  9877. ////验证编辑权限
  9878. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9879. //if (!isEdit) return Ok(JsonView(false, msg));
  9880. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9881. .UpdateColumns(x => new
  9882. {
  9883. x.ChoiceOne,
  9884. x.ChoiceTwo,
  9885. x.SumJJC,
  9886. x.SumGWC,
  9887. x.SumTDC,
  9888. x.ChoiceThree,
  9889. x.ChoiceFour,
  9890. x.ChoiceFive,
  9891. x.ChoiceSix,
  9892. x.OtherExpenses_Checked
  9893. })
  9894. .Where(x => x.Id == id)
  9895. .ExecuteCommandAsync();
  9896. if (upd < 1) return Ok(JsonView(false));
  9897. }
  9898. return Ok(JsonView(new { parentId = id }));
  9899. }
  9900. /// <summary>
  9901. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9902. /// </summary>
  9903. /// <returns></returns>
  9904. [HttpPost]
  9905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9906. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9907. {
  9908. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9909. // if (provinceId < 1) provinceId = 122;
  9910. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9911. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9912. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9913. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9914. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9915. var checkboxInfo = new Grp_EnterExitCost()
  9916. {
  9917. Id = id,
  9918. //ProvinceId = provinceId,
  9919. DiId = diId,
  9920. CreateUserId = currUserId
  9921. };
  9922. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9923. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9924. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9925. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9926. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9927. if (id <= 0) //add
  9928. {
  9929. checkboxInfo.CreateUserId = dto.CurrUserId;
  9930. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9931. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9932. if (add < 1) return Ok(JsonView(false));
  9933. }
  9934. else //update
  9935. {
  9936. ////验证编辑权限
  9937. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9938. //if (!isEdit) return Ok(JsonView(false, msg));
  9939. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9940. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9941. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9942. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9943. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9944. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9945. .Where(x => x.Id == id)
  9946. .ExecuteCommandAsync();
  9947. if (upd < 1) return Ok(JsonView(false));
  9948. }
  9949. return Ok(JsonView(new { parentId = id }));
  9950. }
  9951. /// <summary>
  9952. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9953. /// </summary>
  9954. /// <returns></returns>
  9955. [HttpPost]
  9956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9957. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9958. {
  9959. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9960. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9961. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9962. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9963. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9964. info.FirstItemRemark = dto.FirstItemRemark;
  9965. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9966. int id = dto.Id;
  9967. if (id <= 0) //add
  9968. {
  9969. info.CreateUserId = dto.CurrUserId;
  9970. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9971. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9972. if (add < 1) return Ok(JsonView(false));
  9973. id = add;
  9974. }
  9975. else //update
  9976. {
  9977. ////验证编辑权限
  9978. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9979. //if (!isEdit) return Ok(JsonView(false, msg));
  9980. var upd = await _sqlSugar.Updateable(info)
  9981. .UpdateColumns(x => new
  9982. {
  9983. x.ChoiceOne,
  9984. x.InsidePay,
  9985. x.VisaRemark,
  9986. x.Visa,
  9987. x.Service,
  9988. x.Safe,
  9989. x.Ticket,
  9990. x.HeSuan,
  9991. x.YiMiao,
  9992. x.FirstItemRemark
  9993. })
  9994. .Where(x => x.Id == id)
  9995. .ExecuteCommandAsync();
  9996. if (upd < 1) return Ok(JsonView(false));
  9997. }
  9998. //消息通知
  9999. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10000. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10001. }
  10002. /// <summary>
  10003. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10004. /// </summary>
  10005. /// <returns></returns>
  10006. [HttpPost]
  10007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10008. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10009. {
  10010. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10011. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10012. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10013. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10014. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10015. info.DiId = dto.DiId;
  10016. //info.ProvinceId = dto.ProvinceId;
  10017. info.OutsideJJPay = dto.OutsideJJPay;
  10018. info.OutsideGWPay = dto.OutsideGWPay;
  10019. info.OutsideTDPay = dto.OutsideTDPay;
  10020. info.AirJJ = dto.AirJJ;
  10021. info.AirGW = dto.AirGW;
  10022. info.AirTD = dto.AirTD;
  10023. info.CityTranffic = dto.CityTranffic;
  10024. info.TwoItemRemark = dto.TwoItemRemark;
  10025. info.SumJJC = dto.ChoiceTwoJJ;
  10026. info.SumGWC = dto.ChoiceTwoGW;
  10027. info.SumTDC = dto.ChoiceTwoTD;
  10028. int id = dto.Id;
  10029. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10030. if (id <= 0) //add
  10031. {
  10032. info.CreateUserId = dto.CurrUserId;
  10033. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10034. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10035. if (addId <= 0) return Ok(JsonView(false));
  10036. id = addId;
  10037. }
  10038. else //update
  10039. {
  10040. ////验证编辑权限
  10041. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10042. //if (!isEdit) return Ok(JsonView(false, msg));
  10043. var upd = await _sqlSugar.Updateable(info)
  10044. .UpdateColumns(x => new
  10045. {
  10046. x.SumJJC,
  10047. x.OutsideJJPay,
  10048. x.SumGWC,
  10049. x.OutsideGWPay,
  10050. x.SumTDC,
  10051. x.OutsideTDPay,
  10052. x.AirJJ,
  10053. x.AirGW,
  10054. x.AirTD,
  10055. x.CityTranffic,
  10056. x.TwoItemRemark
  10057. })
  10058. .Where(x => x.Id == id)
  10059. .ExecuteCommandAsync();
  10060. if (upd < 1) return Ok(JsonView(false));
  10061. }
  10062. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10063. gwcItemTotal = info.AirGW + info.CityTranffic;
  10064. tdcItemTotal = info.AirTD + info.CityTranffic;
  10065. //消息通知
  10066. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10067. return Ok(JsonView(new
  10068. {
  10069. parentId = id,
  10070. choiceTwoJJ = dto.ChoiceTwoJJ,
  10071. jjcItemTotal = jjcItemTotal,
  10072. choiceTwoGW = dto.ChoiceTwoGW,
  10073. gwcItemTotal = gwcItemTotal,
  10074. choiceTwoTD = dto.ChoiceTwoTD,
  10075. tdcItemTotal = tdcItemTotal
  10076. }));
  10077. }
  10078. /// <summary>
  10079. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10080. /// </summary>
  10081. /// <returns></returns>
  10082. [HttpPost]
  10083. [ApiExplorerSettings(IgnoreApi = true)]
  10084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10085. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10086. {
  10087. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10088. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10089. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10090. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10091. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10092. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10093. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10094. var infos = infos1.Select(x => new Grp_DayAndCost
  10095. {
  10096. Id = x.Id,
  10097. DiId = dto.DiId,
  10098. Type = dto.FeeType,
  10099. Days = x.Days,
  10100. NationalTravelFeeId = x.NationalTravelFeeId,
  10101. Cost = x.Cost,
  10102. Currency = x.Currency,
  10103. SubTotal = x.SubTotal,
  10104. CreateUserId = dto.CurrUserId
  10105. })
  10106. .ToList();
  10107. var adds = infos.Where(x => x.Id <= 0).ToList();
  10108. var upds = infos.Where(x => x.Id > 0).ToList();
  10109. if (adds.Count > 0)
  10110. {
  10111. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10112. if (add < 1) return Ok(JsonView(false));
  10113. }
  10114. if (upds.Count > 0)
  10115. {
  10116. var upd = await _sqlSugar.Updateable(adds)
  10117. .UpdateColumns(x => new
  10118. {
  10119. x.Days,
  10120. x.NationalTravelFeeId,
  10121. x.Cost,
  10122. x.Currency,
  10123. x.SubTotal
  10124. })
  10125. .WhereColumns(x => new { x.Id })
  10126. .ExecuteCommandAsync();
  10127. if (upd < 1) return Ok(JsonView(false));
  10128. }
  10129. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10130. //消息通知
  10131. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10132. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10133. return Ok(JsonView(new { itemTotal = itemTotal }));
  10134. }
  10135. /// <summary>
  10136. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10137. /// </summary>
  10138. /// <returns></returns>
  10139. [HttpPost]
  10140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10141. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10142. {
  10143. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10144. int subId = dto.SubId, feeType = dto.FeeType;
  10145. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10146. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10147. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10148. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10149. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10150. subInfo.Id = subId;
  10151. subInfo.DiId = dto.DiId;
  10152. if (feeType == 3) subInfo.Type = 1;
  10153. else if (feeType == 4) subInfo.Type = 2;
  10154. else if (feeType == 5) subInfo.Type = 3;
  10155. else if (feeType == 6) subInfo.Type = 4;
  10156. subInfo.CreateUserId = dto.CurrUserId;
  10157. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10158. if (parentId < 1) return Ok(JsonView(false));
  10159. //子表op
  10160. if (subId < 1)
  10161. {
  10162. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10163. if (subAdd < 1) return Ok(JsonView(false));
  10164. }
  10165. else
  10166. {
  10167. ////验证编辑权限
  10168. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10169. //if (!isEdit) return Ok(JsonView(false, msg));
  10170. var subUpd = await _sqlSugar.Updateable(subInfo)
  10171. .UpdateColumns(x => new
  10172. {
  10173. x.Days,
  10174. x.NationalTravelFeeId,
  10175. x.Cost,
  10176. x.Currency,
  10177. x.SubTotal
  10178. })
  10179. .WhereColumns(x => new { x.Id })
  10180. .ExecuteCommandAsync();
  10181. if (subUpd < 1) return Ok(JsonView(false));
  10182. }
  10183. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10184. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10185. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10186. }
  10187. /// <summary>
  10188. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10189. /// </summary>
  10190. /// <returns></returns>
  10191. [HttpPost]
  10192. [ApiExplorerSettings(IgnoreApi = true)]
  10193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10194. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10195. {
  10196. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10197. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10198. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10199. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10200. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10201. {
  10202. Id = x.Id,
  10203. Diid = dto.DiId,
  10204. SetDataId = x.SetDataId,
  10205. Index = x.Index,
  10206. Cost = x.Cost,
  10207. Currency = x.Currency,
  10208. SubTotal = x.SubTotal,
  10209. CreateUserId = dto.CurrUserId,
  10210. Remark = x.Remark
  10211. }).ToList();
  10212. var adds = infos.Where(x => x.Id <= 0).ToList();
  10213. var upds = infos.Where(x => x.Id > 0).ToList();
  10214. if (adds.Count > 0)
  10215. {
  10216. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10217. if (add < 1) return Ok(JsonView(false));
  10218. }
  10219. if (upds.Count > 0)
  10220. {
  10221. var upd = await _sqlSugar.Updateable(adds)
  10222. .UpdateColumns(x => new
  10223. {
  10224. x.Index,
  10225. x.SetDataId,
  10226. x.Cost,
  10227. x.Currency,
  10228. x.SubTotal,
  10229. x.Remark
  10230. })
  10231. .WhereColumns(x => new { x.Id })
  10232. .ExecuteCommandAsync();
  10233. if (upd < 1) return Ok(JsonView(false));
  10234. }
  10235. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10236. //消息通知
  10237. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10238. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10239. return Ok(JsonView(new { itemTotal = itemTotal }));
  10240. }
  10241. /// <summary>
  10242. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10243. /// </summary>
  10244. /// <returns></returns>
  10245. [HttpPost]
  10246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10247. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10248. {
  10249. int subId = dto.SubId;
  10250. int diId = dto.Diid;
  10251. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10252. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10253. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10254. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10255. subInfo.Id = subId;
  10256. subInfo.Diid = dto.Diid;
  10257. subInfo.CreateUserId = dto.CurrUserId;
  10258. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10259. if (parentId < 1) return Ok(JsonView(false));
  10260. #region 子表op
  10261. if (subId < 1)//add
  10262. {
  10263. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10264. if (subAdd < 1) return Ok(JsonView(false));
  10265. }
  10266. else //upd
  10267. {
  10268. ////验证编辑权限
  10269. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10270. //if (!isEdit) return Ok(JsonView(false, msg));
  10271. var subUpd = await _sqlSugar.Updateable(subInfo)
  10272. .UpdateColumns(x => new
  10273. {
  10274. x.Index,
  10275. x.SetDataId,
  10276. x.Cost,
  10277. x.Currency,
  10278. x.SubTotal,
  10279. x.Remark
  10280. })
  10281. .WhereColumns(x => new { x.Id })
  10282. .ExecuteCommandAsync();
  10283. if (subUpd < 1) return Ok(JsonView(false));
  10284. }
  10285. #endregion
  10286. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10287. //消息通知
  10288. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10289. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10290. }
  10291. /// <summary>
  10292. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10293. /// </summary>
  10294. /// <returns></returns>
  10295. [HttpPost]
  10296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10297. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10298. {
  10299. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10300. if (data.Code != 0)
  10301. {
  10302. return Ok(JsonView(false, data.Msg));
  10303. }
  10304. return Ok(JsonView(true, "操作成功!", data.Data));
  10305. }
  10306. /// <summary>
  10307. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10308. /// </summary>
  10309. /// <param name="dto"></param>
  10310. /// <returns></returns>
  10311. [HttpPost]
  10312. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10313. {
  10314. var data = new Grp_DayOtherPrice()
  10315. {
  10316. Id = dto.Id,
  10317. IsDel = 1,
  10318. DeleteUserId = dto.DeleteUserId,
  10319. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10320. };
  10321. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10322. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10323. return Ok(JsonView(false, "删除失败!"));
  10324. }
  10325. #endregion
  10326. #endregion
  10327. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10328. /// <summary>
  10329. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10330. /// </summary>
  10331. /// <returns></returns>
  10332. [HttpGet]
  10333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10334. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10335. {
  10336. var provData = await _groupRepository.ProvinceBasicSource();
  10337. return Ok(JsonView(true, "查询成功!", provData));
  10338. }
  10339. /// <summary>
  10340. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10341. /// </summary>
  10342. /// <returns></returns>
  10343. [HttpPost]
  10344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10345. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10346. {
  10347. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10348. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10349. RefAsync<int> total = 0;
  10350. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10351. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10352. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10353. .Select(x => new
  10354. {
  10355. Id = x.Id,
  10356. DraftName = x.DraftName,
  10357. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10358. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10359. .Any()
  10360. })
  10361. .OrderByDescending(x => x.Id)
  10362. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10363. return Ok(JsonView(true, "查询成功!", data, total));
  10364. }
  10365. /// <summary>
  10366. /// 出入境费用-草稿 移动端
  10367. /// 获取币种基础数据(含逻辑处理)
  10368. /// </summary>
  10369. /// <returns></returns>
  10370. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10371. {
  10372. return await GeneralMethod.EnterExitCostInitRate();
  10373. }
  10374. /// <summary>
  10375. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10376. /// </summary>
  10377. /// <returns></returns>
  10378. [HttpPost]
  10379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10380. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10381. {
  10382. //验证城市归属并给默认值
  10383. int provinceId = dto.ProvinceId;
  10384. if (provinceId < 1) provinceId = 122;
  10385. var dataSource = await _sqlSugar
  10386. .Queryable<Sys_SetData>()
  10387. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10388. .ToListAsync();
  10389. //三公费用-Word明细类型
  10390. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10391. .Select(x => new SetDataInfoView
  10392. {
  10393. Id = x.Id,
  10394. Name = x.Name,
  10395. Remark = x.Remark
  10396. })
  10397. .ToList();
  10398. //三公费用-Excel明细类型
  10399. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10400. .Select(x => new SetDataInfoView
  10401. {
  10402. Id = x.Id,
  10403. Name = x.Name,
  10404. Remark = x.Remark
  10405. })
  10406. .ToList();
  10407. //默认币种显示
  10408. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10409. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10410. return Ok(JsonView(true, "查询成功!", new
  10411. {
  10412. WordTypeData = wordTypeData,
  10413. ExcelTypeData = excelTypeData,
  10414. CurrencyInit = _currencyInfos,
  10415. viewPermissionData = viewPermissionData
  10416. }));
  10417. }
  10418. /// <summary>
  10419. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10420. /// </summary>
  10421. /// <returns></returns>
  10422. [HttpPost]
  10423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10424. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10425. {
  10426. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10427. RefAsync<int> total = 0;
  10428. int diId = 0;
  10429. var status = int.TryParse(dto.GroupName, out diId);
  10430. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10431. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10432. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10433. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10434. .OrderByDescending(x => x.VisitStartDate)
  10435. .Select(x => new
  10436. {
  10437. Id = x.Id,
  10438. GroupName = x.TeamName
  10439. })
  10440. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10441. return Ok(JsonView(true, "查询成功!", data, total));
  10442. }
  10443. /// <summary>
  10444. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10445. /// </summary>
  10446. /// <returns></returns>
  10447. [HttpPost]
  10448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10449. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10450. {
  10451. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10452. RefAsync<int> total = 0;
  10453. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10454. .Where(x => x.IsDel == 0 && x.STid == 66)
  10455. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10456. .Select(x => new
  10457. {
  10458. id = x.Id,
  10459. name = x.Name,
  10460. remark = x.Remark,
  10461. })
  10462. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10463. return Ok(JsonView(true, "查询成功!", data, total));
  10464. }
  10465. /// <summary>
  10466. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10467. /// </summary>
  10468. /// <returns></returns>
  10469. [HttpPost]
  10470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10471. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10472. {
  10473. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10474. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10475. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10476. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10477. var groupOtherRateData = groupRateData.TeamRates;
  10478. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10479. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10480. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10481. groupOtherRateData = groupOtherRateData
  10482. .Select(x => new TeamRateDescAddCurrencyIdView
  10483. {
  10484. CurrencyId = x.CurrencyId,
  10485. CurrencyName = x.CurrencyName,
  10486. CurrencyCode = x.CurrencyCode,
  10487. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10488. }).ToList();
  10489. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10490. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10491. }
  10492. /// <summary>
  10493. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10494. /// </summary>
  10495. /// <returns></returns>
  10496. [HttpPost]
  10497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10498. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10499. {
  10500. int portType = dto.PortType;
  10501. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10502. var tipsData = new List<int>() { 1, 2, 3 };
  10503. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10504. if (dto.TipsType == 1)
  10505. {
  10506. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10507. }
  10508. else if (dto.TipsType == 2)
  10509. {
  10510. if (portType == 2)
  10511. {
  10512. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10513. }
  10514. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10515. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10516. .Select(x => x.NationalTravelFeeId)
  10517. .Distinct()
  10518. .ToListAsync();
  10519. if (portType == 2)
  10520. {
  10521. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10522. }
  10523. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10524. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10525. .Select(x => x.Country)
  10526. .Distinct()
  10527. .ToArrayAsync();
  10528. if (portType == 2)
  10529. {
  10530. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10531. }
  10532. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10533. return Ok(JsonView(true, "查询成功!", new
  10534. {
  10535. totalAmt = totalAmt,
  10536. remark = remark
  10537. }));
  10538. }
  10539. else if (dto.TipsType == 3)
  10540. {
  10541. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10542. }
  10543. return Ok(JsonView(false));
  10544. }
  10545. /// <summary>
  10546. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10547. /// </summary>
  10548. /// <returns></returns>
  10549. [HttpPost]
  10550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10551. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10552. {
  10553. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10554. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10555. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10556. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10557. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10558. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10559. var info = new Grp_EnterExitCostDraft()
  10560. {
  10561. ProvinceId = dto.ProvinceId,
  10562. DraftName = dto.DraftName,
  10563. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10564. CreateUserId = dto.CurrUserId
  10565. };
  10566. _sqlSugar.BeginTran();
  10567. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10568. if (draftId < 1)
  10569. {
  10570. _sqlSugar.RollbackTran();
  10571. return Ok(JsonView(false, "草稿创建失败!"));
  10572. }
  10573. //添加默认权限
  10574. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10575. _sqlSugar.CommitTran();
  10576. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10577. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10578. mobileInfo.Id = draftId;
  10579. mobileInfo.DraftName = dto.DraftName;
  10580. mobileInfo.Currencys = rateInfos;
  10581. mobileInfo.IsAssignPerm = assignPerm;
  10582. return Ok(JsonView(mobileInfo));
  10583. }
  10584. /// <summary>
  10585. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10586. /// </summary>
  10587. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10588. /// <summary>
  10589. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10590. /// </summary>
  10591. /// <returns></returns>
  10592. [HttpPost]
  10593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10594. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10595. {
  10596. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10597. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10598. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10599. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10600. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10601. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10602. //验证查看编辑权限
  10603. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10604. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10605. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10606. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10607. mobileInfo.IsAssignPerm = assignPerm;
  10608. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10609. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10610. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10611. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10612. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10613. {
  10614. ParentId = dac.ParentId,
  10615. SubId = dac.Id,
  10616. Type = dac.Type,
  10617. Days = dac.Days,
  10618. NationalTravelFeeId = dac.NationalTravelFeeId,
  10619. Arae = $"{ntf.Country}-{ntf.City}",
  10620. Cost = dac.Cost,
  10621. Currency = dac.Currency,
  10622. CurrencyName = sd.Name,
  10623. SubTotal = dac.SubTotal,
  10624. })
  10625. .ToList();
  10626. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10627. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10628. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10629. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10630. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10631. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10632. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10633. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10634. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10635. //其他款项
  10636. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10637. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10638. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10639. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10640. .OrderBy((dop, sd1, sd2) => dop.Index)
  10641. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10642. {
  10643. ParentId = dop.ParentId,
  10644. SubId = dop.Id,
  10645. Index = dop.Index,
  10646. SetDataId = dop.SetDataId,
  10647. SetDataName = sd1.Name,
  10648. Cost = dop.Cost,
  10649. Currency = dop.Currency,
  10650. CurrencyName = sd2.Remark,
  10651. SubTotal = dop.SubTotal,
  10652. Remark = dop.Remark,
  10653. })
  10654. .ToArray();
  10655. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10656. return Ok(mobileInfo);
  10657. }
  10658. /// <summary>
  10659. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10660. /// </summary>
  10661. /// <returns></returns>
  10662. [HttpPost]
  10663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10664. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10665. {
  10666. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10667. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10668. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10669. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10670. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10671. //验证查看编辑权限
  10672. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10673. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10674. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10675. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10676. var subType = dto.SubType;
  10677. if (subType == 1) //1:境内费用
  10678. {
  10679. var oneData = new ChoiceOneMobileSubInfoView()
  10680. {
  10681. Id = eecInfo.Id,
  10682. ChoiceOne = eecInfo.ChoiceOne,
  10683. ChoiceOneTotalCost = eecInfo.InsidePay,
  10684. Visa = eecInfo.Visa,
  10685. VisaRemark = eecInfo.VisaRemark,
  10686. YiMiao = eecInfo.YiMiao,
  10687. HeSuan = eecInfo.HeSuan,
  10688. Service = eecInfo.Service,
  10689. Ticket = eecInfo.Ticket,
  10690. Safe = eecInfo.Safe,
  10691. FirstItemRemark = eecInfo.FirstItemRemark
  10692. };
  10693. return Ok(JsonView(oneData));
  10694. }
  10695. else if (subType == 2) //2:国际旅费
  10696. {
  10697. var twoData = new ChoiceTwoMobileSubInfoView()
  10698. {
  10699. Id = eecInfo.Id,
  10700. ChoiceTwoJJ = eecInfo.SumJJC,
  10701. OutsideJJPay = eecInfo.OutsideJJPay,
  10702. ChoiceTwoGW = eecInfo.SumGWC,
  10703. OutsideGWPay = eecInfo.OutsideGWPay,
  10704. ChoiceTwoTD = eecInfo.SumTDC,
  10705. OutsideTDPay = eecInfo.OutsideTDPay,
  10706. AirJJ = eecInfo.AirJJ,
  10707. AirGW = eecInfo.AirGW,
  10708. AirTD = eecInfo.AirTD,
  10709. CityTranffic = eecInfo.CityTranffic,
  10710. TwoItemRemark = eecInfo.TwoItemRemark
  10711. };
  10712. return Ok(JsonView(twoData));
  10713. }
  10714. else if (subType == 3) //3:住宿费
  10715. {
  10716. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10717. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10718. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10719. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10720. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10721. {
  10722. ParentId = dac.ParentId,
  10723. SubId = dac.Id,
  10724. Type = dac.Type,
  10725. Days = dac.Days,
  10726. NationalTravelFeeId = dac.NationalTravelFeeId,
  10727. Arae = $"{ntf.Country}-{ntf.City}",
  10728. Cost = dac.Cost,
  10729. Currency = dac.Currency,
  10730. CurrencyName = sd.Name,
  10731. SubTotal = dac.SubTotal,
  10732. })
  10733. .ToArray();
  10734. var data = new ChoiceDraftMobileSubInfo3To6View()
  10735. {
  10736. ParentId = eecInfo.Id,
  10737. Choice = eecInfo.ChoiceThree,
  10738. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10739. Details = dayAndCostDatas
  10740. };
  10741. return Ok(JsonView(data));
  10742. }
  10743. else if (subType == 4) //4:伙食费
  10744. {
  10745. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10746. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10747. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10748. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10749. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10750. {
  10751. ParentId = dac.ParentId,
  10752. SubId = dac.Id,
  10753. Type = dac.Type,
  10754. Days = dac.Days,
  10755. NationalTravelFeeId = dac.NationalTravelFeeId,
  10756. Arae = $"{ntf.Country}-{ntf.City}",
  10757. Cost = dac.Cost,
  10758. Currency = dac.Currency,
  10759. CurrencyName = sd.Name,
  10760. SubTotal = dac.SubTotal,
  10761. })
  10762. .ToArray();
  10763. var data = new ChoiceDraftMobileSubInfo3To6View()
  10764. {
  10765. ParentId = eecInfo.Id,
  10766. Choice = eecInfo.ChoiceFour,
  10767. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10768. Details = dayAndCostDatas
  10769. };
  10770. return Ok(JsonView(data));
  10771. }
  10772. else if (subType == 5) //5:公杂费
  10773. {
  10774. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10775. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10776. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10777. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10778. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10779. {
  10780. ParentId = dac.ParentId,
  10781. SubId = dac.Id,
  10782. Type = dac.Type,
  10783. Days = dac.Days,
  10784. NationalTravelFeeId = dac.NationalTravelFeeId,
  10785. Arae = $"{ntf.Country}-{ntf.City}",
  10786. Cost = dac.Cost,
  10787. Currency = dac.Currency,
  10788. CurrencyName = sd.Name,
  10789. SubTotal = dac.SubTotal,
  10790. })
  10791. .ToArray();
  10792. var data = new ChoiceDraftMobileSubInfo3To6View()
  10793. {
  10794. ParentId = eecInfo.Id,
  10795. Choice = eecInfo.ChoiceFive,
  10796. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10797. Details = dayAndCostDatas
  10798. };
  10799. return Ok(JsonView(data));
  10800. }
  10801. else if (subType == 6) //6:培训费
  10802. {
  10803. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10804. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10805. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10806. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10807. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10808. {
  10809. ParentId = dac.ParentId,
  10810. SubId = dac.Id,
  10811. Type = dac.Type,
  10812. Days = dac.Days,
  10813. NationalTravelFeeId = dac.NationalTravelFeeId,
  10814. Arae = $"{ntf.Country}-{ntf.City}",
  10815. Cost = dac.Cost,
  10816. Currency = dac.Currency,
  10817. CurrencyName = sd.Name,
  10818. SubTotal = dac.SubTotal,
  10819. })
  10820. .ToArray();
  10821. var data = new ChoiceDraftMobileSubInfo3To6View()
  10822. {
  10823. ParentId = eecInfo.Id,
  10824. Choice = eecInfo.ChoiceSix,
  10825. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10826. Details = dayAndCostDatas
  10827. };
  10828. return Ok(JsonView(data));
  10829. }
  10830. else if (subType == 7) //7:其他
  10831. {
  10832. //其他款项
  10833. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10834. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10835. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10836. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10837. .OrderBy((dop, sd1, sd2) => dop.Index)
  10838. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10839. {
  10840. ParentId = dop.ParentId,
  10841. SubId = dop.Id,
  10842. Index = dop.Index,
  10843. SetDataId = dop.SetDataId,
  10844. SetDataName = sd1.Name,
  10845. Cost = dop.Cost,
  10846. Currency = dop.Currency,
  10847. CurrencyName = sd2.Name,
  10848. SubTotal = dop.SubTotal,
  10849. Remark = dop.Remark,
  10850. })
  10851. .ToArray();
  10852. var data = new ChoiceSevenDraftMobileSubInfoView()
  10853. {
  10854. ParentId = eecInfo.Id,
  10855. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10856. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10857. Details = otherData
  10858. };
  10859. return Ok(JsonView(data));
  10860. }
  10861. return Ok(JsonView(false));
  10862. }
  10863. #region op
  10864. /// <summary>
  10865. /// 移动端更新费用消息通知
  10866. /// </summary>
  10867. /// <param name="draftId"></param>
  10868. /// <param name="id"></param>
  10869. /// <param name="currUserId"></param>
  10870. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10871. {
  10872. try
  10873. {
  10874. ////生成默认文件pdf并且通知人员
  10875. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10876. //{
  10877. // DiId = draftId,
  10878. // ExportType = 1,
  10879. // SubTypeId = 1005
  10880. //}, "pdf");
  10881. ////发送通知
  10882. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10883. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10884. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10885. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10886. ////汇率信息记录
  10887. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10888. }
  10889. catch (Exception ex)
  10890. {
  10891. //记录日志
  10892. throw;
  10893. }
  10894. }
  10895. /// <summary>
  10896. /// 验证出入境费用数据是否存在
  10897. /// 不存在添加
  10898. /// </summary>
  10899. /// <param name="draftId"></param>
  10900. /// <param name="currUserId"></param>
  10901. /// <returns></returns>
  10902. /// <exception cref="CustomException"></exception>
  10903. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10904. {
  10905. var parentId = 0;
  10906. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10907. if (info != null) parentId = info.Id;
  10908. else
  10909. {
  10910. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10911. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10912. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10913. parentId = addId;
  10914. }
  10915. return parentId;
  10916. }
  10917. /// <summary>
  10918. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10919. /// </summary>
  10920. /// <returns></returns>
  10921. [HttpPost]
  10922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10923. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10924. {
  10925. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10926. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10927. //验证查看权限
  10928. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10929. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10930. var userIds = await _sqlSugar
  10931. .Queryable<Grp_EnterExitCostDraftPermission>()
  10932. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10933. .Select(x => x.UserId)
  10934. .ToArrayAsync();
  10935. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10936. var perUsersView = new List<dynamic>();
  10937. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10938. var viewPermissionData = new List<PermissionViewUserview>();
  10939. if (feeBasePerm.Any())
  10940. {
  10941. foreach (var item in feeBasePerm)
  10942. {
  10943. if (item.Users.Any())
  10944. {
  10945. viewPermissionData.AddRange(item.Users);
  10946. }
  10947. }
  10948. }
  10949. foreach (var item in perUsers)
  10950. {
  10951. bool isView1 = false;
  10952. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10953. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10954. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10955. }
  10956. return Ok(JsonView(perUsersView));
  10957. }
  10958. /// <summary>
  10959. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10960. /// </summary>
  10961. /// <returns></returns>
  10962. [HttpPost]
  10963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10964. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10965. {
  10966. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10967. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10968. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10969. //验证查看编辑权限
  10970. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10971. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10972. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10973. foreach (var userId in dto.UserIds)
  10974. {
  10975. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10976. }
  10977. if (permissions.Any())
  10978. {
  10979. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10980. {
  10981. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10982. }
  10983. _sqlSugar.BeginTran();
  10984. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10985. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10986. if (result < 1)
  10987. {
  10988. _sqlSugar.RollbackTran();
  10989. return Ok(JsonView(false));
  10990. }
  10991. _sqlSugar.CommitTran();
  10992. return Ok(JsonView(true));
  10993. }
  10994. return Ok(JsonView(false));
  10995. }
  10996. /// <summary>
  10997. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10998. /// </summary>
  10999. /// <returns></returns>
  11000. [HttpPost]
  11001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11002. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11003. {
  11004. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11005. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11006. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11007. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11008. int id = dto.DraftId;
  11009. if (id <= 0) //add
  11010. {
  11011. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11012. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11013. if (add < 1) return Ok(JsonView(false));
  11014. id = add;
  11015. }
  11016. else //update
  11017. {
  11018. //验证查看编辑权限
  11019. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11020. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11021. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11022. if (upd < 1) return Ok(JsonView(false));
  11023. }
  11024. return Ok(JsonView(new { parentId = id }));
  11025. }
  11026. /// <summary>
  11027. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11028. /// </summary>
  11029. /// <returns></returns>
  11030. [HttpPost]
  11031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11032. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11033. {
  11034. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11035. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11036. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11037. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11038. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11039. int id = dto.DraftId;
  11040. if (id <= 0) //add
  11041. {
  11042. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11043. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11044. if (add < 1) return Ok(JsonView(false));
  11045. id = add;
  11046. }
  11047. else //update
  11048. {
  11049. //验证查看编辑权限
  11050. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11051. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11052. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11053. if (upd < 1) return Ok(JsonView(false));
  11054. }
  11055. #region 汇率变更时更改币种相关费用
  11056. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11057. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11058. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11059. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11060. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11061. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11062. .Select((dac, sd) => new
  11063. {
  11064. dac.Id,
  11065. dac.ParentId,
  11066. CurrencyCode = sd.Name,
  11067. dac.Cost
  11068. })
  11069. .ToList();
  11070. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11071. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11072. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11073. .Select((dop, sd) => new
  11074. {
  11075. dop.Id,
  11076. dop.ParentId,
  11077. CurrencyCode = sd.Name,
  11078. dop.Cost
  11079. })
  11080. .ToList();
  11081. if (dayCosts.Count > 0)
  11082. {
  11083. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11084. foreach (var dc in new_dayCosts)
  11085. {
  11086. var thisCurrency = dc.Key.ToUpper();
  11087. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11088. if (thisRate == 0.00M) continue;
  11089. foreach (var dcSub in dc)
  11090. {
  11091. opDayCosts.Add(new Grp_DayAndCostDraft()
  11092. {
  11093. Id = dcSub.Id,
  11094. ParentId = dcSub.ParentId,
  11095. Cost = dcSub.Cost,
  11096. SubTotal = dcSub.Cost * thisRate,
  11097. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11098. });
  11099. }
  11100. }
  11101. if (opDayCosts.Count > 0)
  11102. {
  11103. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11104. }
  11105. }
  11106. if (dayOtherCosts.Count > 0)
  11107. {
  11108. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11109. foreach (var dc in new_dayOtherCosts)
  11110. {
  11111. var thisCurrency = dc.Key.ToUpper();
  11112. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11113. if (thisRate == 0.00M) continue;
  11114. foreach (var dcSub in dc)
  11115. {
  11116. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11117. {
  11118. Id = dcSub.Id,
  11119. ParentId = dcSub.ParentId,
  11120. Cost = dcSub.Cost,
  11121. SubTotal = dcSub.Cost * thisRate,
  11122. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11123. });
  11124. }
  11125. }
  11126. if (opDayOtherCosts.Count > 0)
  11127. {
  11128. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11129. }
  11130. }
  11131. #endregion
  11132. ////消息通知
  11133. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11134. ////汇率信息记录
  11135. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11136. return Ok(JsonView(new { parentId = id }));
  11137. }
  11138. /// <summary>
  11139. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11140. /// </summary>
  11141. /// <returns></returns>
  11142. [HttpPost]
  11143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11144. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11145. {
  11146. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11147. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11148. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11149. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11150. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11151. int id = dto.DraftId;
  11152. if (id <= 0) //add
  11153. {
  11154. checkboxInfo.ProvinceId = dto.ProvinceId;
  11155. checkboxInfo.CreateUserId = dto.CurrUserId;
  11156. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11157. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11158. if (add < 1) return Ok(JsonView(false));
  11159. }
  11160. else //update
  11161. {
  11162. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11163. .UpdateColumns(x => new
  11164. {
  11165. x.ChoiceOne,
  11166. x.ChoiceTwo,
  11167. x.SumJJC,
  11168. x.SumGWC,
  11169. x.SumTDC,
  11170. x.ChoiceThree,
  11171. x.ChoiceFour,
  11172. x.ChoiceFive,
  11173. x.ChoiceSix,
  11174. x.OtherExpenses_Checked
  11175. })
  11176. .Where(x => x.Id == id)
  11177. .ExecuteCommandAsync();
  11178. if (upd < 1) return Ok(JsonView(false));
  11179. }
  11180. return Ok(JsonView(new { parentId = id }));
  11181. }
  11182. /// <summary>
  11183. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11184. /// </summary>
  11185. /// <returns></returns>
  11186. [HttpPost]
  11187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11188. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11189. {
  11190. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11191. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11192. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11193. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11194. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11195. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11196. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11197. var checkboxInfo = new Grp_EnterExitCostDraft()
  11198. {
  11199. Id = draftId,
  11200. ProvinceId = dto.ProvinceId,
  11201. CreateUserId = currUserId
  11202. };
  11203. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11204. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11205. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11206. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11207. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11208. if (draftId <= 0) //add
  11209. {
  11210. checkboxInfo.CreateUserId = dto.CurrUserId;
  11211. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11212. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11213. if (add < 1) return Ok(JsonView(false));
  11214. }
  11215. else //update
  11216. {
  11217. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11218. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11219. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11220. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11221. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11222. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11223. .Where(x => x.Id == draftId)
  11224. .ExecuteCommandAsync();
  11225. if (upd < 1) return Ok(JsonView(false));
  11226. }
  11227. return Ok(JsonView(new { parentId = draftId }));
  11228. }
  11229. /// <summary>
  11230. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11231. /// </summary>
  11232. /// <returns></returns>
  11233. [HttpPost]
  11234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11235. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11236. {
  11237. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11238. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11239. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11240. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11241. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11242. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11243. info.ProvinceId = dto.ProvinceId;
  11244. info.FirstItemRemark = dto.FirstItemRemark;
  11245. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11246. if (id <= 0) //add
  11247. {
  11248. info.CreateUserId = dto.CurrUserId;
  11249. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11250. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11251. if (add < 1) return Ok(JsonView(false));
  11252. id = add;
  11253. }
  11254. else //update
  11255. {
  11256. var upd = await _sqlSugar.Updateable(info)
  11257. .UpdateColumns(x => new
  11258. {
  11259. x.ChoiceOne,
  11260. x.InsidePay,
  11261. x.VisaRemark,
  11262. x.Visa,
  11263. x.Service,
  11264. x.Safe,
  11265. x.Ticket,
  11266. x.HeSuan,
  11267. x.YiMiao,
  11268. x.FirstItemRemark
  11269. })
  11270. .Where(x => x.Id == id)
  11271. .ExecuteCommandAsync();
  11272. if (upd < 1) return Ok(JsonView(false));
  11273. }
  11274. ////消息通知
  11275. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11276. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11277. }
  11278. /// <summary>
  11279. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11280. /// </summary>
  11281. /// <returns></returns>
  11282. [HttpPost]
  11283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11284. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11285. {
  11286. int id = dto.DraftId;
  11287. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11288. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11289. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11290. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11291. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11292. info.ProvinceId = dto.ProvinceId;
  11293. info.OutsideJJPay = dto.OutsideJJPay;
  11294. info.OutsideGWPay = dto.OutsideGWPay;
  11295. info.OutsideTDPay = dto.OutsideTDPay;
  11296. info.AirJJ = dto.AirJJ;
  11297. info.AirGW = dto.AirGW;
  11298. info.AirTD = dto.AirTD;
  11299. info.CityTranffic = dto.CityTranffic;
  11300. info.TwoItemRemark = dto.TwoItemRemark;
  11301. info.SumJJC = dto.ChoiceTwoJJ;
  11302. info.SumGWC = dto.ChoiceTwoGW;
  11303. info.SumTDC = dto.ChoiceTwoTD;
  11304. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11305. if (id <= 0) //add
  11306. {
  11307. info.CreateUserId = dto.CurrUserId;
  11308. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11309. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11310. if (addId <= 0) return Ok(JsonView(false));
  11311. id = addId;
  11312. }
  11313. else //update
  11314. {
  11315. var upd = await _sqlSugar.Updateable(info)
  11316. .UpdateColumns(x => new
  11317. {
  11318. x.SumJJC,
  11319. x.OutsideJJPay,
  11320. x.SumGWC,
  11321. x.OutsideGWPay,
  11322. x.SumTDC,
  11323. x.OutsideTDPay,
  11324. x.AirJJ,
  11325. x.AirGW,
  11326. x.AirTD,
  11327. x.CityTranffic,
  11328. x.TwoItemRemark
  11329. })
  11330. .Where(x => x.Id == id)
  11331. .ExecuteCommandAsync();
  11332. if (upd < 1) return Ok(JsonView(false));
  11333. }
  11334. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11335. gwcItemTotal = info.AirGW + info.CityTranffic;
  11336. tdcItemTotal = info.AirTD + info.CityTranffic;
  11337. ////消息通知
  11338. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11339. return Ok(JsonView(new
  11340. {
  11341. parentId = id,
  11342. choiceTwoJJ = dto.ChoiceTwoJJ,
  11343. jjcItemTotal = jjcItemTotal,
  11344. choiceTwoGW = dto.ChoiceTwoGW,
  11345. gwcItemTotal = gwcItemTotal,
  11346. choiceTwoTD = dto.ChoiceTwoTD,
  11347. tdcItemTotal = tdcItemTotal
  11348. }));
  11349. }
  11350. /// <summary>
  11351. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11352. /// </summary>
  11353. /// <returns></returns>
  11354. [HttpPost]
  11355. [ApiExplorerSettings(IgnoreApi = true)]
  11356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11357. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11358. {
  11359. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11360. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11361. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11362. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11363. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11364. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11365. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11366. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11367. {
  11368. Id = x.Id,
  11369. ParentId = dto.DraftId,
  11370. Type = dto.FeeType,
  11371. Days = x.Days,
  11372. NationalTravelFeeId = x.NationalTravelFeeId,
  11373. Cost = x.Cost,
  11374. Currency = x.Currency,
  11375. SubTotal = x.SubTotal,
  11376. CreateUserId = dto.CurrUserId
  11377. })
  11378. .ToList();
  11379. var adds = infos.Where(x => x.Id <= 0).ToList();
  11380. var upds = infos.Where(x => x.Id > 0).ToList();
  11381. if (adds.Count > 0)
  11382. {
  11383. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11384. if (add < 1) return Ok(JsonView(false));
  11385. }
  11386. if (upds.Count > 0)
  11387. {
  11388. var upd = await _sqlSugar.Updateable(adds)
  11389. .UpdateColumns(x => new
  11390. {
  11391. x.Days,
  11392. x.NationalTravelFeeId,
  11393. x.Cost,
  11394. x.Currency,
  11395. x.SubTotal
  11396. })
  11397. .WhereColumns(x => new { x.Id })
  11398. .ExecuteCommandAsync();
  11399. if (upd < 1) return Ok(JsonView(false));
  11400. }
  11401. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11402. ////消息通知
  11403. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11404. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11405. return Ok(JsonView(new { itemTotal = itemTotal }));
  11406. }
  11407. /// <summary>
  11408. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11409. /// </summary>
  11410. /// <returns></returns>
  11411. [HttpPost]
  11412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11413. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11414. {
  11415. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11416. int subId = dto.SubId, feeType = dto.FeeType;
  11417. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11418. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11419. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11420. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11421. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11422. subInfo.Id = subId;
  11423. subInfo.ParentId = dto.DraftId;
  11424. if (feeType == 3) subInfo.Type = 1;
  11425. else if (feeType == 4) subInfo.Type = 2;
  11426. else if (feeType == 5) subInfo.Type = 3;
  11427. else if (feeType == 6) subInfo.Type = 4;
  11428. subInfo.CreateUserId = dto.CurrUserId;
  11429. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11430. if (parentId < 1) return Ok(JsonView(false));
  11431. //子表op
  11432. if (subId < 1)
  11433. {
  11434. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11435. if (subAdd < 1) return Ok(JsonView(false));
  11436. }
  11437. else
  11438. {
  11439. var subUpd = await _sqlSugar.Updateable(subInfo)
  11440. .UpdateColumns(x => new
  11441. {
  11442. x.Days,
  11443. x.NationalTravelFeeId,
  11444. x.Cost,
  11445. x.Currency,
  11446. x.SubTotal
  11447. })
  11448. .WhereColumns(x => new { x.Id })
  11449. .ExecuteCommandAsync();
  11450. if (subUpd < 1) return Ok(JsonView(false));
  11451. }
  11452. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11453. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11454. }
  11455. /// <summary>
  11456. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11457. /// </summary>
  11458. /// <returns></returns>
  11459. [HttpPost]
  11460. [ApiExplorerSettings(IgnoreApi = true)]
  11461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11462. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11463. {
  11464. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11465. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11466. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11467. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11468. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11469. {
  11470. Id = x.Id,
  11471. ParentId = dto.DraftId,
  11472. SetDataId = x.SetDataId,
  11473. Index = x.Index,
  11474. Cost = x.Cost,
  11475. Currency = x.Currency,
  11476. SubTotal = x.SubTotal,
  11477. CreateUserId = dto.CurrUserId,
  11478. Remark = x.Remark
  11479. }).ToList();
  11480. var adds = infos.Where(x => x.Id <= 0).ToList();
  11481. var upds = infos.Where(x => x.Id > 0).ToList();
  11482. if (adds.Count > 0)
  11483. {
  11484. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11485. if (add < 1) return Ok(JsonView(false));
  11486. }
  11487. if (upds.Count > 0)
  11488. {
  11489. var upd = await _sqlSugar.Updateable(adds)
  11490. .UpdateColumns(x => new
  11491. {
  11492. x.Index,
  11493. x.SetDataId,
  11494. x.Cost,
  11495. x.Currency,
  11496. x.SubTotal,
  11497. x.Remark
  11498. })
  11499. .WhereColumns(x => new { x.Id })
  11500. .ExecuteCommandAsync();
  11501. if (upd < 1) return Ok(JsonView(false));
  11502. }
  11503. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11504. //消息通知
  11505. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11506. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11507. return Ok(JsonView(new { itemTotal = itemTotal }));
  11508. }
  11509. /// <summary>
  11510. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11511. /// </summary>
  11512. /// <returns></returns>
  11513. [HttpPost]
  11514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11515. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11516. {
  11517. int subId = dto.SubId, id = dto.DraftId;
  11518. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11519. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11520. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11521. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11522. subInfo.Id = subId;
  11523. subInfo.ParentId = id;
  11524. subInfo.CreateUserId = dto.CurrUserId;
  11525. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11526. if (parentId < 1) return Ok(JsonView(false));
  11527. #region 子表op
  11528. if (subId < 1)//add
  11529. {
  11530. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11531. if (subAdd < 1) return Ok(JsonView(false));
  11532. }
  11533. else //upd
  11534. {
  11535. var subUpd = await _sqlSugar.Updateable(subInfo)
  11536. .UpdateColumns(x => new
  11537. {
  11538. x.Index,
  11539. x.SetDataId,
  11540. x.Cost,
  11541. x.Currency,
  11542. x.SubTotal,
  11543. x.Remark
  11544. })
  11545. .WhereColumns(x => new { x.Id })
  11546. .ExecuteCommandAsync();
  11547. if (subUpd < 1) return Ok(JsonView(false));
  11548. }
  11549. #endregion
  11550. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11551. ////消息通知
  11552. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11553. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11554. }
  11555. /// <summary>
  11556. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11557. /// </summary>
  11558. /// <returns></returns>
  11559. [HttpPost]
  11560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11561. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11562. {
  11563. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11564. if (data.Code != 0)
  11565. {
  11566. return Ok(JsonView(false, data.Msg));
  11567. }
  11568. return Ok(JsonView(true, "操作成功!", data.Data));
  11569. }
  11570. /// <summary>
  11571. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11572. /// </summary>
  11573. /// <param name="dto"></param>
  11574. /// <returns></returns>
  11575. [HttpPost]
  11576. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11577. {
  11578. var data = new Grp_DayOtherPriceDraft()
  11579. {
  11580. Id = dto.Id,
  11581. IsDel = 1,
  11582. DeleteUserId = dto.DeleteUserId,
  11583. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11584. };
  11585. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11586. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11587. return Ok(JsonView(false, "删除失败!"));
  11588. }
  11589. #endregion
  11590. #endregion
  11591. #region 团组经理模块 出入境费用报价表
  11592. /// <summary>
  11593. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11594. /// </summary>
  11595. /// <returns></returns>
  11596. [HttpPost]
  11597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11598. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11599. {
  11600. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11601. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11602. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11603. initRates.Insert(0, cnyInfo);
  11604. liveRates.Insert(0, cnyInfo);
  11605. return Ok(JsonView(true, "查询成功!", new
  11606. {
  11607. InitRates = initRates,
  11608. LiveRates = liveRates
  11609. }));
  11610. }
  11611. /// <summary>
  11612. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11613. /// </summary>
  11614. /// <returns></returns>
  11615. [HttpPost]
  11616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11617. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11618. {
  11619. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11620. }
  11621. /// <summary>
  11622. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11623. /// </summary>
  11624. /// <returns></returns>
  11625. [HttpPost]
  11626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11627. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11628. {
  11629. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11630. }
  11631. /// <summary>
  11632. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11633. /// </summary>
  11634. /// <returns></returns>
  11635. [HttpPost]
  11636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11637. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11638. {
  11639. int groupId = dto.DiId,
  11640. currUserId = dto.CurrUserId;
  11641. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11642. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11643. //验证报价数据是否存在
  11644. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11645. if (isNull != null)
  11646. {
  11647. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11648. if (!info1.Rates.Any())
  11649. {
  11650. var rates = await GeneralMethod.EnterExitCostInitRate();
  11651. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11652. info1.Rates = rates.ToArray();
  11653. }
  11654. return Ok(JsonView(info1));
  11655. }
  11656. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11657. result.GroupId = groupId;
  11658. //处理报价名称
  11659. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11660. if (groupInfo != null)
  11661. {
  11662. var visitCountry = groupInfo.VisitCountry;
  11663. if (!string.IsNullOrEmpty(visitCountry))
  11664. {
  11665. string quoteName = string.Empty;
  11666. if (visitCountry.Contains("|"))
  11667. {
  11668. var countrys = visitCountry.Split("|");
  11669. quoteName = string.Join("、", countrys);
  11670. }
  11671. else quoteName = visitCountry;
  11672. quoteName += $"团组报价表";
  11673. result.Name = quoteName;
  11674. }
  11675. }
  11676. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11677. if (info.Code != StatusCodes.Status200OK)
  11678. {
  11679. if (!result.Rates.Any())
  11680. {
  11681. var rates = await GeneralMethod.EnterExitCostInitRate();
  11682. result.Rates = rates.ToArray();
  11683. }
  11684. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11685. }
  11686. var infoView = info.Data as EnterExitCostInfoView;
  11687. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11688. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11689. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11690. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11691. var eecRates = infoView.Currencys;
  11692. //默认添加人名币
  11693. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11694. {
  11695. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11696. }
  11697. //处理团组人数
  11698. int pplNum = 1;
  11699. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11700. var views = new List<QuoteSubItemInfo>();
  11701. #region 数据填充
  11702. var intTravelCosts = new List<QuoteSubItemInfo>();
  11703. #region 机票费用 1354
  11704. int intTravelIndex = 1;
  11705. if (infoView.SumJJC == 1)
  11706. {
  11707. intTravelCosts.Add(new QuoteSubItemInfo
  11708. {
  11709. ItemId = 1354,
  11710. Index = intTravelIndex,
  11711. FeeName = "经济舱",
  11712. UnitPrice = infoView.AirJJ,
  11713. Currency = "CNY",
  11714. Quantity = 1,
  11715. PplNum = 1,
  11716. TotalAmt = infoView.AirJJ,
  11717. Remark = "",
  11718. });
  11719. intTravelIndex++;
  11720. }
  11721. if (infoView.SumGWC == 1)
  11722. {
  11723. intTravelCosts.Add(new QuoteSubItemInfo
  11724. {
  11725. ItemId = 1354,
  11726. Index = intTravelIndex,
  11727. FeeName = "公务舱",
  11728. UnitPrice = infoView.AirGW,
  11729. Currency = "CNY",
  11730. Quantity = 1,
  11731. PplNum = 1,
  11732. TotalAmt = infoView.AirGW,
  11733. Remark = "",
  11734. });
  11735. intTravelIndex++;
  11736. }
  11737. if (infoView.SumTDC == 1)
  11738. {
  11739. intTravelCosts.Add(new QuoteSubItemInfo
  11740. {
  11741. ItemId = 1354,
  11742. Index = intTravelIndex,
  11743. FeeName = "头等舱",
  11744. UnitPrice = infoView.AirTD,
  11745. Currency = "CNY",
  11746. Quantity = 1,
  11747. PplNum = 1,
  11748. TotalAmt = infoView.AirTD,
  11749. Remark = "",
  11750. });
  11751. intTravelIndex++;
  11752. }
  11753. intTravelCosts.Add(new QuoteSubItemInfo
  11754. {
  11755. ItemId = 1354,
  11756. Index = intTravelIndex,
  11757. FeeName = "城市间交通费用",
  11758. UnitPrice = infoView.CityTranffic,
  11759. Currency = "CNY",
  11760. Quantity = 1,
  11761. PplNum = pplNum,
  11762. TotalAmt = infoView.CityTranffic * pplNum,
  11763. Remark = "",
  11764. });
  11765. views.AddRange(intTravelCosts);
  11766. #endregion
  11767. var accomCosts = new List<QuoteSubItemInfo>();
  11768. #region 住宿费 1355
  11769. if (infoView.QuarterageData.Any())
  11770. {
  11771. int accomIndex = 1;
  11772. int accomItemTypeId = 1355;
  11773. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11774. foreach (var item in groupData)
  11775. {
  11776. string feeName = string.Empty;
  11777. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11778. if (countryInfo != null)
  11779. {
  11780. feeName = countryInfo.Country;
  11781. var city = countryInfo.City;
  11782. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11783. {
  11784. feeName += $"-{city}";
  11785. }
  11786. }
  11787. var hotelInfo = item.FirstOrDefault();
  11788. if (hotelInfo == null) continue;
  11789. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11790. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11791. int quantity = item.ToList().Count;
  11792. accomCosts.Add(new QuoteSubItemInfo
  11793. {
  11794. ItemId = accomItemTypeId,
  11795. Index = accomIndex,
  11796. FeeName = feeName,
  11797. UnitPrice = hotelInfo.Cost,
  11798. Currency = thisCurrency,
  11799. Quantity = quantity,
  11800. PplNum = pplNum,
  11801. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11802. Remark = "",
  11803. });
  11804. accomIndex++;
  11805. }
  11806. views.AddRange(accomCosts);
  11807. }
  11808. #endregion
  11809. var mealCosts = new List<QuoteSubItemInfo>();
  11810. #region 餐饮费 1356
  11811. if (infoView.BoardWagesData.Any())
  11812. {
  11813. var mealIndex = 1;
  11814. int mealItemTypeId = 1356;
  11815. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11816. foreach (var item in groupData)
  11817. {
  11818. string feeName = string.Empty;
  11819. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11820. if (countryInfo != null)
  11821. {
  11822. feeName = countryInfo.Country;
  11823. var city = countryInfo.City;
  11824. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11825. {
  11826. feeName += $"-{city}";
  11827. }
  11828. }
  11829. var mealInfo = item.FirstOrDefault();
  11830. if (mealInfo == null) continue;
  11831. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11832. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11833. int quantity = item.ToList().Count;
  11834. mealCosts.Add(new QuoteSubItemInfo
  11835. {
  11836. ItemId = mealItemTypeId,
  11837. Index = mealIndex,
  11838. FeeName = feeName,
  11839. UnitPrice = mealInfo.Cost,
  11840. Currency = thisCurrency,
  11841. Quantity = quantity,
  11842. PplNum = pplNum,
  11843. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11844. Remark = "",
  11845. });
  11846. mealIndex++;
  11847. }
  11848. views.AddRange(mealCosts);
  11849. }
  11850. #endregion
  11851. var miscCosts = new List<QuoteSubItemInfo>();
  11852. #region 公杂费 1364
  11853. if (infoView.MiscellaneousFeeData.Any())
  11854. {
  11855. var miscIndex = 1;
  11856. int miscItemTypeId = 1364;
  11857. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11858. foreach (var item in groupData)
  11859. {
  11860. string feeName = string.Empty;
  11861. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11862. if (countryInfo != null)
  11863. {
  11864. feeName = countryInfo.Country;
  11865. var city = countryInfo.City;
  11866. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11867. {
  11868. feeName += $"-{city}";
  11869. }
  11870. }
  11871. var miscInfo = item.FirstOrDefault();
  11872. if (miscInfo == null) continue;
  11873. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11874. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11875. int quantity = item.ToList().Count;
  11876. miscCosts.Add(new QuoteSubItemInfo
  11877. {
  11878. ItemId = miscItemTypeId,
  11879. Index = miscIndex,
  11880. FeeName = feeName,
  11881. UnitPrice = miscInfo.Cost,
  11882. Currency = thisCurrency,
  11883. Quantity = quantity,
  11884. PplNum = pplNum,
  11885. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11886. Remark = "",
  11887. });
  11888. miscIndex++;
  11889. }
  11890. views.AddRange(miscCosts);
  11891. }
  11892. #endregion
  11893. #region 签证+保险 1362
  11894. int visaInsIndex = 1;
  11895. int visaInsItemTypeId = 1362;
  11896. if (infoView.Visa > 0)
  11897. {
  11898. views.Add(new QuoteSubItemInfo()
  11899. {
  11900. ItemId = visaInsItemTypeId,
  11901. Index = visaInsIndex,
  11902. FeeName = $"签证",
  11903. UnitPrice = infoView.Visa,
  11904. Currency = $"CNY",
  11905. Quantity = 1,
  11906. PplNum = pplNum,
  11907. TotalAmt = infoView.Visa * pplNum,
  11908. Remark = "",
  11909. });
  11910. visaInsIndex++;
  11911. }
  11912. if (infoView.Safe > 0)
  11913. {
  11914. views.Add(new QuoteSubItemInfo()
  11915. {
  11916. ItemId = visaInsItemTypeId,
  11917. Index = visaInsIndex,
  11918. FeeName = $"保险",
  11919. UnitPrice = infoView.Safe,
  11920. Currency = $"CNY",
  11921. Quantity = 1,
  11922. PplNum = pplNum,
  11923. TotalAmt = infoView.Safe * pplNum,
  11924. Remark = "",
  11925. });
  11926. }
  11927. #endregion
  11928. #region 服务费 1363
  11929. int serviceFeeIndex = 1;
  11930. int serviceFeeItemTypeId = 1363;
  11931. if (infoView.Service > 0)
  11932. {
  11933. views.Add(new QuoteSubItemInfo()
  11934. {
  11935. ItemId = serviceFeeItemTypeId,
  11936. Index = serviceFeeIndex,
  11937. FeeName = $"服务费",
  11938. UnitPrice = infoView.Service,
  11939. Currency = $"CNY",
  11940. Quantity = 1,
  11941. PplNum = pplNum,
  11942. TotalAmt = infoView.Service * pplNum,
  11943. Remark = "",
  11944. });
  11945. }
  11946. #endregion
  11947. #endregion
  11948. if (result.FeeItems.Any())
  11949. {
  11950. result.FeeItems.Select(x =>
  11951. {
  11952. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11953. if (feeInfos.Any()) x.Infos = feeInfos;
  11954. return x;
  11955. }
  11956. ).OrderBy(x => x.Index)
  11957. .ToList();
  11958. if (!result.Rates.Any())
  11959. {
  11960. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  11961. else
  11962. {
  11963. var rates = await GeneralMethod.EnterExitCostInitRate();
  11964. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11965. result.Rates = rates.ToArray();
  11966. }
  11967. }
  11968. }
  11969. return Ok(JsonView(result));
  11970. }
  11971. /// <summary>
  11972. /// 团组模块 - 出入境费用报价表 - Info
  11973. /// </summary>
  11974. /// <returns></returns>
  11975. [HttpPost]
  11976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11977. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11978. {
  11979. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11980. if (!info.Rates.Any())
  11981. {
  11982. var rates = await GeneralMethod.EnterExitCostInitRate();
  11983. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11984. info.Rates = rates.ToArray();
  11985. }
  11986. return Ok(JsonView(info));
  11987. }
  11988. /// <summary>
  11989. /// 团组模块 - 出入境费用报价表 - OP
  11990. /// </summary>
  11991. /// <returns></returns>
  11992. [HttpPost]
  11993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11994. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11995. {
  11996. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11997. }
  11998. /// <summary>
  11999. /// 团组模块 - 出入境费用报价表 - 删除 项
  12000. /// </summary>
  12001. /// <returns></returns>
  12002. [HttpPost]
  12003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12004. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12005. {
  12006. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12007. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12008. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12009. }
  12010. /// <summary>
  12011. /// 团组模块 - 出入境费用报价表 - 导出
  12012. /// </summary>
  12013. /// <returns></returns>
  12014. [HttpPost]
  12015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12016. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12017. {
  12018. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12019. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12020. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12021. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12022. var rates = info.Rates;
  12023. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12024. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12025. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12026. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12027. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12028. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12029. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12030. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12031. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12032. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12033. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12034. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12035. //获取模板
  12036. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12037. var designer = new WorkbookDesigner();
  12038. designer.Workbook = new Workbook(tempPath);
  12039. designer.SetDataSource("QuoteName", info.Name);
  12040. designer.SetDataSource("CompanyTitle", "公司名称");
  12041. designer.SetDataSource("CompanyLabel", "");
  12042. #region 国际旅费
  12043. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12044. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12045. {
  12046. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12047. StringBuilder label = new StringBuilder();
  12048. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12049. if (infos.Any())
  12050. {
  12051. label.Append(infos.Sum(x => x.PplNum));
  12052. label.Append("人全程机票:");
  12053. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12054. label.AppendLine("元");
  12055. }
  12056. foreach (var item in intTravelCosts.Infos)
  12057. {
  12058. label.Append(item.FeeName);
  12059. label.Append(":");
  12060. label.Append(item.UnitPrice.TruncDecimals(2));
  12061. label.Append("元/人*");
  12062. label.Append(item.PplNum);
  12063. label.AppendLine("人");
  12064. }
  12065. if (label.HasValue())
  12066. {
  12067. label.Append("\r\n以上小计:");
  12068. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12069. label.Append("元");
  12070. }
  12071. designer.SetDataSource("IntTravelLabel", label.ToString());
  12072. }
  12073. #endregion
  12074. #region 住宿费
  12075. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12076. if (accomCosts != null && accomCosts.Infos.Any())
  12077. {
  12078. string currencyName = string.Empty,
  12079. countryName = string.Empty;
  12080. decimal rate = 1.0000M;
  12081. StringBuilder label = new StringBuilder();
  12082. label.AppendLine("全程五星酒店,每人1间房");
  12083. foreach (var item in accomCosts.Infos)
  12084. {
  12085. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12086. string name = string.Empty, thisCountryName = string.Empty;
  12087. if (item.FeeName.Contains("-"))
  12088. {
  12089. var feeName = item.FeeName.Split('-');
  12090. thisCountryName = feeName[0];
  12091. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12092. name = feeName[1];
  12093. }
  12094. else name = item.FeeName;
  12095. string thisFeeName = string.Empty;
  12096. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12097. else thisFeeName = $"\r\n{name}:";
  12098. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12099. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12100. rate = rateInfo?.Rate ?? 1.0000M;
  12101. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12102. label.AppendLine(subLabel);
  12103. }
  12104. if (label.HasValue())
  12105. {
  12106. //以上小计:52440元(美金汇率:7.5 )
  12107. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12108. label.AppendLine(subLabel);
  12109. }
  12110. designer.SetDataSource("AccomLabel", label.ToString());
  12111. }
  12112. #endregion
  12113. #region 餐饮费
  12114. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12115. if (mealCosts != null && mealCosts.Infos.Any())
  12116. {
  12117. string currencyName = string.Empty;
  12118. decimal rate = 1.0000M;
  12119. StringBuilder label = new StringBuilder();
  12120. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12121. foreach (var item in mealCosts.Infos)
  12122. {
  12123. string name = string.Empty;
  12124. if (item.FeeName.Contains("-"))
  12125. {
  12126. var feeName = item.FeeName.Split('-');
  12127. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12128. }
  12129. else name = $"\r\n{item.FeeName}:";
  12130. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12131. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12132. rate = rateInfo?.Rate ?? 1.0000M;
  12133. label.Append(name);
  12134. label.Append(item.UnitPrice.TruncDecimals(2));
  12135. label.Append(currencyName);
  12136. label.Append("/天*");
  12137. label.Append(item.Quantity.ToString("#0"));
  12138. label.Append("*");
  12139. label.Append(item.PplNum);
  12140. label.Append("人\r\n");
  12141. }
  12142. if (label.HasValue())
  12143. {
  12144. label.Append("\r\n以上小计:");
  12145. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12146. label.Append("元\r\n(");
  12147. label.Append("汇率:");
  12148. label.Append(rate.TruncDecimals(4));
  12149. label.Append(")");
  12150. }
  12151. designer.SetDataSource("MealLabel", label.ToString());
  12152. }
  12153. #endregion
  12154. #region 车辆安排
  12155. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12156. if (vehArranges != null && vehArranges.Infos.Any())
  12157. {
  12158. string currencyName = string.Empty;
  12159. //decimal rate = 1.0000M;
  12160. StringBuilder label = new StringBuilder();
  12161. foreach (var item in vehArranges.Infos)
  12162. {
  12163. label.AppendLine();
  12164. label.AppendLine();
  12165. label.Append(item.FeeName);
  12166. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12167. }
  12168. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12169. }
  12170. #endregion
  12171. #region 邀请函发放对象
  12172. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12173. designer.SetDataSource("InviteToContent", "");
  12174. #endregion
  12175. #region 邀请函费
  12176. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12177. StringBuilder is_label = new StringBuilder();
  12178. if (inviteCosts != null && inviteCosts.Infos.Any())
  12179. {
  12180. string currencyName = string.Empty;
  12181. decimal rate = 1.0000M;
  12182. foreach (var item in inviteCosts.Infos)
  12183. {
  12184. //乌兹别克斯坦:2000美金
  12185. currencyName = item.Currency;
  12186. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12187. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12188. is_label.AppendLine(label);
  12189. }
  12190. if (is_label.HasValue())
  12191. {
  12192. //以上小计:28500元(美金汇率:7.5)
  12193. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12194. is_label.AppendLine(label);
  12195. }
  12196. }
  12197. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12198. #endregion
  12199. #region 邀请函发放时间
  12200. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12201. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12202. #endregion
  12203. #region 公务活动(含翻译)
  12204. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12205. StringBuilder oa_label = new StringBuilder();
  12206. if (officialActs != null && officialActs.Infos.Any())
  12207. {
  12208. string currencyName = string.Empty;
  12209. decimal rate = 1.0000M;
  12210. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12211. foreach (var item in officialActs.Infos)
  12212. {
  12213. //乌兹别克斯坦:1000美金/场
  12214. currencyName = item.Currency;
  12215. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12216. string label_remark = string.Empty;
  12217. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12218. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12219. }
  12220. label_content += "*总费用中未含超出公务活动价格";
  12221. //8场公务活动(以上小计:60000元)
  12222. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12223. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12224. oa_label.AppendLine(label_title);
  12225. oa_label.AppendLine(label_content);
  12226. }
  12227. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12228. #endregion
  12229. #region 签证+保险
  12230. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12231. StringBuilder vi_label = new StringBuilder();
  12232. if (visaIns != null && visaIns.Infos.Any())
  12233. {
  12234. foreach (var item in visaIns.Infos)
  12235. {
  12236. //签证:500元/人
  12237. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12238. vi_label.AppendLine(label);
  12239. }
  12240. if (vi_label.HasValue())
  12241. {
  12242. //以上小计:6000元
  12243. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12244. vi_label.AppendLine(label);
  12245. }
  12246. }
  12247. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12248. #endregion
  12249. #region 服务费
  12250. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12251. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12252. #endregion
  12253. #region 公杂费
  12254. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12255. StringBuilder pm_label = new StringBuilder();
  12256. if (pubMiscs != null && pubMiscs.Infos.Any())
  12257. {
  12258. string currencyName = string.Empty,
  12259. countryName = string.Empty;
  12260. decimal rate = 1.0000M;
  12261. foreach (var item in pubMiscs.Infos)
  12262. {
  12263. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12264. string name = string.Empty, thisCountryName = string.Empty;
  12265. if (item.FeeName.Contains("-"))
  12266. {
  12267. var feeName = item.FeeName.Split('-');
  12268. thisCountryName = feeName[0];
  12269. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12270. name = feeName[1];
  12271. }
  12272. else name = item.FeeName;
  12273. string thisFeeName = string.Empty;
  12274. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12275. else thisFeeName = $"\r\n{name}:";
  12276. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12277. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12278. rate = rateInfo?.Rate ?? 1.0000M;
  12279. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12280. pm_label.AppendLine(label);
  12281. }
  12282. if (pm_label.HasValue())
  12283. {
  12284. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12285. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12286. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12287. pm_label.AppendLine(string.Format("部分发放成员"));
  12288. }
  12289. }
  12290. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12291. #endregion
  12292. #region 税费
  12293. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12294. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12295. #endregion
  12296. #region 合计(单位:元)
  12297. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12298. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12299. #endregion
  12300. #region 汇率 Remark
  12301. var rate_label = new StringBuilder();
  12302. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12303. foreach (var item in rateGroups)
  12304. {
  12305. //美元汇率按\r\n1:7.5
  12306. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12307. rate_label.AppendLine(label);
  12308. }
  12309. designer.SetDataSource("RateLabel", rate_label.ToString());
  12310. #endregion
  12311. designer.Process();
  12312. //文件名
  12313. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12314. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12315. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12316. return Ok(JsonView(true, "成功", url));
  12317. }
  12318. #endregion
  12319. #region 签证费用录入
  12320. /// <summary>
  12321. /// 根据diid查询签证费用列表
  12322. /// </summary>
  12323. /// <param name="dto"></param>
  12324. /// <returns></returns>
  12325. [HttpPost]
  12326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12327. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12328. {
  12329. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12330. if (groupData.Code != 0)
  12331. {
  12332. return Ok(JsonView(false, groupData.Msg));
  12333. }
  12334. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12335. }
  12336. /// <summary>
  12337. /// 根据签证费用Id查询单条数据及c表数据
  12338. /// </summary>
  12339. /// <param name="dto"></param>
  12340. /// <returns></returns>
  12341. [HttpPost]
  12342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12343. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12344. {
  12345. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12346. if (groupData.Code != 0)
  12347. {
  12348. return Ok(JsonView(false, groupData.Msg));
  12349. }
  12350. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12351. }
  12352. /// <summary>
  12353. /// 签证费用删除
  12354. /// </summary>
  12355. /// <param name="dto"></param>
  12356. /// <returns></returns>
  12357. [HttpPost]
  12358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12359. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12360. {
  12361. _sqlSugar.BeginTran();
  12362. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12363. if (!res)
  12364. {
  12365. _sqlSugar.RollbackTran();
  12366. return Ok(JsonView(false, "删除失败"));
  12367. }
  12368. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12369. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12370. .SetColumns(a => new Grp_CreditCardPayment()
  12371. {
  12372. IsDel = 1,
  12373. DeleteUserId = dto.DeleteUserId,
  12374. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12375. })
  12376. .ExecuteCommand();
  12377. if (resSub < 1)
  12378. {
  12379. _sqlSugar.RollbackTran();
  12380. return Ok(JsonView(false, "删除失败"));
  12381. }
  12382. _sqlSugar.CommitTran();
  12383. return Ok(JsonView(true, "删除成功!"));
  12384. }
  12385. /// <summary>
  12386. /// 签证费用录入下拉框初始化
  12387. /// </summary>
  12388. /// <returns></returns>
  12389. [HttpPost]
  12390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12391. public async Task<IActionResult> VisaPriceAddSelect()
  12392. {
  12393. //支付方式
  12394. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12395. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12396. //币种
  12397. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12398. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12399. //乘客类型
  12400. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12401. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12402. //卡类型
  12403. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12404. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12405. //代办费类型
  12406. var agencyFeeTypeData = new List<dynamic>() {
  12407. new { id = 0 , Text = "未选择" },
  12408. new { id = 1 , Text = "小公务" },
  12409. new { id = 2 , Text = "大公务" },
  12410. };
  12411. //签证费用标准国家Data
  12412. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12413. var data = new
  12414. {
  12415. Payment = _Payment,
  12416. CurrencyList = _CurrencyList,
  12417. PassengerType = _PassengerType,
  12418. BankCard = _BankCard,
  12419. AgencyFeeType = agencyFeeTypeData,
  12420. CountryFeeData = visaCountryFeeData
  12421. };
  12422. return Ok(JsonView(true, "查询成功!", data));
  12423. }
  12424. /// <summary>
  12425. /// 签证费用录入操作(Status:1.新增,2.修改)
  12426. /// </summary>
  12427. /// <param name="dto"></param>
  12428. /// <returns></returns>
  12429. [HttpPost]
  12430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12431. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12432. {
  12433. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12434. if (groupData.Code != 0)
  12435. {
  12436. return Ok(JsonView(false, groupData.Msg));
  12437. }
  12438. #region 应用推送
  12439. try
  12440. {
  12441. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12442. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12443. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12444. //2024-10-21 新增LZ UID
  12445. var userIds = new List<int>() { 21 };
  12446. string title = $"系统通知";
  12447. string content = "";
  12448. var diId = dto.DiId;
  12449. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12450. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12451. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12452. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12453. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12454. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12455. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12456. }
  12457. catch (Exception ex)
  12458. {
  12459. }
  12460. #endregion
  12461. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12462. }
  12463. #endregion
  12464. #region 签证提成录入
  12465. /// <summary>
  12466. /// 签证提成录入
  12467. /// 基础数据
  12468. /// </summary>
  12469. /// <returns></returns>
  12470. [HttpGet]
  12471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12472. public async Task<IActionResult> VisaCommissionInit()
  12473. {
  12474. return Ok(await _visaCommissionRep.Init());
  12475. }
  12476. /// <summary>
  12477. /// 签证提成录入
  12478. /// Item
  12479. /// </summary>
  12480. /// <param name="_dto"></param>
  12481. /// <returns></returns>
  12482. [HttpPost]
  12483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12484. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12485. {
  12486. var validator = new VisaCommissionItemDtoValidator();
  12487. var validatorRes = await validator.ValidateAsync(_dto);
  12488. if (!validatorRes.IsValid)
  12489. {
  12490. StringBuilder sb = new StringBuilder();
  12491. foreach (var item in validatorRes.Errors)
  12492. {
  12493. sb.AppendLine(item.ErrorMessage);
  12494. }
  12495. return Ok(JsonView(false, sb.ToString()));
  12496. }
  12497. return Ok(await _visaCommissionRep.Item(_dto));
  12498. }
  12499. /// <summary>
  12500. /// 签证提成录入
  12501. /// Save
  12502. /// </summary>
  12503. /// <param name="_dto"></param>
  12504. /// <returns></returns>
  12505. [HttpPost]
  12506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12507. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12508. {
  12509. //参数验证
  12510. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12511. foreach (var item in _dto.Items)
  12512. {
  12513. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12514. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12515. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12516. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12517. }
  12518. return Ok(await _visaCommissionRep.Save(_dto));
  12519. }
  12520. /// <summary>
  12521. /// 签证提成录入
  12522. /// Create
  12523. /// </summary>
  12524. /// <param name="_dto"></param>
  12525. /// <returns></returns>
  12526. [HttpPost]
  12527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12528. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12529. {
  12530. var validator = new VisaCommissionCreateDtoValidator();
  12531. var validatorRes = await validator.ValidateAsync(_dto);
  12532. if (!validatorRes.IsValid)
  12533. {
  12534. StringBuilder sb = new StringBuilder();
  12535. foreach (var item in validatorRes.Errors)
  12536. {
  12537. sb.AppendLine(item.ErrorMessage);
  12538. }
  12539. return Ok(JsonView(false, sb.ToString()));
  12540. }
  12541. return Ok(await _visaCommissionRep.Create(_dto));
  12542. }
  12543. /// <summary>
  12544. /// 签证提成录入
  12545. /// Put(编辑)
  12546. /// </summary>
  12547. /// <param name="id"></param>
  12548. /// <param name="_dto"></param>
  12549. /// <returns></returns>
  12550. [HttpPut]
  12551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12552. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12553. {
  12554. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12555. var validator = new VisaCommissionCreateDtoValidator();
  12556. var validatorRes = await validator.ValidateAsync(_dto);
  12557. if (!validatorRes.IsValid)
  12558. {
  12559. StringBuilder sb = new StringBuilder();
  12560. foreach (var item in validatorRes.Errors)
  12561. {
  12562. sb.AppendLine(item.ErrorMessage);
  12563. }
  12564. return Ok(JsonView(false, sb.ToString()));
  12565. }
  12566. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12567. }
  12568. /// <summary>
  12569. /// 签证提成录入
  12570. /// Del
  12571. /// </summary>
  12572. /// <param name="id"></param>
  12573. /// <param name="currUserId"></param>
  12574. /// <returns></returns>
  12575. [HttpPost]
  12576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12577. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12578. {
  12579. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12580. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12581. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12582. }
  12583. #endregion
  12584. #region op费用录入
  12585. /// <summary>
  12586. /// 根据diid查询op费用列表
  12587. /// </summary>
  12588. /// <param name="dto"></param>
  12589. /// <returns></returns>
  12590. [HttpPost]
  12591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12592. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12593. {
  12594. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12595. if (groupData.Code != 0)
  12596. {
  12597. return Ok(JsonView(false, groupData.Msg));
  12598. }
  12599. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12600. }
  12601. /// <summary>
  12602. /// 根据op费用Id查询单条数据及c表数据
  12603. /// </summary>
  12604. /// <param name="dto"></param>
  12605. /// <returns></returns>
  12606. [HttpPost]
  12607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12608. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12609. {
  12610. try
  12611. {
  12612. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12613. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12614. var data = new
  12615. {
  12616. CarTouristGuideGround = _groupData,
  12617. CreditCardPayment = _creditCardPayment
  12618. };
  12619. return Ok(JsonView(true, "查询成功!", data));
  12620. }
  12621. catch (Exception ex)
  12622. {
  12623. return Ok(JsonView(false, "程序错误!"));
  12624. }
  12625. }
  12626. /// <summary>
  12627. /// op费用删除
  12628. /// </summary>
  12629. /// <param name="dto"></param>
  12630. /// <returns></returns>
  12631. [HttpPost]
  12632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12633. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12634. {
  12635. try
  12636. {
  12637. _sqlSugar.BeginTran();
  12638. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12639. if (!res)
  12640. {
  12641. return Ok(JsonView(false, "删除失败"));
  12642. }
  12643. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12644. {
  12645. IsDel = 1,
  12646. DeleteUserId = dto.DeleteUserId,
  12647. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12648. }).ExecuteCommandAsync();
  12649. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12650. {
  12651. IsDel = 1,
  12652. DeleteUserId = dto.DeleteUserId,
  12653. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12654. }).ExecuteCommandAsync();
  12655. #region 删除超支相关数据
  12656. //删除导入的超支数据
  12657. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12658. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12659. {
  12660. IsDel = 1,
  12661. DeleteUserId = dto.DeleteUserId,
  12662. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12663. }).ExecuteCommand();
  12664. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12665. {
  12666. IsDel = 1,
  12667. DeleteUserId = dto.DeleteUserId,
  12668. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12669. }).ExecuteCommand();
  12670. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12671. {
  12672. IsDel = 1,
  12673. DeleteUserId = dto.DeleteUserId,
  12674. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12675. }).ExecuteCommand();
  12676. #endregion
  12677. _sqlSugar.CommitTran();
  12678. return Ok(JsonView(true, "删除成功!"));
  12679. }
  12680. catch (Exception ex)
  12681. {
  12682. _sqlSugar.RollbackTran();
  12683. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12684. }
  12685. }
  12686. /// <summary>
  12687. /// op费用录入操作(Status:1.新增,2.修改)
  12688. /// </summary>
  12689. /// <param name="dto"></param>
  12690. /// <returns></returns>
  12691. [HttpPost]
  12692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12693. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12694. {
  12695. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12696. if (groupData.Code != 0)
  12697. {
  12698. return Ok(JsonView(false, groupData.Msg));
  12699. }
  12700. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12701. }
  12702. /// <summary>
  12703. /// 填写费用详细页面初始化绑定
  12704. /// </summary>
  12705. /// <param name="dto"></param>
  12706. /// <returns></returns>
  12707. [HttpPost]
  12708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12709. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12710. {
  12711. try
  12712. {
  12713. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12714. if (groupData.Code != 0)
  12715. {
  12716. return Ok(JsonView(false, groupData.Msg));
  12717. }
  12718. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12719. }
  12720. catch (Exception ex)
  12721. {
  12722. return Ok(JsonView(false, ex.Message));
  12723. }
  12724. }
  12725. /// <summary>
  12726. /// 根据op费用Id查询详细数据
  12727. /// </summary>
  12728. /// <param name="dto"></param>
  12729. /// <returns></returns>
  12730. [HttpPost]
  12731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12732. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12733. {
  12734. try
  12735. {
  12736. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12737. if (groupData.Code != 0)
  12738. {
  12739. return Ok(JsonView(false, groupData.Msg));
  12740. }
  12741. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12742. }
  12743. catch (Exception ex)
  12744. {
  12745. return Ok(JsonView(false, ex.Message));
  12746. }
  12747. }
  12748. /// <summary>
  12749. /// OP费用录入填写详情
  12750. /// </summary>
  12751. /// <param name="dto"></param>
  12752. /// <returns></returns>
  12753. [HttpPost]
  12754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12755. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12756. {
  12757. try
  12758. {
  12759. #region 参数校验
  12760. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12761. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12762. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12763. #endregion
  12764. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12765. if (groupData.Code != 0)
  12766. {
  12767. return Ok(JsonView(false, groupData.Msg));
  12768. }
  12769. //自动审核
  12770. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12771. #region 应用推送
  12772. try
  12773. {
  12774. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12775. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12776. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12777. //2024-10-21 新增LZ UID
  12778. var userIds = new List<int>() { 21 };
  12779. string title = $"系统通知";
  12780. var diId = dto.DiId;
  12781. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12782. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12783. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12784. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12785. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12786. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12787. }
  12788. catch (Exception ex)
  12789. {
  12790. }
  12791. #endregion
  12792. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12793. }
  12794. catch (Exception ex)
  12795. {
  12796. return Ok(JsonView(false, ex.Message));
  12797. }
  12798. }
  12799. /// <summary>
  12800. /// 获取三公详细所有城市
  12801. /// </summary>
  12802. /// <returns></returns>
  12803. [HttpGet]
  12804. public IActionResult OpCarCityResult()
  12805. {
  12806. var jw = JsonView(false);
  12807. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12808. {
  12809. x.Id,
  12810. x.Country,
  12811. x.City,
  12812. }).ToList();
  12813. if (data.Count > 0)
  12814. {
  12815. jw = JsonView(true, "获取成功!", data);
  12816. }
  12817. else
  12818. {
  12819. jw.Msg = "城市数据为空!";
  12820. jw.Data = new string[0];
  12821. }
  12822. return Ok(jw);
  12823. }
  12824. /// <summary>
  12825. /// 导出地接费用明细
  12826. /// </summary>
  12827. /// <param name="dto"></param>
  12828. /// <returns></returns>
  12829. [HttpPost]
  12830. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12831. {
  12832. var jw = JsonView(false);
  12833. if (dto.Diid < 1)
  12834. {
  12835. jw.Msg = "请输入正确的diid!";
  12836. return Ok(jw);
  12837. }
  12838. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12839. if (group == null)
  12840. {
  12841. jw.Msg = "未找到团组信息!";
  12842. return Ok(jw);
  12843. }
  12844. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12845. if (localGuideArr.Count == 0)
  12846. {
  12847. jw.Msg = "该团组暂无地接信息!";
  12848. return Ok(jw);
  12849. }
  12850. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12851. var overspendSoure = new Dictionary<int, int>
  12852. {
  12853. { 91, 982 }, //车
  12854. { 92 , 1059} ,//导游
  12855. { 994 , 1073}, //翻译
  12856. { 988 , 1074 }, //早餐
  12857. { 93 , 1075 }, //午餐
  12858. { 989 , 1076 }, //晚餐
  12859. };
  12860. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12861. foreach (var groupArr in localGroup)
  12862. {
  12863. var keyValue = groupArr.Key;
  12864. if (int.TryParse(keyValue, out int cityid))
  12865. {
  12866. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12867. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12868. }
  12869. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12870. foreach (var item in groupArr)
  12871. {
  12872. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12873. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12874. new Grp_CarTouristGuideGroundReservationsContentExtend
  12875. {
  12876. Count = a.Count,
  12877. CreateTime = a.CreateTime,
  12878. CreateUserId = a.CreateUserId,
  12879. CTGGRId = a.CTGGRId,
  12880. Currency = a.Currency,
  12881. DatePrice = a.DatePrice,
  12882. DeleteTime = a.DeleteTime,
  12883. DeleteUserId = a.DeleteUserId,
  12884. DiId = a.DiId,
  12885. Id = a.Id,
  12886. IsDel = a.IsDel,
  12887. Price = a.Price,
  12888. PriceContent = a.PriceContent,
  12889. Remark = a.Remark,
  12890. SId = a.SId,
  12891. SidName = b.Name,
  12892. Units = a.Units,
  12893. }
  12894. ).ToList();
  12895. if (content.Count > 0)
  12896. {
  12897. contentArr.Add(content);
  12898. }
  12899. }
  12900. //open excel
  12901. //set excel
  12902. //save excel
  12903. try
  12904. {
  12905. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12906. IWorkbook workbook;
  12907. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12908. {
  12909. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12910. }
  12911. else
  12912. {
  12913. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12914. }
  12915. ISheet sheet = workbook.GetSheetAt(0);
  12916. var rowStartIndex = 2;
  12917. var clounmCount = 10;
  12918. var initStyleRow = sheet.GetRow(2);
  12919. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12920. //var overspendArrDetail =
  12921. var existsId = new List<CarCompare>();
  12922. var lastElem = arr.Last();
  12923. var thisSid = -1;
  12924. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12925. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12926. {
  12927. Name = "未知币种!",
  12928. Remark = "未知币种!",
  12929. };
  12930. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12931. Action cloneRowFn = () =>
  12932. {
  12933. rowStartIndex++;
  12934. var cloneRow = sheet.CreateRow(rowStartIndex);
  12935. // 复制样式
  12936. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12937. {
  12938. ICell sourceCell = initStyleRow.GetCell(i);
  12939. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12940. // 确保单元格存在样式
  12941. if (sourceCell.CellStyle != null)
  12942. {
  12943. targetCell.CellStyle = sourceCell.CellStyle;
  12944. }
  12945. }
  12946. };
  12947. var mergeRow = () =>
  12948. {
  12949. for (int i = 2; i < sheet.LastRowNum; i++)
  12950. {
  12951. var row = sheet.GetRow(i);
  12952. var cellFirst = row.GetCell(0);
  12953. var thisIndex = i + 1;
  12954. while (thisIndex < sheet.LastRowNum)
  12955. {
  12956. var nextRow = sheet.GetRow(thisIndex);
  12957. var nextCellFirst = nextRow.GetCell(0);
  12958. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12959. {
  12960. thisIndex++;
  12961. }
  12962. else
  12963. {
  12964. break;
  12965. }
  12966. }
  12967. thisIndex--;
  12968. if (thisIndex != i)
  12969. {
  12970. //合并row
  12971. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12972. i, // 起始行索引(0-based)
  12973. thisIndex, // 结束行索引(0-based)
  12974. 0, // 起始列索引(0-based)
  12975. 0 // 结束列索引(0-based)
  12976. );
  12977. sheet.AddMergedRegion(cellRangeAddress);
  12978. i = thisIndex;
  12979. }
  12980. }
  12981. };
  12982. var chaoshiNumber = 0;
  12983. var totalNumber = 0.00M;
  12984. string lastStr = "";
  12985. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12986. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12987. {
  12988. b.IsAuditGM,
  12989. x.Id,
  12990. x.Area,
  12991. b.PayPercentage,
  12992. b.PayMoney,
  12993. }).ToList();
  12994. string yesPayment = "", noPayment = "";
  12995. foreach (var item in queryCarArrByCityAndDiid)
  12996. {
  12997. if (item.IsAuditGM == 1)
  12998. {
  12999. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13000. }
  13001. else
  13002. {
  13003. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13004. }
  13005. }
  13006. lastStr = yesPayment + noPayment;
  13007. foreach (var item in arr)
  13008. {
  13009. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  13010. {
  13011. if (thisSid != item.SId)
  13012. {
  13013. if (thisSid == -1)
  13014. {
  13015. thisSid = item.SId;
  13016. }
  13017. else
  13018. {
  13019. //合并小计行
  13020. //创建合并区域的实例
  13021. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13022. rowStartIndex, // 起始行索引(0-based)
  13023. rowStartIndex, // 结束行索引(0-based)
  13024. 0, // 起始列索引(0-based)
  13025. 3 // 结束列索引(0-based)
  13026. );
  13027. sheet.AddMergedRegion(cellRangeAddress);
  13028. var CellStyle = workbook.CreateCellStyle();
  13029. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13030. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13031. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13032. for (int i = 0; i <= clounmCount; i++)
  13033. {
  13034. if (i > 6)
  13035. {
  13036. var CellStyle1 = workbook.CreateCellStyle();
  13037. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13038. IFont Font = workbook.CreateFont(); // 创建字体
  13039. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13040. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13041. CellStyle1.SetFont(Font);
  13042. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13043. }
  13044. else
  13045. {
  13046. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13047. }
  13048. }
  13049. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13050. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13051. //超时合计
  13052. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13053. //超时数
  13054. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13055. //超时合计费用
  13056. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13057. thisSid = item.SId;
  13058. cloneRowFn();
  13059. chaoshiNumber = 0;
  13060. totalNumber = 0;
  13061. }
  13062. }
  13063. IRow row = sheet.GetRow(rowStartIndex);
  13064. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13065. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  13066. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13067. if (isOpenOverspendSoure)
  13068. {
  13069. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13070. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13071. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13072. }
  13073. for (int i = 0; i <= clounmCount; i++)
  13074. {
  13075. var cell = row.GetCell(i);
  13076. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13077. if (cell == null)
  13078. {
  13079. cell = row.CreateCell(i);
  13080. }
  13081. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13082. fontRed.CloneStyleFrom(cell.CellStyle);
  13083. IFont Font = workbook.CreateFont(); // 创建字体
  13084. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13085. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13086. fontRed.SetFont(Font);
  13087. byte[] rgb = new byte[3] { 255, 242, 204 };
  13088. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13089. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13090. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13091. if (workbook is XSSFWorkbook)
  13092. {
  13093. BackgroundColor255_242_204.FillForegroundColor = 0;
  13094. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13095. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13096. }
  13097. else
  13098. {
  13099. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13100. }
  13101. if (i == 1 || i > 6)
  13102. {
  13103. if (i > 6)
  13104. {
  13105. fontRed.FillForegroundColor = 0;
  13106. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13107. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13108. }
  13109. cell.CellStyle = fontRed;
  13110. }
  13111. if (i > 2 && i < 7)
  13112. {
  13113. cell.CellStyle = BackgroundColor255_242_204;
  13114. }
  13115. cell.SetCellValue(setCellValue); //写入单元格
  13116. }
  13117. if (overspendSoure.ContainsKey(thisSid))
  13118. {
  13119. var overspendId = overspendSoure[thisSid];
  13120. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13121. }
  13122. cloneRowFn();
  13123. existsId.Add(new CarCompare
  13124. {
  13125. DataPrice = item.DatePrice.ObjToDate(),
  13126. Sid = item.SId
  13127. });
  13128. }
  13129. if (item.Equals(lastElem))
  13130. {
  13131. //合并小计行
  13132. //创建合并区域的实例
  13133. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13134. rowStartIndex, // 起始行索引(0-based)
  13135. rowStartIndex, // 结束行索引(0-based)
  13136. 0, // 起始列索引(0-based)
  13137. 3 // 结束列索引(0-based)
  13138. );
  13139. sheet.AddMergedRegion(cellRangeAddress);
  13140. var CellStyle = workbook.CreateCellStyle();
  13141. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13142. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13143. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13144. for (int i = 0; i <= clounmCount; i++)
  13145. {
  13146. if (i > 6)
  13147. {
  13148. var CellStyle1 = workbook.CreateCellStyle();
  13149. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13150. IFont Font = workbook.CreateFont(); // 创建字体
  13151. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13152. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13153. CellStyle1.SetFont(Font);
  13154. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13155. }
  13156. else
  13157. {
  13158. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13159. }
  13160. }
  13161. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13162. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13163. //超时合计
  13164. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13165. //超时数
  13166. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13167. //超时合计费用
  13168. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13169. cloneRowFn();
  13170. // 创建合并区域的实例
  13171. cellRangeAddress = new CellRangeAddress(
  13172. rowStartIndex, // 起始行索引(0-based)
  13173. rowStartIndex, // 结束行索引(0-based)
  13174. 0, // 起始列索引(0-based)
  13175. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13176. );
  13177. // 添加合并区域
  13178. sheet.AddMergedRegion(cellRangeAddress);
  13179. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13180. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13181. }
  13182. }
  13183. mergeRow();
  13184. // 保存修改后的Excel文件到新文件
  13185. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13186. // new FileStream(newFilePath, FileMode.CreateNew)
  13187. using (var stream = new MemoryStream())
  13188. {
  13189. workbook.Write(stream, true);
  13190. stream.Flush();
  13191. stream.Seek(0, SeekOrigin.Begin);
  13192. MemoryStream memoryStream = new MemoryStream();
  13193. stream.CopyTo(memoryStream);
  13194. memoryStream.Seek(0, SeekOrigin.Begin);
  13195. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13196. }
  13197. workbook.Close();
  13198. workbook.Dispose();
  13199. }
  13200. catch (Exception ex)
  13201. {
  13202. jw.Msg = "出现异常!" + ex.Message;
  13203. return Ok(jw);
  13204. }
  13205. }
  13206. if (Zips.Count > 0)
  13207. {
  13208. IOOperatorHelper io = new IOOperatorHelper();
  13209. var byts = io.ConvertZipStream(Zips);
  13210. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13211. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13212. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13213. }
  13214. else
  13215. {
  13216. jw.Msg = "暂无生成文件!";
  13217. }
  13218. return Ok(jw);
  13219. }
  13220. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13221. {
  13222. string outStr = string.Empty;
  13223. switch (i)
  13224. {
  13225. case 0:
  13226. outStr = arr[0].SidName;
  13227. break;
  13228. case 1:
  13229. outStr = arr[0].DataPriceStr;
  13230. break;
  13231. case 2:
  13232. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13233. break;
  13234. case 4:
  13235. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13236. break;
  13237. case 7:
  13238. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13239. {
  13240. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13241. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13242. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13243. }
  13244. break;
  13245. case 8:
  13246. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13247. {
  13248. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13249. }
  13250. break;
  13251. case 9:
  13252. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13253. {
  13254. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13255. }
  13256. break;
  13257. case 10:
  13258. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13259. {
  13260. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13261. }
  13262. break;
  13263. }
  13264. return outStr;
  13265. }
  13266. #region OP行程单
  13267. /// <summary>
  13268. /// OP行程单初始化
  13269. /// </summary>
  13270. /// <param name="dto"></param>
  13271. /// <returns></returns>
  13272. [HttpPost]
  13273. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13274. {
  13275. var jw = JsonView(false);
  13276. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13277. var group = groupList.First();
  13278. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13279. if (group == null)
  13280. {
  13281. jw.Msg = "暂无团组!";
  13282. return Ok(jw);
  13283. }
  13284. group = groupList.Find(x => x.Id == diid);
  13285. if (group == null)
  13286. {
  13287. jw.Msg = "请输入正确的团组ID!";
  13288. return Ok(jw);
  13289. }
  13290. string city = string.Empty;
  13291. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13292. if (blackCode.Count > 0)
  13293. {
  13294. var black = blackCode.First();
  13295. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13296. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13297. if (blackSp.Length > 0)
  13298. {
  13299. try
  13300. {
  13301. var cityArrCode = new List<string>(20);
  13302. foreach (var item in blackSp)
  13303. {
  13304. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13305. var IndexSelect = itemSp[2];
  13306. var cityArrCodeLength = cityArrCode.Count - 1;
  13307. var startCity = IndexSelect.Substring(0, 3);
  13308. if (cityArrCodeLength > 0)
  13309. {
  13310. var arrEndCity = cityArrCode[cityArrCodeLength];
  13311. if (arrEndCity != startCity)
  13312. {
  13313. cityArrCode.Add(startCity.ToUpper());
  13314. }
  13315. }
  13316. else
  13317. {
  13318. cityArrCode.Add(startCity.ToUpper());
  13319. }
  13320. var endCity = IndexSelect.Substring(3, 3);
  13321. cityArrCode.Add(endCity.ToUpper());
  13322. }
  13323. var cityThree = string.Empty;
  13324. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13325. cityThree = cityThree.TrimEnd(',');
  13326. if (string.IsNullOrWhiteSpace(cityThree))
  13327. {
  13328. throw new
  13329. Exception("error");
  13330. }
  13331. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13332. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13333. foreach (var item in cityArrCode)
  13334. {
  13335. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13336. if (find != null)
  13337. {
  13338. city += find.City + "/";
  13339. }
  13340. else
  13341. {
  13342. city += item + "三字码未收入/";
  13343. }
  13344. }
  13345. city = city.TrimEnd('/');
  13346. }
  13347. catch (Exception e)
  13348. {
  13349. city = "黑屏代码格式不正确!";
  13350. }
  13351. }
  13352. }
  13353. else
  13354. {
  13355. city = "未录入黑屏代码";
  13356. }
  13357. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13358. {
  13359. Date = x.Date,
  13360. Days = x.Days,
  13361. Diffgroup = x.Diffgroup,
  13362. Diid = x.Diid,
  13363. Traffic_First = x.Traffic_First,
  13364. Traffic_Second = x.Traffic_Second,
  13365. Trip = x.Trip,
  13366. WeekDay = x.WeekDay,
  13367. Id = x.Id
  13368. }).ToList();
  13369. jw.Data = new
  13370. {
  13371. groupList = groupList.Select(x => new
  13372. {
  13373. x.Id,
  13374. x.TeamName,
  13375. x.TourCode
  13376. }).ToList(),
  13377. groupInfo = new
  13378. {
  13379. group.VisitDays,
  13380. group.TourCode,
  13381. group.VisitPNumber,
  13382. group.TeamName,
  13383. city
  13384. },
  13385. OpTravelList
  13386. };
  13387. jw.Code = 200;
  13388. jw.Msg = "操作成功!";
  13389. return Ok(jw);
  13390. }
  13391. /// <summary>
  13392. /// 删除团组行程单
  13393. /// </summary>
  13394. /// <returns></returns>
  13395. [HttpPost]
  13396. public IActionResult DelTravel(DelOpTravelDto dto)
  13397. {
  13398. var jw = JsonView(false);
  13399. if (dto.UserId <= 0 || dto.Diid <= 0)
  13400. {
  13401. jw.Msg = "请输入正确的参数!";
  13402. return Ok(jw);
  13403. }
  13404. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13405. .SetColumns(x => new Grp_TravelList
  13406. {
  13407. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13408. DeleteUserId = dto.UserId,
  13409. IsDel = 1,
  13410. }).ExecuteCommand();
  13411. jw = JsonView(true);
  13412. return Ok(jw);
  13413. }
  13414. /// <summary>
  13415. /// 行程单保存
  13416. /// </summary>
  13417. /// <returns></returns>
  13418. [HttpPost]
  13419. public IActionResult TravelSave(TravelSaveDto dto)
  13420. {
  13421. var jw = JsonView(false);
  13422. if (dto.Arr.Count > 0)
  13423. {
  13424. try
  13425. {
  13426. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13427. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13428. .ToList();
  13429. _sqlSugar.BeginTran();
  13430. foreach (var item in dto.Arr)
  13431. {
  13432. if (item.Id == 0)
  13433. {
  13434. throw new Exception("请传入正确的Id");
  13435. }
  13436. //比较上一次的差异
  13437. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13438. if (findTravel != null)
  13439. {
  13440. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13441. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13442. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13443. }
  13444. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13445. .SetColumns(x => new Grp_TravelList
  13446. {
  13447. Trip = item.Trip
  13448. }).ExecuteCommand();
  13449. }
  13450. _sqlSugar.CommitTran();
  13451. jw = JsonView(true);
  13452. }
  13453. catch (Exception ex)
  13454. {
  13455. _sqlSugar.RollbackTran();
  13456. jw.Msg = "程序异常!" + ex.Message;
  13457. }
  13458. }
  13459. else
  13460. {
  13461. jw.Msg = "请传入正确的参数!";
  13462. }
  13463. return Ok(jw);
  13464. }
  13465. private string CheckStr(string original, string changed)
  13466. {
  13467. // 创建diff_match_patch对象
  13468. var dmp = new diff_match_patch();
  13469. // 计算差异
  13470. List<Diff> diffs = dmp.diff_main(original, changed);
  13471. // 清理和合并差异
  13472. dmp.diff_cleanupSemantic(diffs);
  13473. // 使用StringBuilder构建最终的字符串
  13474. StringBuilder finalString = new StringBuilder();
  13475. // 输出差异结果,并构建变动后的字符串
  13476. foreach (Diff diff in diffs)
  13477. {
  13478. switch (diff.operation)
  13479. {
  13480. case Operation.EQUAL:
  13481. // 相等的部分,直接添加到最终字符串
  13482. finalString.Append(diff.text);
  13483. break;
  13484. case Operation.INSERT:
  13485. // 插入的部分,添加标记并添加到最终字符串
  13486. finalString.Append("[++]" + diff.text + "[++]");
  13487. break;
  13488. case Operation.DELETE:
  13489. // 删除的部分,不添加到最终字符串
  13490. //finalString.Append("[++]" + diff.text + "[++]");
  13491. break;
  13492. }
  13493. }
  13494. // 输出变动后的字符串
  13495. return finalString.ToString();
  13496. }
  13497. private class tagContent
  13498. {
  13499. public DateTime Date { get; set; }
  13500. public string StartTag { get; set; }
  13501. public string EndTag { get; set; }
  13502. public string Content { get; set; }
  13503. public static int tagLength { get { return 3; } }
  13504. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13505. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13506. public bool IsFinally { get; set; }
  13507. }
  13508. private List<string> ExtractContentBetweenTags(string input, string tag)
  13509. {
  13510. List<string> results = new List<string>();
  13511. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13512. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13513. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13514. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13515. string[] strValueArr = new string[1];
  13516. foreach (System.Text.RegularExpressions.Match match in matches)
  13517. {
  13518. var strValue = match.Groups[1].Value;
  13519. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13520. }
  13521. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13522. return results;
  13523. }
  13524. /// <summary>
  13525. /// 导出行程单
  13526. /// </summary>
  13527. /// <param name="dto"></param>
  13528. /// <returns></returns>
  13529. [HttpPost]
  13530. public IActionResult ExportTravel(ExportTravelDto dto)
  13531. {
  13532. var jw = JsonView(false);
  13533. jw.Data = "";
  13534. int diid = 0;
  13535. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13536. if (Find == null)
  13537. {
  13538. jw.Msg = "请选择正确的团组!";
  13539. return Ok(jw);
  13540. }
  13541. else
  13542. {
  13543. diid = Find.Id;
  13544. }
  13545. //数据源
  13546. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13547. DataTable dtBlack = null;
  13548. try
  13549. {
  13550. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13551. }
  13552. catch (Exception)
  13553. {
  13554. jw.Msg = "机票黑屏代码有误!";
  13555. return Ok(jw);
  13556. }
  13557. string CityStr = string.Empty;
  13558. if (dtBlack.Rows.Count == 0)
  13559. {
  13560. jw.Msg = "机票黑屏代码有误!";
  13561. return Ok(jw);
  13562. }
  13563. else
  13564. {
  13565. foreach (DataRow row in dtBlack.Rows)
  13566. {
  13567. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13568. {
  13569. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13570. return Ok(jw);
  13571. }
  13572. }
  13573. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13574. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13575. }
  13576. // 指定的文字
  13577. var targetTextDic = new Dictionary<string, List<string>>();
  13578. //创建数据源Table
  13579. DataTable dtSource = new DataTable();
  13580. dtSource.Columns.Add("Days", typeof(string));
  13581. dtSource.Columns.Add("Date", typeof(string));
  13582. dtSource.Columns.Add("Week", typeof(string));
  13583. dtSource.Columns.Add("Traffic", typeof(string));
  13584. dtSource.Columns.Add("Trip", typeof(string));
  13585. //获取数据,放到datatable
  13586. foreach (var item in _travelList)
  13587. {
  13588. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13589. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13590. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13591. .Replace("[++]", string.Empty);
  13592. DataRow dr = dtSource.NewRow();
  13593. dr["Days"] = item.Days;
  13594. dr["Date"] = item.Date;
  13595. dr["Week"] = item.WeekDay;
  13596. dr["Traffic"] = item.Traffic_First
  13597. + "\r\n"
  13598. + item.Traffic_Second;
  13599. dr["Trip"] = item.Trip;
  13600. dtSource.Rows.Add(dr);
  13601. }
  13602. Dictionary<string, string> dic = new Dictionary<string, string>();
  13603. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13604. dic.Add("City", CityStr);
  13605. dic.Add("Days", Find.VisitDays.ToString());
  13606. dic.Add("DeleCode", Find.TourCode);
  13607. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13608. //模板路径
  13609. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13610. //载入模板
  13611. Document doc = null;
  13612. DocumentBuilder builder = null;
  13613. try
  13614. {
  13615. //载入模板
  13616. doc = new Document(tempPath);
  13617. builder = new DocumentBuilder(doc);
  13618. }
  13619. catch (Exception)
  13620. {
  13621. jw.Msg = "模板位置不存在!";
  13622. return Ok(jw);
  13623. }
  13624. foreach (var key in dic.Keys)
  13625. {
  13626. Bookmark bookmark = doc.Range.Bookmarks[key];
  13627. if (bookmark != null)
  13628. {
  13629. builder.MoveToBookmark(key);
  13630. builder.Write(dic[key]);
  13631. }
  13632. }
  13633. //获取word里所有表格
  13634. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13635. //获取所填表格的序数
  13636. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13637. try
  13638. {
  13639. //循环赋值
  13640. for (int i = 0; i < dtSource.Rows.Count; i++)
  13641. {
  13642. builder.MoveToCell(0, i + 1, 0, 0);
  13643. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13644. builder.MoveToCell(0, i + 1, 1, 0);
  13645. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13646. builder.MoveToCell(0, i + 1, 2, 0);
  13647. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13648. var trip = dtSource.Rows[i]["Trip"].ToString();
  13649. builder.MoveToCell(0, i + 1, 3, 0);
  13650. builder.Write(trip);
  13651. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13652. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13653. // 获取特定索引的段落
  13654. Paragraph paragraph = (Paragraph)paragraphs[0];
  13655. Run run = paragraph.Runs[0];
  13656. Aspose.Words.Font font = run.Font;
  13657. font.Name = "黑体";
  13658. //设置双休红色
  13659. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13660. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13661. paragraph = (Paragraph)paragraphs[1];
  13662. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13663. {
  13664. run = paragraph.Runs[0];
  13665. font = run.Font;
  13666. font.Color = Color.Red;
  13667. }
  13668. }
  13669. }
  13670. catch (Exception ex)
  13671. {
  13672. }
  13673. //删除多余行
  13674. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13675. {
  13676. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13677. }
  13678. var targetTextList = new List<string>();
  13679. // 遍历文档中的表格
  13680. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13681. {
  13682. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13683. {
  13684. var cellIndex = 0;
  13685. foreach (Cell cell in row.Cells)
  13686. {
  13687. if (cellIndex == 1 && row.Cells.Count == 4)
  13688. {
  13689. foreach (var target in targetTextDic.Keys)
  13690. {
  13691. if (cell.GetText().Contains(target))
  13692. {
  13693. targetTextList = targetTextDic[target];
  13694. break;
  13695. }
  13696. }
  13697. }
  13698. // 遍历单元格中的所有段落
  13699. foreach (Paragraph paragraph in cell.Paragraphs)
  13700. {
  13701. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13702. List<Run> runs = new List<Run>();
  13703. foreach (Run run in paragraph.Runs)
  13704. {
  13705. runs.Add(run);
  13706. }
  13707. foreach (Run run in runs)
  13708. {
  13709. foreach (var targetText in targetTextList)
  13710. {
  13711. // 检查文字是否包含指定文字
  13712. if (run.Text.Contains(targetText))
  13713. {
  13714. // 将包含的部分设置为红色
  13715. HighlightText(run, targetText, Color.Red);
  13716. }
  13717. }
  13718. }
  13719. }
  13720. cellIndex++;
  13721. }
  13722. }
  13723. }
  13724. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13725. if (!Directory.Exists(savePath))
  13726. {
  13727. try
  13728. {
  13729. Directory.CreateDirectory(savePath);
  13730. }
  13731. catch
  13732. {
  13733. }
  13734. }
  13735. string path = savePath + Find.TeamName + "出访日程";
  13736. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13737. try
  13738. {
  13739. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13740. string postfix = ".docx";
  13741. if (dto.IsPDF == 1)
  13742. {
  13743. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13744. postfix = ".pdf";
  13745. }
  13746. doc.Save(path + postfix, saveFormat);
  13747. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13748. }
  13749. catch (Exception)
  13750. {
  13751. jw = JsonView(false);
  13752. }
  13753. return Ok(jw);
  13754. }
  13755. /// <summary>
  13756. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13757. /// </summary>
  13758. /// <param name="num"></param>
  13759. /// <returns></returns>
  13760. string GetNum(string num)
  13761. {
  13762. string str = "";
  13763. switch (num)
  13764. {
  13765. case "1":
  13766. str = "一";
  13767. break;
  13768. case "2":
  13769. str = "二";
  13770. break;
  13771. case "3":
  13772. str = "三";
  13773. break;
  13774. case "4":
  13775. str = "四";
  13776. break;
  13777. case "5":
  13778. str = "五";
  13779. break;
  13780. case "6":
  13781. str = "六";
  13782. break;
  13783. case "7":
  13784. str = "七";
  13785. break;
  13786. case "8":
  13787. str = "八";
  13788. break;
  13789. case "9":
  13790. str = "九";
  13791. break;
  13792. case "10":
  13793. str = "十";
  13794. break;
  13795. case "11":
  13796. str = "十一";
  13797. break;
  13798. case "12":
  13799. str = "十二";
  13800. break;
  13801. case "一":
  13802. str = "1";
  13803. break;
  13804. case "二":
  13805. str = "2";
  13806. break;
  13807. case "三":
  13808. str = "3";
  13809. break;
  13810. case "四":
  13811. str = "4";
  13812. break;
  13813. case "五":
  13814. str = "5";
  13815. break;
  13816. case "六":
  13817. str = "6";
  13818. break;
  13819. case "七":
  13820. str = "7";
  13821. break;
  13822. case "八":
  13823. str = "8";
  13824. break;
  13825. case "九":
  13826. str = "9";
  13827. break;
  13828. case "十":
  13829. str = "10";
  13830. break;
  13831. case "十一":
  13832. str = "11";
  13833. break;
  13834. case "十二":
  13835. str = "12";
  13836. break;
  13837. }
  13838. return str;
  13839. }
  13840. // 高亮包含指定文字的部分
  13841. void HighlightText(Run run, string targetText, Color color)
  13842. {
  13843. string text = run.Text;
  13844. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13845. if (startIndex >= 0)
  13846. {
  13847. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13848. // 前部分
  13849. if (startIndex > 0)
  13850. {
  13851. Run beforeRun = (Run)run.Clone(true);
  13852. beforeRun.Text = text.Substring(0, startIndex);
  13853. parentParagraph.InsertBefore(beforeRun, run);
  13854. }
  13855. // 匹配部分
  13856. Run matchRun = (Run)run.Clone(true);
  13857. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13858. matchRun.Font.Color = color;
  13859. parentParagraph.InsertBefore(matchRun, run);
  13860. // 后部分
  13861. if (startIndex + targetText.Length < text.Length)
  13862. {
  13863. Run afterRun = (Run)run.Clone(true);
  13864. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13865. parentParagraph.InsertBefore(afterRun, run);
  13866. }
  13867. // 删除原始Run
  13868. run.Remove();
  13869. }
  13870. }
  13871. #endregion
  13872. #endregion
  13873. #region 团组成本
  13874. /// <summary>
  13875. /// 团组成本数据初始化
  13876. /// </summary>
  13877. /// <param name="dto"></param>
  13878. /// <returns></returns>
  13879. [HttpPost]
  13880. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13881. {
  13882. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13883. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13884. WHEN COUNT(*) >= 0 THEN 'True'
  13885. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13886. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13887. ").ToList(); //团组列表
  13888. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13889. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13890. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13891. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13892. if (groupinfoValue != null)
  13893. {
  13894. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13895. var spArr = new string[1] { countryArr };
  13896. if (countryArr.Contains("|"))
  13897. {
  13898. spArr = countryArr.Split("|");
  13899. }
  13900. else if (countryArr.Contains("、"))
  13901. {
  13902. spArr = countryArr.Split("、");
  13903. }
  13904. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13905. {
  13906. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13907. if (dbQueryCountry != null)
  13908. {
  13909. visaCountryInfoArr.Add(dbQueryCountry);
  13910. }
  13911. }
  13912. }
  13913. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13914. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13915. #region 屏蔽黑屏代码生成
  13916. //var create = _GroupCostRepository.
  13917. // CreateGroupCostByBlackCode(dto.Diid);
  13918. //if (groupCost.Count == 0 && create.Code == 0)
  13919. //{
  13920. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13921. //}
  13922. #endregion
  13923. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13924. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13925. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13926. groupCostMap = groupCostMap.Select(x =>
  13927. {
  13928. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13929. {
  13930. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13931. }
  13932. return x;
  13933. }).ToList();
  13934. //GroupCostParameter.Add(new
  13935. // Grp_GroupCostParameter());
  13936. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13937. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13938. return Ok(JsonView(new
  13939. {
  13940. groupList,
  13941. groupInfo,
  13942. groupChecks,
  13943. groupCost = groupCostMap,
  13944. hotelNumber,
  13945. GroupCostParameter = GroupCostParameterMap,
  13946. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13947. {
  13948. x.VisaCountry,
  13949. x.VisaPrice,
  13950. x.Id,
  13951. }).ToList(),
  13952. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13953. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  13954. hotelIsTrue = hotelIsTrue,
  13955. }));
  13956. }
  13957. /// <summary>
  13958. /// 团组成本信息保存
  13959. /// </summary>
  13960. /// <param name="dto"></param>
  13961. /// <returns></returns>
  13962. [HttpPost]
  13963. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13964. {
  13965. if (dto.Diid <= 0 || dto.Userid <= 0)
  13966. {
  13967. return Ok(JsonView(false));
  13968. }
  13969. JsonView jw = null;
  13970. bool isTrue = false;
  13971. #region 复制团组成本
  13972. //if (dto.Diid == 2581)
  13973. //{
  13974. // dto.Diid = 2599;
  13975. // dto.CheckBoxs.ForEach(x =>
  13976. // {
  13977. // x.Diid = 2599;
  13978. // });
  13979. // dto.GroupCosts.ForEach(x =>
  13980. // {
  13981. // x.Diid = 2599;
  13982. // });
  13983. // dto.CostTypeHotelNumbers.ForEach(x =>
  13984. // {
  13985. // x.Diid = 2599;
  13986. // });
  13987. // dto.GroupCostParameters.ForEach(x =>
  13988. // {
  13989. // x.DiId = 2599;
  13990. // });
  13991. //}
  13992. #endregion
  13993. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13994. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13995. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13996. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13997. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13998. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13999. try
  14000. {
  14001. _sqlSugar.BeginTran();
  14002. isTrue = await _GroupCostRepository.
  14003. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14004. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14005. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14006. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14007. _sqlSugar.CommitTran();
  14008. jw = JsonView(true, "保存成功!", isTrue);
  14009. }
  14010. catch (Exception)
  14011. {
  14012. _sqlSugar.RollbackTran();
  14013. jw = JsonView(false);
  14014. }
  14015. return Ok(jw);
  14016. }
  14017. /// <summary>
  14018. /// 复制团组成本信息
  14019. /// </summary>
  14020. /// <param name="dto"></param>
  14021. /// <returns></returns>
  14022. [HttpPost]
  14023. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14024. {
  14025. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14026. {
  14027. return Ok(JsonView(false, "参数有误!"));
  14028. }
  14029. #region 复制团组成本
  14030. dto.Diid = dto.ToGroupId;
  14031. dto.CheckBoxs.ForEach(x =>
  14032. {
  14033. x.Diid = dto.ToGroupId;
  14034. });
  14035. dto.GroupCosts.ForEach(x =>
  14036. {
  14037. x.Diid = dto.ToGroupId;
  14038. });
  14039. dto.CostTypeHotelNumbers.ForEach(x =>
  14040. {
  14041. x.Diid = dto.ToGroupId;
  14042. });
  14043. dto.GroupCostParameters.ForEach(x =>
  14044. {
  14045. x.DiId = dto.ToGroupId;
  14046. });
  14047. #endregion
  14048. JsonView jw = null;
  14049. bool isTrue = false;
  14050. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14051. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14052. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14053. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14054. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14055. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14056. try
  14057. {
  14058. _sqlSugar.BeginTran();
  14059. isTrue = await _GroupCostRepository.
  14060. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14061. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14062. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14063. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14064. _sqlSugar.CommitTran();
  14065. jw = JsonView(true, "保存成功!", isTrue);
  14066. }
  14067. catch (Exception)
  14068. {
  14069. _sqlSugar.RollbackTran();
  14070. jw = JsonView(false);
  14071. }
  14072. return Ok(jw);
  14073. }
  14074. /// <summary>
  14075. /// 司兼导数据
  14076. /// </summary>
  14077. /// <param name="dto"></param>
  14078. /// <returns></returns>
  14079. [HttpPost]
  14080. public IActionResult GetCarGuides(CarGuidesDto dto)
  14081. {
  14082. JsonView jw = null;
  14083. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14084. jw = JsonView(true, "获取成功!", Data);
  14085. return Ok(jw);
  14086. }
  14087. /// <summary>
  14088. /// 导游数据
  14089. /// </summary>
  14090. /// <param name="dto"></param>
  14091. /// <returns></returns>
  14092. [HttpPost]
  14093. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14094. {
  14095. JsonView jw = null;
  14096. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14097. // 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
  14098. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14099. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14100. jw = JsonView(true, "获取成功!", Data);
  14101. return Ok(jw);
  14102. }
  14103. /// <summary>
  14104. /// 成本车数据
  14105. /// </summary>
  14106. /// <param name="dto"></param>
  14107. /// <returns></returns>
  14108. [HttpPost]
  14109. public IActionResult GetCarInfo(CarGuidesDto dto)
  14110. {
  14111. JsonView jw = null;
  14112. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14113. jw = JsonView(true, "获取成功!", Data);
  14114. return Ok(jw);
  14115. }
  14116. /// <summary>
  14117. /// 景点数据
  14118. /// </summary>
  14119. /// <param name="dto"></param>
  14120. /// <returns></returns>
  14121. [HttpPost]
  14122. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14123. {
  14124. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14125. return Ok(JsonView(true, "获取成功!", Data));
  14126. }
  14127. /// <summary>
  14128. /// 成本通知
  14129. /// </summary>
  14130. /// <param name="dto"></param>
  14131. /// <returns></returns>
  14132. [HttpPost]
  14133. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14134. {
  14135. if (dto.Diid < 0)
  14136. {
  14137. return Ok(JsonView(false));
  14138. }
  14139. JsonView jw = null;
  14140. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14141. if (GroupCostParameter != null)
  14142. {
  14143. int IsShare = 0;
  14144. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14145. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14146. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14147. string msg = string.Empty;
  14148. if (isTrue)
  14149. {
  14150. if (IsShare == 0)
  14151. {
  14152. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14153. }
  14154. else
  14155. {
  14156. #region 企微通知对应岗位用户
  14157. try
  14158. {
  14159. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14160. }
  14161. catch (Exception ex)
  14162. {
  14163. }
  14164. #endregion
  14165. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14166. }
  14167. jw = JsonView(isTrue, msg, new { IsShare });
  14168. }
  14169. else
  14170. {
  14171. msg = "修改失败!";
  14172. jw = JsonView(isTrue, msg);
  14173. }
  14174. }
  14175. else
  14176. {
  14177. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14178. }
  14179. return Ok(jw);
  14180. }
  14181. /// <summary>
  14182. /// 导出报价单
  14183. /// </summary>
  14184. /// <param name="dto"></param>
  14185. /// <returns></returns>
  14186. [HttpPost]
  14187. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14188. {
  14189. if (dto.Diid == 0)
  14190. {
  14191. return Ok(JsonView(false, "请传递团组id"));
  14192. }
  14193. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14194. if (deleInfo.Code != 0)
  14195. {
  14196. return Ok(JsonView(false, "团组信息查询失败!"));
  14197. }
  14198. var di = deleInfo.Data as DelegationInfoWebView;
  14199. if (di != null)
  14200. {
  14201. di.TeamName = di.TeamName.Replace("|", "、");
  14202. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14203. //文件名
  14204. string strFileName = di.TeamName + "-收款账单.doc";
  14205. //获取模板
  14206. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14207. //载入模板
  14208. Document doc = new Document(tmppath);
  14209. decimal TotalPrice = 0.00M;
  14210. string itemStr = string.Empty;
  14211. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14212. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14213. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14214. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14215. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14216. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14217. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14218. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14219. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14220. foreach (var cost in groupCostType)
  14221. {
  14222. var List = cost.ToList();
  14223. if (cost.Key == "A")
  14224. {
  14225. foreach (var ListItem in List)
  14226. {
  14227. if (ListItem.number > 0)
  14228. {
  14229. if (ListItem.code.Contains("TBR"))
  14230. {
  14231. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14232. }
  14233. else
  14234. {
  14235. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14236. }
  14237. TotalPrice += (ListItem.number * ListItem.price);
  14238. }
  14239. }
  14240. }
  14241. else
  14242. {
  14243. itemStr = itemStr.Insert(0, "A段\r\n");
  14244. itemStr += "B段\r\n";
  14245. foreach (var ListItem in List)
  14246. {
  14247. if (ListItem.number > 0)
  14248. {
  14249. if (ListItem.code.Contains("TBR"))
  14250. {
  14251. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14252. }
  14253. else
  14254. {
  14255. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14256. }
  14257. TotalPrice += (ListItem.number * ListItem.price);
  14258. }
  14259. }
  14260. }
  14261. }
  14262. #region 替换Word模板书签内容
  14263. Dictionary<string, string> marks = new Dictionary<string, string>();
  14264. marks.Add("To", di.ClientUnit);//付款方
  14265. marks.Add("ToTel", di.TellPhone);//付款方电话
  14266. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14267. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14268. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14269. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14270. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14271. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14272. marks.Add("PayItemContent", itemStr);//详细信息
  14273. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14274. #endregion
  14275. ////注
  14276. //if (doc.Range.Bookmarks["Attention"] != null)
  14277. //{
  14278. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14279. // mark.Text = frList[0].Attention;
  14280. //}
  14281. foreach (var item in marks.Keys)
  14282. {
  14283. if (doc.Range.Bookmarks[item] != null)
  14284. {
  14285. Bookmark mark = doc.Range.Bookmarks[item];
  14286. mark.Text = marks[item];
  14287. }
  14288. }
  14289. byte[] bytes = null;
  14290. using (MemoryStream stream = new MemoryStream())
  14291. {
  14292. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14293. bytes = stream.ToArray();
  14294. }
  14295. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14296. return Ok(JsonView(true, "", new
  14297. {
  14298. Data = bytes,
  14299. strFileName,
  14300. }));
  14301. }
  14302. else
  14303. {
  14304. return Ok(JsonView(false, "团组信息不存在!"));
  14305. }
  14306. }
  14307. /// <summary>
  14308. /// 导出团组成本
  14309. /// </summary>
  14310. /// <param name="dto"></param>
  14311. /// <returns></returns>
  14312. [HttpPost]
  14313. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14314. {
  14315. var jw = JsonView(false);
  14316. if (dto.Diid == 0)
  14317. {
  14318. return Ok(JsonView(false, "请传递团组id"));
  14319. }
  14320. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14321. if (deleInfo.Code != 0)
  14322. {
  14323. return Ok(JsonView(false, "团组信息查询失败!"));
  14324. }
  14325. var di = deleInfo.Data as DelegationInfoWebView;
  14326. if (di == null)
  14327. {
  14328. return Ok(JsonView(false, "团组信息查询失败!"));
  14329. }
  14330. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14331. WorkbookDesigner designer = new WorkbookDesigner();
  14332. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14333. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14334. for (int i = 0; i < List_GC.Count; i++)
  14335. {
  14336. GroupCost_Excel gc = new GroupCost_Excel();
  14337. gc.Id = List_GC[i].Id;
  14338. gc.Diid = List_GC[i].Diid.ToString();
  14339. gc.DAY = List_GC[i].DAY;
  14340. string week = "";
  14341. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14342. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14343. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14344. gc.ITIN = List_GC[i].ITIN;
  14345. gc.CarType = List_GC[i].CarType;
  14346. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14347. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14348. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14349. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14350. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14351. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14352. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14353. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14354. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14355. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14356. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14357. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14358. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14359. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14360. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14361. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14362. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14363. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14364. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14365. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14366. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14367. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14368. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14369. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14370. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14371. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14372. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14373. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14374. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14375. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14376. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14377. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14378. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14379. List_GC1.Add(gc);
  14380. }
  14381. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14382. dt.TableName = "TB";
  14383. //报表标题等不用dt的值
  14384. designer.SetDataSource("TeamName", dto.title.TeamName);
  14385. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14386. designer.SetDataSource("Tax", dto.title.Tax);
  14387. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14388. designer.SetDataSource("Currency", dto.title.Currency);
  14389. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14390. designer.SetDataSource("Rate", dto.title.Rate);
  14391. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14392. var Aparams = hotels.Find(x => x.Type == "Default");
  14393. if (Aparams == null)
  14394. {
  14395. return Ok(jw);
  14396. }
  14397. //酒店数量
  14398. var txtSGRNumber = Aparams.SGR.ToString();
  14399. var txtTBRNumber = Aparams.TBR.ToString();
  14400. var txtJSESNumber = Aparams.JSES.ToString();
  14401. var txtSUITENumbe = Aparams.SUITE.ToString();
  14402. if (dto.costType == "B")
  14403. {
  14404. Aparams = hotels.Find(x => x.Type == "A");
  14405. var Bparams = hotels.Find(x => x.Type == "B");
  14406. if (Aparams == null || Bparams == null)
  14407. {
  14408. return Ok(jw);
  14409. }
  14410. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14411. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14412. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14413. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14414. }
  14415. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14416. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14417. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14418. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14419. var ws = designer.Workbook.Worksheets[0];
  14420. int Row = List_GC.Count;
  14421. int startIndex = 11;
  14422. int HideRows = 0;
  14423. List<int> hideRowsList = new List<int>();
  14424. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14425. #region A段left数据
  14426. var left = dto.leftInfo.Find(x => x.Type == "A");
  14427. if (left == null)
  14428. {
  14429. return Ok(jw);
  14430. }
  14431. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14432. if (leftBindData != null)
  14433. {
  14434. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14435. designer.SetDataSource("VisaRS", leftBindData.rs);
  14436. designer.SetDataSource("VisaXS", leftBindData.xs);
  14437. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14438. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14439. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14440. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14441. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14442. }
  14443. else
  14444. {
  14445. hideRowsList.Add(Row + startIndex + HideRows);
  14446. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14447. }
  14448. HideRows += 2;
  14449. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14450. if (leftBindData != null)
  14451. {
  14452. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14453. designer.SetDataSource("BXRS", leftBindData.rs);
  14454. designer.SetDataSource("BXXS", leftBindData.xs);
  14455. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14456. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14457. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14458. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14459. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14460. }
  14461. else
  14462. {
  14463. hideRowsList.Add(Row + startIndex + HideRows);
  14464. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14465. }
  14466. HideRows += 2;
  14467. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14468. if (leftBindData != null)
  14469. {
  14470. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14471. designer.SetDataSource("HSRS", leftBindData.rs);
  14472. designer.SetDataSource("HSXS", leftBindData.xs);
  14473. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14474. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14475. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14476. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14477. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14478. }
  14479. else
  14480. {
  14481. hideRowsList.Add(Row + startIndex + HideRows);
  14482. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14483. }
  14484. HideRows += 2;
  14485. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14486. if (leftBindData != null)
  14487. {
  14488. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14489. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14490. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14491. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14492. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14493. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14494. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14495. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14496. }
  14497. else
  14498. {
  14499. hideRowsList.Add(Row + startIndex + HideRows);
  14500. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14501. }
  14502. HideRows += 2;
  14503. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14504. if (leftBindData != null)
  14505. {
  14506. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14507. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14508. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14509. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14510. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14511. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14512. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14513. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14514. }
  14515. else
  14516. {
  14517. hideRowsList.Add(Row + startIndex + HideRows);
  14518. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14519. }
  14520. HideRows += 2;
  14521. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14522. if (leftBindData != null)
  14523. {
  14524. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14525. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14526. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14527. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14528. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14529. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14530. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14531. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14532. }
  14533. else
  14534. {
  14535. hideRowsList.Add(Row + startIndex + HideRows);
  14536. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14537. }
  14538. HideRows += 2;
  14539. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14540. if (leftBindData != null)
  14541. {
  14542. ////TBR
  14543. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14544. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14545. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14546. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14547. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14548. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14549. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14550. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14551. }
  14552. else
  14553. {
  14554. hideRowsList.Add(Row + startIndex + HideRows);
  14555. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14556. }
  14557. HideRows += 2;
  14558. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14559. if (leftBindData != null)
  14560. {
  14561. ////SGR
  14562. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14563. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14564. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14565. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14566. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14567. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14568. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14569. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14570. }
  14571. else
  14572. {
  14573. hideRowsList.Add(Row + startIndex + HideRows);
  14574. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14575. }
  14576. HideRows += 2;
  14577. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14578. if (leftBindData != null)
  14579. {
  14580. ////JS/ES
  14581. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14582. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14583. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14584. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14585. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14586. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14587. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14588. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14589. }
  14590. else
  14591. {
  14592. hideRowsList.Add(Row + startIndex + HideRows);
  14593. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14594. }
  14595. HideRows += 2;
  14596. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14597. if (leftBindData != null)
  14598. {
  14599. ////SUITE
  14600. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14601. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14602. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14603. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14604. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14605. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14606. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14607. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14608. }
  14609. else
  14610. {
  14611. hideRowsList.Add(Row + startIndex + HideRows);
  14612. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14613. }
  14614. HideRows += 2;
  14615. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14616. if (leftBindData != null)
  14617. {
  14618. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14619. designer.SetDataSource("DJRS", leftBindData.rs);
  14620. designer.SetDataSource("DJXS", leftBindData.xs);
  14621. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14622. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14623. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14624. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14625. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14626. }
  14627. else
  14628. {
  14629. hideRowsList.Add(Row + startIndex + HideRows);
  14630. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14631. }
  14632. HideRows += 2;
  14633. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14634. if (leftBindData != null)
  14635. {
  14636. designer.SetDataSource("HCPCB", leftBindData.cb);
  14637. designer.SetDataSource("HCPRS", leftBindData.rs);
  14638. designer.SetDataSource("HCPXS", leftBindData.xs);
  14639. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14640. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14641. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14642. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14643. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14644. }
  14645. else
  14646. {
  14647. hideRowsList.Add(Row + startIndex + HideRows);
  14648. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14649. }
  14650. HideRows += 2;
  14651. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14652. if (leftBindData != null)
  14653. {
  14654. designer.SetDataSource("CPCB", leftBindData.cb);
  14655. designer.SetDataSource("CPRS", leftBindData.rs);
  14656. designer.SetDataSource("CPXS", leftBindData.xs);
  14657. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14658. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14659. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14660. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14661. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14662. }
  14663. else
  14664. {
  14665. hideRowsList.Add(Row + startIndex + HideRows);
  14666. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14667. }
  14668. HideRows += 2;
  14669. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14670. if (leftBindData != null)
  14671. {
  14672. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14673. designer.SetDataSource("GWRS", leftBindData.rs);
  14674. designer.SetDataSource("GWXS", leftBindData.xs);
  14675. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14676. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14677. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14678. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14679. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14680. }
  14681. else
  14682. {
  14683. hideRowsList.Add(Row + startIndex + HideRows);
  14684. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14685. }
  14686. HideRows += 2;
  14687. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14688. if (leftBindData != null)
  14689. {
  14690. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14691. designer.SetDataSource("LYJRS", leftBindData.rs);
  14692. designer.SetDataSource("LYJXS", leftBindData.xs);
  14693. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14694. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14695. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14696. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14697. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14698. }
  14699. else
  14700. {
  14701. hideRowsList.Add(Row + startIndex + HideRows);
  14702. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14703. }
  14704. #endregion
  14705. #region A段Right信息
  14706. var right = dto.rightInfo.Find(x => x.Type == "A");
  14707. if (right == null)
  14708. {
  14709. return Ok(jw);
  14710. }
  14711. HideRows += 4;
  14712. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14713. if (rightBindData != null)
  14714. {
  14715. //经济舱 + 双人间 TBR
  14716. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14717. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14718. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14719. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14720. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14721. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14722. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14723. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14724. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14725. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14726. }
  14727. else
  14728. {
  14729. hideRowsList.Add(Row + startIndex + HideRows);
  14730. }
  14731. HideRows += 2;
  14732. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14733. if (rightBindData != null)
  14734. {
  14735. //经济舱 + 单人间 SGR
  14736. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14737. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14738. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14739. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14740. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14741. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14742. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14743. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14744. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14745. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14746. }
  14747. else
  14748. {
  14749. hideRowsList.Add(Row + startIndex + HideRows);
  14750. }
  14751. HideRows += 2;
  14752. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14753. if (rightBindData != null)
  14754. {
  14755. //公务舱 + 单人间 SGR
  14756. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14757. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14758. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14759. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14760. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14761. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14762. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14763. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14764. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14765. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14766. }
  14767. else
  14768. {
  14769. hideRowsList.Add(Row + startIndex + HideRows);
  14770. }
  14771. HideRows += 2;
  14772. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14773. if (rightBindData != null)
  14774. {
  14775. //公务舱 + 小套房 JSES
  14776. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14777. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14778. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14779. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14780. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14781. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14782. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14783. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14784. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14785. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14786. }
  14787. else
  14788. {
  14789. hideRowsList.Add(Row + startIndex + HideRows);
  14790. }
  14791. HideRows += 2;
  14792. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14793. if (rightBindData != null)
  14794. {
  14795. //公务舱 + 小套房 JSES
  14796. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14797. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14798. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14799. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14800. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14801. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14802. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14803. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14804. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14805. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14806. }
  14807. else
  14808. {
  14809. hideRowsList.Add(Row + startIndex + HideRows);
  14810. }
  14811. HideRows += 2;
  14812. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14813. if (rightBindData != null)
  14814. {
  14815. //经济舱 + 大套房
  14816. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14817. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14818. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14819. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14820. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14821. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14822. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14823. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14824. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14825. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14826. }
  14827. else
  14828. {
  14829. hideRowsList.Add(Row + startIndex + HideRows);
  14830. }
  14831. HideRows += 2;
  14832. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14833. if (rightBindData != null)
  14834. {
  14835. //头等舱 + 小套房 JSES
  14836. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14837. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14838. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14839. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14840. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14841. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14842. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14843. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14844. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14845. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14846. }
  14847. else
  14848. {
  14849. hideRowsList.Add(Row + startIndex + HideRows);
  14850. }
  14851. HideRows += 2;
  14852. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14853. if (rightBindData != null)
  14854. {
  14855. //头等舱 + 大套房
  14856. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14857. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14858. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14859. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14860. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14861. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14862. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14863. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14864. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14865. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14866. }
  14867. else
  14868. {
  14869. hideRowsList.Add(Row + startIndex + HideRows);
  14870. }
  14871. #endregion
  14872. #region B段标题清空
  14873. designer.SetDataSource("CostBDRCB", "");
  14874. designer.SetDataSource("CostBRS", "");
  14875. designer.SetDataSource("CostBXS", "");
  14876. designer.SetDataSource("CostBZCB", "");
  14877. designer.SetDataSource("CostBDRBJ", "");
  14878. designer.SetDataSource("CostBZBJ", "");
  14879. designer.SetDataSource("CostBDRLR", "");
  14880. designer.SetDataSource("CostBZLR", "");
  14881. designer.SetDataSource("CostBDRCBOM", "");
  14882. designer.SetDataSource("CostBRSOM", "");
  14883. designer.SetDataSource("CostBZCBOM", "");
  14884. designer.SetDataSource("CostBDRBJOM", "");
  14885. designer.SetDataSource("CostBZBJOM", "");
  14886. designer.SetDataSource("CostBDRLROM", "");
  14887. designer.SetDataSource("CostBZLROM", "");
  14888. #endregion
  14889. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14890. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14891. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14892. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14893. designer.SetDataSource("DJName", "地接(CNY)");
  14894. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14895. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14896. designer.SetDataSource("GWName", "公务(CNY)");
  14897. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14898. designer.SetDataSource("LYJName", "零用金(CNY)");
  14899. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14900. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14901. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14902. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14903. designer.SetDataSource("BXName", "保险(CNY)");
  14904. designer.SetDataSource("VisaName", "签证(CNY)");
  14905. #region B段基本数据
  14906. if (dto.costType == "B")
  14907. {
  14908. left = dto.leftInfo.Find(x => x.Type == "B");
  14909. if (left == null)
  14910. {
  14911. return Ok(jw);
  14912. }
  14913. #region B段left数据
  14914. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14915. if (leftBindData != null)
  14916. {
  14917. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14918. designer.SetDataSource("BHSRS", leftBindData.rs);
  14919. designer.SetDataSource("BHSXS", leftBindData.xs);
  14920. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14921. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14922. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14923. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14924. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14925. }
  14926. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14927. if (leftBindData != null)
  14928. {
  14929. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14930. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14931. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14932. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14933. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14934. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14935. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14936. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14937. }
  14938. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14939. if (leftBindData != null)
  14940. {
  14941. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14942. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14943. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14944. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14945. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14946. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14947. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14948. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14949. }
  14950. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14951. if (leftBindData != null)
  14952. {
  14953. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14954. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14955. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14956. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14957. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14958. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14959. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14960. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14961. }
  14962. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14963. if (leftBindData != null)
  14964. {
  14965. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14966. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14967. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14968. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14969. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14970. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14971. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14972. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14973. }
  14974. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14975. if (leftBindData != null)
  14976. {
  14977. designer.SetDataSource("BCPCB", leftBindData.cb);
  14978. designer.SetDataSource("BCPRS", leftBindData.rs);
  14979. designer.SetDataSource("BCPXS", leftBindData.xs);
  14980. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14981. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14982. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14983. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14984. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14985. }
  14986. //TBR
  14987. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14988. if (leftBindData != null)
  14989. {
  14990. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14991. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14992. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14993. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14994. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14995. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14996. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14997. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14998. }
  14999. //SGR
  15000. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15001. if (leftBindData != null)
  15002. {
  15003. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15004. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15005. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15006. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15007. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15008. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15009. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15010. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15011. }
  15012. //JS/ES
  15013. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15014. if (leftBindData != null)
  15015. {
  15016. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15017. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15018. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15019. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15020. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15021. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15022. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15023. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15024. }
  15025. //SUITE
  15026. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15027. if (leftBindData != null)
  15028. {
  15029. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15030. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15031. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15032. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15033. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15034. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15035. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15036. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15037. }
  15038. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15039. if (leftBindData != null)
  15040. {
  15041. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15042. designer.SetDataSource("BDJRS", leftBindData.rs);
  15043. designer.SetDataSource("BDJXS", leftBindData.xs);
  15044. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15045. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15046. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15047. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15048. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15049. }
  15050. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15051. if (leftBindData != null)
  15052. {
  15053. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15054. designer.SetDataSource("BGWRS", leftBindData.rs);
  15055. designer.SetDataSource("BGWXS", leftBindData.xs);
  15056. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15057. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15058. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15059. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15060. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15061. }
  15062. #region 优化方案
  15063. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15064. //excelBind.Add("零用金", new {
  15065. //cb="",
  15066. //rs="",
  15067. //xs ="",
  15068. //zcb = "",
  15069. //});
  15070. #endregion
  15071. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15072. if (leftBindData != null)
  15073. {
  15074. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15075. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15076. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15077. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15078. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15079. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15080. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15081. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15082. }
  15083. #endregion
  15084. #region B段Right信息
  15085. right = dto.rightInfo.Find(x => x.Type == "B");
  15086. if (right == null)
  15087. {
  15088. return Ok(jw);
  15089. }
  15090. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15091. if (rightBindData != null)
  15092. {
  15093. //经济舱 + 双人间 TBR
  15094. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15095. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15096. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15097. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15098. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15099. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15100. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15101. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15102. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15103. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15104. }
  15105. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15106. if (rightBindData != null)
  15107. {
  15108. //经济舱 + 单人间 SGR
  15109. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15110. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15111. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15112. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15113. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15114. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15115. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15116. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15117. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15118. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15119. }
  15120. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15121. if (rightBindData != null)
  15122. {
  15123. //公务舱 + 单人间 SGR
  15124. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15125. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15126. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15127. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15128. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15129. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15130. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15131. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15132. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15133. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15134. }
  15135. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15136. if (rightBindData != null)
  15137. {
  15138. //公务舱 + 小套房 JSES
  15139. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15140. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15141. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15142. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15143. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15144. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15145. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15146. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15147. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15148. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15149. }
  15150. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15151. if (rightBindData != null)
  15152. {
  15153. //公务舱 + 小套房 JSES
  15154. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15155. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15156. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15157. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15158. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15159. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15160. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15161. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15162. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15163. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15164. }
  15165. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15166. if (rightBindData != null)
  15167. {
  15168. //经济舱 + 大套房
  15169. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15170. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15171. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15172. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15173. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15174. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15175. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15176. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15177. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15178. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15179. }
  15180. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15181. if (rightBindData != null)
  15182. {
  15183. //头等舱 + 小套房 JSES
  15184. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15185. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15186. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15187. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15188. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15189. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15190. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15191. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15192. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15193. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15194. }
  15195. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15196. if (rightBindData != null)
  15197. {
  15198. //头等舱 + 大套房
  15199. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15200. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15201. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15202. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15203. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15204. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15205. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15206. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15207. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15208. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15209. }
  15210. #endregion
  15211. #region 标题
  15212. designer.SetDataSource("CostBDRCB", "单人成本");
  15213. designer.SetDataSource("CostBRS", "人数");
  15214. designer.SetDataSource("CostBXS", "系数");
  15215. designer.SetDataSource("CostBZCB", "总成本");
  15216. designer.SetDataSource("CostBDRBJ", "单人报价");
  15217. designer.SetDataSource("CostBZBJ", "总报价");
  15218. designer.SetDataSource("CostBDRLR", "单人利润");
  15219. designer.SetDataSource("CostBZLR", "总利润");
  15220. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15221. designer.SetDataSource("CostBRSOM", "人数");
  15222. designer.SetDataSource("CostBZCBOM", "总成本");
  15223. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15224. designer.SetDataSource("CostBZBJOM", "总报价");
  15225. designer.SetDataSource("CostBDRLROM", "单人利润");
  15226. designer.SetDataSource("CostBZLROM", "总利润");
  15227. #endregion
  15228. }
  15229. #endregion
  15230. designer.SetDataSource("TzZCB2", TzZCB2);
  15231. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15232. designer.SetDataSource("TzZLR2", TzZLR2);
  15233. string[] dataSourceKeys = new string[]
  15234. {
  15235. "VF",
  15236. "TGS",
  15237. "TGOF",
  15238. "TGM",
  15239. "TGA",
  15240. "TGTF",
  15241. "TGEF",
  15242. "CFM",
  15243. "CFOF",
  15244. "B",
  15245. "L",
  15246. "D",
  15247. "TBR",
  15248. "SGR",
  15249. "JSES",
  15250. "Suite",
  15251. "TV",
  15252. "1L",
  15253. "IF",
  15254. "EF",
  15255. "BRF",
  15256. "TE",
  15257. "TGT",
  15258. "DRVT",
  15259. "PC",
  15260. "TLF",
  15261. "ECT"
  15262. };
  15263. foreach (var item in dataSourceKeys)
  15264. {
  15265. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15266. if (find != null)
  15267. {
  15268. designer.SetDataSource(item, find.text);
  15269. }
  15270. else
  15271. {
  15272. designer.SetDataSource(item, 0);
  15273. }
  15274. }
  15275. designer.SetDataSource(dt);
  15276. //根据数据源处理生成报表内容
  15277. designer.Process();
  15278. designer.Workbook.Worksheets[0].Name = "清单";
  15279. Worksheet sheet = designer.Workbook.Worksheets[0];
  15280. foreach (var Rowindex in hideRowsList)
  15281. {
  15282. ws.Cells.HideRows(Rowindex, 2);
  15283. }
  15284. byte[] bytes = null;
  15285. string strFileName = di.TeamName + "-团组-成本.xls";
  15286. using (MemoryStream stream = new MemoryStream())
  15287. {
  15288. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15289. bytes = stream.ToArray();
  15290. }
  15291. return Ok(JsonView(true, "", new
  15292. {
  15293. Data = bytes,
  15294. strFileName,
  15295. }));
  15296. }
  15297. /// <summary>
  15298. /// 导出客户报表
  15299. /// </summary>
  15300. /// <returns></returns>
  15301. [HttpPost]
  15302. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15303. {
  15304. var jw = JsonView(false);
  15305. if (dto.Diid == 0)
  15306. {
  15307. return Ok(JsonView(false, "请传递团组id"));
  15308. }
  15309. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15310. if (deleInfo.Code != 0)
  15311. {
  15312. return Ok(JsonView(false, "团组信息查询失败!"));
  15313. }
  15314. var di = deleInfo.Data as DelegationInfoWebView;
  15315. if (di == null)
  15316. {
  15317. return Ok(JsonView(false, "团组信息查询失败!"));
  15318. }
  15319. //文件名
  15320. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15321. //获取模板
  15322. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15323. //载入模板
  15324. Document doc = new Document(tmppath);
  15325. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15326. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15327. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15328. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15329. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15330. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15331. if (AParameter == null)
  15332. {
  15333. return Ok(JsonView(false, "系数不存在!"));
  15334. }
  15335. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15336. , TzAirDesc, TzZCost;
  15337. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15338. = TzAirDesc = TzZCost = string.Empty;
  15339. TzNumber = AParameter.CostTypenumber.ToString();
  15340. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15341. CarGuides1 = dto.CarGuides1;
  15342. Meal = dto.Meal;
  15343. SubsidizedMeals = dto.SubsidizedMeals;
  15344. NightRepair = dto.NightRepair;
  15345. AttractionsTickets = dto.AttractionsTickets;
  15346. MiscellaneousFees = dto.MiscellaneousFees;
  15347. ATip = dto.ATip;
  15348. TzHotelDesc = "";
  15349. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15350. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15351. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15352. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15353. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15354. TzAirDesc = "";
  15355. TzZCost = dto.TzZCost;
  15356. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15357. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15358. var index = 1;
  15359. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15360. foreach (var item in TzHotelDescArr)
  15361. {
  15362. if (AinfoArr != null)
  15363. {
  15364. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15365. if (Ainfo != null)
  15366. {
  15367. if (int.Parse(Ainfo.rs) <= 0)
  15368. {
  15369. continue;
  15370. }
  15371. var hotelText = string.Empty;
  15372. switch (item)
  15373. {
  15374. case "SGR":
  15375. hotelText = "单人间";
  15376. break;
  15377. case "JSES":
  15378. hotelText = "小套房";
  15379. break;
  15380. case "SUITE":
  15381. hotelText = "套房";
  15382. break;
  15383. case "TBR":
  15384. hotelText = "双人间";
  15385. break;
  15386. }
  15387. if (item != "TBR")
  15388. {
  15389. 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";
  15390. }
  15391. else
  15392. {
  15393. 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";
  15394. }
  15395. index++;
  15396. }
  15397. }
  15398. }
  15399. index = 1;
  15400. foreach (var item in TzAirDescArr)
  15401. {
  15402. if (AinfoArr != null)
  15403. {
  15404. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15405. if (Ainfo != null)
  15406. {
  15407. if (int.Parse(Ainfo.rs) <= 0)
  15408. {
  15409. continue;
  15410. }
  15411. 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";
  15412. index++;
  15413. }
  15414. }
  15415. }
  15416. if (dto.costType == "B")
  15417. {
  15418. if (BParameter == null)
  15419. {
  15420. return Ok(JsonView(false, "B段系数不存在!"));
  15421. }
  15422. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15423. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15424. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15425. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15426. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15427. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15428. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15429. foreach (var item in TzHotelDescArr)
  15430. {
  15431. if (AinfoArr != null)
  15432. {
  15433. TzHotelDesc += "B段信息 \r\n";
  15434. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15435. if (Ainfo != null)
  15436. {
  15437. if (int.Parse(Ainfo.rs) <= 0)
  15438. {
  15439. continue;
  15440. }
  15441. var hotelText = string.Empty;
  15442. switch (item)
  15443. {
  15444. case "SGR":
  15445. hotelText = "单人间";
  15446. break;
  15447. case "JSES":
  15448. hotelText = "小套房";
  15449. break;
  15450. case "SUITE":
  15451. hotelText = "套房";
  15452. break;
  15453. case "TBR":
  15454. hotelText = "双人间";
  15455. break;
  15456. }
  15457. if (item != "TBR")
  15458. {
  15459. 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";
  15460. }
  15461. else
  15462. {
  15463. 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";
  15464. }
  15465. index++;
  15466. }
  15467. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15468. }
  15469. }
  15470. index = 1;
  15471. foreach (var item in TzAirDescArr)
  15472. {
  15473. if (AinfoArr != null)
  15474. {
  15475. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15476. if (Ainfo != null)
  15477. {
  15478. if (int.Parse(Ainfo.rs) <= 0)
  15479. {
  15480. continue;
  15481. }
  15482. 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";
  15483. index++;
  15484. }
  15485. }
  15486. }
  15487. }
  15488. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15489. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15490. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15491. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15492. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15493. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15494. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15495. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15496. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15497. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15498. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15499. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15500. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15501. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15502. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15503. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15504. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15505. DickeyValue.Add("TzZCost", TzZCost);
  15506. foreach (var key in DickeyValue.Keys)
  15507. {
  15508. if (doc.Range.Bookmarks[key] != null)
  15509. {
  15510. Bookmark mark = doc.Range.Bookmarks[key];
  15511. mark.Text = DickeyValue[key];
  15512. }
  15513. }
  15514. byte[] bytes = null;
  15515. string strFileName = di.TeamName + "-客户报价.doc";
  15516. using (MemoryStream stream = new MemoryStream())
  15517. {
  15518. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15519. bytes = stream.ToArray();
  15520. }
  15521. return Ok(JsonView(true, "", new
  15522. {
  15523. Data = bytes,
  15524. strFileName,
  15525. }));
  15526. }
  15527. /// <summary>
  15528. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15529. /// </summary>
  15530. /// <param name="dto"></param>
  15531. /// <returns></returns>
  15532. [HttpPost]
  15533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15534. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15535. {
  15536. try
  15537. {
  15538. #region 参数验证
  15539. if (dto.DiId < 0)
  15540. {
  15541. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15542. }
  15543. List<int> cTableIds = new List<int>() {
  15544. 76 ,//酒店预订
  15545. 77 ,//行程
  15546. 79 ,//车/导游地接
  15547. 80 ,//签证
  15548. 81 ,//邀请/公务活
  15549. 82 ,//团组客户保险
  15550. 85 ,//机票预订
  15551. 98 ,//其他款项
  15552. 285 ,//收款退还
  15553. 751 ,//酒店早餐
  15554. 1015 // 超支费用
  15555. };
  15556. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15557. {
  15558. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15559. }
  15560. #endregion
  15561. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15562. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15563. if (_GroupCostParameters.Count <= 0)
  15564. {
  15565. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15566. }
  15567. if (_GroupCostParameters[0].IsShare == 0)
  15568. {
  15569. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15570. }
  15571. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15572. //处理date为空问题
  15573. if (_GroupCosts.Count > 0)
  15574. {
  15575. for (int i = 0; i < _GroupCosts.Count; i++)
  15576. {
  15577. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15578. {
  15579. if (i > 0)
  15580. {
  15581. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15582. }
  15583. }
  15584. }
  15585. }
  15586. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15587. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15588. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15589. string currCode = "";
  15590. #region currCode 验证
  15591. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15592. if (isInt)
  15593. {
  15594. var currData = currDatas.Find(it => it.Id == intCurrency);
  15595. if (currData != null)
  15596. {
  15597. currCode = currData.Name;
  15598. }
  15599. }
  15600. else
  15601. {
  15602. currCode = _GroupCostParameters[0].Currency.Trim();
  15603. }
  15604. #endregion
  15605. //op,酒店单段模式存储
  15606. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15607. {
  15608. CurrencyCode = currCode,
  15609. Rate = _GroupCostParameters[0].Rate,
  15610. CostType = _GroupCostParameters[0].CostType,
  15611. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15612. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15613. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15614. };
  15615. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15616. if (_GroupCostParameters.Count == 2)
  15617. {
  15618. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15619. }
  15620. foreach (var item in _GroupCostParameters)
  15621. {
  15622. decimal _rate = 1;
  15623. decimal _rate1 = item.Rate;
  15624. decimal _scale = 1;
  15625. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15626. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15627. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15628. //if (userInfo != null)
  15629. //{
  15630. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15631. // {
  15632. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15633. // {
  15634. // _scale = 1.00M;
  15635. // }
  15636. // }
  15637. //}
  15638. #endregion
  15639. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15640. {
  15641. CurrencyCode = currCode,
  15642. Rate = _rate1,
  15643. CostType = item.CostType,
  15644. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15645. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15646. CostTypeNumber = item.CostTypenumber
  15647. };
  15648. if (_GroupCostParameters.Count > 1)
  15649. {
  15650. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15651. }
  15652. else
  15653. {
  15654. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15655. }
  15656. if (dto.CTable == 79)//
  15657. {
  15658. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15659. modulePromptInfo.TotalCost = item.DJCB;
  15660. }
  15661. List<string> costTypes = new List<string>() { "A", "B" };
  15662. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15663. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15664. if (_GroupCostsDuplicates.Count() == 1)
  15665. {
  15666. _GroupCostsTypeData = _GroupCosts;
  15667. }
  15668. else
  15669. {
  15670. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15671. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15672. }
  15673. /*
  15674. * 76 酒店预订
  15675. * 77 行程
  15676. * 79 车/导游地接
  15677. * 80 签证
  15678. * 81 邀请/公务活动
  15679. * 82 团组客户保险
  15680. * 85 机票预订
  15681. * 98 其他款项
  15682. * 285 收款退还
  15683. * 751 酒店早餐
  15684. * 1015 超支费用
  15685. */
  15686. switch (dto.CTable)
  15687. {
  15688. case 76: // 酒店预订
  15689. _ModuleSubPromptInfo.AddRange(
  15690. _GroupCostsTypeData.Select(it => new
  15691. {
  15692. it.DAY,
  15693. it.Date,
  15694. it.ACCON,
  15695. it.ITIN,
  15696. it.SGR,
  15697. it.TBR,
  15698. it.JS_ES,
  15699. it.Suite
  15700. })
  15701. );
  15702. break;
  15703. case 79: // 车/导游地接
  15704. _ModuleSubPromptInfo.AddRange(
  15705. _GroupCostsTypeData.Select(it => new
  15706. {
  15707. Date = it.Date, //日期
  15708. CarFee = it.CarCost * _rate * _scale, //车费用
  15709. CarType = it.CarType, //车型
  15710. DriverFee = it.CFS * _rate * _scale, //司机工资
  15711. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15712. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15713. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15714. GuideFee = it.TGS * _rate * _scale, //导游费用
  15715. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15716. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15717. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15718. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15719. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15720. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15721. Breakfast = it.B * _rate * _scale, //早餐费
  15722. Lunch = it.L * _rate * _scale, //午餐费
  15723. Dinner = it.D * _rate * _scale, //晚餐费
  15724. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15725. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15726. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15727. TicketFee = it.EF * _rate * _scale, //门票费
  15728. TicketRemark = it.EFR, //门票费描述
  15729. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15730. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15731. SpentCash = it.PC * _rate * _scale, //零用金
  15732. LeadersFee = it.TLF * _rate * _scale, //领队费
  15733. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15734. })
  15735. );
  15736. break;
  15737. case 85: // 机票
  15738. List<dynamic> datas = new List<dynamic>();
  15739. datas.Add(
  15740. new
  15741. {
  15742. AirType = "经济舱",
  15743. AirNum = item.JJCRS,
  15744. AirDRCB = item.JJCCB,
  15745. AirZCB = (item.JJCRS * item.JJCCB)
  15746. }
  15747. );
  15748. datas.Add(
  15749. new
  15750. {
  15751. AirType = "公务舱",
  15752. AirNum = item.GWCRS,
  15753. AirDRCB = item.GWCCB,
  15754. AirZCB = (item.GWCRS * item.GWCCB)
  15755. }
  15756. );
  15757. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15758. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15759. modulePromptInfo.Data = new
  15760. {
  15761. airFeeData = datas,
  15762. airInitData = initDatas
  15763. };
  15764. _ModulePromptInfos.Add(modulePromptInfo);
  15765. break;
  15766. default:
  15767. break;
  15768. }
  15769. }
  15770. if (dto.CTable != 85)
  15771. {
  15772. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15773. _ModulePromptInfos.Add(_ModulePromptInfo);
  15774. }
  15775. _view.ModulePromptInfos = _ModulePromptInfos;
  15776. return Ok(JsonView(true, "操作成功!", _view));
  15777. }
  15778. catch (Exception ex)
  15779. {
  15780. return Ok(JsonView(false, ex.Message));
  15781. }
  15782. }
  15783. /// <summary>
  15784. /// 根据黑屏代码重新生成行程
  15785. /// </summary>
  15786. /// <param name="dto"></param>
  15787. /// <returns></returns>
  15788. [HttpPost]
  15789. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15790. {
  15791. var jw = JsonView(false, "Error");
  15792. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15793. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15794. .Select(x => new
  15795. {
  15796. x.Id,
  15797. x.Title
  15798. })
  15799. .ToList();
  15800. if (Create.Any())
  15801. {
  15802. jw.Msg = "获取成功!";
  15803. jw.Code = 200;
  15804. jw.Data = new
  15805. {
  15806. BlackCodeListSelect = Create,
  15807. blackCodeIsTrue = true
  15808. };
  15809. }
  15810. else
  15811. {
  15812. jw.Code = 400;
  15813. jw.Data = new
  15814. {
  15815. BlackCodeListSelect = Create,
  15816. blackCodeIsTrue = false,
  15817. };
  15818. }
  15819. return Ok(jw);
  15820. }
  15821. /// <summary>
  15822. /// 根据黑屏代码Id重新生成行程
  15823. /// </summary>
  15824. /// <param name="dto"></param>
  15825. /// <returns></returns>
  15826. [HttpPost]
  15827. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15828. {
  15829. var jw = JsonView(false, "Error");
  15830. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15831. if (result.Code == 0)
  15832. {
  15833. jw.Msg = "获取成功!";
  15834. jw.Code = 200;
  15835. jw.Data = new
  15836. {
  15837. groupCost = result.Data,
  15838. blackCodeIsTrue = true
  15839. };
  15840. }
  15841. else
  15842. {
  15843. jw.Code = 400;
  15844. jw.Data = new
  15845. {
  15846. groupCost = result.Data,
  15847. blackCodeIsTrue = false,
  15848. };
  15849. }
  15850. return Ok(jw);
  15851. }
  15852. /// <summary>
  15853. /// 成本获取OP历史车费用
  15854. /// </summary>
  15855. /// <param name="dto"></param>
  15856. /// <returns></returns>
  15857. [HttpPost]
  15858. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15859. {
  15860. var jw = JsonView(false);
  15861. try
  15862. {
  15863. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15864. //获取现有所有车的数据
  15865. if (!dto.Param.IsNullOrWhiteSpace())
  15866. {
  15867. string sql = $@"
  15868. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15869. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15870. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15871. 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
  15872. AND gctggr.ServiceEndTime is not NULL
  15873. ORDER by gctggrc.id DESC
  15874. ";
  15875. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15876. var numeberResult = await Task.Run(() =>
  15877. {
  15878. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15879. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15880. return numberArr;
  15881. });
  15882. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15883. foreach (var item in numeberResult)
  15884. {
  15885. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15886. {
  15887. Country = "数据异常!",
  15888. City = string.Empty,
  15889. };
  15890. item.Area = find.Country + " " + find.City;
  15891. }
  15892. dbResult.AddRange(numeberResult);
  15893. if (dto.Param.Contains("、"))
  15894. {
  15895. var sp = dto.Param.Split("、");
  15896. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15897. .Where(x =>
  15898. {
  15899. return System.Array.Exists(sp, e =>
  15900. {
  15901. bool where = false;
  15902. if (x.Area != null)
  15903. {
  15904. where = x.Area.Contains(e);
  15905. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15906. {
  15907. return false;
  15908. }
  15909. }
  15910. if (x.PriceName != null && !where)
  15911. {
  15912. where = x.PriceName.Contains(e);
  15913. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15914. {
  15915. return false;
  15916. }
  15917. }
  15918. return where;
  15919. });
  15920. }).ToList();
  15921. }
  15922. else
  15923. {
  15924. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15925. .Where(x =>
  15926. {
  15927. bool where = false;
  15928. if (x.Area != null)
  15929. {
  15930. where = x.Area.Contains(dto.Param);
  15931. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15932. {
  15933. return false;
  15934. }
  15935. }
  15936. if (x.PriceName != null && !where)
  15937. {
  15938. where = x.PriceName.Contains(dto.Param);
  15939. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15940. {
  15941. return false;
  15942. }
  15943. }
  15944. return where;
  15945. }
  15946. )
  15947. .ToList();
  15948. }
  15949. }
  15950. var view = dbResult.Select(x =>
  15951. {
  15952. decimal dp = 0.00M;
  15953. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15954. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15955. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15956. {
  15957. if (startB && endB)
  15958. {
  15959. var timesp = endD.Subtract(startD);
  15960. if ((timesp.Days + 1) != 0)
  15961. {
  15962. dp = x.Price / (timesp.Days + 1);
  15963. }
  15964. }
  15965. }
  15966. else
  15967. {
  15968. dp = x.Price;
  15969. }
  15970. return new
  15971. {
  15972. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15973. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15974. x.Area,
  15975. x.id,
  15976. price = x.Price.ToString("F2"),
  15977. x.PriceName,
  15978. x.PriceContent,
  15979. x.TeamName,
  15980. x.DatePrice,
  15981. dayPrice = dp.ToString("F2"),
  15982. };
  15983. }).OrderByDescending(x => x.id).ToList();
  15984. jw = JsonView(true, "获取成功!", view);
  15985. }
  15986. catch (Exception e)
  15987. {
  15988. jw = JsonView(false, e.Message);
  15989. }
  15990. return Ok(jw);
  15991. }
  15992. [HttpPost]
  15993. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15994. {
  15995. var jw = JsonView(true);
  15996. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15997. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15998. {
  15999. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16000. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16001. WHEN COUNT(*) >= 0 THEN 'True'
  16002. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16003. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16004. ")
  16005. .ToList();
  16006. }
  16007. else
  16008. {
  16009. string likeKey = string.Empty;
  16010. foreach (var item in dto.Keyword)
  16011. {
  16012. likeKey += "%" + item;
  16013. }
  16014. likeKey += "%";
  16015. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16016. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16017. WHEN COUNT(*) >= 0 THEN 'True'
  16018. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16019. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16020. ")
  16021. .ToList();
  16022. }
  16023. if (matches.Any())
  16024. {
  16025. jw.Data = matches;
  16026. }
  16027. else
  16028. {
  16029. jw.Code = 201;
  16030. jw.Msg = "empty list";
  16031. jw.Data = new List<string>(1);
  16032. }
  16033. return Ok(jw);
  16034. }
  16035. /// <summary>
  16036. /// 报价Word下载
  16037. /// </summary>
  16038. /// <param name="dto"></param>
  16039. /// <returns></returns>
  16040. [HttpPost]
  16041. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16042. {
  16043. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16044. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16045. if (di == null)
  16046. {
  16047. return Ok(JsonView(false, "团组不存在!"));
  16048. }
  16049. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16050. if (mainPrice == null || mainPrice.IsShare == 0)
  16051. {
  16052. return Ok(JsonView(false, "团组成本不存在!"));
  16053. }
  16054. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16055. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16056. if (costTypeHotelNumbers == null)
  16057. {
  16058. return Ok(JsonView(false, "团组成本不存在!"));
  16059. }
  16060. //文件名
  16061. string strFileName = di.TeamName + "-收款账单.doc";
  16062. //获取模板
  16063. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16064. //载入模板
  16065. Document doc = new Document(tmppath);
  16066. decimal allPrice = 0.00M;
  16067. string itemStr = string.Empty;
  16068. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16069. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16070. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16071. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16072. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16073. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16074. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16075. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16076. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16077. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16078. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16079. {
  16080. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16081. ("BXRS", "BXCB", "BXXS", "bx"),
  16082. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16083. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16084. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16085. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16086. ("CPRS", "CPCB", "CPXS", "cp"),
  16087. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16088. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16089. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16090. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16091. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16092. ("DJRS", "DJCB", "DJXS", "dj"),
  16093. ("GWRS", "GWCB", "GWXS", "gw"),
  16094. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16095. };
  16096. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16097. var rightSum = 0.00M;
  16098. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16099. {
  16100. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16101. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16102. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16103. if (prefix == "tbr")
  16104. {
  16105. rsValue *= 2;
  16106. cbValue /= 2;
  16107. }
  16108. if (OtherCostPropertyBJ.Contains(prefix))
  16109. {
  16110. rightSum += cbValue * xsValue;
  16111. }
  16112. }
  16113. var hotelRooms = new Dictionary<string, int>
  16114. {
  16115. { "SGR", costTypeHotelNumbers.SGR },
  16116. { "TBR", costTypeHotelNumbers.TBR },
  16117. { "JSES", costTypeHotelNumbers.JSES },
  16118. { "SUITE", costTypeHotelNumbers.SUITE }
  16119. };
  16120. var flights = new Dictionary<string, int>
  16121. {
  16122. { "经济舱", mainPrice.JJCRS },
  16123. { "公务舱", mainPrice.GWCRS },
  16124. { "头等舱", mainPrice.TDCRS }
  16125. };
  16126. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16127. {
  16128. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16129. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16130. { "头等舱", new[] { "SUITE", "JSES" } }
  16131. };
  16132. var result = new Dictionary<string, int>();
  16133. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16134. foreach (var flight in flights.Keys)
  16135. {
  16136. // 获取当前舱位的匹配规则
  16137. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16138. {
  16139. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16140. }
  16141. }
  16142. #region right计算
  16143. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16144. {
  16145. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16146. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16147. airHotelPriceList.Add(new
  16148. AirHotelPrice
  16149. {
  16150. Name = "经济舱TBR",
  16151. Price = rightSum + air + hotel,
  16152. Count = result["经济舱TBR"] * 2
  16153. });
  16154. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16155. }
  16156. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16157. {
  16158. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16159. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16160. airHotelPriceList.Add(new
  16161. AirHotelPrice
  16162. {
  16163. Name = "经济舱SGR",
  16164. Price = rightSum + air + hotel,
  16165. Count = result["经济舱SGR"]
  16166. });
  16167. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16168. }
  16169. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16170. {
  16171. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16172. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16173. airHotelPriceList.Add(new
  16174. AirHotelPrice
  16175. {
  16176. Name = "公务舱SGR",
  16177. Price = rightSum + air + hotel,
  16178. Count = result["公务舱SGR"]
  16179. });
  16180. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16181. }
  16182. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16183. {
  16184. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16185. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16186. airHotelPriceList.Add(new
  16187. AirHotelPrice
  16188. {
  16189. Name = "公务舱JSES",
  16190. Price = rightSum + air + hotel,
  16191. Count = result["公务舱JSES"]
  16192. });
  16193. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16194. }
  16195. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16196. {
  16197. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16198. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16199. airHotelPriceList.Add(new
  16200. AirHotelPrice
  16201. {
  16202. Name = "公务舱SUITE",
  16203. Price = rightSum + air + hotel,
  16204. Count = result["公务舱SUITE"]
  16205. });
  16206. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16207. }
  16208. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16209. {
  16210. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16211. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16212. airHotelPriceList.Add(new
  16213. AirHotelPrice
  16214. {
  16215. Name = "经济舱SUITE",
  16216. Price = rightSum + air + hotel,
  16217. Count = result["经济舱SUITE"]
  16218. });
  16219. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16220. }
  16221. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16222. {
  16223. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16224. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16225. airHotelPriceList.Add(new
  16226. AirHotelPrice
  16227. {
  16228. Name = "头等舱JSES",
  16229. Price = rightSum + air + hotel,
  16230. Count = result["头等舱JSES"]
  16231. });
  16232. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16233. }
  16234. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16235. {
  16236. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16237. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16238. airHotelPriceList.Add(new
  16239. AirHotelPrice
  16240. {
  16241. Name = "头等舱SUITE",
  16242. Price = rightSum + air + hotel,
  16243. Count = result["头等舱SUITE"]
  16244. });
  16245. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16246. }
  16247. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16248. {
  16249. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16250. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16251. airHotelPriceList.Add(new
  16252. AirHotelPrice
  16253. {
  16254. Name = "经济舱JSES",
  16255. Price = rightSum + air + hotel,
  16256. Count = result["经济舱JSES"]
  16257. });
  16258. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16259. }
  16260. #endregion
  16261. foreach (var item in airSouer.Keys)
  16262. {
  16263. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16264. if (find != null && find.Count > 0)
  16265. {
  16266. if (item.Contains("TBR"))
  16267. {
  16268. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16269. }
  16270. else
  16271. {
  16272. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16273. }
  16274. }
  16275. }
  16276. #region 替换Word模板书签内容
  16277. Dictionary<string, string> marks = new Dictionary<string, string>();
  16278. marks.Add("To", di.ClientUnit);//付款方
  16279. marks.Add("ToTel", di.TellPhone);//付款方电话
  16280. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16281. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16282. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16283. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16284. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16285. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16286. marks.Add("PayItemContent", itemStr);//详细信息
  16287. marks.Add("Total", allPrice.ToString("F2"));//合计
  16288. #endregion
  16289. foreach (var item in marks.Keys)
  16290. {
  16291. if (doc.Range.Bookmarks[item] != null)
  16292. {
  16293. Bookmark mark = doc.Range.Bookmarks[item];
  16294. mark.Text = marks[item];
  16295. }
  16296. }
  16297. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16298. doc.Save(savePaht);
  16299. var jw = new JsonView();
  16300. jw.Msg = "生成成功!";
  16301. jw.Code = 200;
  16302. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16303. return Ok(jw);
  16304. }
  16305. /// <summary>
  16306. /// 详细报价费用Excel下载
  16307. /// </summary>
  16308. /// <param name="dto"></param>
  16309. /// <returns></returns>
  16310. [HttpPost]
  16311. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16312. {
  16313. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16314. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16315. if (di == null)
  16316. {
  16317. return Ok(JsonView(false, "团组不存在!"));
  16318. }
  16319. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16320. if (mainPrice == null || mainPrice.IsShare == 0)
  16321. {
  16322. return Ok(JsonView(false, "团组成本不存在!"));
  16323. }
  16324. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16325. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16326. if (costTypeHotelNumbers == null)
  16327. {
  16328. return Ok(JsonView(false, "团组成本不存在!"));
  16329. }
  16330. WorkbookDesigner designer = new WorkbookDesigner();
  16331. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16332. List<int> hideRowsList = new List<int>();
  16333. int conterStartIndex = 3;
  16334. int rowIndex = conterStartIndex;
  16335. designer.SetDataSource("GroupName", di.TeamName);
  16336. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16337. {
  16338. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16339. ("BXRS", "BXCB", "BXXS", "bx"),
  16340. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16341. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16342. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16343. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16344. ("CPRS", "CPCB", "CPXS", "cp") ,
  16345. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16346. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16347. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16348. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16349. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16350. ("DJRS", "DJCB", "DJXS", "dj") ,
  16351. ("GWRS", "GWCB", "GWXS", "gw") ,
  16352. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16353. };
  16354. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16355. var rightSum = 0.00M;
  16356. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16357. {
  16358. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16359. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16360. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16361. if (prefix == "tbr")
  16362. {
  16363. rsValue *= 2;
  16364. cbValue /= 2;
  16365. }
  16366. if (OtherCostPropertyBJ.Contains(prefix))
  16367. {
  16368. rightSum += cbValue * xsValue;
  16369. }
  16370. if (rsValue == 0)
  16371. {
  16372. hideRowsList.Add(rowIndex);
  16373. }
  16374. else
  16375. {
  16376. designer.SetDataSource($"{prefix}rs", rsValue);
  16377. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16378. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16379. }
  16380. rowIndex += 2;
  16381. }
  16382. var hotelRooms = new Dictionary<string, int>
  16383. {
  16384. { "SGR", costTypeHotelNumbers.SGR },
  16385. { "TBR", costTypeHotelNumbers.TBR },
  16386. { "JSES", costTypeHotelNumbers.JSES },
  16387. { "SUITE", costTypeHotelNumbers.SUITE }
  16388. };
  16389. var flights = new Dictionary<string, int>
  16390. {
  16391. { "经济舱", mainPrice.JJCRS },
  16392. { "公务舱", mainPrice.GWCRS },
  16393. { "头等舱", mainPrice.TDCRS }
  16394. };
  16395. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16396. {
  16397. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16398. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16399. { "头等舱", new[] { "SUITE", "JSES" } }
  16400. };
  16401. var result = new Dictionary<string, int>();
  16402. foreach (var flight in flights.Keys)
  16403. {
  16404. // 获取当前舱位的匹配规则
  16405. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16406. {
  16407. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16408. }
  16409. }
  16410. var allPrice = 0.00M;
  16411. #region right计算
  16412. int airRowIndex = 35;
  16413. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16414. {
  16415. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16416. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16417. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16418. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16419. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16420. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16421. }
  16422. else
  16423. {
  16424. hideRowsList.Add(airRowIndex);
  16425. }
  16426. airRowIndex += 2;
  16427. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16428. {
  16429. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16430. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16431. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16432. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16433. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16434. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16435. }
  16436. else
  16437. {
  16438. hideRowsList.Add(airRowIndex);
  16439. }
  16440. airRowIndex += 2;
  16441. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16442. {
  16443. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16444. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16445. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16446. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16447. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16448. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16449. }
  16450. else
  16451. {
  16452. hideRowsList.Add(airRowIndex);
  16453. }
  16454. airRowIndex += 2;
  16455. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16456. {
  16457. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16458. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16459. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16460. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16461. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16462. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16463. }
  16464. else
  16465. {
  16466. hideRowsList.Add(airRowIndex);
  16467. }
  16468. airRowIndex += 2;
  16469. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16470. {
  16471. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16472. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16473. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16474. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16475. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16476. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16477. }
  16478. else
  16479. {
  16480. hideRowsList.Add(airRowIndex);
  16481. }
  16482. airRowIndex += 2;
  16483. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16484. {
  16485. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16486. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16487. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16488. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16489. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16490. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16491. }
  16492. else
  16493. {
  16494. hideRowsList.Add(airRowIndex);
  16495. }
  16496. airRowIndex += 2;
  16497. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16498. {
  16499. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16500. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16501. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16502. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16503. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16504. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16505. }
  16506. else
  16507. {
  16508. hideRowsList.Add(airRowIndex);
  16509. }
  16510. airRowIndex += 2;
  16511. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16512. {
  16513. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16514. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16515. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16516. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16517. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16518. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16519. }
  16520. else
  16521. {
  16522. hideRowsList.Add(airRowIndex);
  16523. }
  16524. airRowIndex += 2;
  16525. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16526. {
  16527. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16528. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16529. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16530. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16531. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16532. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16533. }
  16534. else
  16535. {
  16536. hideRowsList.Add(airRowIndex);
  16537. }
  16538. #endregion
  16539. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16540. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16541. var ws = designer.Workbook.Worksheets[0];
  16542. foreach (var Rowindex in hideRowsList)
  16543. {
  16544. ws.Cells.HideRows(Rowindex, 2);
  16545. }
  16546. designer.Process();
  16547. designer.Workbook.Save(savePaht);
  16548. return Ok(JsonView(true, "生成成功!", new
  16549. {
  16550. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16551. }));
  16552. }
  16553. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16554. {
  16555. foreach (var roomType in roomTypes)
  16556. {
  16557. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16558. {
  16559. hotelRooms[roomType]--;
  16560. flights[flightType]--;
  16561. if (roomType == "TBR")
  16562. {
  16563. flights[flightType]--; // 双人间在减少1
  16564. }
  16565. string key = flightType + roomType;
  16566. if (result.Keys.Contains(key))
  16567. {
  16568. result[key]++;
  16569. }
  16570. else
  16571. {
  16572. result.Add(key, 1);
  16573. }
  16574. }
  16575. }
  16576. }
  16577. private class AirHotelPrice
  16578. {
  16579. public string Name { get; set; }
  16580. public decimal Price { get; set; }
  16581. public int Count { get; set; }
  16582. }
  16583. #endregion
  16584. #region 酒店预订 New 2023-12-28 17:45
  16585. /// <summary>
  16586. /// 酒店预订
  16587. /// 酒店费用列表 根据团组Id查询
  16588. /// </summary>
  16589. /// <param name="_dto"></param>
  16590. /// <returns></returns>
  16591. [HttpPost]
  16592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16593. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16594. {
  16595. #region 参数验证
  16596. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16597. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16598. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16599. #region 团组操作权限验证 76 酒店预定模块
  16600. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16601. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16602. #endregion
  16603. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16604. #region 页面操作权限验证
  16605. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16606. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16607. #endregion
  16608. #endregion
  16609. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16610. }
  16611. /// <summary>
  16612. /// 酒店预订
  16613. /// 基础数据
  16614. /// </summary>
  16615. /// <param name="_dto"></param>
  16616. /// <returns></returns>
  16617. [HttpPost]
  16618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16619. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16620. {
  16621. #region 参数验证
  16622. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16623. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16624. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16625. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16626. #region 页面操作权限验证
  16627. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16628. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16629. #endregion
  16630. #region 团组操作权限验证 76 酒店预定模块
  16631. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16632. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16633. #endregion
  16634. #endregion
  16635. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16636. }
  16637. /// <summary>
  16638. /// 酒店预订
  16639. /// 创建 入住卷号码
  16640. /// </summary>
  16641. /// <param name="_dto"></param>
  16642. /// <returns></returns>
  16643. [HttpPost]
  16644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16645. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16646. {
  16647. #region 参数验证
  16648. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16649. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16650. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16651. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16652. #region 页面操作权限验证
  16653. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16654. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16655. #endregion
  16656. #region 团组操作权限验证 76 酒店预定模块
  16657. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16658. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16659. #endregion
  16660. #endregion
  16661. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16662. if (data.Code != 0)
  16663. {
  16664. return Ok(JsonView(false, data.Msg));
  16665. }
  16666. return Ok(JsonView(true, data.Msg, data.Data));
  16667. }
  16668. /// <summary>
  16669. /// 酒店预订
  16670. /// 详情
  16671. /// </summary>
  16672. /// <param name="_dto"></param>
  16673. /// <returns></returns>
  16674. [HttpPost]
  16675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16676. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16677. {
  16678. #region 参数验证
  16679. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16680. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16681. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16682. #region 团组操作权限验证 76 酒店预定模块
  16683. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16684. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16685. #endregion
  16686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16687. #region 页面操作权限验证
  16688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16689. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16690. #endregion
  16691. #endregion
  16692. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16693. }
  16694. /// <summary>
  16695. /// 酒店预订
  16696. /// Add Or Edit
  16697. /// </summary>
  16698. /// <param name="_dto"></param>
  16699. /// <returns></returns>
  16700. [HttpPost]
  16701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16702. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16703. {
  16704. #region 参数验证
  16705. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16706. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16707. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16708. #region 团组操作权限验证 76 酒店预定模块
  16709. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16710. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16711. #endregion
  16712. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16713. #region 页面操作权限验证
  16714. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16715. if (_dto.Id == 0) // Add
  16716. {
  16717. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16718. }
  16719. else if (_dto.Id > 1) // Edit
  16720. {
  16721. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16722. }
  16723. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16724. #endregion
  16725. #endregion
  16726. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16727. if (_view.Code != 200)
  16728. {
  16729. return Ok(_view);
  16730. }
  16731. #region 成本无酒店价格数据进入超支
  16732. _sqlSugar.BeginTran();
  16733. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16734. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16735. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16736. for (int i = 0; i < groupCost.Count; i++)
  16737. {
  16738. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16739. {
  16740. groupCost[i].Date = groupCost[i - 1].Date;
  16741. }
  16742. }
  16743. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16744. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16745. List<Fin_GroupExtraCostDto_OP>();
  16746. if (start_Bool && end_Bool)
  16747. {
  16748. while (start_Time < end_Time)
  16749. {
  16750. foreach (var item in groupCost_Grp)
  16751. {
  16752. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16753. {
  16754. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16755. {
  16756. extraCostList.Add(new
  16757. Fin_GroupExtraCostDto_OP
  16758. {
  16759. Area = _dto.AreaId,
  16760. coefficient = 1.5M,
  16761. createUser = _dto.UserId,
  16762. currency = _dto.CardPriceCurrency,
  16763. diId = _dto.DiId,
  16764. ManagerConfirm = 0,
  16765. SupervisorConfirm = 0,
  16766. SYsupervisorConfirm = 0,
  16767. editType = 1,
  16768. PortType = 1,
  16769. price = _dto.CardPrice,
  16770. PriceCount = 1,
  16771. priceType = 1027,
  16772. priceDetailType = 1044,
  16773. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16774. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16775. });
  16776. }
  16777. }
  16778. }
  16779. start_Time = start_Time.AddDays(1);
  16780. }
  16781. }
  16782. if (extraCostList.Any())
  16783. {
  16784. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16785. }
  16786. _sqlSugar.CommitTran();
  16787. #endregion
  16788. #region 应用推送
  16789. try
  16790. {
  16791. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16792. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16793. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16794. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16795. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16796. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16797. var diId = _dto.DiId;
  16798. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16799. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16800. #region 操作记录
  16801. var opInfo = new Crm_TableOperationRecord()
  16802. {
  16803. TableName = "Grp_HotelReservations",
  16804. PortType = _dto.PortType,
  16805. DataId = hotelId,
  16806. CreateUserId = _dto.UserId
  16807. };
  16808. //var opStatus = OperationEnum.NoOperation;
  16809. if (_dto.Id < 1) //添加操作
  16810. {
  16811. opInfo.OperationItem = OperationEnum.Add;
  16812. }
  16813. else if (_dto.Id > 0)
  16814. {
  16815. opInfo.OperationItem = OperationEnum.Edit;
  16816. }
  16817. string opRemark = string.Empty;
  16818. if (ccpInfo != null)
  16819. {
  16820. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16821. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16822. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16823. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16824. }
  16825. opInfo.Remark = opRemark;
  16826. await _tableorRep.AddAsync(opInfo);
  16827. #endregion
  16828. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16829. //2024-10-21 新增LZ UID
  16830. var userIds = new List<int>() { 21 };
  16831. string title = $"费用审核";
  16832. string content = "";
  16833. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16834. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16835. try
  16836. {
  16837. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  16838. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  16839. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  16840. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  16841. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  16842. }
  16843. catch (Exception ex)
  16844. {
  16845. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  16846. }
  16847. }
  16848. catch (Exception ex)
  16849. {
  16850. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  16851. }
  16852. try
  16853. {
  16854. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16855. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16856. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16857. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16858. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16859. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16860. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16861. //自动审核
  16862. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  16863. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  16864. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  16865. //2024-10-21 新增LZ UID
  16866. var userIds = new List<int>() { 21 };
  16867. string title = $"系统通知";
  16868. var diId = _dto.DiId;
  16869. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16870. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16871. string content = "";
  16872. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16873. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16874. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16875. }
  16876. catch (Exception ex)
  16877. {
  16878. }
  16879. #endregion
  16880. return Ok(_view);
  16881. }
  16882. /// <summary>
  16883. /// 酒店自动审核测试
  16884. /// Add Or Edit
  16885. /// </summary>
  16886. /// <param name="diid"></param>
  16887. /// <param name="dataId"></param>
  16888. /// <returns></returns>
  16889. [HttpPost]
  16890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16891. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  16892. {
  16893. #region 应用推送
  16894. try
  16895. {
  16896. //自动审核
  16897. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  16898. }
  16899. catch (Exception ex)
  16900. {
  16901. return Ok(JsonView(false, "操作失败"));
  16902. }
  16903. #endregion
  16904. return Ok(JsonView(false, "操作成功"));
  16905. }
  16906. /// <summary>
  16907. /// 酒店预订
  16908. /// Del
  16909. /// </summary>
  16910. /// <param name="_dto"></param>
  16911. /// <returns></returns>
  16912. [HttpPost]
  16913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16914. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  16915. {
  16916. #region 参数验证
  16917. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16918. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16919. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16920. #region 团组操作权限验证 76 酒店预定模块
  16921. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16922. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16923. #endregion
  16924. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16925. #region 页面操作权限验证
  16926. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16927. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16928. #endregion
  16929. #endregion
  16930. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  16931. #region 操作记录
  16932. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  16933. {
  16934. TableName = "Grp_HotelReservations",
  16935. PortType = _dto.PortType,
  16936. OperationItem = OperationEnum.Del,
  16937. DataId = _dto.Id,
  16938. CreateUserId = _dto.UserId
  16939. });
  16940. #endregion
  16941. return Ok(data);
  16942. }
  16943. /// <summary>
  16944. /// 酒店预订
  16945. /// 生成VOUCHER
  16946. /// 2024.05.06 之前版本
  16947. /// </summary>
  16948. /// <param name="_dto"></param>
  16949. /// <returns></returns>
  16950. [HttpPost]
  16951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16952. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  16953. {
  16954. try
  16955. {
  16956. #region 参数验证
  16957. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16958. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16959. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16960. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  16961. #region 团组操作权限验证 76 酒店预定模块
  16962. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16963. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16964. #endregion
  16965. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16966. #region 页面操作权限验证
  16967. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16968. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16969. #endregion
  16970. #endregion
  16971. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  16972. //判断数据是否完整
  16973. if (hr != null)
  16974. {
  16975. if (!string.IsNullOrEmpty(hr.DetermineNo))
  16976. {
  16977. string strFileName = "HotelStatement/";
  16978. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16979. if (dele != null)
  16980. strFileName += dele.TourCode;
  16981. //载入模板
  16982. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  16983. Document doc = new Document(sss);
  16984. DocumentBuilder builder = new DocumentBuilder(doc);
  16985. #region 替换Word模板书签内容
  16986. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  16987. //入住卷预定号码
  16988. if (doc.Range.Bookmarks["VNO"] != null)
  16989. {
  16990. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16991. mark.Text = hr.CheckNumber;
  16992. }
  16993. //酒店时间
  16994. if (doc.Range.Bookmarks["Date"] != null)
  16995. {
  16996. Bookmark mark = doc.Range.Bookmarks["Date"];
  16997. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16998. }
  16999. //团号
  17000. if (doc.Range.Bookmarks["TNo"] != null)
  17001. {
  17002. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17003. mark.Text = dele.TourCode;
  17004. }
  17005. //预定号码
  17006. if (doc.Range.Bookmarks["BookingId"] != null)
  17007. {
  17008. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17009. mark.Text = hr.ReservationsNo;
  17010. }
  17011. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17012. {
  17013. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17014. mark.Text = hr.DetermineNo;
  17015. }
  17016. //酒店城市
  17017. if (doc.Range.Bookmarks["City"] != null)
  17018. {
  17019. Bookmark mark = doc.Range.Bookmarks["City"];
  17020. mark.Text = hr.City;
  17021. }
  17022. //酒店名称
  17023. if (doc.Range.Bookmarks["HName"] != null)
  17024. {
  17025. Bookmark mark = doc.Range.Bookmarks["HName"];
  17026. mark.Text = hr.HotelName;
  17027. }
  17028. //酒店地址
  17029. if (doc.Range.Bookmarks["Address"] != null)
  17030. {
  17031. Bookmark mark = doc.Range.Bookmarks["Address"];
  17032. mark.Text = hr.HotelAddress;
  17033. }
  17034. //酒店电话
  17035. if (doc.Range.Bookmarks["Tel"] != null)
  17036. {
  17037. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17038. mark.Text = hr.HotelTel;
  17039. }
  17040. //酒店传真
  17041. if (doc.Range.Bookmarks["Fax"] != null)
  17042. {
  17043. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17044. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17045. {
  17046. mark.Text = hr.HotelFax;
  17047. }
  17048. }
  17049. //入住时间
  17050. if (doc.Range.Bookmarks["CIn"] != null)
  17051. {
  17052. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17053. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17054. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17055. }
  17056. //退房时间
  17057. if (doc.Range.Bookmarks["COut"] != null)
  17058. {
  17059. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17060. Bookmark mark = doc.Range.Bookmarks["COut"];
  17061. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17062. }
  17063. //客户名称
  17064. if (doc.Range.Bookmarks["GName"] != null)
  17065. {
  17066. string guestName = "";
  17067. string[] clients = new string[] { };
  17068. if (hr.GuestName.Contains(","))
  17069. {
  17070. clients = hr.GuestName.Split(",");
  17071. }
  17072. else
  17073. {
  17074. clients = new string[] { hr.GuestName };
  17075. }
  17076. List<int> clientIds_int = new List<int>();
  17077. if (clients.Length > 0)
  17078. {
  17079. foreach (var item in clients)
  17080. {
  17081. if (item.IsNumeric())
  17082. {
  17083. clientIds_int.Add(int.Parse(item));
  17084. }
  17085. }
  17086. }
  17087. if (clientIds_int.Count > 0)
  17088. {
  17089. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17090. foreach (var client in _clientDatas)
  17091. {
  17092. //男
  17093. if (client.Sex == 0) guestName += $"Mr.";
  17094. //女
  17095. else if (client.Sex == 1) guestName += $"Ms.";
  17096. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17097. {
  17098. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17099. }
  17100. //guestName += $"{client.Pinyin},";
  17101. }
  17102. if (guestName.Length > 0)
  17103. {
  17104. guestName = guestName.Substring(0, guestName.Length - 1);
  17105. }
  17106. }
  17107. else
  17108. {
  17109. guestName = hr.GuestName;
  17110. }
  17111. Bookmark mark = doc.Range.Bookmarks["GName"];
  17112. mark.Text = guestName;
  17113. }
  17114. //房间介绍
  17115. if (doc.Range.Bookmarks["ROOM"] != null)
  17116. {
  17117. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17118. mark.Text = hr.RoomExplanation;
  17119. }
  17120. //报价描述
  17121. if (doc.Range.Bookmarks["NOTE"] != null)
  17122. {
  17123. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17124. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17125. if (ss != null)
  17126. mark.Text = ss.Name;
  17127. }
  17128. //入住时间
  17129. if (doc.Range.Bookmarks["CheckIn"] != null)
  17130. {
  17131. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17132. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17133. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17134. }
  17135. //退房时间
  17136. if (doc.Range.Bookmarks["CheckOut"] != null)
  17137. {
  17138. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17139. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17140. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17141. }
  17142. //日期
  17143. if (doc.Range.Bookmarks["DT"] != null)
  17144. {
  17145. Bookmark mark = doc.Range.Bookmarks["DT"];
  17146. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17147. }
  17148. //名称
  17149. if (doc.Range.Bookmarks["VName"] != null)
  17150. {
  17151. Bookmark mark = doc.Range.Bookmarks["VName"];
  17152. mark.Text = hr.HotelName;
  17153. }
  17154. //号码
  17155. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17156. {
  17157. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17158. mark.Text = hr.CheckNumber;
  17159. }
  17160. #endregion
  17161. strFileName += "VOUCHER.doc";
  17162. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17163. doc.Save(fileDir);
  17164. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17165. return Ok(JsonView(true, "操作成功!", Url));
  17166. }
  17167. else
  17168. {
  17169. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17170. }
  17171. }
  17172. else
  17173. {
  17174. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17175. }
  17176. }
  17177. catch (Exception ex)
  17178. {
  17179. return Ok(JsonView(false, ex.Message));
  17180. }
  17181. }
  17182. /// <summary>
  17183. /// 酒店预订
  17184. /// 生成VOUCHER
  17185. /// 2024.05.06 之后版本
  17186. /// </summary>
  17187. /// <param name="_dto"></param>
  17188. /// <returns></returns>
  17189. [HttpPost]
  17190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17191. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17192. {
  17193. #region 参数验证
  17194. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17195. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17196. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17197. #region 团组操作权限验证 76 酒店预定模块
  17198. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17199. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17200. #endregion
  17201. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17202. #region 页面操作权限验证
  17203. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17204. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17205. #endregion
  17206. #endregion
  17207. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17208. //判断数据是否完整
  17209. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17210. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17211. string strFileName = "HotelStatement/";
  17212. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17213. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17214. #region 数据处理
  17215. List<int> guestIds = new List<int>();
  17216. //int index = 0;
  17217. foreach (var item in hrDtas)
  17218. {
  17219. if (item.GuestName.Contains(","))
  17220. {
  17221. string[] guestIdArr = item.GuestName.Split(',');
  17222. foreach (var guestIdStr in guestIdArr)
  17223. {
  17224. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17225. if (guestBool)
  17226. {
  17227. guestIds.Add(guestId);
  17228. }
  17229. }
  17230. }
  17231. else guestNames += item.GuestName;
  17232. var voucherInfo = new HotelVoucherInfoView()
  17233. {
  17234. HotelName = item.HotelName,
  17235. CheckInDate = item.CheckInDate,
  17236. CheckOutDate = item.CheckOutDate,
  17237. ConfirmationNumber = item.DetermineNo.Trim(),
  17238. RoomType = item.RoomExplanation
  17239. };
  17240. vouchers.Add(voucherInfo);
  17241. }
  17242. if (guestIds.Count > 0)
  17243. {
  17244. guestIds = guestIds.Distinct().ToList();
  17245. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17246. if (guestDatas.Count > 0)
  17247. {
  17248. guestNames = "";
  17249. foreach (var guest in guestDatas)
  17250. {
  17251. string guestName = "";
  17252. if (guest.Sex == 0) guestName += @"MR.";
  17253. else if (guest.Sex == 1) guestName += @"MS.";
  17254. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17255. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17256. guestNames += @$"{guestName.Trim()}、";
  17257. }
  17258. if (guestNames.Length > 0)
  17259. {
  17260. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17261. }
  17262. }
  17263. }
  17264. #endregion
  17265. //载入模板
  17266. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17267. Document doc = new Document(sss);
  17268. DocumentBuilder builder = new DocumentBuilder(doc);
  17269. if (doc.Range.Bookmarks["GuestName"] != null)
  17270. {
  17271. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17272. mark.Text = guestNames;
  17273. }
  17274. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17275. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17276. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17277. for (int i = 1; i <= vouchers.Count; i++)
  17278. {
  17279. HotelVoucherInfoView hviv = vouchers[i - 1];
  17280. builder.MoveToCell(0, i, 0, 0);
  17281. builder.Write(hviv.HotelName);
  17282. builder.MoveToCell(0, i, 1, 0);
  17283. builder.Write(hviv.CheckInDate);
  17284. builder.MoveToCell(0, i, 2, 0);
  17285. builder.Write(hviv.CheckOutDate);
  17286. builder.MoveToCell(0, i, 3, 0);
  17287. builder.Write(hviv.RoomType);
  17288. builder.MoveToCell(0, i, 4, 0);
  17289. builder.Write(hviv.ConfirmationNumber);
  17290. }
  17291. //删除多余行
  17292. int currRowIndex = vouchers.Count + 1;
  17293. int delRows = 21 - currRowIndex;
  17294. if (delRows > 0)
  17295. {
  17296. for (int i = 0; i < delRows; i++)
  17297. {
  17298. table.Rows.RemoveAt(currRowIndex);
  17299. //cultivateRowIndex++;
  17300. }
  17301. }
  17302. strFileName += "VOUCHER.docx";
  17303. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17304. doc.Save(fileDir);
  17305. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17306. return Ok(JsonView(true, "操作成功!", Url));
  17307. }
  17308. /// <summary>
  17309. /// 酒店预订
  17310. /// 生成VOUCHER 批量生成
  17311. /// New
  17312. /// </summary>
  17313. /// <param name="_dto"></param>
  17314. /// <returns></returns>
  17315. [HttpPost]
  17316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17317. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17318. {
  17319. #region 参数验证
  17320. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17321. if (_dto.PageId < 1) _dto.PageId = 28;
  17322. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17323. #region 团组操作权限验证 76 酒店预定模块
  17324. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17325. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17326. #endregion
  17327. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17328. #region 页面操作权限验证
  17329. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17330. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17331. #endregion
  17332. #endregion
  17333. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17334. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17335. .OrderBy(x => x.CheckInDate)
  17336. .ToListAsync();
  17337. //判断数据是否完整
  17338. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17339. string strFileName = "HotelStatement/";
  17340. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17341. if (dele != null)
  17342. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17343. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17344. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17345. .Where(it => it.IsDel == 0)
  17346. .ToListAsync();
  17347. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17348. for (int i = 0; i < hrDtas.Count; i++)
  17349. {
  17350. string guestNames = string.Empty;
  17351. List<int> guestIds = new List<int>();
  17352. var item = hrDtas[i];
  17353. //处理客户姓名
  17354. if (item.GuestName.Contains(","))
  17355. {
  17356. string[] guestIdArr = item.GuestName.Split(',');
  17357. foreach (var guestIdStr in guestIdArr)
  17358. if (int.TryParse(guestIdStr, out int guestId))
  17359. guestIds.Add(guestId);
  17360. }
  17361. else
  17362. {
  17363. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17364. if (guestIdBool)
  17365. {
  17366. guestIds.Add(guestId);
  17367. }
  17368. //NaN
  17369. if (item.GuestName.Contains("NaN"))
  17370. {
  17371. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17372. }
  17373. }
  17374. if (guestIds.Count > 0)
  17375. {
  17376. guestIds = guestIds.Distinct().ToList();
  17377. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17378. if (guestDatas1.Count > 0)
  17379. {
  17380. guestNames = "";
  17381. foreach (var guest in guestDatas1)
  17382. {
  17383. string guestName = "";
  17384. if (guest.Sex == 0) guestName += @"MR.";
  17385. else if (guest.Sex == 1) guestName += @"MS.";
  17386. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17387. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17388. guestNames += @$"{guestName.Trim()}、";
  17389. }
  17390. if (guestNames.Length > 0)
  17391. {
  17392. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17393. }
  17394. }
  17395. }
  17396. //if (!string.IsNullOrEmpty(guestNames))
  17397. //{
  17398. hrDtas[i].GuestName = guestNames;
  17399. //}
  17400. }
  17401. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17402. Document doc = new Document();
  17403. DocumentBuilder builder = new DocumentBuilder(doc);
  17404. try
  17405. {
  17406. builder.MoveToDocumentStart();
  17407. foreach (var item in hrDtas)
  17408. {
  17409. //标题
  17410. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17411. builder.ParagraphFormat.LineSpacing = 1;
  17412. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17413. builder.ParagraphFormat.Style.Font.Size = 9;
  17414. builder.ParagraphFormat.Style.Font.Bold = true;
  17415. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17416. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17417. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17418. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17419. builder.ParagraphFormat.LineSpacing = 1;
  17420. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17421. builder.ParagraphFormat.Style.Font.Size = 9;
  17422. builder.ParagraphFormat.Style.Font.Bold = true;
  17423. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17424. builder.StartTable();
  17425. // 设置边框颜色
  17426. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17427. //设置边框样式
  17428. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17429. //表格
  17430. #region 第一行
  17431. builder.InsertCell();
  17432. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17433. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17434. //builder.CellFormat.AllowAutoFit = false;
  17435. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17436. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17437. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17438. builder.CellFormat.WrapText = true; //自动换行
  17439. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17440. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17441. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17442. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17443. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17444. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17445. builder.Write("TOUR NO:");
  17446. builder.InsertCell();
  17447. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17448. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17449. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17450. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17451. builder.ParagraphFormat.Style.Font.Bold = false;
  17452. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17453. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17454. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17455. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17456. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17457. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17458. builder.Write($"{dele?.TourCode ?? "-"}");
  17459. builder.InsertCell();
  17460. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17461. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17462. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17463. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17464. builder.ParagraphFormat.Style.Font.Bold = false;
  17465. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17466. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17467. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17468. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17469. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17470. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17471. builder.Write($"CITY:");
  17472. builder.InsertCell();
  17473. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17474. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17475. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17476. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17477. builder.ParagraphFormat.Style.Font.Bold = false;
  17478. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17479. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17480. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17481. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17482. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17483. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17484. builder.Write($"{item.City}");
  17485. builder.EndRow();
  17486. #endregion
  17487. #region 第二行
  17488. builder.InsertCell();
  17489. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17490. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17491. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17492. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17493. builder.ParagraphFormat.Style.Font.Bold = false;
  17494. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17495. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17496. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17497. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17498. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17499. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17500. builder.Write("CONFIRMATION NO:");
  17501. builder.InsertCell();
  17502. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17503. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17504. builder.ParagraphFormat.Style.Font.Size = 8;
  17505. builder.ParagraphFormat.Style.Font.Bold = false;
  17506. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17507. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17508. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17509. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17510. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17511. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17512. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17513. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17514. builder.Write($"{item.DetermineNo}");
  17515. builder.InsertCell();
  17516. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17517. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17518. builder.InsertCell();
  17519. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17520. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17521. builder.EndRow();
  17522. #endregion
  17523. #region 第三行
  17524. builder.InsertCell();
  17525. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17526. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17527. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17528. builder.ParagraphFormat.Style.Font.Bold = false;
  17529. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17530. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17531. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17532. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17533. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17534. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17535. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17536. builder.Write($"HOTEL NAME:");
  17537. builder.InsertCell();
  17538. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17539. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17540. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17541. builder.ParagraphFormat.Style.Font.Bold = false;
  17542. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17543. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17544. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17545. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17546. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17547. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17548. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17549. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17550. builder.Write($"{item.HotelName}");
  17551. builder.InsertCell();
  17552. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17553. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17554. builder.InsertCell();
  17555. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17556. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17557. builder.EndRow();
  17558. #endregion
  17559. #region 第四行
  17560. builder.InsertCell();
  17561. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17562. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17563. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17564. builder.ParagraphFormat.Style.Font.Bold = false;
  17565. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17566. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17567. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17568. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17569. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17570. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17571. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17572. builder.Write($"HOTEL ADDRESS:");
  17573. builder.InsertCell();
  17574. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17575. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17576. builder.ParagraphFormat.Style.Font.Size = 8;
  17577. builder.ParagraphFormat.Style.Font.Bold = false;
  17578. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17579. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17580. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17581. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17582. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17583. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17584. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17585. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17586. builder.Write($"{item.HotelAddress}");
  17587. builder.InsertCell();
  17588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17589. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17590. builder.InsertCell();
  17591. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17592. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17593. builder.EndRow();
  17594. #endregion
  17595. #region 第五行
  17596. builder.InsertCell();
  17597. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17598. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17599. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17600. builder.ParagraphFormat.Style.Font.Bold = false;
  17601. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17602. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17603. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17604. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17605. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17606. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17607. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17608. builder.Write("TEL:");
  17609. builder.InsertCell();
  17610. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17611. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17612. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17613. builder.ParagraphFormat.Style.Font.Bold = false;
  17614. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17615. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17616. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17617. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17618. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17619. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17620. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17621. builder.Write($"{item.HotelTel}");
  17622. builder.InsertCell();
  17623. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17624. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17625. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17626. builder.ParagraphFormat.Style.Font.Bold = false;
  17627. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17628. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17629. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17630. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17631. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17632. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17633. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17634. builder.Write($"FAX:");
  17635. builder.InsertCell();
  17636. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17637. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17638. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17639. builder.ParagraphFormat.Style.Font.Bold = false;
  17640. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17641. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17642. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17643. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17644. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17645. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17646. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17647. builder.Write($"{item.HotelFax}");
  17648. builder.EndRow();
  17649. #endregion
  17650. #region 第六行
  17651. builder.InsertCell();
  17652. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17653. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17654. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17655. builder.ParagraphFormat.Style.Font.Bold = false;
  17656. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17657. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17658. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17659. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17660. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17661. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17662. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17663. builder.Write("CHECK IN:");
  17664. builder.InsertCell();
  17665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17666. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17667. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17668. builder.ParagraphFormat.Style.Font.Bold = false;
  17669. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17670. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17671. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17672. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17673. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17674. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17675. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17676. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17677. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17678. builder.Write($"{checkInStr}");
  17679. builder.InsertCell();
  17680. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17681. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17682. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17683. builder.ParagraphFormat.Style.Font.Bold = false;
  17684. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17685. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17686. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17687. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17688. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17689. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17690. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17691. builder.Write($"CHECK OUT:");
  17692. builder.InsertCell();
  17693. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17694. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17695. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17696. builder.ParagraphFormat.Style.Font.Bold = false;
  17697. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17698. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17699. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17700. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17701. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17702. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17703. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17704. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17705. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17706. builder.Write($"{checkOutStr}");
  17707. builder.EndRow();
  17708. #endregion
  17709. #region 第七行
  17710. builder.InsertCell();
  17711. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17712. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17713. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17714. builder.ParagraphFormat.Style.Font.Bold = false;
  17715. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17716. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17717. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17718. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17719. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17720. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17721. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17722. builder.Write($"GUEST NAME:");
  17723. builder.InsertCell();
  17724. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17725. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17726. builder.ParagraphFormat.Style.Font.Size = 8;
  17727. builder.ParagraphFormat.Style.Font.Bold = false;
  17728. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17729. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17730. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17731. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17732. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17733. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17734. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17735. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17736. builder.Write($"{item.GuestName.Trim()}");
  17737. builder.InsertCell();
  17738. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17739. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17740. builder.InsertCell();
  17741. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17742. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17743. builder.EndRow();
  17744. #endregion
  17745. #region 第八行
  17746. builder.InsertCell();
  17747. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17748. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17749. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17750. builder.ParagraphFormat.Style.Font.Bold = false;
  17751. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17752. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17753. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17754. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17755. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17756. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17757. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17758. builder.Write($"ROOM TYPE:");
  17759. builder.InsertCell();
  17760. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17761. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17762. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17763. builder.ParagraphFormat.Style.Font.Bold = false;
  17764. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17765. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17766. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17767. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17768. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17769. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17770. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17771. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17772. builder.Write($"{item.RoomExplanation}");
  17773. builder.InsertCell();
  17774. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17775. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17776. builder.InsertCell();
  17777. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17778. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17779. builder.EndRow();
  17780. #endregion
  17781. #region 第九行
  17782. builder.InsertCell();
  17783. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17784. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17785. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17786. builder.ParagraphFormat.Style.Font.Bold = false;
  17787. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17788. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17789. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17790. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17791. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17792. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17793. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17794. builder.Write($"NOTE:");
  17795. builder.InsertCell();
  17796. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17797. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17798. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17799. builder.ParagraphFormat.Style.Font.Bold = false;
  17800. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17801. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17802. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17803. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17804. 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.");
  17805. builder.InsertCell();
  17806. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17807. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17808. builder.InsertCell();
  17809. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17810. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17811. builder.EndRow();
  17812. #endregion
  17813. builder.EndTable();
  17814. //换行
  17815. builder.Writeln("");
  17816. builder.Writeln("");
  17817. }
  17818. #region 获取文档中的所有表格 设置文字自适应
  17819. // 获取文档中的所有表格。
  17820. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17821. {
  17822. // 遍历表格中的所有行。
  17823. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17824. {
  17825. foreach (Cell cell in row.Cells)
  17826. {
  17827. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17828. cellFormat.Width = 0;
  17829. }
  17830. }
  17831. }
  17832. #endregion
  17833. #region 设置页眉
  17834. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  17835. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  17836. if (System.IO.File.Exists(voucherHeaderPath))
  17837. {
  17838. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  17839. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  17840. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  17841. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  17842. // 调整图片位置
  17843. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  17844. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  17845. shape.Top = 50; // 将图片距离页眉上边缘的距离
  17846. shape.Left = 0; // 将图片距离页面左边缘的距离
  17847. shape.Width = 81; // 设置图片宽度
  17848. shape.Height = 36; // 设置图片高度
  17849. }
  17850. //靠右
  17851. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17852. //// 设置页脚上下边距
  17853. //builder.PageSetup.HeaderDistance = 42;
  17854. // 添加页眉线
  17855. Aspose.Words.Border borderHeader = null;
  17856. try
  17857. {
  17858. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  17859. }
  17860. catch (Exception e)
  17861. {
  17862. // TODO Auto-generated catch block
  17863. //e.printStackTrace();
  17864. }
  17865. borderHeader.Shadow = true;
  17866. borderHeader.DistanceFromText = 2;
  17867. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  17868. #endregion
  17869. }
  17870. catch (Exception ex)
  17871. {
  17872. }
  17873. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17874. doc.Save(fileDir);
  17875. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17876. return Ok(JsonView(true, "操作成功!", Url));
  17877. }
  17878. /// <summary>
  17879. /// 酒店预订
  17880. /// 生成 预定成本 Excel
  17881. /// </summary>
  17882. /// <param name="_dto"></param>
  17883. /// <returns></returns>
  17884. [HttpPost]
  17885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17886. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  17887. {
  17888. #region 参数验证
  17889. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  17890. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  17891. if (!vadalitorRes.IsValid)
  17892. {
  17893. var errors = new StringBuilder();
  17894. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  17895. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  17896. }
  17897. #region 团组操作权限验证 76 酒店预定模块
  17898. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17899. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17900. #endregion
  17901. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17902. #region 页面操作权限验证
  17903. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17904. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17905. #endregion
  17906. #endregion
  17907. decimal _rate = 1.00M;
  17908. string _currency = string.Empty;
  17909. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  17910. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17911. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  17912. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17913. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  17914. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  17915. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  17916. if (_GroupCostParameter == null)
  17917. {
  17918. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  17919. bool isIntType = int.TryParse(_currency, out int currId);
  17920. if (isIntType)
  17921. {
  17922. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17923. }
  17924. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17925. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17926. if (currInfo == null)
  17927. {
  17928. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17929. }
  17930. else _rate = currInfo.Rate;
  17931. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  17932. {
  17933. _rate = _GroupCostParameter.Rate;
  17934. }
  17935. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17936. //string strFileName = "HotelStatement/";
  17937. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17938. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17939. var rateDatas = new List<dynamic>();
  17940. #region 数据处理
  17941. foreach (var item in hrDtas)
  17942. {
  17943. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17944. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17945. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17946. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17947. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17948. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  17949. {
  17950. continue;
  17951. }
  17952. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17953. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  17954. string singleRoomFeeStr = string.Empty,
  17955. doubleRoomFeeStr = string.Empty,
  17956. suiteRoomFeeStr = string.Empty,
  17957. otherRoomFeeStr = string.Empty,
  17958. payMoneyStr = string.Empty,
  17959. cardPriceStr = string.Empty;
  17960. if (roomCurr.Equals("CNY"))
  17961. {
  17962. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  17963. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17964. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17965. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17966. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17967. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  17968. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  17969. }
  17970. else
  17971. {
  17972. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17973. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17974. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17975. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17976. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17977. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17978. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17979. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17980. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17981. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17982. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  17983. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  17984. if (ccpPaymentCurrency.Equals("CNY"))
  17985. {
  17986. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  17987. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17988. }
  17989. else
  17990. {
  17991. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17992. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17993. }
  17994. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17995. if (hotelcardPriceCurrency.Equals("CNY"))
  17996. {
  17997. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17998. }
  17999. else
  18000. {
  18001. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18002. }
  18003. }
  18004. string breakfastPriceStr = string.Empty,
  18005. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18006. governmentRentStr = string.Empty,
  18007. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18008. cityTaxStr = string.Empty,
  18009. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18010. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18011. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18012. {
  18013. if (breakfastCurrency1.Equals("CNY"))
  18014. {
  18015. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18016. }
  18017. else
  18018. {
  18019. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18020. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18021. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18022. }
  18023. }
  18024. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18025. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18026. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18027. {
  18028. if (governmentRentCurrency.Equals("CNY"))
  18029. {
  18030. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18031. }
  18032. else
  18033. {
  18034. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18035. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18036. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18037. }
  18038. }
  18039. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18040. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18041. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18042. {
  18043. if (cityTaxStrCurrency1.Equals("CNY"))
  18044. {
  18045. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18046. }
  18047. else
  18048. {
  18049. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18050. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18051. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18052. }
  18053. }
  18054. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18055. int payDId = roomInfo?.PayDId ?? 0;
  18056. pcfds.Add(new HotelReservations_PCFD_View()
  18057. {
  18058. City = item.City,
  18059. HotelName = item.HotelName,
  18060. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18061. // SingleRoomCount = item.SingleRoomCount,
  18062. SingleRoomPrice = singleRoomFeeStr,
  18063. // DoubleRoomCount = item.DoubleRoomCount,
  18064. DoubleRoomPrice = doubleRoomFeeStr,
  18065. //SuiteRoomCount = item.SuiteRoomCount,
  18066. SuiteRoomPrice = suiteRoomFeeStr,
  18067. OtherRoomPrice = otherRoomFeeStr,
  18068. //OtherRoomCount = item.OtherRoomCount,
  18069. BreakfastPrice = breakfastPriceStr,
  18070. GovernmentRent = governmentRentStr,
  18071. CityTax = cityTaxStr,
  18072. RoomExplanation = item.RoomExplanation,
  18073. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18074. PayTime = roomInfo?.ConsumptionDate,
  18075. BankNo = roomInfo?.BankNo,
  18076. PayMoney = payMoneyStr,
  18077. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18078. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18079. CardPrice = cardPriceStr,
  18080. Remark = ccpInfo.Remark
  18081. });
  18082. }
  18083. #endregion
  18084. //载入模板
  18085. WorkbookDesigner designer = new WorkbookDesigner();
  18086. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18087. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18088. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18089. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18090. var rateDatas1 = rateDatas.Distinct();
  18091. var rateStr = string.Empty;
  18092. foreach (var item in rateDatas1)
  18093. {
  18094. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18095. }
  18096. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18097. designer.SetDataSource("Opertor", userInfo.CnName);
  18098. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18099. dt.TableName = "ViewMyHotelReservations";
  18100. designer.SetDataSource(dt);
  18101. designer.Process();
  18102. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18103. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18104. designer.Workbook.Save(serverPath);
  18105. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18106. #region 删除指定行
  18107. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18108. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18109. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18110. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18111. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18112. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18113. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18114. cssIndex = dt.Columns["CityTax"].Ordinal,
  18115. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18116. remarkIndex = dt.Columns["Remark"].Ordinal;
  18117. //删除指定列
  18118. foreach (DataRow item in dt.Rows)
  18119. {
  18120. string singleStr = item["SingleRoomPrice"].ToString();
  18121. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18122. if (containsDigitButNotZero1) singleDel = false;
  18123. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18124. string doubleStr = item["DoubleRoomPrice"].ToString();
  18125. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18126. if (containsDigitButNotZero2) doubleDel = false;
  18127. string suiteStr = item["SuiteRoomPrice"].ToString();
  18128. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18129. if (containsDigitButNotZero3) suiteDel = false;
  18130. string otherStr = item["OtherRoomPrice"].ToString();
  18131. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18132. if (containsDigitButNotZero4) otherDel = false;
  18133. string zcStr = item["BreakfastPrice"].ToString();
  18134. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18135. if (containsDigitButNotZero5) zcDel = false;
  18136. string dsStr = item["GovernmentRent"].ToString();
  18137. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18138. if (containsDigitButNotZero6) dsDel = false;
  18139. string cssStr = item["CityTax"].ToString();
  18140. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18141. if (containsDigitButNotZero7) cssDel = false;
  18142. string cpStr = item["ConsumptionPatterns"].ToString();
  18143. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18144. string remarkStr = item["Remark"].ToString();
  18145. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18146. }
  18147. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18148. DeleteColumn(serverPath, cpIndex, cpDel);
  18149. DeleteColumn(serverPath, dsIndex, dsDel);
  18150. DeleteColumn(serverPath, cssIndex, cssDel);
  18151. DeleteColumn(serverPath, zcIndex, zcDel);
  18152. DeleteColumn(serverPath, otherIndex, otherDel);
  18153. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18154. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18155. DeleteColumn(serverPath, singleIndex, singleDel);
  18156. #endregion
  18157. //只保留第一个表格
  18158. DeleteSheet(serverPath);
  18159. return Ok(JsonView(true, "操作成功", url = rst));
  18160. }
  18161. else
  18162. {
  18163. _currency = _GroupCostParameter.Currency;
  18164. bool isIntType = int.TryParse(_currency, out int currId);
  18165. if (isIntType)
  18166. {
  18167. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18168. }
  18169. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18170. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18171. if (currInfo == null)
  18172. {
  18173. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18174. }
  18175. if (!_currency.ToUpper().Equals("CNY"))
  18176. {
  18177. _rate = _GroupCostParameter.Rate;
  18178. }
  18179. _rate = currInfo.Rate;
  18180. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18181. //string strFileName = "HotelStatement/";
  18182. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18183. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18184. #region 数据处理
  18185. foreach (var item in hrDtas)
  18186. {
  18187. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18188. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18189. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18190. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18191. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18192. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18193. string singleRoomFeeStr = string.Empty,
  18194. doubleRoomFeeStr = string.Empty,
  18195. suiteRoomFeeStr = string.Empty,
  18196. otherRoomFeeStr = string.Empty,
  18197. payMoneyStr = string.Empty,
  18198. cardPriceStr = string.Empty;
  18199. if (roomCurr.Equals(_currency))
  18200. {
  18201. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18202. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18203. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18204. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18205. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18206. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18207. }
  18208. else
  18209. {
  18210. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18211. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18212. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18213. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18214. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18215. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18216. }
  18217. string breakfastPriceStr = string.Empty,
  18218. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18219. governmentRentStr = string.Empty,
  18220. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18221. cityTaxStrStr = string.Empty,
  18222. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18223. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18224. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18225. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18226. int payDId = roomInfo?.PayDId ?? 0;
  18227. pcfds.Add(new HotelReservations_PCFD_View()
  18228. {
  18229. City = item.City,
  18230. HotelName = item.HotelName,
  18231. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18232. // SingleRoomCount = item.SingleRoomCount,
  18233. SingleRoomPrice = singleRoomFeeStr,
  18234. // DoubleRoomCount = item.DoubleRoomCount,
  18235. DoubleRoomPrice = doubleRoomFeeStr,
  18236. //SuiteRoomCount = item.SuiteRoomCount,
  18237. SuiteRoomPrice = suiteRoomFeeStr,
  18238. OtherRoomPrice = otherRoomFeeStr,
  18239. //OtherRoomCount = item.OtherRoomCount,
  18240. BreakfastPrice = breakfastPriceStr,
  18241. GovernmentRent = governmentRentStr,
  18242. CityTax = cityTaxStrStr,
  18243. RoomExplanation = item.RoomExplanation,
  18244. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18245. PayTime = roomInfo?.ConsumptionDate,
  18246. BankNo = roomInfo?.BankNo,
  18247. PayMoney = payMoneyStr,
  18248. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18249. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18250. CardPrice = cardPriceStr,
  18251. Remark = ccpInfo.Remark
  18252. });
  18253. }
  18254. #endregion
  18255. //载入模板
  18256. WorkbookDesigner designer = new WorkbookDesigner();
  18257. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18258. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18259. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18260. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18261. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18262. designer.SetDataSource("Opertor", userInfo.CnName);
  18263. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18264. dt.TableName = "ViewMyHotelReservations";
  18265. designer.SetDataSource(dt);
  18266. designer.Process();
  18267. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18268. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18269. designer.Workbook.Save(serverPath);
  18270. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18271. #region 删除指定行
  18272. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18273. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18274. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18275. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18276. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18277. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18278. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18279. cssIndex = dt.Columns["CityTax"].Ordinal,
  18280. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18281. remarkIndex = dt.Columns["Remark"].Ordinal;
  18282. //删除指定列
  18283. foreach (DataRow item in dt.Rows)
  18284. {
  18285. string singleStr = item["SingleRoomPrice"].ToString();
  18286. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18287. if (containsDigitButNotZero1) singleDel = false;
  18288. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18289. string doubleStr = item["DoubleRoomPrice"].ToString();
  18290. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18291. if (containsDigitButNotZero2) doubleDel = false;
  18292. string suiteStr = item["SuiteRoomPrice"].ToString();
  18293. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18294. if (containsDigitButNotZero3) suiteDel = false;
  18295. string otherStr = item["OtherRoomPrice"].ToString();
  18296. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18297. if (containsDigitButNotZero4) otherDel = false;
  18298. string zcStr = item["BreakfastPrice"].ToString();
  18299. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18300. if (containsDigitButNotZero5) zcDel = false;
  18301. string dsStr = item["GovernmentRent"].ToString();
  18302. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18303. if (containsDigitButNotZero6) dsDel = false;
  18304. string cssStr = item["CityTax"].ToString();
  18305. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18306. if (containsDigitButNotZero7) cssDel = false;
  18307. string cpStr = item["ConsumptionPatterns"].ToString();
  18308. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18309. string remarkStr = item["Remark"].ToString();
  18310. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18311. }
  18312. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18313. DeleteColumn(serverPath, cpIndex, cpDel);
  18314. DeleteColumn(serverPath, dsIndex, dsDel);
  18315. DeleteColumn(serverPath, cssIndex, cssDel);
  18316. DeleteColumn(serverPath, zcIndex, zcDel);
  18317. DeleteColumn(serverPath, otherIndex, otherDel);
  18318. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18319. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18320. DeleteColumn(serverPath, singleIndex, singleDel);
  18321. #endregion
  18322. //只保留第一个表格
  18323. DeleteSheet(serverPath);
  18324. return Ok(JsonView(true, "操作成功", url = rst));
  18325. }
  18326. //return Ok(JsonView(false));
  18327. }
  18328. /// <summary>
  18329. /// 删除指定列
  18330. /// </summary>
  18331. /// <param name="file"></param>
  18332. /// <param name="columnIndex"></param>
  18333. /// <param name="isDel"></param>
  18334. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18335. {
  18336. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18337. //wb.Save(file);
  18338. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18339. if (sheet1 != null)
  18340. {
  18341. if (isDel)
  18342. {
  18343. Cells cells = sheet1.Cells;
  18344. cells.DeleteColumn(columnIndex);
  18345. }
  18346. }
  18347. wb.Save(file);
  18348. }
  18349. /// <summary>
  18350. /// 删除sheet
  18351. /// </summary>
  18352. /// <param name="file"></param>
  18353. /// <param name="sheetName"></param>
  18354. private void DeleteSheet(string file, string sheetName = "")
  18355. {
  18356. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18357. //wb.Save(file);
  18358. List<string> sheets = new List<string>();
  18359. foreach (var item in wb.Worksheets)
  18360. {
  18361. sheets.Add(item.Name);
  18362. }
  18363. if (sheets.Count > 0)
  18364. {
  18365. sheets.RemoveAt(0);//不删除第一个sheet
  18366. foreach (var item in sheets)
  18367. {
  18368. wb.Worksheets.RemoveAt(item);
  18369. }
  18370. }
  18371. wb.Save(file);
  18372. }
  18373. /// <summary>
  18374. /// 酒店预订
  18375. /// 确认单
  18376. /// </summary>
  18377. /// <param name="_dto"></param>
  18378. /// <returns></returns>
  18379. [HttpPost]
  18380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18381. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18382. {
  18383. try
  18384. {
  18385. #region 参数验证
  18386. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18387. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18388. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18389. #region 团组操作权限验证 76 酒店预定模块
  18390. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18391. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18392. #endregion
  18393. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18394. #region 页面操作权限验证
  18395. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18396. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18397. #endregion
  18398. #endregion
  18399. //团组信息
  18400. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18401. //酒店数据
  18402. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18403. if (listhoteldata.Count < 0)
  18404. {
  18405. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18406. }
  18407. //利datatable存储
  18408. DataTable dt = new DataTable();
  18409. dt.Columns.Add("CheckInDate", typeof(string));
  18410. dt.Columns.Add("City", typeof(string));
  18411. dt.Columns.Add("Hotel", typeof(string));
  18412. dt.Columns.Add("Room", typeof(string));
  18413. for (int i = 0; i < listhoteldata.Count; i++)
  18414. {
  18415. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18416. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18417. while (dayStart < dayEnd)
  18418. {
  18419. string temp = "";
  18420. DataRow row = dt.NewRow();
  18421. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18422. row["City"] = listhoteldata[i].City;
  18423. row["Hotel"] = listhoteldata[i].HotelName;
  18424. if (listhoteldata[i].SingleRoomCount > 0)
  18425. {
  18426. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18427. }
  18428. if (listhoteldata[i].DoubleRoomCount > 0)
  18429. {
  18430. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18431. }
  18432. if (listhoteldata[i].SuiteRoomCount > 0)
  18433. {
  18434. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18435. }
  18436. if (listhoteldata[i].OtherRoomCount > 0)
  18437. {
  18438. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18439. }
  18440. row["Room"] = temp;
  18441. dt.Rows.Add(row);
  18442. dayStart = dayStart.AddDays(1);
  18443. }
  18444. }
  18445. Dictionary<string, string> dic = new Dictionary<string, string>();
  18446. dic.Add("Dele", di.TeamName);
  18447. dic.Add("City", di.VisitCountry);
  18448. //模板路径
  18449. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18450. //载入模板
  18451. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18452. DocumentBuilder builder = new DocumentBuilder(doc);
  18453. foreach (var key in dic.Keys)
  18454. {
  18455. builder.MoveToBookmark(key);
  18456. builder.Write(dic[key]);
  18457. }
  18458. //获取word里所有表格
  18459. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18460. //获取所填表格的序数
  18461. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18462. var rowStart = tableOne.Rows[0]; //获取第1行
  18463. //循环赋值
  18464. for (int i = 0; i < dt.Rows.Count; i++)
  18465. {
  18466. builder.MoveToCell(0, i + 1, 0, 0);
  18467. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18468. builder.MoveToCell(0, i + 1, 1, 0);
  18469. builder.Write(dt.Rows[i]["City"].ToString());
  18470. builder.MoveToCell(0, i + 1, 2, 0);
  18471. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18472. builder.MoveToCell(0, i + 1, 3, 0);
  18473. builder.Write(dt.Rows[i]["Room"].ToString());
  18474. }
  18475. //删除多余行
  18476. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18477. {
  18478. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18479. }
  18480. string strFileName = di.TeamName + "酒店确认单.doc";
  18481. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18482. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18483. return Ok(JsonView(true, "成功", url));
  18484. }
  18485. catch (Exception ex)
  18486. {
  18487. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18488. }
  18489. }
  18490. #endregion
  18491. #region 团组状态
  18492. /// <summary>
  18493. /// 团组状态列表 Page
  18494. /// </summary>
  18495. /// <param name="dto">团组列表请求dto</param>
  18496. /// <returns></returns>
  18497. [HttpPost]
  18498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18499. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18500. {
  18501. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18502. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18503. {
  18504. string sqlWhere = string.Empty;
  18505. if (dto.IsSure == 0) //未完成
  18506. {
  18507. sqlWhere += string.Format(@" And IsSure = 0");
  18508. }
  18509. else if (dto.IsSure == 1) //已完成
  18510. {
  18511. sqlWhere += string.Format(@" And IsSure = 1");
  18512. }
  18513. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18514. {
  18515. string tj = dto.SearchCriteria;
  18516. 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}%')",
  18517. tj, tj, tj, tj, tj);
  18518. }
  18519. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18520. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18521. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18522. From (
  18523. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18524. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18525. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18526. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18527. From Grp_DelegationInfo gdi
  18528. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18529. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18530. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18531. Where gdi.IsDel = 0 {0}
  18532. ) temp ", sqlWhere);
  18533. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18534. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18535. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18536. }
  18537. else
  18538. {
  18539. return Ok(JsonView(false, "查询失败"));
  18540. }
  18541. }
  18542. /// <summary>
  18543. /// 团组状态
  18544. /// 设置操作完成
  18545. /// </summary>
  18546. /// <param name="dto">团组列表请求dto</param>
  18547. /// <returns></returns>
  18548. [HttpPost]
  18549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18550. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18551. {
  18552. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18553. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18554. {
  18555. Id = dto.Id,
  18556. IsSure = 1
  18557. };
  18558. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18559. .UpdateColumns(it => new { it.IsSure })
  18560. .WhereColumns(it => new { it.Id })
  18561. .ExecuteCommandAsync();
  18562. if (result > 0)
  18563. {
  18564. return Ok(JsonView(true, "操作完成!"));
  18565. }
  18566. return Ok(JsonView(false, "操作失败!"));
  18567. }
  18568. #endregion
  18569. #region 保险费用录入
  18570. /// <summary>
  18571. /// 根据团组Id查询保险费用列表
  18572. /// </summary>
  18573. /// <param name="dto"></param>
  18574. /// <returns></returns>
  18575. [HttpPost]
  18576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18577. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18578. {
  18579. Result groupData = await _customersRep.CustomersByDiId(dto);
  18580. if (groupData.Code != 0)
  18581. {
  18582. return Ok(JsonView(false, groupData.Msg));
  18583. }
  18584. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18585. }
  18586. /// <summary>
  18587. /// 根据保险费用Id查询保险费用详细
  18588. /// </summary>
  18589. /// <param name="dto"></param>
  18590. /// <returns></returns>
  18591. [HttpPost]
  18592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18593. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18594. {
  18595. try
  18596. {
  18597. Result groupData = await _customersRep.CustomersById(dto);
  18598. if (groupData.Code != 0)
  18599. {
  18600. return Ok(JsonView(false, groupData.Msg));
  18601. }
  18602. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18603. }
  18604. catch (Exception ex)
  18605. {
  18606. return Ok(JsonView(false, ex.Message));
  18607. }
  18608. }
  18609. /// <summary>
  18610. /// 保险费用录入页面初始化绑定
  18611. /// </summary>
  18612. /// <param name="dto"></param>
  18613. /// <returns></returns>
  18614. [HttpPost]
  18615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18616. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18617. {
  18618. try
  18619. {
  18620. Result groupData = await _customersRep.CustomersInitialize(dto);
  18621. if (groupData.Code != 0)
  18622. {
  18623. return Ok(JsonView(false, groupData.Msg));
  18624. }
  18625. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18626. }
  18627. catch (Exception ex)
  18628. {
  18629. return Ok(JsonView(false, ex.Message));
  18630. }
  18631. }
  18632. /// <summary>
  18633. /// 保险费用操作(Status:1.新增,2.修改)
  18634. /// </summary>
  18635. /// <param name="dto"></param>
  18636. /// <returns></returns>
  18637. [HttpPost]
  18638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18639. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18640. {
  18641. Result groupData = await _customersRep.OpCustomers(dto);
  18642. if (groupData.Code != 0)
  18643. {
  18644. return Ok(JsonView(false, groupData.Msg));
  18645. }
  18646. #region 应用推送
  18647. try
  18648. {
  18649. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18650. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18651. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18652. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18653. //自动审核
  18654. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18655. //2024-10-21 新增LZ UID
  18656. var userIds = new List<int>() { 21 };
  18657. string title = $"系统通知";
  18658. var diId = dto.DiId;
  18659. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18660. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18661. string content = "";
  18662. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18663. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18664. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18665. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18666. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18667. }
  18668. catch (Exception ex)
  18669. {
  18670. }
  18671. #endregion
  18672. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18673. }
  18674. /// <summary>
  18675. /// 保险文件上传
  18676. /// </summary>
  18677. /// <param name="file"></param>
  18678. /// <returns></returns>
  18679. [HttpPost]
  18680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18681. public async Task<IActionResult> UploadCus(IFormFile file)
  18682. {
  18683. try
  18684. {
  18685. if (file != null)
  18686. {
  18687. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18688. //文件名称
  18689. string projectFileName = file.FileName;
  18690. //上传的文件的路径
  18691. string filePath = "";
  18692. if (!Directory.Exists(fileDir))
  18693. {
  18694. Directory.CreateDirectory(fileDir);
  18695. }
  18696. //上传的文件的路径
  18697. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18698. using (FileStream fs = System.IO.File.Create(filePath))
  18699. {
  18700. file.CopyTo(fs);
  18701. fs.Flush();
  18702. }
  18703. return Ok(JsonView(true, "上传成功!", projectFileName));
  18704. }
  18705. else
  18706. {
  18707. return Ok(JsonView(false, "上传失败!"));
  18708. }
  18709. }
  18710. catch (Exception ex)
  18711. {
  18712. return Ok(JsonView(false, "程序错误!"));
  18713. throw;
  18714. }
  18715. }
  18716. /// <summary>
  18717. /// 保险删除指定文件
  18718. /// </summary>
  18719. /// <param name="dto"></param>
  18720. /// <returns></returns>
  18721. [HttpPost]
  18722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18723. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18724. {
  18725. try
  18726. {
  18727. string filePath = "";
  18728. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18729. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18730. //int id = 0;
  18731. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18732. // 删除该文件
  18733. try
  18734. {
  18735. System.IO.File.Delete(filePath);
  18736. 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()
  18737. {
  18738. Attachment = "",
  18739. }).ExecuteCommandAsync();
  18740. if (result != 0)
  18741. {
  18742. return Ok(JsonView(true, "成功!"));
  18743. }
  18744. else
  18745. {
  18746. return Ok(JsonView(false, "失败!"));
  18747. }
  18748. }
  18749. catch (Exception)
  18750. {
  18751. 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()
  18752. {
  18753. Attachment = "",
  18754. }).ExecuteCommandAsync();
  18755. if (result != 0)
  18756. {
  18757. return Ok(JsonView(true, "成功!"));
  18758. }
  18759. else
  18760. {
  18761. return Ok(JsonView(false, "失败!"));
  18762. }
  18763. }
  18764. }
  18765. catch (Exception ex)
  18766. {
  18767. return Ok(JsonView(false, "程序错误!"));
  18768. throw;
  18769. }
  18770. }
  18771. /// <summary>
  18772. /// 保险费用操作(删除)
  18773. /// </summary>
  18774. /// <param name="dto"></param>
  18775. /// <returns></returns>
  18776. [HttpPost]
  18777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18778. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18779. {
  18780. try
  18781. {
  18782. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18783. if (!res)
  18784. {
  18785. return Ok(JsonView(false, "删除失败"));
  18786. }
  18787. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18788. {
  18789. IsDel = 1,
  18790. DeleteUserId = dto.DeleteUserId,
  18791. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18792. }).ExecuteCommandAsync();
  18793. return Ok(JsonView(true, "删除成功!"));
  18794. }
  18795. catch (Exception ex)
  18796. {
  18797. return Ok(JsonView(false, "程序错误!"));
  18798. throw;
  18799. }
  18800. }
  18801. #endregion
  18802. #region 接团客户名单 PageId 104
  18803. /// <summary>
  18804. /// 接团客户名单
  18805. /// 迁移数据(慎用!)
  18806. /// </summary>
  18807. /// <returns></returns>
  18808. [HttpPost]
  18809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18810. public async Task<IActionResult> PostTourClientListChange()
  18811. {
  18812. try
  18813. {
  18814. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18815. //var groupClinetData1
  18816. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18817. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18818. int updateCount = 0;
  18819. if (oldOAClientList.Count > 0)
  18820. {
  18821. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18822. _sqlSugar.BeginTran();
  18823. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18824. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18825. foreach (var item in oldOAClientList)
  18826. {
  18827. int comId = 0;
  18828. string format = "yyyy-MM-dd HH:mm:ss";
  18829. string data11 = "1990-01-01 00:00";
  18830. var data1 = IsValidDate(item.OPdate, format);
  18831. if (data1) data11 = item.OPdate;
  18832. //客户公司验证
  18833. if (!string.IsNullOrEmpty(item.Company))
  18834. {
  18835. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  18836. if (clientComInfo == null) // add
  18837. {
  18838. var addInfo = new Crm_CustomerCompany()
  18839. {
  18840. CompanyAbbreviation = "",
  18841. CompanyFullName = item.Company,
  18842. Address = "",
  18843. PostCodes = "",
  18844. LastedOpUserId = item.OPer,
  18845. LastedOpDt = Convert.ToDateTime(data11),
  18846. CreateUserId = item.OPer,
  18847. CreateTime = Convert.ToDateTime(data11),
  18848. IsDel = 0
  18849. };
  18850. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  18851. if (comId1 > 0) comId = comId1;
  18852. }
  18853. else comId = clientComInfo.Id;
  18854. }
  18855. //客户人员验证
  18856. int clientId = 0;
  18857. string name = item.LastName + item.Name;
  18858. if (!string.IsNullOrEmpty(name))
  18859. {
  18860. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  18861. if (clientInfo == null)
  18862. {
  18863. DateTime? dateTime = null;
  18864. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  18865. if (isDt) dateTime = birthDayDt;
  18866. var addInfo1 = new Crm_DeleClient()
  18867. {
  18868. CrmCompanyId = comId,
  18869. DiId = -1,
  18870. LastName = item.LastName,
  18871. FirstName = item.Name,
  18872. OldName = "",
  18873. Pinyin = item.Pinyin,
  18874. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  18875. Marriage = 0,
  18876. Phone = item.Phone,
  18877. Job = item.Job,
  18878. BirthDay = dateTime
  18879. };
  18880. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  18881. if (clientId1 > 0) clientId = clientId1;
  18882. }
  18883. else clientId = clientInfo.Id;
  18884. }
  18885. if (clientId < 1)
  18886. {
  18887. continue;
  18888. }
  18889. int airType = 0;
  18890. if (item.AirType == "超经舱") airType = 459;
  18891. else if (item.AirType == "公务舱") airType = 458;
  18892. else if (item.AirType == "经济舱") airType = 460;
  18893. else if (item.AirType == "其他") airType = 565;
  18894. else if (item.AirType == "头等舱") airType = 457;
  18895. var _TourClientListEntity = new Grp_TourClientList()
  18896. {
  18897. DiId = item.Diid,
  18898. ClientId = clientId,
  18899. CreateUserId = item.OPer,
  18900. CreateTime = Convert.ToDateTime(data11),
  18901. Remark = item.Remark,
  18902. IsDel = item.Isdel,
  18903. ShippingSpaceTypeId = airType,
  18904. ShippingSpaceSpecialNeeds = item.AirRemark,
  18905. HotelSpecialNeeds = item.RoomType
  18906. };
  18907. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  18908. if (_TourClientList > 0)
  18909. {
  18910. updateCount++;
  18911. }
  18912. }
  18913. _sqlSugar.CommitTran();
  18914. }
  18915. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  18916. }
  18917. catch (Exception ex)
  18918. {
  18919. _sqlSugar.RollbackTran();
  18920. return Ok(JsonView(false, ex.Message));
  18921. }
  18922. //return Ok(JsonView(true));
  18923. }
  18924. private bool IsValidDate(string dateString, string format)
  18925. {
  18926. DateTime dateValue;
  18927. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  18928. return valid;
  18929. }
  18930. /// <summary>
  18931. /// 接团客户名单
  18932. /// 根据团组Id查询List
  18933. /// </summary>
  18934. /// <param name="_dto"></param>
  18935. /// <returns></returns>
  18936. [HttpPost]
  18937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18938. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  18939. {
  18940. #region 参数验证
  18941. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  18942. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  18943. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  18944. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18945. #region 页面操作权限验证
  18946. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18947. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18948. #endregion
  18949. #endregion
  18950. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  18951. if (viewData.Code != 0)
  18952. {
  18953. return Ok(JsonView(false, viewData.Msg));
  18954. }
  18955. return Ok(JsonView(viewData.Data));
  18956. }
  18957. /// <summary>
  18958. /// 接团客户名单
  18959. /// 基础数据 Init
  18960. /// </summary>
  18961. /// <param name="_dto"></param>
  18962. /// <returns></returns>
  18963. [HttpPost]
  18964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18965. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  18966. {
  18967. #region 参数验证
  18968. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18969. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18970. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18971. #region 页面操作权限验证
  18972. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18973. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18974. #endregion
  18975. #endregion
  18976. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  18977. }
  18978. /// <summary>
  18979. /// 接团客户名单
  18980. /// 根据 Id查询 Details
  18981. /// </summary>
  18982. /// <param name="_dto"></param>
  18983. /// <returns></returns>
  18984. [HttpPost]
  18985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18986. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  18987. {
  18988. #region 参数验证
  18989. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18990. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18991. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18992. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18993. #region 页面操作权限验证
  18994. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18995. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18996. #endregion
  18997. #endregion
  18998. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18999. if (viewData.Code != 0)
  19000. {
  19001. return Ok(JsonView(false, viewData.Msg));
  19002. }
  19003. return Ok(JsonView(viewData.Data));
  19004. }
  19005. /// <summary>
  19006. /// 接团客户名单
  19007. /// Add Or Edit
  19008. /// </summary>
  19009. /// <param name="_dto"></param>
  19010. /// <returns></returns>
  19011. [HttpPost]
  19012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19013. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19014. {
  19015. #region 参数验证
  19016. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19017. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19018. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19019. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19020. #region 页面操作权限验证
  19021. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19022. if (_dto.Id == 0) //添加
  19023. {
  19024. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19025. }
  19026. else if (_dto.Id >= 0) //修改
  19027. {
  19028. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19029. }
  19030. #endregion
  19031. #endregion
  19032. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19033. if (viewData.Code != 0)
  19034. {
  19035. return Ok(JsonView(false, viewData.Msg));
  19036. }
  19037. return Ok(JsonView(true));
  19038. }
  19039. /// <summary>
  19040. /// 接团客户名单
  19041. /// json字符串 AddMultiple(添加多个)
  19042. /// </summary>
  19043. /// <param name="_dto"></param>
  19044. /// <returns></returns>
  19045. [HttpPost]
  19046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19047. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19048. {
  19049. #region 参数验证
  19050. string jsonLabel = _dto.JsonLabel;
  19051. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19052. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19053. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19054. #region 页面操作权限验证
  19055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19056. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19057. #endregion
  19058. #endregion
  19059. var request = new TourClientListAddMultipleDto();
  19060. request.DiId = _dto.DiId;
  19061. request.UserId = _dto.UserId;
  19062. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19063. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19064. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19065. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19066. var infos = new List<TourClientListInfo>();
  19067. foreach (var data in datas)
  19068. {
  19069. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19070. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19071. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19072. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19073. {
  19074. continue;
  19075. }
  19076. infos.Add(new TourClientListInfo()
  19077. {
  19078. IsAccompany = 1,
  19079. LastName = lastName,
  19080. FirstName = firstName,
  19081. Pinyin = lastNameEn + @"/" + firstNameEn,
  19082. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19083. CompanyFullName = data.CompanyFullName,
  19084. Job = data.Job
  19085. });
  19086. }
  19087. if (infos.Any())
  19088. {
  19089. var viewData = await _tourClientListRep._AddMultiple(request);
  19090. if (viewData.Code != 0)
  19091. {
  19092. return Ok(JsonView(false, viewData.Msg));
  19093. }
  19094. return Ok(JsonView(true));
  19095. }
  19096. return Ok(JsonView(false));
  19097. }
  19098. /// <summary>
  19099. /// 接团客户名单
  19100. /// AddMultiple(添加多个)
  19101. /// </summary>
  19102. /// <param name="_dto"></param>
  19103. /// <returns></returns>
  19104. [HttpPost]
  19105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19106. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19107. {
  19108. #region 参数验证
  19109. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19110. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19111. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19112. #region 页面操作权限验证
  19113. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19114. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19115. #endregion
  19116. #endregion
  19117. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19118. if (viewData.Code != 0)
  19119. {
  19120. return Ok(JsonView(false, viewData.Msg));
  19121. }
  19122. return Ok(JsonView(true));
  19123. }
  19124. /// <summary>
  19125. /// 接团客户名单
  19126. /// Del
  19127. /// </summary>
  19128. /// <param name="_dto"></param>
  19129. /// <returns></returns>
  19130. [HttpPost]
  19131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19132. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19133. {
  19134. #region 参数验证
  19135. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19136. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19137. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19138. #region 页面操作权限验证
  19139. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19140. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19141. #endregion
  19142. #endregion
  19143. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19144. if (viewData.Code != 0)
  19145. {
  19146. return Ok(JsonView(false, viewData.Msg));
  19147. }
  19148. return Ok(JsonView(true));
  19149. }
  19150. /// <summary>
  19151. /// 接团客户名单
  19152. /// 文件下载 客户名单
  19153. /// </summary>
  19154. /// <param name="_dto"></param>
  19155. /// <returns></returns>
  19156. [HttpPost]
  19157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19158. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19159. {
  19160. #region 参数验证
  19161. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19162. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19163. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19164. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19165. #region 页面操作权限验证
  19166. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19167. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19168. #endregion
  19169. #endregion
  19170. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19171. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19172. From Grp_TourClientList tcl
  19173. Left Join
  19174. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19175. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19176. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19177. From Crm_DeleClient dc
  19178. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19179. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19180. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19181. Where dc.IsDel = 0) temp
  19182. On temp.DcId =tcl.ClientId
  19183. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19184. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19185. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19186. //载入模板
  19187. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19188. if (_dto.Language == 1)
  19189. {
  19190. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19191. }
  19192. //载入模板
  19193. var doc = new Document(tempPath);
  19194. DocumentBuilder builder = new DocumentBuilder(doc);
  19195. //获取word里所有表格
  19196. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19197. //获取所填表格的序数
  19198. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19199. var rowStart = tableOne.Rows[0]; //获取第1行
  19200. if (_dto.Language == 0)
  19201. {
  19202. //循环赋值
  19203. for (int i = 0; i < DcList.Count; i++)
  19204. {
  19205. EncryptionProcessor.DecryptProperties(DcList[i]);
  19206. builder.MoveToCell(0, i + 1, 0, 0);
  19207. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19208. builder.MoveToCell(0, i + 1, 1, 0);
  19209. int sex = DcList[i].Sex;
  19210. string sexStr = string.Empty;
  19211. if (sex == 0) sexStr = "男";
  19212. else if (sex == 1) sexStr = "女";
  19213. else sexStr = "未设置";
  19214. builder.Write(sexStr);
  19215. builder.MoveToCell(0, i + 1, 2, 0);
  19216. string birthDay = DcList[i].BirthDay;
  19217. string birthDayStr = string.Empty;
  19218. if (!string.IsNullOrEmpty(birthDay))
  19219. {
  19220. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19221. }
  19222. builder.Write(birthDayStr);
  19223. builder.MoveToCell(0, i + 1, 3, 0);
  19224. string company = "";
  19225. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19226. {
  19227. company = DcList[i].CompanyFullName.ToString();
  19228. }
  19229. builder.Write(company);
  19230. builder.MoveToCell(0, i + 1, 4, 0);
  19231. builder.Write(DcList[i].Job);
  19232. }
  19233. }
  19234. else if (_dto.Language == 1)
  19235. {
  19236. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19237. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19238. List<string> transArrayStr = new List<string>();
  19239. string transStrRes1 = "";
  19240. for (int i = 0; i < DcList.Count; i++)
  19241. {
  19242. var dc = DcList[i];
  19243. EncryptionProcessor.DecryptProperties(dc);
  19244. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19245. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19246. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19247. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19248. else transStrRes1 += $"{str1}|";
  19249. }
  19250. #region AI转英文
  19251. string jsonValue = JsonConvert.SerializeObject(DcList);
  19252. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19253. List<SeedMessages> messages = new List<SeedMessages>()
  19254. {
  19255. new SeedMessages
  19256. {
  19257. Role = KimiRole.user,
  19258. Content = jsonValue + text
  19259. }
  19260. };
  19261. KiMiApiClient client = new KiMiApiClient();
  19262. var kimiApiResult = await client.SeedMessage(messages);
  19263. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19264. string clients = kimiApiResult_JObject["content"].ToString();
  19265. string startStr = "```json", endStr = "```";
  19266. // 判断并清除开头部分
  19267. if (clients.StartsWith(startStr))
  19268. {
  19269. clients = clients.Remove(0, startStr.Length);
  19270. }
  19271. // 判断并清除结尾部分
  19272. if (clients.EndsWith(endStr))
  19273. {
  19274. clients = clients.Remove(clients.Length - endStr.Length);
  19275. }
  19276. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19277. //循环赋值
  19278. for (int i = 0; i < en_Json.Count; i++)
  19279. {
  19280. var dc = en_Json[i];
  19281. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19282. string PYName = dc.FirstName + " " + dc.LastName;
  19283. builder.MoveToCell(0, i + 1, 0, 0);
  19284. builder.Write(PYName);
  19285. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19286. builder.MoveToCell(0, i + 1, 1, 0);
  19287. builder.Write(sex);
  19288. DateTime birthDt;
  19289. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19290. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19291. builder.MoveToCell(0, i + 1, 2, 0);
  19292. builder.Write(birthday);
  19293. string company = string.Empty, job = string.Empty;
  19294. company = dc.CompanyFullName;
  19295. job = dc.Job;
  19296. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19297. {
  19298. //查询对照表
  19299. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19300. if (tempCec != null)
  19301. {
  19302. company = tempCec.enName;
  19303. }
  19304. }
  19305. builder.MoveToCell(0, i + 1, 3, 0);
  19306. builder.Write(company);
  19307. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19308. {
  19309. //查询对照表
  19310. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19311. if (tempPec != null)
  19312. {
  19313. job = tempPec.enName;
  19314. }
  19315. }
  19316. builder.MoveToCell(0, i + 1, 4, 0);
  19317. builder.Write(job);
  19318. }
  19319. #endregion
  19320. #region 旧翻译英文处理
  19321. ////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";
  19322. //string transStrRes = "";
  19323. //if (transStrRes1.Length > 0)
  19324. //{
  19325. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19326. //}
  19327. ////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
  19328. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19329. ////List<string> transArray = new List<string> { };
  19330. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19331. //if (transStrRes.Contains("|"))
  19332. //{
  19333. // string[] transArray1 = transStrRes.Split('|');
  19334. // if (transArray1.Length > 0)
  19335. // {
  19336. // foreach (var item in transArray1)
  19337. // {
  19338. // if (item.Contains("&"))
  19339. // {
  19340. // string[] transArray2 = item.Split('&');
  19341. // int index = 0;
  19342. // string companyName = "", job = "";
  19343. // if (transArray2.Length > 0)
  19344. // {
  19345. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19346. // if (1 < transArray2.Length) companyName = transArray2[1];
  19347. // if (2 < transArray2.Length) job = transArray2[2];
  19348. // }
  19349. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19350. // }
  19351. // }
  19352. // }
  19353. //}
  19354. ////循环赋值
  19355. //for (int i = 0; i < DcList.Count; i++)
  19356. //{
  19357. // string PYName = "";
  19358. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19359. // {
  19360. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19361. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19362. // PYName = PY_First + " " + PY_Last;
  19363. // }
  19364. // else
  19365. // {
  19366. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19367. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19368. // PYName = PY_First + " " + PY_Last;
  19369. // }
  19370. // builder.MoveToCell(0, i + 1, 0, 0);
  19371. // builder.Write(PYName);
  19372. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19373. // builder.MoveToCell(0, i + 1, 1, 0);
  19374. // builder.Write(sex);
  19375. // DateTime birthDt;
  19376. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19377. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19378. // builder.MoveToCell(0, i + 1, 2, 0);
  19379. // builder.Write(birthday);
  19380. // string company = string.Empty, job = string.Empty;
  19381. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19382. // if (dcTransInfo != null)
  19383. // {
  19384. // company = dcTransInfo.CompanyName;
  19385. // job = dcTransInfo.Job;
  19386. // }
  19387. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19388. // {
  19389. // //查询对照表
  19390. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19391. // if (tempCec != null)
  19392. // {
  19393. // company = tempCec.enName;
  19394. // }
  19395. // //翻译
  19396. // else
  19397. // {
  19398. // }
  19399. // }
  19400. // builder.MoveToCell(0, i + 1, 3, 0);
  19401. // builder.Write(company);
  19402. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19403. // {
  19404. // //查询对照表
  19405. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19406. // if (tempPec != null)
  19407. // {
  19408. // job = tempPec.enName;
  19409. // }
  19410. // //翻译
  19411. // else
  19412. // {
  19413. // }
  19414. // }
  19415. // builder.MoveToCell(0, i + 1, 4, 0);
  19416. // builder.Write(job);
  19417. //}
  19418. #endregion
  19419. }
  19420. //删除多余行
  19421. while (tableOne.Rows.Count > DcList.Count + 1)
  19422. {
  19423. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19424. }
  19425. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19426. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19427. doc.Save(fileDir);
  19428. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19429. return Ok(JsonView(true, "操作成功!", Url));
  19430. }
  19431. private class TranslateInfo
  19432. {
  19433. public int Index { get; set; }
  19434. public string CompanyName { get; set; }
  19435. public string Job { get; set; }
  19436. }
  19437. [HttpPost]
  19438. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19439. {
  19440. if (files.Count == 0)
  19441. {
  19442. return Ok(JsonView(false, "文件为空"));
  19443. }
  19444. KiMiApiClient KiMiApi = new KiMiApiClient();
  19445. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19446. if (seedConter.Count == 0)
  19447. {
  19448. return Ok(JsonView(false, "上传结果为空!"));
  19449. }
  19450. var messages = new List<SeedMessages>
  19451. {
  19452. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19453. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19454. };
  19455. messages.InsertRange(1, seedConter);
  19456. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19457. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19458. string clients = kimiApiResult_JObject["content"].ToString();
  19459. string startStr = "```json", endStr = "```";
  19460. // 判断并清除开头部分
  19461. if (clients.StartsWith(startStr))
  19462. {
  19463. clients = clients.Remove(0, startStr.Length);
  19464. }
  19465. // 判断并清除结尾部分
  19466. if (clients.EndsWith(endStr))
  19467. {
  19468. clients = clients.Remove(clients.Length - endStr.Length);
  19469. }
  19470. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19471. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19472. {
  19473. {"姓", "LastName" },
  19474. {"名", "FirstName" },
  19475. {"姓名拼音", "Pinyin" },
  19476. {"性别", "Sex" },
  19477. {"单位", "CompanyFullName" },
  19478. {"职务", "Job" },
  19479. {"出生日期", "Birthday" },
  19480. };
  19481. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19482. foreach (var item in clients_JObject)
  19483. {
  19484. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19485. foreach (var field in clientFieldMap.Keys)
  19486. {
  19487. if (item.TryGetValue(field, out JToken value))
  19488. {
  19489. var getValue = value.ToString();
  19490. System.Type type = cdc.GetType();
  19491. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19492. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19493. propertyInfo.SetValue(cdc, propertyValue);
  19494. }
  19495. }
  19496. crmClients.Add(cdc);
  19497. }
  19498. return Ok(JsonView(new
  19499. {
  19500. fileCount = files.Count,
  19501. UploadCount = seedConter.Count,
  19502. ApiResult = clients,
  19503. CrmClients = crmClients
  19504. }));
  19505. }
  19506. #endregion
  19507. #region 团组倒推表
  19508. /// <summary>
  19509. /// 倒推表基础数据
  19510. /// Init
  19511. /// </summary>
  19512. /// <returns></returns>
  19513. [HttpPost]
  19514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19515. public async Task<IActionResult> PostInvertedListInit()
  19516. {
  19517. var viewData = await _invertedListRep._Init();
  19518. if (viewData.Code != 0)
  19519. {
  19520. return Ok(JsonView(false, viewData.Msg));
  19521. }
  19522. return Ok(JsonView(viewData.Data));
  19523. }
  19524. /// <summary>
  19525. /// 倒推表
  19526. /// Info
  19527. /// </summary>
  19528. /// <param name="dto"></param>
  19529. /// <returns></returns>
  19530. [HttpPost]
  19531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19532. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19533. {
  19534. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19535. if (viewData.Code != 0)
  19536. {
  19537. return Ok(JsonView(false, viewData.Msg));
  19538. }
  19539. return Ok(JsonView(viewData.Data));
  19540. }
  19541. /// <summary>
  19542. /// 倒推表
  19543. /// Create
  19544. /// </summary>
  19545. /// <param name="dto"></param>
  19546. /// <returns></returns>
  19547. [HttpPost]
  19548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19549. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19550. {
  19551. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19552. if (viewData.Code != 0)
  19553. {
  19554. return Ok(JsonView(false, viewData.Msg));
  19555. }
  19556. return Ok(JsonView(viewData.Data));
  19557. }
  19558. /// <summary>
  19559. /// 倒推表
  19560. /// Update
  19561. /// </summary>
  19562. /// <param name="dto"></param>
  19563. /// <returns></returns>
  19564. [HttpPost]
  19565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19566. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19567. {
  19568. var viewData = await _invertedListRep._Update(dto);
  19569. if (viewData.Code != 0)
  19570. {
  19571. return Ok(JsonView(false, viewData.Msg));
  19572. }
  19573. return Ok(JsonView(viewData.Data));
  19574. }
  19575. /// <summary>
  19576. /// 倒推表
  19577. /// File Download
  19578. /// </summary>
  19579. /// <param name="dto"></param>
  19580. /// <returns></returns>
  19581. [HttpPost]
  19582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19583. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19584. {
  19585. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19586. if (info2.Code != 0)
  19587. {
  19588. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19589. }
  19590. var info1 = info2.Data as InvertedListInfoView;
  19591. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19592. string teamName = "";
  19593. if (info != null) teamName = info.TeamName;
  19594. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19595. var doc = new Document();
  19596. var builder = new DocumentBuilder(doc);
  19597. #region old insert
  19598. ////载入模板
  19599. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19600. //Document doc = new Document(tempPath);
  19601. //DocumentBuilder builder = new DocumentBuilder(doc);
  19602. //利用键值对存放数据
  19603. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19604. //dic.Add("TeamName", teamName);
  19605. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19606. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19607. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19608. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19609. //dic.Add("SQRemark", info1.ApprovalRemark);
  19610. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19611. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19612. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19613. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19614. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19615. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19616. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19617. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19618. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19619. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19620. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19621. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19622. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19623. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19624. //#region 填充word模板书签内容
  19625. //foreach (var key in dic.Keys)
  19626. //{
  19627. // builder.MoveToBookmark(key);
  19628. // builder.Write(dic[key]);
  19629. //}
  19630. //#endregion
  19631. #endregion
  19632. #region New Insert
  19633. string titleFont = $"仿宋",
  19634. contentFont = $"仿宋";
  19635. var fontColor = Color.FromArgb(64, 64, 64);
  19636. //设置标题 团组名称
  19637. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19638. builder.Font.Name = titleFont;
  19639. builder.Font.Color = fontColor;
  19640. builder.Font.Size = 12;
  19641. builder.Font.Bold = true;
  19642. builder.Writeln(teamName);
  19643. //设置副标题 团组出访时间
  19644. builder.Font.Size = 12;
  19645. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19646. builder.Writeln();
  19647. var backgroundColor = Color.FromArgb(199, 199, 199);
  19648. var table = builder.StartTable();
  19649. builder.InsertCell();
  19650. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19651. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19652. builder.CellFormat.Borders.LineWidth = 1;
  19653. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19654. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19655. builder.RowFormat.Height = 40;
  19656. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19657. builder.Font.Name = contentFont;
  19658. builder.Font.Size = 12;
  19659. builder.Font.Bold = true;
  19660. builder.Font.Color = fontColor;
  19661. builder.Write("时间");
  19662. builder.InsertCell();
  19663. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19664. builder.Write("流程");
  19665. builder.InsertCell();
  19666. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19667. builder.Write("说明");
  19668. builder.EndRow();
  19669. //报批资料准备
  19670. if (info1.IsSelectedAirportd)
  19671. {
  19672. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19673. }
  19674. //报批/提供送签资料
  19675. if (info1.IsSelectedApprovalData)
  19676. {
  19677. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19678. }
  19679. //出批件护照办理
  19680. if (info1.IsSelectedIssueApproval)
  19681. {
  19682. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19683. }
  19684. //签证资料准备
  19685. if (info1.IsSelectedVisaInfo)
  19686. {
  19687. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19688. }
  19689. //送签
  19690. if (info1.IsSelectedSendVisa)
  19691. {
  19692. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19693. }
  19694. //出签
  19695. if (info1.IsSelectedIssueVisa)
  19696. {
  19697. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19698. }
  19699. //机票
  19700. if (info1.IsSelectedAirTicket)
  19701. {
  19702. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19703. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19704. }
  19705. //酒店
  19706. if (info1.IsSelectedHotel)
  19707. {
  19708. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19709. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19710. }
  19711. //开行前会
  19712. if (info1.IsSelectedPreTripMeeting)
  19713. {
  19714. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19715. }
  19716. //送机
  19717. if (info1.IsSelectedAirportdDropOff)
  19718. {
  19719. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19720. }
  19721. builder.EndTable();
  19722. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19723. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19724. for (int i = 0; i < table.Rows.Count; i++)
  19725. {
  19726. var row = table.Rows[i];
  19727. //设置宽度
  19728. row.Cells[0].CellFormat.Width = 20.00;
  19729. row.Cells[1].CellFormat.Width = 30.00;
  19730. row.Cells[2].CellFormat.Width = 50.00;
  19731. if (i != 0)
  19732. {
  19733. //边框设置
  19734. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19735. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19736. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19737. }
  19738. }
  19739. #region 页脚插入图片
  19740. // 创建页脚
  19741. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19742. doc.FirstSection.HeadersFooters.Add(footer);
  19743. Paragraph para = new Paragraph(doc);
  19744. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19745. footer.AppendChild(para);
  19746. builder.MoveTo(para);
  19747. string imagePath = "./Images/FMGJ_Log.png";
  19748. builder.InsertImage(imagePath);
  19749. #endregion
  19750. #endregion
  19751. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19752. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19753. string filePath = fileDir + $@"InvertedList/{fileName}";
  19754. doc.Save(filePath);
  19755. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19756. return Ok(JsonView(true, "操作成功!", Url));
  19757. }
  19758. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19759. {
  19760. var fontColor = Color.FromArgb(64, 64, 64);
  19761. builder.InsertCell();
  19762. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19763. builder.RowFormat.Height = 40;
  19764. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19765. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19766. builder.Font.Name = fontName;
  19767. builder.Font.Size = 8;
  19768. builder.Font.Bold = true;
  19769. builder.Font.Color = fontColor;
  19770. builder.Write(dateTime);
  19771. builder.InsertCell();
  19772. builder.Font.Size = 9;
  19773. builder.Font.Bold = true;
  19774. builder.Font.Color = fontColor;
  19775. builder.Write(content);
  19776. builder.InsertCell();
  19777. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19778. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19779. builder.Font.Size = 9;
  19780. builder.Font.Bold = false;
  19781. builder.Font.Color = fontColor;
  19782. builder.Write(reamrk);
  19783. builder.EndRow();
  19784. }
  19785. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19786. {
  19787. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19788. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19789. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19790. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19791. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19792. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19793. }
  19794. #endregion
  19795. #region 会务倒推表
  19796. /// <summary>
  19797. /// 会务倒推表
  19798. /// Init
  19799. /// </summary>
  19800. /// <returns></returns>
  19801. [HttpPost]
  19802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19803. public async Task<IActionResult> InforRetrogressTableInit()
  19804. {
  19805. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19806. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19807. return Ok(JsonView(false, groupData.Msg));
  19808. }
  19809. /// <summary>
  19810. /// 会务倒推表
  19811. /// ExcelDownload
  19812. /// </summary>
  19813. /// <param name="dto"></param>
  19814. /// <returns></returns>
  19815. [HttpPost]
  19816. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19818. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19819. {
  19820. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19821. var validatorRes = await validator.ValidateAsync(dto);
  19822. if (!validatorRes.IsValid)
  19823. {
  19824. StringBuilder sb = new StringBuilder();
  19825. foreach (var item in validatorRes.Errors)
  19826. {
  19827. sb.AppendLine(item.ErrorMessage);
  19828. }
  19829. return Ok(JsonView(false, sb.ToString()));
  19830. }
  19831. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  19832. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  19833. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  19834. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  19835. #region Excel
  19836. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  19837. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  19838. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  19839. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  19840. var fileNamePrefix = string.Empty;
  19841. if (days >= 30)
  19842. {
  19843. tempPath += $"会务工作倒推进度表(30天).xlsx";
  19844. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  19845. }
  19846. else if (days < 30 && days > 7)
  19847. {
  19848. tempPath += $"会务工作倒推进度表(15天).xlsx";
  19849. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  19850. }
  19851. else if (days <= 7)
  19852. {
  19853. tempPath += $"会务工作倒推进度表(7天).xlsx";
  19854. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  19855. }
  19856. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  19857. fileName = CommonFun.ValidFileName(fileName);
  19858. //载入模板
  19859. WorkbookDesigner designer = new WorkbookDesigner();
  19860. designer.Workbook = new Workbook(tempPath);
  19861. designer.Process();
  19862. if (!Directory.Exists(savePath))
  19863. {
  19864. Directory.CreateDirectory(savePath);
  19865. }
  19866. string serverPath = $"{savePath}{fileName}";
  19867. designer.Workbook.Save(serverPath);
  19868. string rst = $"{servicePath}{ftpPath}{fileName}";
  19869. #endregion
  19870. return Ok(JsonView(new { url = rst }));
  19871. }
  19872. #endregion
  19873. #region 三公签证费用(签证费、代办费)
  19874. /// <summary>
  19875. /// 三公签证费用(签证费、代办费)
  19876. /// List
  19877. /// </summary>
  19878. /// <returns></returns>
  19879. [HttpPost]
  19880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19881. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  19882. {
  19883. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  19884. if (_view.Code != 0)
  19885. {
  19886. return Ok(JsonView(false, _view.Msg));
  19887. }
  19888. return Ok(JsonView(true, "操作成功!", _view.Data));
  19889. }
  19890. /// <summary>
  19891. /// 三公签证费用(签证费、代办费)
  19892. /// Add Or Update
  19893. /// </summary>
  19894. /// <returns></returns>
  19895. [HttpPost]
  19896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19897. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  19898. {
  19899. var _view = await _visaFeeInfoRep._Update(_dto);
  19900. if (_view.Code != 0)
  19901. {
  19902. return Ok(JsonView(false, _view.Msg));
  19903. }
  19904. return Ok(JsonView(true, _view.Msg));
  19905. }
  19906. #endregion
  19907. #region 酒店询价
  19908. /// <summary>
  19909. /// 酒店询价
  19910. /// Init
  19911. /// </summary>
  19912. /// <returns></returns>
  19913. [HttpPost]
  19914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19915. public async Task<IActionResult> PostHotelInquiryInit()
  19916. {
  19917. var res = await _hotelInquiryRep._Init();
  19918. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19919. return Ok(JsonView(true, res.Msg, res.Data));
  19920. }
  19921. /// <summary>
  19922. /// 酒店询价
  19923. /// page Item
  19924. /// </summary>
  19925. /// <param name="_dto"></param>
  19926. /// <returns></returns>
  19927. [HttpPost]
  19928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19929. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  19930. {
  19931. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  19932. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19933. var view = res.Data as PageDataViewBase;
  19934. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  19935. }
  19936. /// <summary>
  19937. /// 酒店询价
  19938. /// info
  19939. /// </summary>
  19940. /// <param name="_dto"></param>
  19941. /// <returns></returns>
  19942. [HttpPost]
  19943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19944. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  19945. {
  19946. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  19947. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19948. return Ok(JsonView(true, res.Msg, res.Data));
  19949. }
  19950. /// <summary>
  19951. /// 酒店询价
  19952. /// Add Or Edit
  19953. /// </summary>
  19954. /// <param name="_dto"></param>
  19955. /// <returns></returns>
  19956. [HttpPost]
  19957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19958. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  19959. {
  19960. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  19961. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19962. return Ok(JsonView(true, res.Msg, res.Data));
  19963. }
  19964. /// <summary>
  19965. /// 酒店询价
  19966. /// Del
  19967. /// </summary>
  19968. /// <param name="_dto"></param>
  19969. /// <returns></returns>
  19970. [HttpPost]
  19971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19972. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  19973. {
  19974. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  19975. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19976. return Ok(JsonView(true, res.Msg, res.Data));
  19977. }
  19978. #endregion
  19979. #region 下载匹配op行程单
  19980. /// <summary>
  19981. /// 匹配op行程单
  19982. /// Init
  19983. /// </summary>
  19984. /// <param name="dto">团组列表请求dto</param>
  19985. /// <returns></returns>
  19986. [HttpPost]
  19987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19988. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  19989. {
  19990. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19991. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19992. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  19993. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  19994. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  19995. .Where(it => it.IsDel == 0)
  19996. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  19997. .OrderByDescending(it => it.VisitStartDate)
  19998. .ToList();
  19999. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20000. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20001. var diids = groupInfos.Select(it => it.Id).ToList();
  20002. List<string> countrys = new List<string>();
  20003. foreach (var item in country)
  20004. {
  20005. var data = _groupRepository.FormartTeamName(item);
  20006. var dataArray = _groupRepository.GroupSplitCountry(data);
  20007. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20008. }
  20009. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20010. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20011. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20012. foreach (var item in areaItem)
  20013. {
  20014. string areaStr = item.Value;
  20015. if (!string.IsNullOrEmpty(areaStr))
  20016. {
  20017. string[] str1 = areaStr.Split("-");
  20018. if (str1.Length > 0)
  20019. {
  20020. areaArray.AddRange(str1);
  20021. }
  20022. }
  20023. }
  20024. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20025. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20026. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20027. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20028. .ToList();
  20029. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20030. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20031. .Where(it => countriesIds.Contains(it.Id))
  20032. .Select(it => new { it.Id, Name = it.Name_CN })
  20033. .ToList();
  20034. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20035. .Select(it => it.TeamName).ToList();
  20036. stopwatch.Stop();
  20037. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20038. }
  20039. ///// <summary>
  20040. ///// 匹配op行程单
  20041. ///// Init 查询区域数据
  20042. ///// </summary>
  20043. ///// <param name="dto">团组列表请求dto</param>
  20044. ///// <returns></returns>
  20045. //[HttpPost]
  20046. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20047. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20048. //{
  20049. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20050. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20051. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20052. // if (string.IsNullOrEmpty(countriesDataStr))
  20053. // {
  20054. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20055. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20056. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20057. // }
  20058. // else
  20059. // {
  20060. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20061. // }
  20062. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20063. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20064. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20065. // List<dynamic> childList = new List<dynamic>();
  20066. // int parentId = dto.CountriesId;
  20067. // if (provinceData.Count > 1)
  20068. // {
  20069. // foreach (var item1 in provinceData)
  20070. // {
  20071. // List<dynamic> childList1 = new List<dynamic>();
  20072. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20073. // foreach (var item2 in citiesData1)
  20074. // {
  20075. // List<dynamic> childList2 = new List<dynamic>();
  20076. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20077. // foreach (var item3 in countiesData1)
  20078. // {
  20079. // childList2.Add(new
  20080. // {
  20081. // id = item3.Id,
  20082. // parentId = item2.Id,
  20083. // level = "district",
  20084. // name = item3.Name_CN,
  20085. // });
  20086. // }
  20087. // childList1.Add(new
  20088. // {
  20089. // id = item2.Id,
  20090. // parentId = item1.Id,
  20091. // level = "city",
  20092. // name = item2.Name_CN,
  20093. // childList = childList2
  20094. // });
  20095. // }
  20096. // childList.Add(new
  20097. // {
  20098. // id = item1.Id,
  20099. // parentId = parentId,
  20100. // level = "province",
  20101. // name = item1.Name_CN,
  20102. // childList = childList1
  20103. // });
  20104. // }
  20105. // //城市
  20106. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20107. // foreach (var item2 in citiesData2)
  20108. // {
  20109. // List<dynamic> childList22 = new List<dynamic>();
  20110. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20111. // foreach (var item3 in countiesData1)
  20112. // {
  20113. // childList22.Add(new
  20114. // {
  20115. // id = item3.Id,
  20116. // parentId = item2.Id,
  20117. // level = "district",
  20118. // name = item3.Name_CN,
  20119. // });
  20120. // }
  20121. // childList.Add(new
  20122. // {
  20123. // id = item2.Id,
  20124. // parentId = parentId,
  20125. // level = "city",
  20126. // name = item2.Name_CN,
  20127. // childList = childList22
  20128. // });
  20129. // }
  20130. // }
  20131. // else
  20132. // {
  20133. // foreach (var item2 in citiesData)
  20134. // {
  20135. // string cname = item2.Name_CN;
  20136. // List<dynamic> childList1 = new List<dynamic>();
  20137. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20138. // foreach (var item3 in countiesData1)
  20139. // {
  20140. // childList1.Add(new
  20141. // {
  20142. // Id = item3.Id,
  20143. // parentId = item2.Id,
  20144. // level = "district",
  20145. // name = item3.Name_CN
  20146. // });
  20147. // }
  20148. // childList.Add(new
  20149. // {
  20150. // id = item2.Id,
  20151. // parentId = parentId,
  20152. // level = "city",
  20153. // name = item2.Name_CN,
  20154. // childList = childList1
  20155. // });
  20156. // }
  20157. // }
  20158. // stopwatch.Stop();
  20159. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20160. //}
  20161. /// <summary>
  20162. /// 匹配op行程单
  20163. /// 接团信息列表 Page
  20164. /// </summary>
  20165. /// <param name="dto">团组列表请求dto</param>
  20166. /// <returns></returns>
  20167. [HttpPost]
  20168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20169. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20170. {
  20171. var swatch = new Stopwatch();
  20172. swatch.Start();
  20173. #region 参数验证
  20174. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20175. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20176. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20177. #region 页面操作权限验证
  20178. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20179. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20180. #endregion
  20181. #endregion
  20182. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20183. {
  20184. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20185. //string sqlWhere = "";
  20186. if (!string.IsNullOrEmpty(dto.Country))
  20187. {
  20188. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20189. }
  20190. if (!string.IsNullOrEmpty(dto.Area))
  20191. {
  20192. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20193. }
  20194. if (!string.IsNullOrEmpty(dto.TeamName))
  20195. {
  20196. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20197. }
  20198. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20199. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20200. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20201. swatch.Stop();
  20202. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20203. }
  20204. else
  20205. {
  20206. return Ok(JsonView(false, "查询失败"));
  20207. }
  20208. }
  20209. /// <summary>
  20210. /// 匹配op行程单
  20211. /// 行程单下载
  20212. /// </summary>
  20213. /// <param name="dto">团组列表请求dto</param>
  20214. /// <returns></returns>
  20215. [HttpPost]
  20216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20217. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20218. {
  20219. #region 参数验证
  20220. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20221. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20222. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20223. #region 页面操作权限验证
  20224. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20225. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20226. #endregion
  20227. #endregion
  20228. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20229. {
  20230. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20231. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20232. }
  20233. else
  20234. {
  20235. return Ok(JsonView(false, "下载失败!"));
  20236. }
  20237. }
  20238. #endregion
  20239. #region 国家信息 数据 注释
  20240. //[HttpPost]
  20241. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20242. //{
  20243. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20244. // foreach (var item in dto)
  20245. // {
  20246. // infos.Add(new Grp_GroupsTaskAssignment()
  20247. // {
  20248. // DIId = item,
  20249. // CTId = 82,
  20250. // UId = 248,
  20251. // IsEnable = 1,
  20252. // CreateUserId = 233,
  20253. // CreateTime = DateTime.Now,
  20254. // IsDel = 0
  20255. // });
  20256. // infos.Add(new Grp_GroupsTaskAssignment()
  20257. // {
  20258. // DIId = item,
  20259. // CTId = 82,
  20260. // UId = 286,
  20261. // IsEnable = 1,
  20262. // CreateUserId = 233,
  20263. // CreateTime = DateTime.Now,
  20264. // IsDel = 0
  20265. // });
  20266. // }
  20267. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20268. // return Ok("操作成功");
  20269. //}
  20270. //public class paramJsonDto
  20271. //{
  20272. // public List<CountriesInfo> str { get; set; }
  20273. //}
  20274. //[HttpPost]
  20275. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20276. //{
  20277. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20278. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20279. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20280. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20281. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20282. // _sqlSugar.BeginTran();
  20283. // int countitiesIndex = 0;
  20284. // foreach (var item in dto.str)
  20285. // {
  20286. // dynamic data = item.c;
  20287. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20288. // if (data != null)
  20289. // {
  20290. // countitiesIndex++;
  20291. // foreach (var item1 in data)
  20292. // {
  20293. // string cnname = item1.cn;
  20294. // string enname = item1.en;
  20295. // Sys_Cities provinceInfo = new Sys_Cities()
  20296. // {
  20297. // CountriesId = countriesId,
  20298. // Name_CN = cnname,
  20299. // Name_EN = enname,
  20300. // ParentId = 0,
  20301. // IsCapital = 1,
  20302. // CreateUserId = 208,
  20303. // CreateTime = DateTime.Now,
  20304. // IsDel = 0
  20305. // };
  20306. // if (item1.lv == "province") //省份
  20307. // {
  20308. // provinceInfo.Level = 1;
  20309. // int provinceId = 0;
  20310. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20311. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20312. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20313. // var data1 = item1.c;
  20314. // foreach (var item2 in data1)
  20315. // {
  20316. // if (item2.lv == "city")
  20317. // {
  20318. // string citycnname = item2.cn;
  20319. // string cityenname = item2.en;
  20320. // Sys_Cities cityInfo = new Sys_Cities()
  20321. // {
  20322. // CountriesId = countriesId,
  20323. // ParentId = provinceId,
  20324. // Level = 2,
  20325. // Name_CN = citycnname,
  20326. // Name_EN = cityenname,
  20327. // IsCapital = 1,
  20328. // CreateUserId = 208,
  20329. // CreateTime = DateTime.Now,
  20330. // IsDel = 0
  20331. // };
  20332. // if (item2.c != null)
  20333. // {
  20334. // int cityId = 0;
  20335. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20336. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20337. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20338. // foreach (var item3 in item2.c)
  20339. // {
  20340. // if (item3.lv == "district")
  20341. // {
  20342. // var districtInfo = new Sys_Cities()
  20343. // {
  20344. // CountriesId = countriesId,
  20345. // Name_CN = item3.cn,
  20346. // Name_EN = item3.en,
  20347. // Level = 3,
  20348. // ParentId = cityId,
  20349. // IsCapital = 1,
  20350. // CreateUserId = 208,
  20351. // CreateTime = DateTime.Now,
  20352. // IsDel = 0
  20353. // };
  20354. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20355. // //{
  20356. // districts.Add(districtInfo);
  20357. // //}
  20358. // }
  20359. // }
  20360. // }
  20361. // else
  20362. // {
  20363. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20364. // //{
  20365. // cities.Add(cityInfo);
  20366. // //}
  20367. // }
  20368. // }
  20369. // }
  20370. // }
  20371. // else if (item1.lv == "city")//城市
  20372. // {
  20373. // provinceInfo.Level = 2;
  20374. // if (item1.c != null)
  20375. // {
  20376. // int cityId = 0;
  20377. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20378. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20379. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20380. // foreach (var item3 in item1.c)
  20381. // {
  20382. // if (item3.lv == "district")
  20383. // {
  20384. // var districtInfo = new Sys_Cities()
  20385. // {
  20386. // CountriesId = countriesId,
  20387. // Name_CN = item3.cn,
  20388. // Name_EN = item3.en,
  20389. // Level = 3,
  20390. // ParentId = cityId,
  20391. // IsCapital = 1,
  20392. // CreateUserId = 208,
  20393. // CreateTime = DateTime.Now,
  20394. // IsDel = 0
  20395. // };
  20396. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20397. // //{
  20398. // districts.Add(districtInfo);
  20399. // //}
  20400. // }
  20401. // }
  20402. // }
  20403. // else
  20404. // {
  20405. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20406. // //{
  20407. // cities.Add(provinceInfo);
  20408. // //}
  20409. // }
  20410. // }
  20411. // }
  20412. // }
  20413. // }
  20414. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20415. // cities = cities.Distinct().ToList();
  20416. // districts = districts.Distinct().ToList();
  20417. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20418. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20419. // cities.AddRange(districts);
  20420. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20421. // //_sqlSugar.RollbackTran();
  20422. // _sqlSugar.CommitTran();
  20423. // return Ok(JsonView(false, "操作成功!"));
  20424. //}
  20425. //[HttpPost]
  20426. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20427. //{
  20428. // List<CountitiesInfo> infos = dto.MyProperty;
  20429. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20430. // _sqlSugar.BeginTran();
  20431. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20432. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20433. // foreach (var item in infos)
  20434. // {
  20435. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20436. // if (countryInfo != null)
  20437. // {
  20438. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20439. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20440. // if (cityInfo1 != null)
  20441. // {
  20442. // cityInfo1.IsCapital = 0;
  20443. // cityInfos.Add(cityInfo1);
  20444. // }
  20445. // }
  20446. // }
  20447. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20448. // .UpdateColumns(it => it.IsCapital)
  20449. // .WhereColumns(it => it.Id)
  20450. // .ExecuteCommand();
  20451. // //_sqlSugar.RollbackTran();
  20452. // _sqlSugar.CommitTran();
  20453. // return Ok(JsonView(false, "操作成功!"));
  20454. //}
  20455. //public class CounrtiesDto
  20456. //{
  20457. // public List<CountitiesInfo> MyProperty { get; set; }
  20458. //}
  20459. //public class CountitiesInfo
  20460. //{
  20461. // /// <summary>
  20462. // /// 圣约翰
  20463. // /// </summary>
  20464. // public string capital_name_chinese { get; set; }
  20465. // /// <summary>
  20466. // ///
  20467. // /// </summary>
  20468. // public string capital_name { get; set; }
  20469. // /// <summary>
  20470. // ///
  20471. // /// </summary>
  20472. // public string country_type { get; set; }
  20473. // /// <summary>
  20474. // /// 安提瓜和巴布达
  20475. // /// </summary>
  20476. // public string country_name_chinese { get; set; }
  20477. // /// <summary>
  20478. // /// 安提瓜和巴布达
  20479. // /// </summary>
  20480. // public string country_name_chinese_short { get; set; }
  20481. // /// <summary>
  20482. // /// 安提瓜和巴布达
  20483. // /// </summary>
  20484. // public string country_name_chinese_UN { get; set; }
  20485. // /// <summary>
  20486. // ///
  20487. // /// </summary>
  20488. // public string country_name_english_abbreviation { get; set; }
  20489. // /// <summary>
  20490. // ///
  20491. // /// </summary>
  20492. // public string country_name_english_formal { get; set; }
  20493. // /// <summary>
  20494. // ///
  20495. // /// </summary>
  20496. // public string country_name_english_UN { get; set; }
  20497. // /// <summary>
  20498. // ///
  20499. // /// </summary>
  20500. // public string continent_name { get; set; }
  20501. // /// <summary>
  20502. // ///
  20503. // /// </summary>
  20504. // public string subregion_name { get; set; }
  20505. // /// <summary>
  20506. // ///
  20507. // /// </summary>
  20508. // public string country_code2 { get; set; }
  20509. // /// <summary>
  20510. // ///
  20511. // /// </summary>
  20512. // public string country_code3 { get; set; }
  20513. // /// <summary>
  20514. // ///
  20515. // /// </summary>
  20516. // public string phone_code { get; set; }
  20517. //}
  20518. //public class CountriesInfo : BasicInfo
  20519. //{
  20520. // public List<CitiesInfo> c { get; set; }
  20521. //}
  20522. //public class CitiesInfo : BasicInfo
  20523. //{
  20524. // public List<AreaInfo> c { get; set; }
  20525. //}
  20526. //public class AreaInfo : BasicInfo
  20527. //{
  20528. // public List<AreaInfo> c { get; set; }
  20529. //}
  20530. //public class BasicInfo
  20531. //{
  20532. // public string code { get; set; }
  20533. // public string cn { get; set; }
  20534. // public string lv { get; set; }
  20535. // public string en { get; set; }
  20536. //}
  20537. #endregion
  20538. #region 查看邀请方
  20539. /// <summary>
  20540. /// 查看邀请方
  20541. /// 邀请方信息 Init
  20542. /// </summary>
  20543. /// <param name="dto"></param>
  20544. /// <returns></returns>
  20545. [HttpPost]
  20546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20547. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20548. {
  20549. string sqlWhere = string.Empty;
  20550. if (!string.IsNullOrEmpty(dto.Search))
  20551. {
  20552. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20553. }
  20554. string sql = string.Format($@"Select
  20555. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20556. Id,
  20557. UnitName
  20558. From Res_InvitationOfficialActivityData
  20559. Where IsDel = 0
  20560. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20561. RefAsync<int> total = 0;
  20562. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20563. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20564. }
  20565. /// <summary>
  20566. /// 查看邀请方
  20567. /// 国家信息 Init
  20568. /// </summary>
  20569. /// <param name="dto"></param>
  20570. /// <returns></returns>
  20571. [HttpPost]
  20572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20573. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20574. {
  20575. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20576. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20577. var diids = groupInfos.Select(it => it.Id).ToList();
  20578. List<string> countrys = new List<string>();
  20579. foreach (var item in country)
  20580. {
  20581. var data = _groupRepository.FormartTeamName(item);
  20582. var dataArray = _groupRepository.GroupSplitCountry(data);
  20583. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20584. }
  20585. countrys = countrys.Distinct().ToList();
  20586. for (int i = 0; i < countrys.Count; i++)
  20587. {
  20588. string item = countrys[i];
  20589. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20590. {
  20591. countrys.Remove(item);
  20592. i--;
  20593. }
  20594. }
  20595. RefAsync<int> total = 0;
  20596. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20597. .Where(it => countrys.Contains(it.Name_CN))
  20598. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20599. .Select(it => new { id = it.Id, name = it.Name_CN })
  20600. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20601. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20602. }
  20603. /// <summary>
  20604. /// 查看邀请方
  20605. /// 城市信息 Init
  20606. /// </summary>
  20607. /// <param name="dto"></param>
  20608. /// <returns></returns>
  20609. [HttpPost]
  20610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20611. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20612. {
  20613. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20614. RefAsync<int> total = 0;
  20615. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20616. .Where(it => it.CountriesId == dto.CountiesId)
  20617. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20618. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20619. .Select(it => new { id = it.Id, name = it.Name_CN })
  20620. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20621. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20622. }
  20623. /// <summary>
  20624. /// 查看邀请方
  20625. /// 团组名称 Init
  20626. /// </summary>
  20627. /// <param name="dto"></param>
  20628. /// <returns></returns>
  20629. [HttpPost]
  20630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20631. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20632. {
  20633. var watch = new Stopwatch();
  20634. watch.Start();
  20635. RefAsync<int> total = 0;
  20636. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20637. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20638. .Where((oa, di) => oa.IsDel == 0)
  20639. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20640. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20641. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20642. .Distinct()
  20643. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20644. watch.Stop();
  20645. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20646. }
  20647. /// <summary>
  20648. /// 查看邀请方
  20649. /// 团组 & 邀请方信息
  20650. /// </summary>
  20651. /// <param name="dto"></param>
  20652. /// <returns></returns>
  20653. [HttpPost]
  20654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20655. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20656. {
  20657. var watch = new Stopwatch();
  20658. watch.Start();
  20659. RefAsync<int> total = 0;
  20660. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20661. .AS("Grp_DelegationInfo")
  20662. .Includes(x => x.InvitingInfos)
  20663. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20664. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20665. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20666. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20667. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20668. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20669. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20670. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20671. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20672. infos.ForEach(x =>
  20673. {
  20674. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20675. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20676. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20677. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20678. });
  20679. watch.Stop();
  20680. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20681. }
  20682. #endregion
  20683. #region 报批行程
  20684. /// <summary>
  20685. /// 报批行程初始化
  20686. /// </summary>
  20687. /// <param name="dto"></param>
  20688. /// <returns></returns>
  20689. [HttpPost]
  20690. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20691. {
  20692. const int chiNumber = 5;
  20693. var jw = JsonView(false);
  20694. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20695. var group = groupList.First();
  20696. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20697. group = groupList.First(x => x.Id == diid);
  20698. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20699. .Where(x => x.DiId == diid && x.IsDel == 0)
  20700. .ToArray();
  20701. var count = 1;
  20702. foreach (var item in blackCodeList)
  20703. {
  20704. if (string.IsNullOrWhiteSpace(item.Title))
  20705. {
  20706. item.Title = "未设置名称数据" + count;
  20707. }
  20708. count++;
  20709. }
  20710. ;
  20711. if (group == null)
  20712. {
  20713. jw.Msg = "暂无团组!";
  20714. return Ok(jw);
  20715. }
  20716. var data = new
  20717. {
  20718. groupList = groupList.Select(x => new
  20719. {
  20720. x.TeamName,
  20721. x.Id
  20722. }),
  20723. content = new ArrayList(),
  20724. groupInfo = new
  20725. {
  20726. group.VisitDays,
  20727. group.TourCode,
  20728. group.VisitPNumber,
  20729. group.TeamName,
  20730. group.Id,
  20731. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20732. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  20733. },
  20734. blackCodeList = blackCodeList.Select(x => new
  20735. {
  20736. x.Title,
  20737. x.Id
  20738. }),
  20739. FileTempList = new ArrayList()
  20740. {
  20741. new { Index = 1,FileName = "旧模板" },
  20742. new { Index = 2,FileName = "省外办" },
  20743. new { Index = 3,FileName = "市外办" },
  20744. }
  20745. };
  20746. var resultArr = new ArrayList();
  20747. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20748. #region 默认不生成行程
  20749. //if (content.Count == 0)
  20750. //{
  20751. // var stay = "-";
  20752. // var cityPath = "-";
  20753. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20754. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20755. // .ToList();
  20756. // //添加城市路径以及住宿地
  20757. // //黑屏代码数据
  20758. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20759. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20760. // {
  20761. // jw = JsonView(true, "黑屏代码有误!", data);
  20762. // return Ok(jw);
  20763. // }
  20764. // data = data with
  20765. // {
  20766. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20767. // {
  20768. // x.Title,
  20769. // x.Id,
  20770. // }).ToArray())
  20771. // };
  20772. // foreach (DataRow row in dtBlack.Rows)
  20773. // {
  20774. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20775. // {
  20776. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20777. // return Ok(jw);
  20778. // }
  20779. // }
  20780. // //黑屏代码获取时间区间
  20781. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20782. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20783. // _sqlSugar.BeginTran();
  20784. // for (int i = 0; i < timeArr.Count; i++)
  20785. // {
  20786. // stay = "-";
  20787. // cityPath = "-";
  20788. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20789. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20790. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20791. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20792. // if (tbSelect.Length > 0)
  20793. // {
  20794. // List<string> threeCodeStr = new List<string>();
  20795. // foreach (var item in tbSelect)
  20796. // {
  20797. // var threeCode = item["Three"].ToString() ?? "";
  20798. // if (threeCode.Length == 6)
  20799. // {
  20800. // var start = threeCode.Substring(0, 3);
  20801. // var end = threeCode.Substring(3, 3);
  20802. // if (threeCodeStr.Count == 0)
  20803. // {
  20804. // threeCodeStr.Add(start);
  20805. // threeCodeStr.Add(end);
  20806. // }
  20807. // else
  20808. // {
  20809. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20810. // {
  20811. // threeCodeStr.Add(end);
  20812. // }
  20813. // else
  20814. // {
  20815. // threeCodeStr.Add(start);
  20816. // threeCodeStr.Add(end);
  20817. // }
  20818. // }
  20819. // }
  20820. // }
  20821. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20822. // var last = threeCodeStr.Last();
  20823. // foreach (var item in threeCodeStr)
  20824. // {
  20825. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20826. // if (item.Equals(last))
  20827. // {
  20828. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20829. // }
  20830. // }
  20831. // cityPath = cityPath.Trim('-');
  20832. // }
  20833. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  20834. // appro.Diid = diid ?? -1;
  20835. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20836. // appro.Id = thisId;
  20837. // appro.CreateUserId = dto.UserId;
  20838. // appro.CreateTime = DateTime.Now;
  20839. // content.Add(appro);
  20840. // }
  20841. // _sqlSugar.CommitTran();
  20842. //}
  20843. #endregion
  20844. foreach (var x in content)
  20845. {
  20846. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  20847. if (chiList.Count < chiNumber)
  20848. {
  20849. for (int i = chiList.Count; i < chiNumber; i++)
  20850. {
  20851. chiList.Add(new Grp_ApprovalTravelDetails());
  20852. }
  20853. }
  20854. resultArr.Add(new
  20855. {
  20856. x.Id,
  20857. x.Date,
  20858. x.Diid,
  20859. chiList = chiList.Select(x1 => new
  20860. {
  20861. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20862. x1.Details,
  20863. x1.ParentId,
  20864. x1.Id
  20865. })
  20866. });
  20867. }
  20868. data = data with
  20869. {
  20870. content = resultArr,
  20871. };
  20872. jw = JsonView(true, "获取成功!", data);
  20873. return Ok(jw);
  20874. }
  20875. /// <summary>
  20876. /// 报批行程删除
  20877. /// </summary>
  20878. /// <param name="dto"></param>
  20879. /// <returns></returns>
  20880. [HttpPost]
  20881. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  20882. {
  20883. var jw = JsonView(false);
  20884. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20885. if (group == null)
  20886. {
  20887. jw.Msg = "团组参数有误!";
  20888. return Ok(jw);
  20889. }
  20890. try
  20891. {
  20892. _sqlSugar.BeginTran();
  20893. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  20894. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  20895. {
  20896. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20897. DeleteUserId = dto.uesrId,
  20898. IsDel = 1
  20899. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  20900. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  20901. {
  20902. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20903. DeleteUserId = dto.uesrId,
  20904. IsDel = 1
  20905. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  20906. _sqlSugar.CommitTran();
  20907. jw = JsonView(true, "删除成功");
  20908. }
  20909. catch (Exception ex)
  20910. {
  20911. jw = JsonView(false, ex.Message);
  20912. }
  20913. return Ok(jw);
  20914. }
  20915. /// <summary>
  20916. /// 报批行程保存
  20917. /// </summary>
  20918. /// <param name="dto"></param>
  20919. /// <returns></returns>
  20920. [HttpPost]
  20921. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  20922. {
  20923. var jw = JsonView(false);
  20924. var Find = dto.Arr.Find(x => x.id == 0);
  20925. if (Find != null)
  20926. {
  20927. jw.Msg = "生成的ID为0!";
  20928. return Ok(jw);
  20929. }
  20930. foreach (var item in dto.Arr)
  20931. {
  20932. foreach (var chi in item.chiList)
  20933. {
  20934. if (chi.parentId == 0)
  20935. {
  20936. chi.parentId = item.id;
  20937. }
  20938. }
  20939. }
  20940. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  20941. _sqlSugar.BeginTran();
  20942. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  20943. {
  20944. var parentIds = dto.Arr.Select(x => x.id).ToList();
  20945. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  20946. {
  20947. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20948. DeleteUserId = dto.UserId,
  20949. IsDel = 1
  20950. }).ExecuteCommand();
  20951. }
  20952. try
  20953. {
  20954. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  20955. {
  20956. CreateTime = DateTime.Now,
  20957. CreateUserId = dto.UserId,
  20958. Details = x.details,
  20959. ParentId = x.parentId,
  20960. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20961. Remark = "",
  20962. IsDel = 0
  20963. }).ToList()).ExecuteCommand();
  20964. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  20965. {
  20966. Id = x.id,
  20967. Details = x.details,
  20968. ParentId = x.parentId,
  20969. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20970. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  20971. {
  20972. Details = x.Details,
  20973. ParentId = x.ParentId,
  20974. Time = x.Time
  20975. }).ExecuteCommand();
  20976. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  20977. {
  20978. Id = x.id,
  20979. Date = x.date,
  20980. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  20981. {
  20982. Date = x.Date
  20983. }).ExecuteCommand();
  20984. _sqlSugar.CommitTran();
  20985. jw = JsonView(true, "保存成功!");
  20986. }
  20987. catch (Exception ex)
  20988. {
  20989. _sqlSugar.RollbackTran();
  20990. jw = JsonView(false, "保存失败!" + ex.Message);
  20991. }
  20992. return Ok(jw);
  20993. }
  20994. /// <summary>
  20995. /// 报批行程生成
  20996. /// </summary>
  20997. /// <param name="dto"></param>
  20998. /// <returns></returns>
  20999. [HttpPost]
  21000. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21001. {
  21002. var jw = JsonView(false);
  21003. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21004. if (group == null)
  21005. {
  21006. jw.Msg = "暂无该团组!";
  21007. return Ok(jw);
  21008. }
  21009. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21010. //黑屏代码数据
  21011. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21012. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21013. {
  21014. jw.Msg = "黑屏代码有误!";
  21015. return Ok(jw);
  21016. }
  21017. foreach (DataRow row in dtBlack.Rows)
  21018. {
  21019. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21020. {
  21021. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21022. return Ok(jw);
  21023. }
  21024. }
  21025. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21026. var resultArr = new ArrayList();
  21027. //if (officialActivitiesArr.Count == 0)
  21028. //{
  21029. // jw.Msg = "暂无公务出访信息!";
  21030. // return Ok(jw);
  21031. //}
  21032. try
  21033. {
  21034. _sqlSugar.BeginTran();
  21035. DeleteApprovalJourney(new
  21036. Domain.Dtos.Groups.DeleteApprovalJourney
  21037. {
  21038. Diid = dto.Diid,
  21039. uesrId = dto.Userid
  21040. });
  21041. var stay = "-";
  21042. var cityPath = "-";
  21043. var arriveCountry = string.Empty;
  21044. //添加城市路径以及住宿地
  21045. //黑屏代码获取时间区间
  21046. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21047. var empty = "【未收入该三字码!请机票同事录入】";
  21048. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21049. #region 配置公务活动时间
  21050. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21051. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21052. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21053. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21054. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21055. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21056. {
  21057. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21058. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21059. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21060. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21061. };
  21062. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21063. {
  21064. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21065. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21066. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21067. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21068. };
  21069. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21070. {
  21071. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  21072. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  21073. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21074. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21075. };
  21076. #endregion
  21077. var nextDayNum = 0;
  21078. for (int i = 0; i < timeArr.Count; i++)
  21079. {
  21080. stay = "-";
  21081. cityPath = "-";
  21082. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21083. DateTime NewData = DateTime.Parse(timeArr[i]);
  21084. //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();
  21085. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21086. if (nextDayNum > 0)
  21087. {
  21088. nextDayNum--;
  21089. }
  21090. if (tbSelect.Length > 0)
  21091. {
  21092. List<string> threeCodeStr = new List<string>();
  21093. bool isTrade = false;
  21094. string trip = string.Empty;
  21095. foreach (var item in tbSelect)
  21096. {
  21097. if (nextDayNum == 0)
  21098. {
  21099. nextDayNum = Convert.ToInt32(item["Sign"]);
  21100. }
  21101. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21102. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21103. var takeOffTime = DateTime.Parse(timeArr[i]);
  21104. var fallToTime = DateTime.Parse(timeArr[i]);
  21105. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21106. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21107. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21108. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21109. if (nextDayNum > 0)
  21110. {
  21111. fallToTime = fallToTime.AddDays(nextDayNum);
  21112. }
  21113. trip = string.Empty;
  21114. var start = string.Empty;
  21115. var end = string.Empty;
  21116. var threeCode = item["Three"].ToString() ?? "";
  21117. if (threeCode.Length == 6)
  21118. {
  21119. start = threeCode.Substring(0, 3);
  21120. end = threeCode.Substring(3, 3);
  21121. if (threeCodeStr.Count == 0)
  21122. {
  21123. threeCodeStr.Add(start);
  21124. threeCodeStr.Add(end);
  21125. }
  21126. else
  21127. {
  21128. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21129. {
  21130. threeCodeStr.Add(end);
  21131. }
  21132. else
  21133. {
  21134. threeCodeStr.Add(start);
  21135. threeCodeStr.Add(end);
  21136. }
  21137. }
  21138. }
  21139. //处理机票信息
  21140. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21141. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21142. if (start_Object == null)
  21143. {
  21144. start_Object = new Res_ThreeCode()
  21145. {
  21146. AirPort = empty,
  21147. AirPort_En = empty,
  21148. City = empty,
  21149. Country = empty,
  21150. Four = empty,
  21151. Three = empty,
  21152. };
  21153. }
  21154. if (end_Object == null)
  21155. {
  21156. end_Object = new Res_ThreeCode()
  21157. {
  21158. AirPort = empty,
  21159. AirPort_En = empty,
  21160. City = empty,
  21161. Country = empty,
  21162. Four = empty,
  21163. Three = empty,
  21164. };
  21165. }
  21166. //机型判断
  21167. string airModel = item["AirModel"].ToString();
  21168. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21169. string flightTime = item["FlightTime"].ToString();
  21170. flightTime = ParseBlackTime(flightTime);
  21171. //航班号
  21172. string flightcode = item["Fliagtcode"].ToString();
  21173. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21174. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21175. if (aircompany == null)
  21176. {
  21177. aircompany = new Res_AirCompany
  21178. {
  21179. CnName = hsEmpty,
  21180. EnName = hsEmpty,
  21181. ShortCode = hsEmpty,
  21182. };
  21183. }
  21184. //航班前公务安排
  21185. if (tbSelect.First().Equals(item) && i != 0)
  21186. {
  21187. foreach (var takeoff in takeoffTimes)
  21188. {
  21189. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21190. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21191. {
  21192. foreach (var addTime in takeoff.Item2)
  21193. {
  21194. chiarr.Add(new Grp_ApprovalTravelDetails
  21195. {
  21196. Time = addTime,
  21197. CreateTime = DateTime.Now,
  21198. CreateUserId = dto.Userid,
  21199. ParentId = 0,
  21200. Details = "公务活动"
  21201. });
  21202. }
  21203. break;
  21204. }
  21205. }
  21206. }
  21207. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21208. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21209. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21210. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City}{flightTime}";
  21211. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21212. if (isTrade)
  21213. {
  21214. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21215. trip += "(转机不出机场)。";
  21216. }
  21217. //else
  21218. //{
  21219. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21220. //}
  21221. chiarr.Add(new Grp_ApprovalTravelDetails
  21222. {
  21223. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21224. CreateTime = DateTime.Now,
  21225. CreateUserId = dto.Userid,
  21226. ParentId = 0,
  21227. Details = trip
  21228. });
  21229. //最后一条到达的时间安排公务
  21230. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21231. {
  21232. bool isCheckCountry = false;
  21233. if (end_Object.Country != arriveCountry)
  21234. {
  21235. arriveCountry = end_Object.Country;
  21236. isCheckCountry = true;
  21237. }
  21238. if (nextDayNum == 0)
  21239. {
  21240. //需要入境的情况
  21241. if (isCheckCountry)
  21242. {
  21243. foreach (var fallTime in fallTimesCheckCountry)
  21244. {
  21245. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21246. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21247. {
  21248. foreach (var addTime in fallTime.Item2)
  21249. {
  21250. chiarr.Add(new Grp_ApprovalTravelDetails
  21251. {
  21252. Time = addTime,
  21253. CreateTime = DateTime.Now,
  21254. CreateUserId = dto.Userid,
  21255. ParentId = 0,
  21256. Details = "公务活动"
  21257. });
  21258. }
  21259. break;
  21260. }
  21261. }
  21262. }
  21263. else
  21264. {
  21265. foreach (var fallTime in fallTimesNotCheckCountry)
  21266. {
  21267. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21268. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21269. {
  21270. foreach (var addTime in fallTime.Item2)
  21271. {
  21272. chiarr.Add(new Grp_ApprovalTravelDetails
  21273. {
  21274. Time = addTime,
  21275. CreateTime = DateTime.Now,
  21276. CreateUserId = dto.Userid,
  21277. ParentId = 0,
  21278. Details = "公务活动"
  21279. });
  21280. }
  21281. break;
  21282. }
  21283. }
  21284. }
  21285. }
  21286. }
  21287. }
  21288. //添加乘车语句
  21289. //chiarr.Add(new Grp_ApprovalTravelDetails
  21290. //{
  21291. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21292. // CreateTime = DateTime.Now,
  21293. // CreateUserId = dto.Userid,
  21294. // ParentId = 0,
  21295. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21296. //});
  21297. //if (i != timeArr.Count - 1)
  21298. //{
  21299. // fallToTime = fallToTime.AddHours(2.5);
  21300. // foreach (var item in Times)
  21301. // {
  21302. // //排列公务时间
  21303. // if (fallToTime.Hour < item.Item1)
  21304. // {
  21305. // chiarr.Add(new Grp_ApprovalTravelDetails
  21306. // {
  21307. // Time = $"{item.Item2} - {item.Item3}",
  21308. // CreateTime = DateTime.Now,
  21309. // CreateUserId = dto.Userid,
  21310. // ParentId = 0,
  21311. // Details = "公务活动"
  21312. // });
  21313. // }
  21314. // }
  21315. //}
  21316. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21317. var last = threeCodeStr.Last();
  21318. foreach (var item in threeCodeStr)
  21319. {
  21320. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21321. if (item.Equals(last))
  21322. {
  21323. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21324. }
  21325. }
  21326. cityPath = cityPath.Trim('-');
  21327. }
  21328. else
  21329. {
  21330. foreach (var item in Times)
  21331. {
  21332. chiarr.Add(new Grp_ApprovalTravelDetails
  21333. {
  21334. Time = $"{item.Item2} - {item.Item3}",
  21335. CreateTime = DateTime.Now,
  21336. CreateUserId = dto.Userid,
  21337. ParentId = 0,
  21338. Details = "公务活动"
  21339. });
  21340. }
  21341. }
  21342. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21343. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21344. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21345. appro.Diid = dto.Diid;
  21346. appro.CreateUserId = dto.Userid;
  21347. appro.CreateTime = DateTime.Now;
  21348. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21349. appro.Id = thisId;
  21350. //foreach (var item in gwinfo)
  21351. //{
  21352. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21353. // chi.Details = "拜访" + item.Client;
  21354. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21355. // {
  21356. // chi.Details += "," + item.ReqSample;
  21357. // }
  21358. // chi.ParentId = thisId;
  21359. // chi.Time = item.Time;
  21360. // chiarr.Add(chi);
  21361. //}
  21362. if (chiarr.Count < 6)
  21363. {
  21364. for (int j = chiarr.Count; j < 6; j++)
  21365. {
  21366. chiarr.Add(new
  21367. Grp_ApprovalTravelDetails());
  21368. }
  21369. }
  21370. resultArr.Add(new
  21371. {
  21372. appro.Id,
  21373. appro.Date,
  21374. appro.Diid,
  21375. chiList = chiarr.Select(x1 => new
  21376. {
  21377. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21378. x1.Details,
  21379. x1.ParentId,
  21380. x1.Id
  21381. })
  21382. });
  21383. }
  21384. _sqlSugar.CommitTran();
  21385. jw = JsonView(true, "生成成功!", resultArr);
  21386. }
  21387. catch (Exception ex)
  21388. {
  21389. jw.Code = 400;
  21390. jw.Msg = "生成失败!" + ex.Message;
  21391. }
  21392. return Ok(jw);
  21393. }
  21394. /// <summary>
  21395. /// 报批行程word导出
  21396. /// </summary>
  21397. /// <param name="dto"></param>
  21398. /// <returns></returns>
  21399. [HttpPost]
  21400. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21401. {
  21402. var jw = JsonView(false);
  21403. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21404. if (group == null)
  21405. {
  21406. jw.Msg = "暂无该团组!";
  21407. return Ok(jw);
  21408. }
  21409. //模板路径
  21410. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21411. var fileName = string.Empty;
  21412. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21413. bool bold = false;
  21414. if (dto.FileIndex == 1)
  21415. {
  21416. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21417. }
  21418. else if (dto.FileIndex == 2)
  21419. {
  21420. fileName = "省外办-报批.docx";
  21421. bold = false;
  21422. titleFont = "方正黑体简体";
  21423. timeFont = "Times New Roman";
  21424. contentFont = "方正仿宋_GBK";
  21425. }
  21426. else if (dto.FileIndex == 3)
  21427. {
  21428. fileName = "市外办-报批.docx";
  21429. titleFont = "方正黑体简体";
  21430. timeFont = "Times New Roman";
  21431. contentFont = "方正仿宋简体";
  21432. }
  21433. tempPath = tempPath + fileName;
  21434. //载入模板
  21435. Document doc = new Document(tempPath);
  21436. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21437. //获取所填表格的序数
  21438. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21439. Aspose.Words.Tables.Row titleRowClone = null;
  21440. Aspose.Words.Tables.Row CenterRowClone = null;
  21441. int index = 0;
  21442. int indexChi = 0;
  21443. int SetIndex = 0;
  21444. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21445. //获取数据,放到datatable
  21446. foreach (var item in ApprovalTravelArr)
  21447. {
  21448. if (index > 0)
  21449. {
  21450. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21451. tableOne.AppendChild(titleRowClone);
  21452. }
  21453. var textTime = item.Date;
  21454. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21455. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21456. SetIndex++;
  21457. if (ChiRep.Count > 0)
  21458. {
  21459. foreach (var itemChi in ChiRep)
  21460. {
  21461. var txtTime = itemChi.Time;
  21462. var txtDetail = itemChi.Details;
  21463. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21464. {
  21465. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21466. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21467. //indexChi++;
  21468. //SetIndex++;
  21469. break;
  21470. }
  21471. if (indexChi > 0)
  21472. {
  21473. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21474. tableOne.AppendChild(CenterRowClone);
  21475. }
  21476. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21477. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21478. indexChi++;
  21479. SetIndex++;
  21480. }
  21481. }
  21482. //else
  21483. //{
  21484. // if (indexChi > 0)
  21485. // {
  21486. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21487. // tableOne.AppendChild(CenterRowClone);
  21488. // }
  21489. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21490. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21491. // indexChi++;
  21492. // SetIndex++;
  21493. //}
  21494. index++;
  21495. }
  21496. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21497. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21498. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21499. jw.Code = 200;
  21500. jw.Msg = "";
  21501. return Ok(jw);
  21502. }
  21503. private string ParseBlackTime(string time)
  21504. {
  21505. // 匹配可能只有分钟的情况
  21506. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21507. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21508. if (match.Success)
  21509. {
  21510. string hours = match.Groups[1].Value;
  21511. string minutes = match.Groups[2].Value;
  21512. // 如果小时部分为空,则只显示分钟
  21513. if (string.IsNullOrEmpty(hours))
  21514. {
  21515. return $"{minutes}分钟";
  21516. }
  21517. // 如果分钟部分为空,则只显示小时
  21518. else if (string.IsNullOrEmpty(minutes))
  21519. {
  21520. return $"{hours}小时";
  21521. }
  21522. // 否则显示完整格式
  21523. else
  21524. {
  21525. return $"{hours}小时{minutes}分钟";
  21526. }
  21527. }
  21528. else
  21529. {
  21530. return "未知时长";
  21531. }
  21532. }
  21533. private string intToString(int numberVal)
  21534. {
  21535. string numberval = numberVal.ToString();
  21536. Dictionary<char, string> Number = new Dictionary<char, string>();
  21537. Number.Add('1', "一");
  21538. Number.Add('2', "二");
  21539. Number.Add('3', "三");
  21540. Number.Add('4', "四");
  21541. Number.Add('5', "五");
  21542. Number.Add('6', "六");
  21543. Number.Add('7', "七");
  21544. Number.Add('8', "八");
  21545. Number.Add('9', "九");
  21546. string stringNumberVal = string.Empty;
  21547. for (int i = 0; i < numberval.Length; i++)
  21548. {
  21549. if (i == 0)
  21550. {
  21551. stringNumberVal += Number[numberval[i]];
  21552. }
  21553. else if (i >= 1)
  21554. {
  21555. if (numberval[i] == '0')
  21556. {
  21557. stringNumberVal = "十";
  21558. }
  21559. else
  21560. {
  21561. stringNumberVal += "十" + Number[numberval[i]];
  21562. }
  21563. }
  21564. }
  21565. return stringNumberVal;
  21566. }
  21567. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21568. {
  21569. //获取table中的某个单元格,从0开始
  21570. Cell lshCell = table.Rows[rows].Cells[cells];
  21571. //将单元格中段落移除
  21572. foreach (Paragraph item in lshCell.Paragraphs)
  21573. {
  21574. lshCell.Paragraphs.Remove(item);
  21575. }
  21576. if (val.Contains("\r\n"))
  21577. {
  21578. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21579. foreach (var item in spArr)
  21580. {
  21581. //新建一个段落
  21582. Paragraph p = new Paragraph(doc);
  21583. var r = new Run(doc, item);
  21584. //设置字体
  21585. if (!string.IsNullOrEmpty(font))
  21586. {
  21587. r.Font.Name = font;
  21588. }
  21589. r.Font.Bold = bold;
  21590. //把设置的值赋给之前新建的段落
  21591. p.AppendChild(r);
  21592. //将此段落加到单元格内
  21593. lshCell.AppendChild(p);
  21594. }
  21595. }
  21596. else
  21597. {
  21598. //新建一个段落
  21599. Paragraph p = new Paragraph(doc);
  21600. var r = new Run(doc, val);
  21601. //设置字体
  21602. if (!string.IsNullOrEmpty(font))
  21603. {
  21604. r.Font.Name = font;
  21605. }
  21606. r.Font.Bold = bold;
  21607. //把设置的值赋给之前新建的段落
  21608. p.AppendChild(r);
  21609. //将此段落加到单元格内
  21610. lshCell.AppendChild(p);
  21611. }
  21612. }
  21613. //[HttpPost]
  21614. //public async Task<IActionResult> ServerHttp(string paramStr)
  21615. //{
  21616. // paramStr = paramStr.TrimEnd('\'');
  21617. // paramStr = paramStr.TrimStart('\'');
  21618. // JsonView jw = JsonView(false);
  21619. // JObject param = JObject.Parse(paramStr);
  21620. // if (!param.ContainsKey("url"))
  21621. // {
  21622. // jw.Msg = "url null";
  21623. // return Ok(jw);
  21624. // }
  21625. // string url = param["url"]!.ToString();
  21626. // var methon = "get";
  21627. // Dictionary<string, string> headValues = null;
  21628. // string bodyStr = string.Empty;
  21629. // if (param.ContainsKey("methon"))
  21630. // {
  21631. // methon = param["methon"]!.ToString().ToLower();
  21632. // }
  21633. // if (param.ContainsKey("header"))
  21634. // {
  21635. // var header = param["header"]!.ToString();
  21636. // JObject headerJobject = JObject.Parse(header);
  21637. // headValues = new Dictionary<string, string>();
  21638. // foreach (JProperty item in headerJobject.Properties())
  21639. // {
  21640. // var value = item.Value.ToString();
  21641. // var head = item.Path;
  21642. // headValues.Add(head, value);
  21643. // }
  21644. // }
  21645. // HttpClient client = new HttpClient();
  21646. // string responseString = string.Empty;
  21647. // StringContent content = null;
  21648. // if (headValues != null)
  21649. // {
  21650. // foreach (var item in headValues.Keys)
  21651. // {
  21652. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  21653. // {
  21654. // if (param.ContainsKey("body"))
  21655. // {
  21656. // bodyStr = param["body"]!.ToString();
  21657. // }
  21658. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  21659. // }
  21660. // else
  21661. // {
  21662. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  21663. // }
  21664. // }
  21665. // }
  21666. // try
  21667. // {
  21668. // if (methon == "get")
  21669. // {
  21670. // responseString = await client.GetStringAsync(url);
  21671. // }
  21672. // else if (methon == "post")
  21673. // {
  21674. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  21675. // {
  21676. // Content = content
  21677. // };
  21678. // var response = await client.SendAsync(request);
  21679. // try
  21680. // {
  21681. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  21682. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  21683. // {
  21684. // using (StreamReader reader = new StreamReader(gzipStream))
  21685. // {
  21686. // responseString = await reader.ReadToEndAsync();
  21687. // }
  21688. // }
  21689. // }
  21690. // catch (Exception)
  21691. // {
  21692. // responseString = await response.Content.ReadAsStringAsync();
  21693. // }
  21694. // }
  21695. // else
  21696. // {
  21697. // responseString = "methon error";
  21698. // }
  21699. // jw = JsonView(true, "success", responseString);
  21700. // }
  21701. // catch (Exception ex)
  21702. // {
  21703. // jw.Msg = "error " + ex.Message;
  21704. // jw.Data = ex.StackTrace;
  21705. // }
  21706. // finally
  21707. // {
  21708. // client.Dispose();
  21709. // }
  21710. // return Ok(jw);
  21711. //}
  21712. #endregion
  21713. #region 团组接待意见调查
  21714. /// <summary>
  21715. /// 团组接待意见调查 - 信息管理
  21716. /// 基础数据(团组)
  21717. /// </summary>
  21718. /// <returns></returns>
  21719. [HttpGet]
  21720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21721. public async Task<IActionResult> OpinionaireInit()
  21722. {
  21723. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21724. .Select(x => new
  21725. {
  21726. x.Id,
  21727. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21728. })
  21729. .OrderByDescending(x => x.Id)
  21730. .ToListAsync();
  21731. return Ok(JsonView(groupData, groupData.Count));
  21732. }
  21733. /// <summary>
  21734. /// 团组接待意见调查 - 信息管理
  21735. /// 列表
  21736. /// </summary>
  21737. /// <param name="groupId"></param>
  21738. /// <returns></returns>
  21739. [HttpGet("{groupId}")]
  21740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21741. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21742. {
  21743. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21744. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21745. .Select(x => new
  21746. {
  21747. x.Id,
  21748. x.TourGuideName,
  21749. x.CityName,
  21750. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21751. x.CreateTime
  21752. })
  21753. .OrderBy(x => x.Id)
  21754. .ToListAsync();
  21755. return Ok(JsonView(data));
  21756. }
  21757. /// <summary>
  21758. /// 团组接待意见调查 - 信息管理
  21759. /// 保存
  21760. /// </summary>
  21761. /// <param name="dto"></param>
  21762. /// <returns></returns>
  21763. [HttpPost]
  21764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21765. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21766. {
  21767. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21768. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21769. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21770. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21771. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21772. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21773. _opinionaireRep.BeginTran();
  21774. if (addData != null && addData.Count > 0)
  21775. {
  21776. foreach (var item in addData)
  21777. {
  21778. item.CreateUserId = currUserInfo.UserId;
  21779. item.DiId = dto.DiId;
  21780. }
  21781. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21782. }
  21783. if (updData != null && updData.Count > 0)
  21784. {
  21785. var upd = await _opinionaireRep._sqlSugar
  21786. .Updateable(updData)
  21787. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21788. .WhereColumns(x => new { x.Id })
  21789. .ExecuteCommandAsync();
  21790. }
  21791. _opinionaireRep.CommitTran();
  21792. return Ok(JsonView("操作成功!"));
  21793. }
  21794. /// <summary>
  21795. /// 团组接待意见调查 - 信息管理
  21796. /// 删除
  21797. /// </summary>
  21798. /// <param name="id"></param>
  21799. /// <returns></returns>
  21800. [HttpDelete("{id}")]
  21801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21802. public async Task<IActionResult> OpinionaireManageDel(int id)
  21803. {
  21804. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21805. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21806. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21807. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21808. if (!del) return Ok(JsonView("操作失败!"));
  21809. return Ok(JsonView("操作成功!"));
  21810. }
  21811. /// <summary>
  21812. /// 团组接待意见调查 - 用户
  21813. /// 列表
  21814. /// </summary>
  21815. /// <param name="diId"></param>
  21816. /// <returns></returns>
  21817. [HttpGet("{diId}")]
  21818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21819. public async Task<IActionResult> OpinionaireUserList(int diId)
  21820. {
  21821. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21822. var sql = string.Format(@"
  21823. SELECT
  21824. o.Id,
  21825. o.DiId,
  21826. di.TeamName AS 'GroupName',
  21827. di.VisitPNumber AS 'PeopleNumber',
  21828. di.ClientName AS 'LeadGroup',
  21829. di.VisitCountry AS 'Travel',
  21830. di.VisitDays AS 'Days',
  21831. o.CityName,
  21832. o.TourGuideName,
  21833. o.Catering,
  21834. o.CateringReason,
  21835. o.Stay,
  21836. o.StayReason,
  21837. o.[Route],
  21838. o.RouteReason,
  21839. o.OfficialActivity,
  21840. o.OfficialActivityReason,
  21841. o.TourGuide,
  21842. o.TourGuideReason,
  21843. o.[Translate],
  21844. o.TranslateReason,
  21845. o.Trip,
  21846. o.TripReason,
  21847. o.ESFileName,
  21848. o.SignatureDate,
  21849. o.Remark
  21850. FROM
  21851. Grp_Opinionaire o
  21852. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21853. WHERE
  21854. o.IsDel = 0
  21855. AND o.DiId = {0}
  21856. ORDER BY
  21857. o.Id ASC", diId);
  21858. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21859. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21860. return Ok(JsonView(data));
  21861. }
  21862. /// <summary>
  21863. /// 团组接待意见调查 - 用户
  21864. /// 保存
  21865. /// </summary>
  21866. /// <param name="dto"></param>
  21867. /// <returns></returns>
  21868. [HttpPost]
  21869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21870. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21871. {
  21872. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21873. foreach (var item in dto)
  21874. {
  21875. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21876. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21877. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21878. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21879. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21880. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21881. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21882. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21883. }
  21884. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21885. if (!Directory.Exists(filePathBase))
  21886. {
  21887. Directory.CreateDirectory(filePathBase);
  21888. }
  21889. #region 上传文件
  21890. var filePaths = new List<string>();
  21891. foreach (var item in dto)
  21892. {
  21893. var file = item.File;
  21894. // 将文件保存到指定位置
  21895. var filePath = Path.Combine(filePathBase, file.FileName);
  21896. using (var stream = new FileStream(filePath, FileMode.Create))
  21897. {
  21898. await file.CopyToAsync(stream);
  21899. }
  21900. //验证文件是否上传成功
  21901. if (!System.IO.File.Exists(filePath))
  21902. {
  21903. foreach (var filePathStr in filePaths)
  21904. {
  21905. System.IO.File.Delete(filePathStr);
  21906. }
  21907. return Ok(JsonView(false, "文件上传失败!"));
  21908. }
  21909. item.ESFileName = file.FileName;
  21910. }
  21911. #endregion
  21912. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  21913. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  21914. .UpdateColumns(x => new
  21915. {
  21916. x.Catering,
  21917. x.CateringReason,
  21918. x.Stay,
  21919. x.StayReason,
  21920. x.Route,
  21921. x.RouteReason,
  21922. x.OfficialActivity,
  21923. x.OfficialActivityReason,
  21924. x.TourGuide,
  21925. x.TourGuideReason,
  21926. x.Translate,
  21927. x.TranslateReason,
  21928. x.Trip,
  21929. x.TripReason,
  21930. x.ESFileName,
  21931. x.SignatureDate,
  21932. x.Remark
  21933. })
  21934. .WhereColumns(x => new { x.Id })
  21935. .ExecuteCommandAsync();
  21936. if (upd < 1)
  21937. {
  21938. foreach (var filePathStr in filePaths)
  21939. {
  21940. System.IO.File.Delete(filePathStr);
  21941. }
  21942. return Ok(JsonView(false));
  21943. }
  21944. return Ok(JsonView(true));
  21945. }
  21946. #endregion
  21947. #region 团组餐厅相关信息
  21948. /// <summary>
  21949. /// 团组相关餐厅信息
  21950. /// 基础数据(团组)
  21951. /// </summary>
  21952. /// <returns></returns>
  21953. [HttpGet]
  21954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21955. public async Task<IActionResult> RestaurantInit()
  21956. {
  21957. return Ok(await _restaurantRep.InitAsync());
  21958. }
  21959. /// <summary>
  21960. /// 团组相关餐厅信息
  21961. /// Item
  21962. /// </summary>
  21963. /// <param name="dto"></param>
  21964. /// <returns></returns>
  21965. [HttpPost]
  21966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21967. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  21968. {
  21969. int portType = dto.PortType,
  21970. groupId = dto.GroupId;
  21971. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21972. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21973. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  21974. }
  21975. /// <summary>
  21976. /// 团组相关餐厅信息
  21977. /// List
  21978. /// </summary>
  21979. /// <param name="dto"></param>
  21980. /// <returns></returns>
  21981. [HttpPost]
  21982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21983. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  21984. {
  21985. int portType = dto.PortType,
  21986. groupId = dto.GroupId;
  21987. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21988. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21989. var sql = string.Format(@" SELECT
  21990. ri.Id,
  21991. ri.GroupId,
  21992. ri.Date,
  21993. ri.StartTime,
  21994. ri.EndTime,
  21995. CASE WHEN ri.Type = 1 THEN '早餐'
  21996. WHEN ri.Type = 2 THEN '午餐'
  21997. WHEN ri.Type = 3 THEN '晚餐'
  21998. ELSE '其他'
  21999. END AS 'Type',
  22000. ri.Name,
  22001. ri.Address,
  22002. ri.Tel,
  22003. ri.Remark,
  22004. ri.CreateTime,
  22005. u.CnName AS CreateUserName
  22006. FROM
  22007. Grp_RestaurantInfo ri
  22008. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22009. WHERE
  22010. ri.IsDel = 0
  22011. AND ri.GroupId = {0}
  22012. ORDER BY
  22013. ri.Date ASC
  22014. ", groupId);
  22015. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22016. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22017. return Ok(JsonView(infos));
  22018. }
  22019. /// <summary>
  22020. /// 团组相关餐厅信息
  22021. /// Info
  22022. /// </summary>
  22023. /// <param name="dto"></param>
  22024. /// <returns></returns>
  22025. [HttpPost]
  22026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22027. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22028. {
  22029. int portType = dto.PortType,
  22030. id = dto.Id;
  22031. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22032. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22033. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22034. }
  22035. /// <summary>
  22036. /// 团组相关餐厅信息
  22037. /// Op
  22038. /// </summary>
  22039. /// <param name="dto"></param>
  22040. /// <returns></returns>
  22041. [HttpPost]
  22042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22043. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22044. {
  22045. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22046. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22047. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22048. return Ok(await _restaurantRep.OpAsync(dto));
  22049. }
  22050. /// <summary>
  22051. /// 团组相关餐厅信息
  22052. /// Del
  22053. /// </summary>
  22054. /// <param name="dto"></param>
  22055. /// <returns></returns>
  22056. [HttpPost]
  22057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22058. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22059. {
  22060. int userId = dto.DeleteUserId;
  22061. var id = dto.Id;
  22062. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22063. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22064. return Ok(await _restaurantRep.DelAsync(dto));
  22065. }
  22066. #endregion
  22067. // /// <summary>
  22068. // ///
  22069. // /// </summary>
  22070. // /// <param name="_dto"></param>
  22071. // /// <returns></returns>
  22072. // [HttpPost]
  22073. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22074. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22075. // {
  22076. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22077. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  22078. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  22079. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22080. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  22081. // dic_psg.Add("客人", 974);
  22082. // dic_psg.Add("司机", 975);
  22083. // dic_psg.Add("导游", 976);
  22084. // dic_psg.Add("公司内部人员", 977);
  22085. // dic_psg.Add("司机/导游/公司内部人员", 978);
  22086. // foreach (var item in list_visa)
  22087. // {
  22088. // Grp_VisaInfo temp = new Grp_VisaInfo();
  22089. // temp.Id = item.Id;
  22090. // temp.DIId = item.DIId;
  22091. // temp.VisaClient = item.VisaClient;
  22092. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  22093. // temp.VisaCurrency = item.VisaCurrency;
  22094. // temp.IsThird = item.IsThird;
  22095. // if (dic_psg.ContainsKey(item.PassengerType))
  22096. // {
  22097. // temp.PassengerType = dic_psg[item.PassengerType];
  22098. // }
  22099. // else {
  22100. // temp.PassengerType = -1;
  22101. // }
  22102. // temp.VisaNumber = item.VisaNumber;
  22103. // temp.VisaFreeNumber = item.VisaFreeNumber;
  22104. // temp.CreateUserId = item.Operators;
  22105. // DateTime dt_ct;
  22106. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  22107. // if (b_ct)
  22108. // {
  22109. // temp.CreateTime = dt_ct;
  22110. // }
  22111. // else
  22112. // {
  22113. // temp.CreateTime = DateTime.Now;
  22114. // }
  22115. // temp.DeleteTime = "";
  22116. // temp.DeleteUserId = 0;
  22117. // temp.Remark = item.Remark;
  22118. // if (string.IsNullOrEmpty(temp.Remark)) {
  22119. // temp.Remark = "";
  22120. // }
  22121. // temp.IsDel = item.IsDel;
  22122. // temp.VisaDescription = item.VisaAttachment;
  22123. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  22124. //([Id]
  22125. // ,[DIId]
  22126. // ,[VisaClient]
  22127. // ,[VisaPrice]
  22128. // ,[VisaCurrency]
  22129. // ,[IsThird]
  22130. // ,[PassengerType]
  22131. // ,[VisaNumber]
  22132. // ,[VisaFreeNumber]
  22133. // ,[CreateUserId]
  22134. // ,[CreateTime]
  22135. // ,[DeleteTime]
  22136. // ,[DeleteUserId]
  22137. // ,[Remark]
  22138. // ,[IsDel]
  22139. // ,[visaDescription])
  22140. // VALUES
  22141. // ({0},{1},'{2}',{3},{4}
  22142. //,{5},{6},{7},{8},{9}
  22143. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  22144. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  22145. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  22146. //);
  22147. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  22148. // }
  22149. // return Ok(JsonView(true, "操作成功!"));
  22150. // }
  22151. /// <summary>
  22152. /// 123132123
  22153. /// </summary>
  22154. /// <param name="_dto"></param>
  22155. /// <returns></returns>
  22156. [HttpPost]
  22157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22158. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22159. {
  22160. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22161. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22162. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22163. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22164. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22165. dicDetail.Add(789, 1034);
  22166. dicDetail.Add(790, 1035);
  22167. dicDetail.Add(791, 1036);
  22168. dicDetail.Add(792, 1037);
  22169. dicDetail.Add(793, 1038);
  22170. dicDetail.Add(794, 1039);
  22171. dicDetail.Add(795, 1040);
  22172. dicDetail.Add(796, 1041);
  22173. dicDetail.Add(797, 1042);
  22174. dicDetail.Add(798, 1043);
  22175. dicDetail.Add(801, 1044);
  22176. dicDetail.Add(802, 1045);
  22177. dicDetail.Add(803, 1046);
  22178. Dictionary<int, int> dic = new Dictionary<int, int>();
  22179. dic.Add(806, 1027);
  22180. dic.Add(807, 1028);
  22181. dic.Add(808, 1029);
  22182. dic.Add(809, 1030);
  22183. dic.Add(810, 1031);
  22184. dic.Add(811, 1032);
  22185. dic.Add(812, 1033);
  22186. foreach (var item in list_visa)
  22187. {
  22188. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22189. temp.Coefficient = item.coefficient;
  22190. DateTime dtCrt;
  22191. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22192. if (b1)
  22193. {
  22194. temp.CreateTime = dtCrt;
  22195. }
  22196. else
  22197. {
  22198. temp.CreateTime = DateTime.Now;
  22199. }
  22200. temp.CreateUserId = item.Operators;
  22201. temp.DeleteTime = "";
  22202. temp.DeleteUserId = 0;
  22203. temp.DiId = int.Parse(item.DIID);
  22204. temp.FilePath = item.FilePath;
  22205. temp.IsDel = item.IsDel;
  22206. temp.Price = item.Price;
  22207. temp.PriceCount = 1;
  22208. temp.PriceCurrency = item.Currency;
  22209. int detailId = 0;
  22210. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22211. {
  22212. detailId = dicDetail[item.PriceTypeDetail];
  22213. }
  22214. temp.PriceDetailType = detailId;
  22215. temp.PriceDt = DateTime.Now;
  22216. temp.PriceName = item.PriceName;
  22217. temp.PriceSum = item.Price;
  22218. int tid = 0;
  22219. if (dic.ContainsKey(item.PriceType))
  22220. {
  22221. tid = dic[item.PriceType];
  22222. }
  22223. temp.PriceType = tid;
  22224. temp.Remark = item.Remark;
  22225. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22226. }
  22227. return Ok(JsonView(true, "操作成功!"));
  22228. }
  22229. [HttpPost]
  22230. public IActionResult TimeTest()
  22231. {
  22232. var jw = JsonView(false, "error");
  22233. _sqlSugar.BeginTran();
  22234. try
  22235. {
  22236. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22237. .Select(x => new Crm_NewClientData
  22238. {
  22239. Id = x.Id,
  22240. Client = x.Client,
  22241. Contact = x.Contact,
  22242. Location = x.Location,
  22243. })
  22244. .ToList();
  22245. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22246. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22247. Stopwatch stopwatch = new Stopwatch();
  22248. // 开始计时
  22249. stopwatch.Start();
  22250. foreach (var item in clientList)
  22251. {
  22252. EncryptionProcessor.DecryptProperties(item);
  22253. }
  22254. stopwatch.Stop();
  22255. jw.Code = 200;
  22256. jw.Data = stopwatch.ElapsedMilliseconds;
  22257. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22258. }
  22259. catch (Exception ex)
  22260. {
  22261. jw.Code = 400;
  22262. jw.Msg = ex.Message;
  22263. }
  22264. return Ok(jw);
  22265. }
  22266. }
  22267. }