GroupsController.cs 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using DiffMatchPatch;
  7. using EyeSoft.Runtime.InteropServices;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.Mvc.RazorPages;
  10. using Microsoft.AspNetCore.SignalR;
  11. using Microsoft.EntityFrameworkCore.Metadata.Internal;
  12. using Microsoft.IdentityModel.Tokens;
  13. using Microsoft.VisualBasic;
  14. using MySqlX.XDevAPI.Relational;
  15. using NetTaste;
  16. using NPOI.HSSF.UserModel;
  17. using NPOI.SS.Formula.Functions;
  18. using NPOI.SS.UserModel;
  19. using NPOI.SS.Util;
  20. using NPOI.XSSF.UserModel;
  21. using OASystem.API.Middlewares;
  22. using OASystem.API.OAMethodLib;
  23. using OASystem.API.OAMethodLib.APNs;
  24. using OASystem.API.OAMethodLib.File;
  25. using OASystem.API.OAMethodLib.Hub.HubClients;
  26. using OASystem.API.OAMethodLib.Hub.Hubs;
  27. using OASystem.API.OAMethodLib.JuHeAPI;
  28. using OASystem.API.OAMethodLib.KiMiApi;
  29. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  30. using OASystem.Domain.AesEncryption;
  31. using OASystem.Domain.Attributes;
  32. using OASystem.Domain.Dtos.CRM;
  33. using OASystem.Domain.Dtos.FileDto;
  34. using OASystem.Domain.Dtos.Financial;
  35. using OASystem.Domain.Dtos.Groups;
  36. using OASystem.Domain.Entities.Customer;
  37. using OASystem.Domain.Entities.Financial;
  38. using OASystem.Domain.Entities.Groups;
  39. using OASystem.Domain.ViewModels.Financial;
  40. using OASystem.Domain.ViewModels.Groups;
  41. using OASystem.Domain.ViewModels.OCR;
  42. using OASystem.Domain.ViewModels.QiYeWeChat;
  43. using OASystem.Domain.ViewModels.Statistics;
  44. using OASystem.Infrastructure.Repositories.CRM;
  45. using OASystem.Infrastructure.Repositories.Financial;
  46. using OASystem.Infrastructure.Repositories.Groups;
  47. using OASystem.Infrastructure.Tools;
  48. using OASystem.RedisRepository;
  49. using Org.BouncyCastle.Crypto;
  50. using Org.BouncyCastle.Utilities;
  51. using Quartz.Util;
  52. using SqlSugar.Extensions;
  53. using System.Collections;
  54. using System.Collections.Generic;
  55. using System.Data;
  56. using System.Diagnostics;
  57. using System.Drawing.Printing;
  58. using System.Globalization;
  59. using System.IO;
  60. using System.IO.Compression;
  61. using System.Reflection;
  62. using System.Text.Json;
  63. using System.Web;
  64. using System.Xml.Linq;
  65. using TencentCloud.Ocr.V20181119.Models;
  66. using static OASystem.API.OAMethodLib.JWTHelper;
  67. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  68. using Bookmark = Aspose.Words.Bookmark;
  69. using Cell = Aspose.Words.Tables.Cell;
  70. using Table = Aspose.Words.Tables.Table;
  71. namespace OASystem.API.Controllers
  72. {
  73. /// <summary>
  74. /// 团组相关
  75. /// </summary>
  76. //[Authorize]
  77. [Route("api/[controller]/[action]")]
  78. public class GroupsController : ControllerBase
  79. {
  80. private readonly ILogger<GroupsController> _logger;
  81. private readonly GrpScheduleRepository _grpScheduleRep;
  82. private readonly IMapper _mapper;
  83. private readonly DelegationInfoRepository _groupRepository;
  84. private readonly TaskAssignmentRepository _taskAssignmentRep;
  85. private readonly AirTicketResRepository _airTicketResRep;
  86. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  87. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  88. private readonly DelegationEnDataRepository _delegationEnDataRep;
  89. private readonly DelegationVisaRepository _delegationVisaRep;
  90. private readonly VisaPriceRepository _visaPriceRep;
  91. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  92. private readonly HotelPriceRepository _hotelPriceRep;
  93. private readonly CustomersRepository _customersRep;
  94. private readonly MessageRepository _message;
  95. private readonly SqlSugarClient _sqlSugar;
  96. private readonly TourClientListRepository _tourClientListRep;
  97. private readonly TeamRateRepository _teamRateRep;
  98. #region 成本相关
  99. private readonly CheckBoxsRepository _checkBoxs;
  100. private readonly GroupCostRepository _GroupCostRepository;
  101. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  102. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  103. #endregion
  104. private readonly SetDataRepository _setDataRep;
  105. private string url;
  106. private string path;
  107. private readonly EnterExitCostRepository _enterExitCostRep;
  108. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  109. private readonly UsersRepository _usersRep;
  110. private readonly IJuHeApiService _juHeApi;
  111. private readonly InvertedListRepository _invertedListRep;
  112. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  113. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  114. private readonly ThreeCodeRepository _threeCodeRepository;
  115. private readonly HotelInquiryRepository _hotelInquiryRep;
  116. private readonly FeeAuditRepository _feeAuditRep;
  117. private readonly VisaCommissionRepository _visaCommissionRep;
  118. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  119. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  120. private readonly List<CurrencyInfo> _currencyInit;
  121. private readonly List<int> _portTypeData;
  122. private readonly TableOperationRecordRepository _tableorRep;
  123. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  124. private readonly RestaurantRepository _restaurantRep;
  125. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  126. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  127. /// <summary>
  128. /// 构造函数
  129. /// </summary>
  130. /// <param name="logger"></param>
  131. /// <param name="mapper"></param>
  132. /// <param name="hubContext"></param>
  133. /// <param name="sqlSugar"></param>
  134. /// <param name="grpScheduleRep"></param>
  135. /// <param name="groupRepository"></param>
  136. /// <param name="taskAssignmentRep"></param>
  137. /// <param name="airTicketResRep"></param>
  138. /// <param name="decreasePaymentsRep"></param>
  139. /// <param name="InvitationOfficialActivitiesRep"></param>
  140. /// <param name="delegationEnDataRep"></param>
  141. /// <param name="enterExitCostRep"></param>
  142. /// <param name="delegationVisaRep"></param>
  143. /// <param name="message"></param>
  144. /// <param name="visaPriceRep"></param>
  145. /// <param name="carTouristGuideGroundRep"></param>
  146. /// <param name="checkBoxs"></param>
  147. /// <param name="GroupCostRepository"></param>
  148. /// <param name="CostTypeHotelNumberRepository"></param>
  149. /// <param name="GroupCostParameterRepository"></param>
  150. /// <param name="hotelPriceRep"></param>
  151. /// <param name="customersRep"></param>
  152. /// <param name="setDataRep"></param>
  153. /// <param name="tourClientListRep"></param>
  154. /// <param name="teamRateRep"></param>
  155. /// <param name="usersRep"></param>
  156. /// <param name="juHeApi"></param>
  157. /// <param name="invertedListRep"></param>
  158. /// <param name="visaFeeInfoRep"></param>
  159. /// <param name="ticketBlackCodeRep"></param>
  160. /// <param name="hotelInquiryRep"></param>
  161. /// <param name="threeCodeRepository"></param>
  162. /// <param name="feeAuditRep"></param>
  163. /// <param name="visaCommissionRep"></param>
  164. /// <param name="ffrRep"></param>
  165. /// <param name="opinionaireRep"></param>
  166. /// <param name="tableorRep"></param>
  167. /// <param name="enterExitCostDraftRep"></param>
  168. /// <param name="restaurantRep"></param>
  169. /// <param name="enterExitCostQuoteRep"></param>
  170. /// <param name="grpOrderPreInfoRep"></param>
  171. public GroupsController(
  172. ILogger<GroupsController> logger,
  173. IMapper mapper,
  174. IHubContext<ChatHub, IChatClient> hubContext,
  175. SqlSugarClient sqlSugar,
  176. GrpScheduleRepository grpScheduleRep,
  177. DelegationInfoRepository groupRepository,
  178. TaskAssignmentRepository taskAssignmentRep,
  179. AirTicketResRepository airTicketResRep,
  180. DecreasePaymentsRepository decreasePaymentsRep,
  181. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  182. DelegationEnDataRepository delegationEnDataRep,
  183. EnterExitCostRepository enterExitCostRep,
  184. DelegationVisaRepository delegationVisaRep,
  185. MessageRepository message,
  186. VisaPriceRepository visaPriceRep,
  187. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  188. CheckBoxsRepository checkBoxs,
  189. GroupCostRepository GroupCostRepository,
  190. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  191. GroupCostParameterRepository GroupCostParameterRepository,
  192. HotelPriceRepository hotelPriceRep,
  193. CustomersRepository customersRep,
  194. SetDataRepository setDataRep,
  195. TourClientListRepository tourClientListRep,
  196. TeamRateRepository teamRateRep,
  197. UsersRepository usersRep,
  198. IJuHeApiService juHeApi,
  199. InvertedListRepository invertedListRep,
  200. VisaFeeInfoRepository visaFeeInfoRep,
  201. TicketBlackCodeRepository ticketBlackCodeRep,
  202. HotelInquiryRepository hotelInquiryRep,
  203. ThreeCodeRepository threeCodeRepository,
  204. FeeAuditRepository feeAuditRep,
  205. VisaCommissionRepository visaCommissionRep,
  206. ForeignReceivablesRepository ffrRep,
  207. OpinionaireRepository opinionaireRep,
  208. TableOperationRecordRepository tableorRep,
  209. EnterExitCostDraftRepository enterExitCostDraftRep,
  210. RestaurantRepository restaurantRep,
  211. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  212. GroupOrderPreInfoRepository grpOrderPreInfoRep
  213. )
  214. {
  215. _logger = logger;
  216. _mapper = mapper;
  217. _grpScheduleRep = grpScheduleRep;
  218. _groupRepository = groupRepository;
  219. _taskAssignmentRep = taskAssignmentRep;
  220. _airTicketResRep = airTicketResRep;
  221. _sqlSugar = sqlSugar;
  222. url = AppSettingsHelper.Get("ExcelBaseUrl");
  223. path = AppSettingsHelper.Get("ExcelBasePath");
  224. if (!System.IO.Directory.Exists(path))
  225. {
  226. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  227. }
  228. _decreasePaymentsRep = decreasePaymentsRep;
  229. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  230. _delegationEnDataRep = delegationEnDataRep;
  231. _enterExitCostRep = enterExitCostRep;
  232. _delegationVisaRep = delegationVisaRep;
  233. _message = message;
  234. _visaPriceRep = visaPriceRep;
  235. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  236. _checkBoxs = checkBoxs;
  237. _GroupCostRepository = GroupCostRepository;
  238. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  239. _GroupCostParameterRepository = GroupCostParameterRepository;
  240. _hotelPriceRep = hotelPriceRep;
  241. _customersRep = customersRep;
  242. _setDataRep = setDataRep;
  243. _tourClientListRep = tourClientListRep;
  244. _teamRateRep = teamRateRep;
  245. _hubContext = hubContext;
  246. _usersRep = usersRep;
  247. _juHeApi = juHeApi;
  248. _invertedListRep = invertedListRep;
  249. _visaFeeInfoRep = visaFeeInfoRep;
  250. _ticketBlackCodeRep = ticketBlackCodeRep;
  251. _hotelInquiryRep = hotelInquiryRep;
  252. _threeCodeRepository = threeCodeRepository;
  253. _feeAuditRep = feeAuditRep;
  254. _visaCommissionRep = visaCommissionRep;
  255. _ffrRep = ffrRep;
  256. _opinionaireRep = opinionaireRep;
  257. _currencyInit = new List<CurrencyInfo>()
  258. {
  259. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  260. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  261. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  262. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  263. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  264. };
  265. _portTypeData = new List<int>() { 2, 3 };
  266. _tableorRep = tableorRep;
  267. _enterExitCostDraftRep = enterExitCostDraftRep;
  268. _restaurantRep = restaurantRep;
  269. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  270. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  271. }
  272. #region 流程管控
  273. /// <summary>
  274. /// 获取团组流程管控信息
  275. /// </summary>
  276. /// <param name="_jsonDto">查询参数</param>
  277. /// <returns></returns>
  278. [HttpPost]
  279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  280. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  281. {
  282. if (string.IsNullOrEmpty(_jsonDto.Paras))
  283. {
  284. return Ok(JsonView(false, "参数为空"));
  285. }
  286. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  287. if (_ScheduleDto != null)
  288. {
  289. if (_ScheduleDto.SearchType == 2)//获取列表
  290. {
  291. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  292. return Ok(JsonView(_grpScheduleViewList));
  293. }
  294. else//获取对象
  295. {
  296. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  297. if (_grpScheduleView != null)
  298. {
  299. return Ok(JsonView(_grpScheduleView));
  300. }
  301. }
  302. }
  303. else
  304. {
  305. return Ok(JsonView(false, "参数反序列化失败"));
  306. }
  307. return Ok(JsonView(false, "暂无数据!"));
  308. }
  309. /// <summary>
  310. /// 修改团组流程管控详细表数据
  311. /// </summary>
  312. /// <param name="dto"></param>
  313. /// <returns></returns>
  314. [HttpPost]
  315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  316. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  317. {
  318. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  319. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  320. .SetColumns(it => it.Duty == _detail.Duty)
  321. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  322. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  323. .SetColumns(it => it.JobContent == _detail.JobContent)
  324. .SetColumns(it => it.Remark == _detail.Remark)
  325. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  326. .Where(s => s.Id == dto.Id)
  327. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  328. .ExecuteCommandAsync();
  329. if (result > 0)
  330. {
  331. return Ok(JsonView(true, "保存成功!"));
  332. }
  333. return Ok(JsonView(false, "保存失败!"));
  334. }
  335. /// <summary>
  336. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  337. /// </summary>
  338. /// <param name="dto"></param>
  339. /// <returns></returns>
  340. [HttpPost]
  341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  342. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  343. {
  344. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  345. _detail.IsDel = 1;
  346. _detail.DeleteUserId = dto.Duty;
  347. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  348. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  349. .SetColumns(it => it.IsDel == _detail.IsDel)
  350. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  351. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  352. .Where(it => it.Id == dto.Id)
  353. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  354. //.WhereColumns(s => s.Id == dto.Id)
  355. .ExecuteCommandAsync();
  356. if (result > 0)
  357. {
  358. return Ok(JsonView(true, "删除成功!"));
  359. }
  360. return Ok(JsonView(false, "删除失败!"));
  361. }
  362. /// <summary>
  363. /// 增加团组流程管控详细表数据
  364. /// </summary>
  365. /// <param name="dto"></param>
  366. /// <returns></returns>
  367. [HttpPost]
  368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  369. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  370. {
  371. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  372. if (DateTime.Now < _detail.ExpectBeginDt)
  373. {
  374. _detail.StepStatus = 0;
  375. }
  376. else
  377. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  378. _detail.StepStatus = 1;
  379. }
  380. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  381. if (result > 0)
  382. {
  383. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  384. return Ok(JsonView(true, "添加成功!", _result));
  385. }
  386. return Ok(JsonView(false, "添加失败!"));
  387. }
  388. #endregion
  389. #region 团组前期信息
  390. /// <summary>
  391. /// 团组前期信息 List
  392. /// </summary>
  393. /// <returns></returns>
  394. [HttpPost]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  397. {
  398. var search = dto.Search;
  399. int[] nameTempIds = new int[] { 1, 12, 28 },
  400. countryTempIds = new int[] { 2, 13, 29 },
  401. daysTempIds = new int[] { 4, 15, 31 },
  402. ppNumTempIds = new int[] { 6 };
  403. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  404. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  405. .Where((opi, u) => opi.IsDel == 0)
  406. .OrderByDescending((opi, u) => opi.CreateTime)
  407. .Select((opi, u) => new GroupOrderPreInfoListView()
  408. {
  409. Id = opi.Id,
  410. Name = opi.Name,
  411. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains( x.FormTempId)).Select(x => x.Value),
  412. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  413. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  415. Operator = u.CnName,
  416. OperationTime = opi.CreateTime
  417. })
  418. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  419. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  420. .ToListAsync();
  421. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  422. int total = list.Count;
  423. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  424. var listPageData1 = listPageData
  425. .Skip((dto.PageIndex - 1) * dto.PageSize)
  426. .Take(dto.PageSize)
  427. .ToList();
  428. var infoIds = listPageData1.Select(x => x.Id).ToList();
  429. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  430. .Where(x => x.IsDel == 0 && x.STid == 109)
  431. .ToArrayAsync();
  432. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  433. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  434. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  435. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  436. .ToListAsync();
  437. foreach (var item in listPageData1)
  438. {
  439. var typeDatas1 = typeDatas.Select(x => new
  440. {
  441. Id = x.Id,
  442. Name = x.Name,
  443. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  444. }).ToArray();
  445. item.VersionDetails = typeDatas1;
  446. }
  447. return Ok(JsonView(listPageData1, listPageData1.Count));
  448. }
  449. /// <summary>
  450. /// 团组前期信息 Init
  451. /// </summary>
  452. /// <returns></returns>
  453. [HttpGet("{userId}")]
  454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  455. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  456. {
  457. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  458. }
  459. /// <summary>
  460. /// 国家数据源
  461. /// </summary>
  462. /// <returns></returns>
  463. [HttpGet]
  464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  465. public async Task<IActionResult> CountryInit()
  466. {
  467. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  468. return Ok(JsonView(countrys));
  469. }
  470. /// <summary>
  471. /// 城市数据源
  472. /// </summary>
  473. /// <returns></returns>
  474. [HttpGet("{countryLabel}")]
  475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  476. public async Task<IActionResult> CityByCountry(string countryLabel)
  477. {
  478. countryLabel = HttpUtility.UrlDecode(countryLabel);
  479. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  480. var citys = Array.Empty<string?>();
  481. if (countryList.Any())
  482. {
  483. var cityDatas = await _sqlSugar
  484. .Queryable<Grp_NationalTravelFee>()
  485. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  486. .ToArrayAsync();
  487. foreach (var item in cityDatas)
  488. {
  489. if (item.City.Contains("城市"))
  490. {
  491. item.City = item.Country + "-所有城市";
  492. }
  493. }
  494. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  495. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  496. }
  497. return Ok(JsonView(citys));
  498. }
  499. /// <summary>
  500. /// 团组前期信息 Info
  501. /// </summary>
  502. /// <param name="dto">Id</param>
  503. /// <returns></returns>
  504. [HttpGet("{Id}/{TempId}")]
  505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  506. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  507. {
  508. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  509. }
  510. /// <summary>
  511. /// 团组前期信息 Save
  512. /// </summary>
  513. /// <param name="dto">Id</param>
  514. /// <returns></returns>
  515. [HttpPost]
  516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  517. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  518. {
  519. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  520. }
  521. /// <summary>
  522. /// 团组前期信息 Del
  523. /// </summary>
  524. /// <param name="dto">Id</param>
  525. /// <returns></returns>
  526. [HttpPost]
  527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  528. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  529. {
  530. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  531. }
  532. /// <summary>
  533. /// 团组前期信息 文件下载
  534. /// </summary>
  535. /// <param name="dto">Id</param>
  536. /// <returns></returns>
  537. [HttpGet("{Id}/{TempId}")]
  538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  539. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  540. {
  541. int id = dto.Id, tempId = dto.TempId;
  542. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  543. var data = view.Data as GrpOrderPreInfoView;
  544. #region Excel
  545. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  546. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  547. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  548. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  549. var fileNamePrefix = string.Empty;
  550. if (tempId == 1405)
  551. {
  552. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  553. fileNamePrefix = $"{data.Name}_无商邀版";
  554. }
  555. else if (tempId == 1406)
  556. {
  557. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  558. fileNamePrefix = $"{data.Name}_有商邀版";
  559. }
  560. else
  561. {
  562. //tempId == 1404 默认下载
  563. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  564. fileNamePrefix = $"{data.Name}_单接送机";
  565. }
  566. foreach (var item in data.Items)
  567. {
  568. var obj = item.NewValue;
  569. if (obj == null) item.OriginVal = "";
  570. else if (obj.Equals("有") || obj.Equals("无"))
  571. {
  572. item.OriginVal = obj.ToString();
  573. }
  574. else if (obj is object[] objArray)
  575. {
  576. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  577. item.OriginVal = string.Join("、", stringArray);
  578. }
  579. else if (obj is string[] stringArray)
  580. {
  581. item.OriginVal = string.Join("、", stringArray);
  582. }
  583. else if (obj.Equals("-"))
  584. {
  585. item.OriginVal = "";
  586. }
  587. }
  588. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  589. fileName = CommonFun.ValidFileName(fileName);
  590. //载入模板
  591. WorkbookDesigner designer = new WorkbookDesigner();
  592. designer.Workbook = new Workbook(tempPath);
  593. if (tempId == 1406)
  594. {
  595. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  596. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  597. for (int i = 1; i <= view2.Length; i++)
  598. {
  599. view2[i - 1].Index = i;
  600. }
  601. designer.SetDataSource("View1", view1);
  602. designer.SetDataSource("View2", view2);
  603. }
  604. else
  605. {
  606. designer.SetDataSource("View", data.Items);
  607. }
  608. designer.Process();
  609. if (!Directory.Exists(savePath))
  610. {
  611. Directory.CreateDirectory(savePath);
  612. }
  613. string serverPath = $"{savePath}{fileName}";
  614. designer.Workbook.Save(serverPath);
  615. string rst = $"{servicePath}{ftpPath}{fileName}";
  616. #endregion
  617. return Ok(JsonView(new { url = rst }));
  618. }
  619. #endregion
  620. #region 团组基本信息
  621. /// <summary>
  622. /// 接团信息列表
  623. /// </summary>
  624. /// <param name="dto">团组列表请求dto</param>
  625. /// <returns></returns>
  626. [HttpPost]
  627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  628. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  629. {
  630. var groupData = await _groupRepository.GetGroupList(dto);
  631. if (groupData.Code != 0)
  632. {
  633. return Ok(JsonView(false, groupData.Msg));
  634. }
  635. return Ok(JsonView(groupData.Data));
  636. }
  637. /// <summary>
  638. /// 分页查询团组列表
  639. /// </summary>
  640. /// <param name="dto"></param>
  641. /// <returns></returns>
  642. [HttpPost]
  643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  644. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  645. {
  646. var watch = new Stopwatch();
  647. watch.Start();
  648. RefAsync<int> total = 0;
  649. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  650. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  651. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  652. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  653. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  654. .Distinct()
  655. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  656. watch.Stop();
  657. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  658. }
  659. /// <summary>
  660. /// 接团信息列表 Page Init
  661. /// </summary>
  662. /// <returns></returns>
  663. [HttpPost]
  664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  665. public async Task<IActionResult> PostGroupPageListInit()
  666. {
  667. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  668. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  669. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  670. var _view = new
  671. {
  672. depData = depDatas,
  673. rankData = rankDatas
  674. };
  675. return Ok(JsonView(true, "查询成功!", _view));
  676. }
  677. /// <summary>
  678. /// 接团信息列表 Page
  679. /// </summary>
  680. /// <param name="dto">团组列表请求dto</param>
  681. /// <returns></returns>
  682. [HttpPost]
  683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  684. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  685. {
  686. #region 参数验证
  687. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  688. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  689. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  690. #region 页面操作权限验证
  691. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  692. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  693. #endregion
  694. #endregion
  695. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  696. {
  697. string sqlWhere = string.Empty;
  698. if (dto.IsSure == 0) //未完成
  699. {
  700. sqlWhere += string.Format(@" And IsSure = 0");
  701. }
  702. else if (dto.IsSure == 1) //已完成
  703. {
  704. sqlWhere += string.Format(@" And IsSure = 1");
  705. }
  706. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  707. {
  708. string tj = dto.SearchCriteria;
  709. 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}%')",
  710. tj, tj, tj, tj, tj);
  711. }
  712. if (int.TryParse(dto.Rank, out int rankId))
  713. {
  714. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  715. }
  716. string sqlWhere1 = string.Empty;
  717. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  718. {
  719. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  720. }
  721. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  722. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  723. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  724. JietuanOperator,IsSure,CreateTime,IsBid
  725. From (
  726. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  727. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  728. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  729. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  730. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  731. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  732. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  733. From Grp_DelegationInfo gdi
  734. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  735. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  736. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  737. Where gdi.IsDel = 0 {0}
  738. ) temp {1}", sqlWhere, sqlWhere1);
  739. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  740. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  741. var _view = new
  742. {
  743. PageFuncAuth = pageFunAuthView,
  744. Data = _DelegationList
  745. };
  746. return Ok(JsonView(true, "查询成功!", _view, total));
  747. }
  748. else
  749. {
  750. return Ok(JsonView(false, "查询失败"));
  751. }
  752. }
  753. /// <summary>
  754. /// 团组列表
  755. /// </summary>
  756. /// <returns></returns>
  757. [HttpPost]
  758. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  759. {
  760. #region 参数验证
  761. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  762. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  763. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  764. #region 页面操作权限验证
  765. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  766. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  767. #endregion
  768. #endregion
  769. if (dto.PortType != 1 && dto.PortType != 2)
  770. {
  771. return Ok(JsonView(false, "查询失败!"));
  772. }
  773. string orderbyStr = "order by gdi.CreateTime Desc";
  774. string sqlWhere = string.Empty;
  775. if (dto.IsSure == 0) //未完成
  776. {
  777. sqlWhere += string.Format(@" And IsSure = 0");
  778. }
  779. else if (dto.IsSure == 1) //已完成
  780. {
  781. sqlWhere += string.Format(@" And IsSure = 1");
  782. }
  783. //团组类型
  784. if (dto.TeamDid > 0)
  785. {
  786. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  787. }
  788. //团组名称
  789. if (!string.IsNullOrEmpty(dto.TeamName))
  790. {
  791. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  792. }
  793. //客户名称
  794. if (!string.IsNullOrEmpty(dto.ClientName))
  795. {
  796. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  797. }
  798. //客户单位
  799. if (!string.IsNullOrEmpty(dto.ClientUnit))
  800. {
  801. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  802. }
  803. //出访时间
  804. if (!string.IsNullOrEmpty(dto.visitDataTime))
  805. {
  806. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  807. orderbyStr = "order by gdi.VisitDate";
  808. }
  809. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  810. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  811. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  812. JietuanOperator,IsSure,CreateTime
  813. From (
  814. Select row_number() over({0}) as Row_Number,
  815. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  816. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  817. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  818. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  819. From Grp_DelegationInfo gdi
  820. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  821. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  822. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  823. Where gdi.IsDel = 0 {1}
  824. ) temp ", orderbyStr, sqlWhere);
  825. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  826. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  827. #region 处理所属部门
  828. /*
  829. * 1.sq 和 gyy 等显示 市场部
  830. * 2.王鸽和主管及张总还有管理员号统一国交部
  831. * 2-1. 4 管理员 ,21 张海麟
  832. */
  833. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  834. List<int> userIds1 = new List<int>() { 4, 21 };
  835. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  836. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  837. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  838. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  839. .ToList();
  840. foreach (var item in _DelegationList)
  841. {
  842. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  843. }
  844. #endregion
  845. var _view = new
  846. {
  847. PageFuncAuth = pageFunAuthView,
  848. Data = _DelegationList
  849. };
  850. return Ok(JsonView(true, "查询成功!", _view, total));
  851. }
  852. /// <summary>
  853. /// 接团信息详情
  854. /// </summary>
  855. /// <param name="dto">团组info请求dto</param>
  856. /// <returns></returns>
  857. [HttpPost]
  858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  859. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  860. {
  861. var groupData = await _groupRepository.GetGroupInfo(dto);
  862. if (groupData.Code != 0)
  863. {
  864. return Ok(JsonView(false, groupData.Msg));
  865. }
  866. return Ok(JsonView(groupData.Data));
  867. }
  868. /// <summary>
  869. /// 接团信息 编辑添加
  870. /// 基础信息数据源
  871. /// </summary>
  872. /// <param name="dto"></param>
  873. /// <returns></returns>
  874. [HttpPost]
  875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  876. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  877. {
  878. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  879. if (groupData.Code != 0)
  880. {
  881. return Ok(JsonView(false, groupData.Msg));
  882. }
  883. return Ok(JsonView(groupData.Data));
  884. }
  885. /// <summary>
  886. /// 接团信息 编辑添加
  887. /// 省份-城市 基础信息数据源
  888. /// </summary>
  889. /// <param name="dto"></param>
  890. /// <returns></returns>
  891. [HttpPost]
  892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  893. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  894. {
  895. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  896. string search = dto.Search;
  897. var data = await _groupRepository.CityBasicSource();
  898. int total = data.Length;
  899. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  900. .Skip((pageIndex - 1) * pageSize)
  901. .Take(pageSize)
  902. .ToArray();
  903. return Ok(JsonView(data, total));
  904. }
  905. /// <summary>
  906. /// 接团信息 操作(增改)
  907. /// </summary>
  908. /// <param name="dto"></param>
  909. /// <returns></returns>
  910. [HttpPost]
  911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  912. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  913. {
  914. // 创建 Stopwatch 实例
  915. Stopwatch stopwatch = Stopwatch.StartNew();
  916. decimal ffrPrice = 0.00M;
  917. DateTime? visitDt = null;
  918. if (dto.Status == 2)
  919. {
  920. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  921. if (groupInfo != null)
  922. {
  923. ffrPrice = groupInfo.PaymentMoney;
  924. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  925. }
  926. }
  927. var groupData = await _groupRepository.GroupOperation(dto);
  928. if (groupData.Code != 0)
  929. {
  930. return Ok(JsonView(false, groupData.Msg));
  931. }
  932. int diId = 0;
  933. try
  934. {
  935. //添加时 默认加入团组汇率
  936. if (dto.Status == 1) //添加
  937. {
  938. diId = groupData.Data;
  939. //添加默认币种
  940. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  941. //默认分配权限
  942. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  943. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  944. var _managerIds = new List<int>() { 22, 32, 21 };
  945. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  946. if (userIds.Count > 0)
  947. {
  948. userIds.Add(208);
  949. //创建团组管控
  950. GroupStepForDelegation.CreateWorkStep(diId);
  951. //发送消息
  952. string groupName = dto.TeamName;
  953. string createGroupUser = string.Empty;
  954. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  955. if (userInfo != null) createGroupUser = userInfo.CnName;
  956. string title = $"系统通知";
  957. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  958. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  959. }
  960. //默认创建倒推表
  961. await _invertedListRep._Create(dto.UserId, diId);
  962. }
  963. else if (dto.Status == 2)
  964. {
  965. diId = dto.Id;
  966. }
  967. #region 签证人员团组时间通知
  968. #region 计算出访起止时间
  969. var startTime = new DateTime();
  970. var endTime = new DateTime();
  971. if (DateTime.TryParse(dto.VisitDate, out startTime))
  972. {
  973. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  974. }
  975. #endregion
  976. #endregion
  977. #region 团组操作默认添加/修改收款账单
  978. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  979. {
  980. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  981. .Where(x => x.IsDel == 0 &&
  982. x.Diid == diId &&
  983. x.Remark.Equals("预付款")
  984. )
  985. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  986. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  987. .FirstAsync();
  988. ffrInfo = new Fin_ForeignReceivables()
  989. {
  990. Diid = diId,
  991. PriceName = dto.ClientUnit,
  992. Price = dto.PaymentMoney,
  993. Count = 1,
  994. Unit = $"元",
  995. ItemSumPrice = dto.PaymentMoney,
  996. Rate = 1.0000M,
  997. Currency = 836,
  998. AddingWay = 0,
  999. CreateUserId = dto.UserId,
  1000. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1001. Remark = $"预付款"
  1002. };
  1003. if (ffrInfo == null) //Add
  1004. {
  1005. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1006. }
  1007. else //修改
  1008. {
  1009. await _sqlSugar.Updateable(ffrInfo)
  1010. .UpdateColumns(x => new
  1011. {
  1012. x.PriceName,
  1013. x.Price,
  1014. x.ItemSumPrice,
  1015. x.CreateTime,
  1016. x.CreateUserId
  1017. })
  1018. .WhereColumns(x => x.Id)
  1019. .ExecuteCommandAsync();
  1020. }
  1021. }
  1022. #endregion
  1023. if (diId > 0)
  1024. {
  1025. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1026. }
  1027. // 停止计时
  1028. stopwatch.Stop();
  1029. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1030. }
  1031. catch (Exception ex)
  1032. {
  1033. // 停止计时
  1034. stopwatch.Stop();
  1035. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1036. Logs(ex.Message);
  1037. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1038. }
  1039. // 停止计时
  1040. stopwatch.Stop();
  1041. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1042. }
  1043. /// <summary>
  1044. /// 接团流程操作(增改)
  1045. /// 安卓端使用 建团时添加客户名单
  1046. /// </summary>
  1047. /// <param name="dto"></param>
  1048. /// <returns></returns>
  1049. [HttpPost]
  1050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1051. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1052. {
  1053. #region 参数验证
  1054. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1055. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1056. #region 页面操作权限验证
  1057. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1058. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1059. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1060. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1061. #endregion
  1062. #endregion
  1063. try
  1064. {
  1065. //_sqlSugar.BeginTran();
  1066. decimal ffrPrice = 0.00M;
  1067. DateTime? visitDt = null;
  1068. if (dto.Status == 2)
  1069. {
  1070. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1071. if (groupInfo != null)
  1072. {
  1073. ffrPrice = groupInfo.PaymentMoney;
  1074. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1075. }
  1076. }
  1077. var _dto = new GroupOperationDto();
  1078. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1079. var groupData = await _groupRepository.GroupOperation(_dto);
  1080. if (groupData.Code != 0)
  1081. {
  1082. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1083. }
  1084. int diId = 0;
  1085. //添加时 默认加入团组汇率
  1086. if (dto.Status == 1) //添加
  1087. {
  1088. diId = groupData.Data;
  1089. //添加默认币种
  1090. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1091. //默认分配权限
  1092. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1093. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1094. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1095. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1096. if (userIds.Count > 0)
  1097. {
  1098. userIds.Add(208);
  1099. //创建团组管控
  1100. GroupStepForDelegation.CreateWorkStep(diId);
  1101. //发送消息
  1102. string groupName = dto.TeamName;
  1103. string createGroupUser = string.Empty;
  1104. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1105. if (userInfo != null) createGroupUser = userInfo.CnName;
  1106. string title = $"系统通知";
  1107. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1108. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1109. }
  1110. #region 应用推送
  1111. try
  1112. {
  1113. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1114. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1115. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1116. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1117. {
  1118. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1119. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1120. }
  1121. }
  1122. catch (Exception ex)
  1123. {
  1124. }
  1125. #endregion
  1126. //默认创建倒推表
  1127. await _invertedListRep._Create(dto.UserId, diId);
  1128. }
  1129. if (dto.Status == 2)
  1130. {
  1131. diId = dto.Id;
  1132. if (diId == 0)
  1133. {
  1134. //_sqlSugar.RollbackTran();
  1135. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1136. }
  1137. }
  1138. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1139. if (viewData.Code != 0)
  1140. {
  1141. //_sqlSugar.RollbackTran();
  1142. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1143. }
  1144. #region 团组操作默认添加/修改收款账单
  1145. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1146. {
  1147. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1148. .Where(x => x.IsDel == 0 &&
  1149. x.Diid == diId &&
  1150. x.Remark.Equals("预付款")
  1151. )
  1152. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1153. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1154. .FirstAsync();
  1155. ffrInfo = new Fin_ForeignReceivables()
  1156. {
  1157. Diid = diId,
  1158. PriceName = dto.ClientUnit,
  1159. Price = dto.PaymentMoney,
  1160. Count = 1,
  1161. Unit = $"元",
  1162. ItemSumPrice = dto.PaymentMoney,
  1163. Rate = 1.0000M,
  1164. Currency = 836,
  1165. AddingWay = 0,
  1166. CreateUserId = dto.UserId,
  1167. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1168. Remark = $"预付款"
  1169. };
  1170. if (ffrInfo == null) //Add
  1171. {
  1172. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1173. }
  1174. else //修改
  1175. {
  1176. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1177. .UpdateColumns(x => new
  1178. {
  1179. x.PriceName,
  1180. x.Price,
  1181. x.ItemSumPrice,
  1182. x.CreateTime,
  1183. x.CreateUserId
  1184. })
  1185. .WhereColumns(x => x.Id)
  1186. .ExecuteCommandAsync();
  1187. }
  1188. }
  1189. #endregion
  1190. #region 签证人员团组时间通知
  1191. #region 计算出访起止时间
  1192. var startTime = new DateTime();
  1193. var endTime = new DateTime();
  1194. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1195. {
  1196. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1197. }
  1198. #endregion
  1199. if (diId > 0)
  1200. {
  1201. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1202. }
  1203. #endregion
  1204. //_sqlSugar.CommitTran();
  1205. return Ok(JsonView(true, "添加成功"));
  1206. }
  1207. catch (Exception ex)
  1208. {
  1209. _sqlSugar.RollbackTran();
  1210. return Ok(JsonView(false, ex.Message));
  1211. }
  1212. }
  1213. /// <summary>
  1214. /// 接团流程操作(增改)
  1215. /// 安卓端使用 建团时添加客户名单
  1216. /// </summary>
  1217. /// <param name="dto"></param>
  1218. /// <returns></returns>
  1219. [HttpPost]
  1220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1221. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1222. {
  1223. #region 参数验证
  1224. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1225. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1226. #region 页面操作权限验证
  1227. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1228. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1229. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1230. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1231. #endregion
  1232. #endregion
  1233. _sqlSugar.BeginTran();
  1234. decimal ffrPrice = 0.00M;
  1235. DateTime? visitDt = null;
  1236. if (dto.Status == 2)
  1237. {
  1238. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1239. if (groupInfo != null)
  1240. {
  1241. ffrPrice = groupInfo.PaymentMoney;
  1242. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1243. }
  1244. }
  1245. var _dto = new GroupOperationDto();
  1246. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1247. var groupData = await _groupRepository.GroupOperation(_dto);
  1248. if (groupData.Code != 0)
  1249. {
  1250. _sqlSugar.RollbackTran();
  1251. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1252. }
  1253. try
  1254. {
  1255. int diId = 0;
  1256. //添加时 默认加入团组汇率
  1257. if (dto.Status == 1) //添加
  1258. {
  1259. diId = groupData.Data;
  1260. //添加默认币种
  1261. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1262. //默认分配权限
  1263. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1264. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1265. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1266. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1267. if (userIds.Count > 0)
  1268. {
  1269. userIds.Add(208);
  1270. //创建团组管控
  1271. GroupStepForDelegation.CreateWorkStep(diId);
  1272. //发送消息
  1273. string groupName = dto.TeamName;
  1274. string createGroupUser = string.Empty;
  1275. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1276. if (userInfo != null) createGroupUser = userInfo.CnName;
  1277. string title = $"系统通知";
  1278. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1279. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1280. }
  1281. #region 应用推送
  1282. try
  1283. {
  1284. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1285. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1286. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1287. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1288. {
  1289. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1290. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1291. }
  1292. }
  1293. catch (Exception ex)
  1294. {
  1295. _sqlSugar.CommitTran();
  1296. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1297. }
  1298. #endregion
  1299. //默认创建倒推表
  1300. await _invertedListRep._Create(dto.UserId, diId);
  1301. }
  1302. else if (dto.Status == 2)
  1303. {
  1304. diId = dto.Id;
  1305. if (diId == 0)
  1306. {
  1307. _sqlSugar.RollbackTran();
  1308. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1309. }
  1310. }
  1311. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1312. if (viewData.Code != 0)
  1313. {
  1314. _sqlSugar.RollbackTran();
  1315. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1316. }
  1317. #region 团组操作默认添加/修改收款账单
  1318. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1319. {
  1320. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1321. .Where(x => x.IsDel == 0 &&
  1322. x.Diid == diId &&
  1323. x.Remark.Equals("预付款")
  1324. )
  1325. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1326. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1327. .FirstAsync();
  1328. ffrInfo = new Fin_ForeignReceivables()
  1329. {
  1330. Diid = diId,
  1331. PriceName = dto.ClientUnit,
  1332. Price = dto.PaymentMoney,
  1333. Count = 1,
  1334. Unit = $"元",
  1335. ItemSumPrice = dto.PaymentMoney,
  1336. Rate = 1.0000M,
  1337. Currency = 836,
  1338. AddingWay = 0,
  1339. CreateUserId = dto.UserId,
  1340. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1341. Remark = $"预付款"
  1342. };
  1343. if (ffrInfo == null) //Add
  1344. {
  1345. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1346. }
  1347. else //修改
  1348. {
  1349. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1350. .UpdateColumns(x => new
  1351. {
  1352. x.PriceName,
  1353. x.Price,
  1354. x.ItemSumPrice,
  1355. x.CreateTime,
  1356. x.CreateUserId
  1357. })
  1358. .WhereColumns(x => x.Id)
  1359. .ExecuteCommandAsync();
  1360. }
  1361. }
  1362. #endregion
  1363. #region 签证人员团组时间通知
  1364. #region 计算出访起止时间
  1365. var startTime = new DateTime();
  1366. var endTime = new DateTime();
  1367. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1368. {
  1369. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1370. }
  1371. #endregion
  1372. if (diId > 0)
  1373. {
  1374. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1375. }
  1376. #endregion
  1377. _sqlSugar.CommitTran();
  1378. return Ok(JsonView(true));
  1379. }
  1380. catch (Exception ex)
  1381. {
  1382. _sqlSugar.RollbackTran();
  1383. return Ok(JsonView(false, ex.Message));
  1384. }
  1385. }
  1386. /// <summary>
  1387. /// 接团信息 操作(删除)
  1388. /// </summary>
  1389. /// <param name="dto"></param>
  1390. /// <returns></returns>
  1391. [HttpPost]
  1392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1393. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1394. {
  1395. var diId = dto.Id;
  1396. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1397. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1398. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1399. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1400. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1401. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1402. #endregion
  1403. var groupData = await _groupRepository.GroupDel(dto);
  1404. if (groupData.Code != 0)
  1405. {
  1406. return Ok(JsonView(false, groupData.Msg));
  1407. }
  1408. return Ok(JsonView(true));
  1409. }
  1410. /// <summary>
  1411. /// 获取团组销售报价号
  1412. /// 团组添加时 使用
  1413. /// </summary>
  1414. /// <returns></returns>
  1415. [HttpPost]
  1416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1417. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1418. {
  1419. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1420. if (groupData.Code != 0)
  1421. {
  1422. return Ok(JsonView(false, groupData.Msg));
  1423. }
  1424. object salesQuoteNo = new
  1425. {
  1426. SalesQuoteNo = groupData.Data
  1427. };
  1428. return Ok(JsonView(salesQuoteNo));
  1429. }
  1430. /// <summary>
  1431. /// 设置确认出团
  1432. /// </summary>
  1433. /// <param name="dto"></param>
  1434. /// <returns></returns>
  1435. [HttpPost]
  1436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1437. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1438. {
  1439. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1440. if (groupData.Code != 0)
  1441. {
  1442. return Ok(JsonView(false, groupData.Msg));
  1443. }
  1444. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1445. #region OA消息推送
  1446. try
  1447. {
  1448. string groupName = groupInfo.TeamName;
  1449. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1450. string title = $"系统通知";
  1451. string content = $"团组[{groupName}]已确认出团!";
  1452. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1453. }
  1454. catch (Exception ex)
  1455. {
  1456. }
  1457. #endregion
  1458. #region 应用推送
  1459. try
  1460. {
  1461. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1462. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1463. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1464. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1465. {
  1466. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1467. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1468. }
  1469. }
  1470. catch (Exception ex)
  1471. {
  1472. }
  1473. #endregion
  1474. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1475. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1476. }
  1477. /// <summary>
  1478. /// 获取团组名称data And 签证国别Data
  1479. /// </summary>
  1480. /// <param name="dto"></param>
  1481. /// <returns></returns>
  1482. [HttpPost]
  1483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1484. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1485. {
  1486. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1487. if (groupData.Code != 0)
  1488. {
  1489. return Ok(JsonView(false, groupData.Msg));
  1490. }
  1491. return Ok(JsonView(groupData.Data));
  1492. }
  1493. /// <summary>
  1494. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1495. /// </summary>
  1496. /// <returns></returns>
  1497. [HttpPost]
  1498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1499. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1500. {
  1501. try
  1502. {
  1503. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1504. if (groupData.Code != 0)
  1505. {
  1506. return Ok(JsonView(false, groupData.Msg));
  1507. }
  1508. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1509. }
  1510. catch (Exception ex)
  1511. {
  1512. return Ok(JsonView(false, "程序错误!"));
  1513. throw;
  1514. }
  1515. }
  1516. /// <summary>
  1517. /// 团组清单 Excel
  1518. /// </summary>
  1519. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1520. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1521. /// <returns></returns>
  1522. [HttpGet]
  1523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1524. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1525. {
  1526. DateTime _beginDt, _endDt;
  1527. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1528. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1529. if (!beginBool && !endBool)
  1530. {
  1531. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1532. }
  1533. string sql = string.Format(@"
  1534. SELECT
  1535. ROW_NUMBER,
  1536. Id,
  1537. SalesQuoteNo,
  1538. TourCode,
  1539. TeamTypeId,
  1540. TeamType,
  1541. TeamLevId,
  1542. TeamLev,
  1543. TeamName,
  1544. ClientName,
  1545. ClientUnit,
  1546. VisitDate,
  1547. VisitDays,
  1548. VisitPNumber,
  1549. JietuanOperatorId,
  1550. JietuanOperator,
  1551. IsSure,
  1552. CreateUserName,
  1553. IsBid
  1554. FROM
  1555. (
  1556. SELECT
  1557. ROW_NUMBER() OVER(
  1558. ORDER BY
  1559. gdi.CreateTime Desc
  1560. ) AS ROW_NUMBER,
  1561. gdi.Id,
  1562. SalesQuoteNo,
  1563. TourCode,
  1564. ssd.Id TeamTypeId,
  1565. ssd.Name TeamType,
  1566. ssd1.Id TeamLevId,
  1567. ssd1.Name TeamLev,
  1568. TeamName,
  1569. ClientName,
  1570. ClientUnit,
  1571. VisitDate,
  1572. VisitDays,
  1573. VisitPNumber,
  1574. JietuanOperator JietuanOperatorId,
  1575. su.CnName JietuanOperator,
  1576. IsSure,
  1577. gdi.CreateTime,
  1578. su1.CnName As CreateUserName,
  1579. gdi.IsBid
  1580. FROM
  1581. Grp_DelegationInfo gdi
  1582. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1583. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1584. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1585. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1586. WHERE
  1587. gdi.IsDel = 0
  1588. AND gdi.IsBid = 0
  1589. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1590. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1591. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1592. #region 处理所属部门
  1593. /*
  1594. * 1.sq 和 gyy 等显示 市场部
  1595. * 2.王鸽和主管及张总还有管理员号统一国交部
  1596. * 2-1. 4 管理员 ,21 张海麟
  1597. */
  1598. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1599. List<int> userIds1 = new List<int>() { 4, 21 };
  1600. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1601. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1602. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1603. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1604. .ToListAsync();
  1605. var droupIds = groupList.Select(it => it.Id).ToList();
  1606. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1607. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1608. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1609. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1610. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1611. {
  1612. DiId = tcl.DiId,
  1613. LastName = dc.LastName,
  1614. FirstName = dc.FirstName,
  1615. Sex = dc.Sex,
  1616. Birthday = dc.BirthDay,
  1617. Company = cc.CompanyFullName,
  1618. Job = dc.Job,
  1619. CreateTime = tcl.CreateTime,
  1620. })
  1621. .ToList();
  1622. foreach (var item in groupList)
  1623. {
  1624. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1625. string groupFirstName = "";
  1626. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1627. if (currDatas.Any())
  1628. {
  1629. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1630. }
  1631. item.GroupFirst = groupFirstName;
  1632. }
  1633. #endregion
  1634. #region Excel
  1635. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1636. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1637. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1638. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1639. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1640. //载入模板
  1641. WorkbookDesigner designer = new WorkbookDesigner();
  1642. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1643. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1644. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1645. dt.TableName = "GroupList";
  1646. designer.SetDataSource(dt);
  1647. designer.Process();
  1648. if (!Directory.Exists(savePath))
  1649. {
  1650. Directory.CreateDirectory(savePath);
  1651. }
  1652. string serverPath = $"{savePath}{fileName}";
  1653. designer.Workbook.Save(serverPath);
  1654. string rst = $"{servicePath}{ftpPath}{fileName}";
  1655. #endregion
  1656. return Ok(JsonView(true, "操作成功!", rst));
  1657. }
  1658. /// <summary>
  1659. /// 团组合同下载(1.付款80% 2.付全款)
  1660. /// </summary>
  1661. /// <param name="dto"></param>
  1662. /// <returns></returns>
  1663. /// <exception cref="Exception"></exception>
  1664. [HttpPost]
  1665. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1666. {
  1667. var jw = JsonView(false);
  1668. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1669. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1670. if (di == null)
  1671. {
  1672. jw.Msg = "团组Id有误!";
  1673. return Ok(jw);
  1674. }
  1675. #region 权限校验
  1676. var allDownFile = new List<int>() { 21 };
  1677. try
  1678. {
  1679. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1680. .First(x => x.Id == 1418 && x.IsDel == 0);
  1681. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1682. }
  1683. catch (Exception)
  1684. { }
  1685. var guojiaoDownFile = new List<int>() { 330 };
  1686. var shichangDownFile = new List<int>() { 95 };
  1687. if (allDownFile.Contains(dto.UserId))
  1688. {
  1689. }
  1690. else if (guojiaoDownFile.Contains(dto.UserId))
  1691. {
  1692. var guojiaobuDi = new List<int>() { 4, 21 };
  1693. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1694. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1695. .Where((d, u) => u.Id == di.JietuanOperator)
  1696. .Select((d, u) => d.DepName)
  1697. .First();
  1698. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1699. {
  1700. jw.Msg = "暂无下载权限!";
  1701. return Ok(jw);
  1702. }
  1703. }
  1704. else if (shichangDownFile.Contains(dto.UserId))
  1705. {
  1706. var dic = new Dictionary<int, int[]>()
  1707. {
  1708. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1709. };
  1710. try
  1711. {
  1712. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1713. if (sqSetting != null)
  1714. {
  1715. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1716. foreach (var item in result.Keys)
  1717. {
  1718. if (dic.Keys.Contains(item))
  1719. {
  1720. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1721. Array.Copy(dic[item], dilatation, dic[item].Length);
  1722. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1723. dic[item] = dilatation;
  1724. }
  1725. else
  1726. {
  1727. dic.Add(item, result[item]);
  1728. }
  1729. }
  1730. }
  1731. if (!dic[95].Contains(di.CreateUserId))
  1732. {
  1733. jw.Msg = "暂无下载权限!";
  1734. return Ok(jw);
  1735. }
  1736. }
  1737. catch (Exception)
  1738. { }
  1739. }
  1740. else if (dto.UserId == di.CreateUserId)
  1741. {
  1742. }
  1743. else
  1744. {
  1745. jw.Msg = "暂无下载权限!";
  1746. return Ok(jw);
  1747. }
  1748. #endregion
  1749. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1750. .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
  1751. .ToListAsync();
  1752. if (!blackCodeList.Any())
  1753. {
  1754. jw.Msg = "该团无机票行程代码!";
  1755. return Ok(jw);
  1756. }
  1757. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1758. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1759. if (groupEnterExitCost == null)
  1760. {
  1761. jw.Msg = "暂无三公费用信息!";
  1762. return Ok(jw);
  1763. }
  1764. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1765. rateList ??= new List<CurrencyInfo>();
  1766. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1767. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1768. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1769. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1770. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1771. .Select((x, a, b) => new
  1772. {
  1773. x.Index,
  1774. itemName = a.Name,
  1775. CurrencyStr = b.Name,
  1776. x.Cost,
  1777. x.SubTotal,
  1778. x.Remark
  1779. })
  1780. .OrderBy((x) => x.Index)
  1781. .ToList();
  1782. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1783. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1784. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1785. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1786. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1787. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1788. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1789. decimal subJJC = 0.00M,
  1790. subGWC = 0.00M,
  1791. subTDC = 0.00M;
  1792. //经济舱
  1793. if (groupEnterExitCost.SumJJC == 1)
  1794. {
  1795. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1796. }
  1797. //公务舱
  1798. if (groupEnterExitCost.SumGWC == 1)
  1799. {
  1800. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1801. }
  1802. //头等舱
  1803. if (groupEnterExitCost.SumTDC == 1)
  1804. {
  1805. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1806. }
  1807. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1808. .LeftJoin<Sys_SetData>((x,s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0 )
  1809. .Where((x, s) => x.DiId == dto.GroupId && x.IsDel == 0)
  1810. .Select((x, s) => new
  1811. {
  1812. x.Id,
  1813. s.Name,
  1814. })
  1815. .ToListAsync();
  1816. //获取舱位人数
  1817. var cabinCount = groupClints.GroupBy(x => x.Name)
  1818. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1819. .ToList();
  1820. string cityPath = string.Empty;
  1821. string startCity = string.Empty;
  1822. string endCity = string.Empty;
  1823. foreach (var item in blackCodeList)
  1824. {
  1825. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1826. cityPath += city + "\r\n";
  1827. if (item.Equals(blackCodeList.First()))
  1828. {
  1829. var sp = city.Split('-');
  1830. startCity = sp[0];
  1831. endCity = sp[sp.Length - 1];
  1832. }
  1833. }
  1834. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1835. bookMarkDic.Add("ClientUnit",di.ClientUnit);
  1836. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1837. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1838. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1839. bookMarkDic.Add("CityPath", cityPath);
  1840. bookMarkDic.Add("StartCity", startCity);
  1841. bookMarkDic.Add("EndCity", endCity);
  1842. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
  1843. Document doc = null;
  1844. var percentage = 0.8M;
  1845. var fileNameadd = "预付";
  1846. if (dto.FileType == 1)
  1847. {
  1848. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1849. }
  1850. else if (dto.FileType == 2)
  1851. {
  1852. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1853. percentage = 1;
  1854. fileNameadd = "全款";
  1855. }
  1856. else
  1857. {
  1858. throw new Exception("FileType有误!");
  1859. }
  1860. DocumentBuilder builder = new DocumentBuilder(doc);
  1861. decimal totalPrice = 0.00M;
  1862. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1863. if (firstTable != null)
  1864. {
  1865. // 遍历表格的行和单元格
  1866. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1867. {
  1868. for (int i = 0; i < row.Cells.Count; i++)
  1869. {
  1870. var cell = row.Cells[i];
  1871. // 读取单元格内容
  1872. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  1873. if (cellTextFirst.Contains("舱位"))
  1874. {
  1875. break;
  1876. }
  1877. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  1878. {
  1879. if (i == 2)
  1880. {
  1881. if (cellTextFirst == "经济舱")
  1882. {
  1883. // 设置单元格内容
  1884. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1885. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  1886. }
  1887. else
  1888. {
  1889. // 设置单元格内容
  1890. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1891. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  1892. }
  1893. }
  1894. if (i == 3)
  1895. {
  1896. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1897. if (count != null)
  1898. {
  1899. // 设置单元格内容
  1900. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1901. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  1902. }
  1903. }
  1904. if (i == 4)
  1905. {
  1906. var rowPrice = 0.00M;
  1907. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1908. count ??= 0;
  1909. if (cellTextFirst == "经济舱")
  1910. {
  1911. rowPrice = subJJC * (int)count;
  1912. }
  1913. else
  1914. {
  1915. rowPrice = subGWC * (int)count;
  1916. }
  1917. totalPrice += rowPrice;
  1918. // 设置单元格内容
  1919. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1920. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  1921. }
  1922. }
  1923. }
  1924. }
  1925. }
  1926. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  1927. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  1928. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  1929. //--合同表格部分
  1930. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  1931. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  1932. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  1933. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  1934. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日")+"-"+di.VisitEndDate.ToString("yyyy年MM月dd日"));
  1935. bookMarkDic.Add("CityPath1", cityPath);
  1936. bookMarkDic.Add("CityPath2", cityPath);
  1937. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  1938. if (contractTable != null)
  1939. {
  1940. //数据源
  1941. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  1942. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  1943. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  1944. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  1945. .Select((it, y, s) => new
  1946. {
  1947. it.Cost,
  1948. it.SubTotal,
  1949. it.Type,
  1950. y.Id,
  1951. y.City,
  1952. s.Name,
  1953. CurrencyCodeCn = s.Remark
  1954. })
  1955. .ToList()
  1956. .Select(x => new
  1957. {
  1958. CurrencyCode = x.Name,
  1959. CityId = x.Id,
  1960. x.City,
  1961. VisitPNumber = di.VisitPNumber,
  1962. x.Type,
  1963. x.Cost,
  1964. x.SubTotal,
  1965. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  1966. x.CurrencyCodeCn,
  1967. });
  1968. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  1969. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  1970. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  1971. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  1972. List<tableSetting> tableSettings = new List<tableSetting>()
  1973. {
  1974. new tableSetting{ Index = 1 , Property = "City"},
  1975. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  1976. new tableSetting{ Index = 3 , Property = "Cost"},
  1977. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  1978. //new tableSetting{ Index = 5 , Property = ""},
  1979. //new tableSetting{ Index = 6 , Property = ""},
  1980. new tableSetting{ Index = 7 , Property = "Rate"},
  1981. //new tableSetting{ Index = 8 , Property = ""},
  1982. };
  1983. //1.住宿费
  1984. int cloneRow = 8;
  1985. int startDayPrice = 8; //写入index
  1986. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  1987. foreach (var dac in dac1)
  1988. {
  1989. var first = dac.First();
  1990. var dayCount = dac.Count();
  1991. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  1992. for (int i = 1; i < row.Cells.Count; i++)
  1993. {
  1994. var cell = row.Cells[i];
  1995. var findProperty = tableSettings.Find(x => x.Index == i);
  1996. if (findProperty != null)
  1997. {
  1998. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  1999. // 设置单元格内容
  2000. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2001. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2002. }
  2003. else
  2004. {
  2005. switch (i)
  2006. {
  2007. case 5:
  2008. cell.FirstParagraph.Runs.Clear();
  2009. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2010. break;
  2011. case 6:
  2012. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2013. cell.FirstParagraph.Runs.Clear();
  2014. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2015. break;
  2016. case 8:
  2017. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2018. cell.FirstParagraph.Runs.Clear();
  2019. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2020. ZSPriceSum += xiaojiRMB;
  2021. break;
  2022. default:
  2023. break;
  2024. }
  2025. }
  2026. }
  2027. startDayPrice++;
  2028. if (!dac1.Last().Equals(dac))
  2029. {
  2030. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2031. // 将克隆的行追加到原行后面
  2032. contractTable.Rows.Insert(startDayPrice, newRow);
  2033. }
  2034. else
  2035. {
  2036. cloneRow += dac1.Count() + 1;
  2037. startDayPrice = cloneRow;
  2038. }
  2039. }
  2040. //2.伙食费
  2041. foreach (var dac in dac2)
  2042. {
  2043. var first = dac.First();
  2044. var dayCount = dac.Count();
  2045. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2046. for (int i = 1; i < row.Cells.Count; i++)
  2047. {
  2048. var cell = row.Cells[i];
  2049. var findProperty = tableSettings.Find(x => x.Index == i);
  2050. if (findProperty != null)
  2051. {
  2052. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2053. // 设置单元格内容
  2054. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2055. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2056. }
  2057. else
  2058. {
  2059. switch (i)
  2060. {
  2061. case 5:
  2062. cell.FirstParagraph.Runs.Clear();
  2063. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2064. break;
  2065. case 6:
  2066. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2067. cell.FirstParagraph.Runs.Clear();
  2068. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2069. break;
  2070. case 8:
  2071. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2072. cell.FirstParagraph.Runs.Clear();
  2073. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2074. HSPriceSum += xiaojiRMB;
  2075. break;
  2076. default:
  2077. break;
  2078. }
  2079. }
  2080. }
  2081. startDayPrice++;
  2082. if (!dac2.Last().Equals(dac))
  2083. {
  2084. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2085. // 将克隆的行追加到原行后面
  2086. contractTable.Rows.Insert(startDayPrice, newRow);
  2087. }
  2088. else
  2089. {
  2090. cloneRow += dac2.Count() + 1;
  2091. startDayPrice = cloneRow;
  2092. }
  2093. }
  2094. //3.公杂费
  2095. foreach (var dac in dac3)
  2096. {
  2097. var first = dac.First();
  2098. var dayCount = dac.Count();
  2099. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2100. for (int i = 1; i < row.Cells.Count; i++)
  2101. {
  2102. var cell = row.Cells[i];
  2103. var findProperty = tableSettings.Find(x => x.Index == i);
  2104. if (findProperty != null)
  2105. {
  2106. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2107. // 设置单元格内容
  2108. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2109. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2110. }
  2111. else
  2112. {
  2113. switch (i)
  2114. {
  2115. case 5:
  2116. cell.FirstParagraph.Runs.Clear();
  2117. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2118. break;
  2119. case 6:
  2120. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2121. cell.FirstParagraph.Runs.Clear();
  2122. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2123. break;
  2124. case 8:
  2125. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2126. cell.FirstParagraph.Runs.Clear();
  2127. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2128. GZPriceSum += xiaojiRMB;
  2129. break;
  2130. default:
  2131. break;
  2132. }
  2133. }
  2134. }
  2135. startDayPrice++;
  2136. if (!dac3.Last().Equals(dac))
  2137. {
  2138. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2139. // 将克隆的行追加到原行后面
  2140. contractTable.Rows.Insert(startDayPrice, newRow);
  2141. }
  2142. else
  2143. {
  2144. cloneRow += dac3.Count() + 1;
  2145. startDayPrice = cloneRow;
  2146. }
  2147. }
  2148. //合并单元格
  2149. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2150. {
  2151. var currentRow = contractTable.Rows[i];
  2152. var nextRow = contractTable.Rows[i + 1];
  2153. // 获取当前行和下一行的第一个单元格
  2154. Cell currentCell = currentRow.Cells[0];
  2155. Cell nextCell = nextRow.Cells[0];
  2156. // 检查单元格内容是否一致(去除尾部的换行符)
  2157. string currentText = currentCell.GetText().Trim();
  2158. string nextText = nextCell.GetText().Trim();
  2159. if (currentText == nextText)
  2160. {
  2161. // 如果当前单元格已经被合并,找到合并的起始单元格
  2162. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2163. {
  2164. // 找到合并的起始单元格
  2165. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2166. // 将下一行的单元格设置为合并的后续单元格
  2167. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2168. }
  2169. else
  2170. {
  2171. // 如果当前单元格是合并的起始单元格
  2172. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2173. // 将下一行的单元格设置为合并的后续单元格
  2174. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2175. }
  2176. }
  2177. else
  2178. {
  2179. // 如果内容不一致,重置当前单元格的合并属性
  2180. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2181. {
  2182. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2183. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2184. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2185. }
  2186. else
  2187. {
  2188. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2189. }
  2190. }
  2191. }
  2192. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2193. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2194. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2195. }
  2196. foreach (var bookmarkName in bookMarkDic.Keys)
  2197. {
  2198. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2199. if (bookmark != null)
  2200. {
  2201. if (bookmarkName == "ClientUnit")
  2202. {
  2203. // 移动到书签位置
  2204. builder.MoveTo(bookmark.BookmarkStart);
  2205. // 设置字体样式为下划线
  2206. builder.Font.Underline = Aspose.Words.Underline.Single;
  2207. // 插入书签值
  2208. builder.Write(bookMarkDic[bookmarkName]);
  2209. // 清除字体格式,避免影响后续文本
  2210. builder.Font.ClearFormatting();
  2211. }
  2212. else
  2213. {
  2214. builder.MoveToBookmark(bookmarkName);
  2215. builder.Write(bookMarkDic[bookmarkName]);
  2216. }
  2217. }
  2218. }
  2219. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2220. doc.Save(savePaht);
  2221. jw.Msg = "生成成功!";
  2222. jw.Code = 200;
  2223. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
  2224. return Ok(jw);
  2225. }
  2226. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2227. {
  2228. int index = rowIndex;
  2229. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2230. {
  2231. index--;
  2232. }
  2233. return index;
  2234. }
  2235. #endregion
  2236. #region 团组&签证
  2237. /// <summary>
  2238. /// 根据团组Id获取签证客户信息List
  2239. /// </summary>
  2240. /// <param name="dto">请求dto</param>
  2241. /// <returns></returns>
  2242. [HttpPost]
  2243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2244. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2245. {
  2246. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2247. if (groupData.Code != 0)
  2248. {
  2249. return Ok(JsonView(false, groupData.Msg));
  2250. }
  2251. return Ok(JsonView(groupData.Data));
  2252. }
  2253. /// <summary>
  2254. /// IOS获取团组签证拍照上传进度01(团组列表)
  2255. /// </summary>
  2256. /// <param name="dto">请求dto</param>
  2257. /// <returns></returns>
  2258. [HttpPost]
  2259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2260. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2261. {
  2262. if (dto == null)
  2263. {
  2264. return Ok(JsonView(false, "参数为空"));
  2265. }
  2266. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2267. return Ok(JsonView(visaList));
  2268. }
  2269. /// <summary>
  2270. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2271. /// </summary>
  2272. /// <returns></returns>
  2273. [HttpPost]
  2274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2275. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2276. {
  2277. if (dto == null)
  2278. {
  2279. return Ok(JsonView(false, "请求错误:"));
  2280. }
  2281. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2282. return Ok(JsonView(list));
  2283. }
  2284. /// <summary>
  2285. /// IOS获取团组签证拍照上传进度03(相册)
  2286. /// </summary>
  2287. /// <returns></returns>
  2288. [HttpPost]
  2289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2290. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2291. {
  2292. if (dto == null)
  2293. {
  2294. return Ok(JsonView(false, "请求错误:"));
  2295. }
  2296. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2297. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2298. list.ForEach(s => s.url = url);
  2299. return Ok(JsonView(list));
  2300. }
  2301. /// <summary>
  2302. /// IOS获取团组签证拍照上传进度04(图片上传)
  2303. /// </summary>
  2304. /// <param name="dto"></param>
  2305. /// <returns></returns>
  2306. [HttpPost]
  2307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2308. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2309. {
  2310. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2311. //if (!string.IsNullOrEmpty(result))
  2312. //{
  2313. //}
  2314. //else {
  2315. // return Ok(JsonView(false, "上传失败"));
  2316. //}
  2317. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2318. int sucNum = 0;
  2319. try
  2320. {
  2321. foreach (var item in dto.base64DataList)
  2322. {
  2323. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2324. string result = DecodeBase64ToImage(item, imageName);
  2325. if (!string.IsNullOrEmpty(result))
  2326. {
  2327. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2328. pic.CreateUserId = dto.CreateUserId;
  2329. pic.PicName = imageName;
  2330. pic.PicPath = result;
  2331. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2332. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2333. if (insertResult > 0)
  2334. {
  2335. sucNum++;
  2336. }
  2337. }
  2338. }
  2339. }
  2340. catch (Exception ex)
  2341. {
  2342. return Ok(JsonView(false, ex.Message));
  2343. }
  2344. string msg = string.Format(@"成功上传{0}张", sucNum);
  2345. return Ok(JsonView(true, msg));
  2346. }
  2347. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2348. {
  2349. string filename = "";//声明一个string类型的相对路径
  2350. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2351. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2352. try//会有异常抛出,try,catch一下
  2353. {
  2354. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2355. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2356. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2357. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2358. //文件名称
  2359. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2360. //上传的文件的路径
  2361. string filePath = "";
  2362. if (!Directory.Exists(fileDir))
  2363. {
  2364. Directory.CreateDirectory(fileDir);
  2365. }
  2366. //上传的文件的路径
  2367. filePath = fileDir + filename;
  2368. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2369. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2370. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2371. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2372. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2373. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2374. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2375. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2376. bitmap.Dispose();
  2377. }
  2378. catch (Exception e)
  2379. {
  2380. string massage = e.Message;
  2381. Logs("IOS图片上传Error:" + massage);
  2382. //filename = e.Message;
  2383. }
  2384. return filename;//返回相对路径
  2385. }
  2386. /// <summary>
  2387. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2388. /// </summary>
  2389. /// <param name="dto"></param>
  2390. /// <returns></returns>
  2391. [HttpPost]
  2392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2393. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2394. {
  2395. if (dto == null)
  2396. {
  2397. return Ok(JsonView(false, "请求错误:"));
  2398. }
  2399. string msg = "参数错误";
  2400. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2401. {
  2402. try
  2403. {
  2404. //_delegationVisaRep.BeginTran();
  2405. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2406. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2407. .Where(s => s.Id == dto.visaProgressCustomerId)
  2408. .ExecuteCommandAsync();
  2409. if (updCount > 0 && dto.publishCode == 1)
  2410. {
  2411. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2412. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2413. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2414. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2415. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2416. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2417. if (groupData == null)
  2418. {
  2419. _delegationVisaRep.RollbackTran();
  2420. }
  2421. string title = string.Format(@"[签证进度更新]");
  2422. string content = string.Format(@"测试文本");
  2423. bool rst = await _message.AddMsg(new MessageDto()
  2424. {
  2425. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2426. IssuerId = dto.publisher,
  2427. Title = title,
  2428. Content = content,
  2429. ReleaseTime = DateTime.Now,
  2430. UIdList = new List<int> {
  2431. 234
  2432. }
  2433. });
  2434. if (rst)
  2435. {
  2436. return Ok(JsonView(true, "发送通知成功"));
  2437. }
  2438. }
  2439. //_delegationVisaRep.CommitTran();
  2440. }
  2441. catch (Exception)
  2442. {
  2443. //_delegationVisaRep.RollbackTran();
  2444. }
  2445. }
  2446. return Ok(JsonView(true, msg));
  2447. }
  2448. #endregion
  2449. #region 团组任务分配
  2450. /// <summary>
  2451. /// 团组任务分配初始化
  2452. /// </summary>
  2453. /// <returns></returns>
  2454. [HttpPost]
  2455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2456. public async Task<IActionResult> GetTaskAssignmen()
  2457. {
  2458. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2459. if (groupData.Code != 0)
  2460. {
  2461. return Ok(JsonView(false, groupData.Msg));
  2462. }
  2463. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2464. }
  2465. /// <summary>
  2466. /// 团组任务分配查询
  2467. /// </summary>
  2468. /// <param name="dto"></param>
  2469. /// <returns></returns>
  2470. [HttpPost]
  2471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2472. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2473. {
  2474. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2475. if (groupData.Code != 0)
  2476. {
  2477. return Ok(JsonView(false, groupData.Msg));
  2478. }
  2479. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2480. }
  2481. /// <summary>
  2482. /// 团组任务分配操作
  2483. /// </summary>
  2484. /// <param name="dto"></param>
  2485. /// <returns></returns>
  2486. [HttpPost]
  2487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2488. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2489. {
  2490. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2491. if (groupData.Code != 0)
  2492. {
  2493. return Ok(JsonView(false, groupData.Msg));
  2494. }
  2495. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2496. }
  2497. /// <summary>
  2498. /// 团组任务分配
  2499. /// 批量分配
  2500. /// 查询团组
  2501. /// </summary>
  2502. /// <param name="dto"></param>
  2503. /// <returns></returns>
  2504. [HttpPost]
  2505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2506. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2507. {
  2508. //参数验证
  2509. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2510. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2511. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2512. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2513. }
  2514. /// <summary>
  2515. /// 团组任务分配
  2516. /// 批量分配
  2517. /// </summary>
  2518. /// <param name="dto"></param>
  2519. /// <returns></returns>
  2520. [HttpPost]
  2521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2522. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2523. {
  2524. //参数验证
  2525. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2526. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2527. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2528. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2529. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2530. }
  2531. #endregion
  2532. #region 团组费用审核
  2533. /// <summary>
  2534. /// 费用审核
  2535. /// 团组列表 Page
  2536. /// </summary>
  2537. /// <param name="_dto">团组列表请求dto</param>
  2538. /// <returns></returns>
  2539. [HttpPost]
  2540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2541. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2542. {
  2543. #region 参数验证
  2544. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2545. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2546. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2547. #region 页面操作权限验证
  2548. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2549. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2550. #endregion
  2551. #endregion
  2552. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2553. {
  2554. string sqlWhere = string.Empty;
  2555. if (_dto.IsSure == 0) //未完成
  2556. {
  2557. sqlWhere += string.Format(@" And IsSure = 0");
  2558. }
  2559. else if (_dto.IsSure == 1) //已完成
  2560. {
  2561. sqlWhere += string.Format(@" And IsSure = 1");
  2562. }
  2563. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2564. {
  2565. string tj = _dto.SearchCriteria;
  2566. 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}%')",
  2567. tj, tj, tj, tj, tj);
  2568. }
  2569. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2570. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2571. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2572. From (
  2573. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2574. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2575. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2576. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2577. From Grp_DelegationInfo gdi
  2578. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2579. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2580. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2581. Where gdi.IsDel = 0 {0}
  2582. ) temp ", sqlWhere);
  2583. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2584. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2585. var _view = new
  2586. {
  2587. PageFuncAuth = pageFunAuthView,
  2588. Data = _DelegationList
  2589. };
  2590. return Ok(JsonView(true, "查询成功!", _view, total));
  2591. }
  2592. else
  2593. {
  2594. return Ok(JsonView(false, "查询失败"));
  2595. }
  2596. }
  2597. /// <summary>
  2598. /// 获取团组费用审核
  2599. /// </summary>
  2600. /// <param name="_dto"></param>
  2601. /// <returns></returns>
  2602. [HttpPost]
  2603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2604. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2605. {
  2606. try
  2607. {
  2608. #region 参数验证
  2609. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2610. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2611. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2612. #region 页面操作权限验证
  2613. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2614. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2615. #endregion
  2616. #endregion
  2617. var _view = new Grp_CreditCardPaymentView();
  2618. var clientNameList = getSimplClientList(_dto.DiId);
  2619. #region 费用清单
  2620. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2621. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2622. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2623. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2624. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2625. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2626. /*
  2627. * 76://酒店预订
  2628. */
  2629. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2630. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2631. /*
  2632. * 79://车/导游地接
  2633. */
  2634. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2635. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2636. /*
  2637. * 80: //签证
  2638. */
  2639. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2640. /*
  2641. *81: //邀请/公务活动
  2642. */
  2643. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2644. /*
  2645. * 82: //团组客户保险
  2646. */
  2647. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2648. /*
  2649. * Lable = 85 机票预订
  2650. */
  2651. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2652. /*
  2653. * 85 机票预定
  2654. */
  2655. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2656. /*
  2657. * 98 其他款项
  2658. */
  2659. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2660. /*
  2661. * 285:收款退还
  2662. */
  2663. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2664. /*
  2665. * 1015: //超支费用
  2666. */
  2667. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2668. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2669. /*
  2670. * 币种信息
  2671. */
  2672. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2673. /*
  2674. * 车/导游地接 费用类型
  2675. */
  2676. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2677. /*
  2678. * 车/导游地接 费用类型
  2679. */
  2680. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2681. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2682. /*
  2683. * 用户信息
  2684. */
  2685. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2686. /*
  2687. * 费用模块
  2688. */
  2689. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2690. string priceModule = string.Empty;
  2691. if (sdPriceName != null)
  2692. {
  2693. priceModule = sdPriceName.Name;
  2694. }
  2695. /*
  2696. * 成本信息
  2697. */
  2698. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2699. decimal _groupRate = 0.0000M;
  2700. string _groupCurrencyCode = "-";
  2701. if (groupCost != null)
  2702. {
  2703. _groupRate = groupCost.Rate;
  2704. if (int.TryParse(groupCost.Currency, out int _currency))
  2705. {
  2706. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2707. }
  2708. else _groupCurrencyCode = groupCost.Currency;
  2709. }
  2710. string costContentSql = $"Select * From Grp_GroupCost";
  2711. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2712. //处理日期为空的天数
  2713. for (int i = 0; i < groupCostDetails.Count; i++)
  2714. if (i != 0)
  2715. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2716. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2717. /*
  2718. * 处理详情数据
  2719. */
  2720. foreach (var entity in entityList)
  2721. {
  2722. var _detail = new Grp_CreditCardPaymentDetailView();
  2723. _detail.Id = entity.Id;
  2724. _detail.PriceName = priceModule;
  2725. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2726. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2727. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2728. //处理金额
  2729. if (entity.CTable == 1015)
  2730. {
  2731. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2732. if (czInfo != null)
  2733. {
  2734. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2735. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2736. }
  2737. }
  2738. /*
  2739. * 应付款金额
  2740. */
  2741. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2742. string PaymentCurrency_WaitPay = "Unknown";
  2743. string hotelCurrncyCode = "Unknown";
  2744. string hotelCurrncyName = "Unknown";
  2745. if (sdPaymentCurrency_WaitPay != null)
  2746. {
  2747. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2748. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2749. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2750. if (hotelCurrncyCode.Equals("CNY"))
  2751. {
  2752. entity.DayRate = 1.0000M;
  2753. }
  2754. }
  2755. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2756. /*
  2757. * 此次付款金额
  2758. */
  2759. decimal CurrPayStr = 0.00M,
  2760. OriginalCurrPay = 0.00M;
  2761. if (entity.PayPercentage == 0)
  2762. {
  2763. if (entity.PayThenMoney != 0)
  2764. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2765. }
  2766. else
  2767. {
  2768. if (entity.PayMoney != 0)
  2769. {
  2770. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2771. }
  2772. }
  2773. //if (_dto.Label == 79)
  2774. //{
  2775. // string original = string.Empty;
  2776. // if (hotelCurrncyCode.Equals("CNY"))
  2777. // {
  2778. // OriginalCurrPay = CurrPayStr;
  2779. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2780. // }
  2781. // else
  2782. // {
  2783. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2784. // //760 EUR(7600.00 CNY)
  2785. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2786. // }
  2787. //}
  2788. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2789. string original = string.Empty;
  2790. if (hotelCurrncyCode.Equals("CNY"))
  2791. {
  2792. OriginalCurrPay = CurrPayStr;
  2793. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2794. }
  2795. else
  2796. {
  2797. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2798. //760 EUR(7600.00 CNY)
  2799. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2800. }
  2801. /*
  2802. * 剩余尾款
  2803. */
  2804. decimal BalanceStr = 0;
  2805. if (CurrPayStr != 0)
  2806. {
  2807. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2808. BalanceStr = 0;
  2809. else
  2810. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2811. }
  2812. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2813. /*
  2814. * Bus名称
  2815. */
  2816. _detail.BusName = "待增加";
  2817. /*
  2818. *费用所属
  2819. */
  2820. switch (entity.CTable)
  2821. {
  2822. case 76://酒店预订
  2823. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2824. if (hotelReservations != null)
  2825. {
  2826. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2827. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2828. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2829. string roomFeeStr = "", roomFeestr1 = "";
  2830. //是否比较房型价格
  2831. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2832. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2833. roomFeeStr += $"<br/>";
  2834. var roomTotal = 0.00M;
  2835. if (hotelReservations.SingleRoomPrice > 0)
  2836. {
  2837. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2838. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2839. //__isSingle = true;
  2840. roomTotal += fee;
  2841. }
  2842. if (hotelReservations.DoubleRoomPrice > 0)
  2843. {
  2844. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2845. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2846. // __isDouble = true;
  2847. roomTotal += fee;
  2848. }
  2849. if (hotelReservations.SuiteRoomPrice > 0)
  2850. {
  2851. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2852. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2853. //__isSuite = true;
  2854. roomTotal += fee;
  2855. }
  2856. if (hotelReservations.OtherRoomPrice > 0)
  2857. {
  2858. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2859. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2860. //__isOther = true;
  2861. roomTotal += fee;
  2862. }
  2863. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2864. else roomFeeStr += " 0.00 * 0";
  2865. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2866. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2867. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2868. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2869. /*
  2870. * 费用类型
  2871. * 1:房费
  2872. * 2:早餐
  2873. * 3:地税
  2874. * 4:城市税
  2875. * </summary>
  2876. */
  2877. //地税
  2878. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2879. if (governmentRentData != null)
  2880. {
  2881. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2882. governmentRentFee = governmentRentData.Price;
  2883. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2884. if (governmentRentCurrData != null)
  2885. {
  2886. governmentRentCode = governmentRentCurrData.Name;
  2887. governmentRentName = $"({governmentRentCurrData.Remark})";
  2888. }
  2889. }
  2890. //城市税
  2891. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2892. if (cityTaxData != null)
  2893. {
  2894. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2895. cityTaxFee = cityTaxData.Price;
  2896. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2897. if (cityTaxCurrData != null)
  2898. {
  2899. cityTaxCode = cityTaxCurrData.Name;
  2900. cityTaxName = $"({cityTaxCurrData.Remark})";
  2901. }
  2902. }
  2903. //酒店早餐
  2904. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2905. if (breakfastData != null)
  2906. {
  2907. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2908. breakfastFee = breakfastData.Price;
  2909. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2910. if (breakfastCurrData != null)
  2911. {
  2912. breakfastCode = breakfastCurrData.Name;
  2913. breakfastName = $"({breakfastCurrData.Remark})";
  2914. }
  2915. }
  2916. //房间费用
  2917. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2918. if (roomData != null)
  2919. {
  2920. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2921. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2922. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2923. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2924. roomFee = roomData.Price;
  2925. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2926. if (roomCurrData != null)
  2927. {
  2928. roomCode = roomCurrData.Name;
  2929. roomName = $"({roomCurrData.Remark})";
  2930. }
  2931. }
  2932. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2933. string hotelCostStr = "";
  2934. decimal hotelCsotTotal = 0.00M;
  2935. if (groupCost != null)
  2936. {
  2937. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2938. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2939. }
  2940. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2941. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2942. string hotelCost_day = "";
  2943. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2944. foreach (var item in hotelCostDetails1)
  2945. {
  2946. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2947. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2948. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2949. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2950. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2951. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2952. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2953. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2954. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2955. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2956. hotelCost_day += @$"<br/>";
  2957. }
  2958. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2959. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2960. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2961. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2962. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2963. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2964. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2965. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2966. $"房间说明: {hotelReservations.Remark} <br/>" +
  2967. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2968. $"{hotelBreakfastStr}" +
  2969. $"{hotelGovernmentRentStr}" +
  2970. $"{hotelCityTaxStr}";
  2971. _detail.PriceNameContent = hotelReservations.HotelName;
  2972. }
  2973. break;
  2974. case 79://车/导游地接
  2975. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2976. if (touristGuideGroundReservations != null)
  2977. {
  2978. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2979. {
  2980. _detail.BusName = touristGuideGroundReservations.BusName;
  2981. }
  2982. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2983. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2984. //if (isInt)
  2985. //{
  2986. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2987. // if (cityInfo != null)
  2988. // {
  2989. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2990. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2991. // if (carFeeItem != null)
  2992. // {
  2993. // nameContent += $@"({carFeeItem.Name})";
  2994. // }
  2995. // _detail.PriceNameContent = nameContent;
  2996. // }
  2997. //}
  2998. //else
  2999. //{
  3000. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3001. //}
  3002. var touristGuideGroundReservationsContents =
  3003. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3004. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3005. foreach (var item in touristGuideGroundReservationsContents)
  3006. {
  3007. string typeName = "Unknown";
  3008. string carCurrencyCode = "Unknown";
  3009. string carCurrencyName = "Unknown";
  3010. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3011. if (carTypeData != null) typeName = carTypeData.Name;
  3012. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3013. if (currencyData != null)
  3014. {
  3015. carCurrencyCode = currencyData.Name;
  3016. carCurrencyName = currencyData.Remark;
  3017. }
  3018. //op、成本 币种是否一致
  3019. bool IsCurrencyAgreement = false;
  3020. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3021. string opCostStr = string.Empty;
  3022. decimal opCostTypePrice = 0.00M;
  3023. #region 处理成本各项费用
  3024. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3025. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3026. if (opCost.Count > 0)
  3027. {
  3028. switch (item.SId)
  3029. {
  3030. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3031. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3032. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3033. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3034. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3035. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3036. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3037. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3038. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3039. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3040. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3041. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3042. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3043. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3044. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3045. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3046. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3047. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3048. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3049. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3050. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3051. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3052. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3053. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3054. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3055. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3056. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3057. }
  3058. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  3059. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  3060. }
  3061. #endregion
  3062. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  3063. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  3064. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3065. $"{opTypeStr} {opCostStr}<br/>" +
  3066. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3067. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3068. }
  3069. _detail.PriceMsgContent = priceMsg;
  3070. }
  3071. break;
  3072. case 80: //签证
  3073. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3074. if (visaInfo != null)
  3075. {
  3076. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3077. _detail.PriceNameContent = visaInfo.VisaDescription;
  3078. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3079. }
  3080. break;
  3081. case 81: //邀请/公务活动
  3082. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3083. if (_ioa != null)
  3084. {
  3085. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3086. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3087. sendCurrName = "Unknown", //快递费用币种 Name
  3088. sendCurrCode = "Unknown", //快递费用币种 Code
  3089. eventsCurrName = "Unknown", //公务活动费币种 Name
  3090. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3091. translateCurrName = "Unknown", //公务翻译费 Name
  3092. translateCurrCode = "Unknown"; //公务翻译费 Code
  3093. #region 处理费用币种
  3094. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3095. if (inviteCurrData != null)
  3096. {
  3097. inviteCurrName = inviteCurrData.Remark;
  3098. inviteCurrCode = inviteCurrData.Name;
  3099. }
  3100. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3101. if (sendCurrData != null)
  3102. {
  3103. sendCurrName = sendCurrData.Remark;
  3104. sendCurrCode = sendCurrData.Name;
  3105. }
  3106. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3107. if (eventsCurrData != null)
  3108. {
  3109. eventsCurrName = eventsCurrData.Remark;
  3110. eventsCurrCode = eventsCurrData.Name;
  3111. }
  3112. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3113. if (translateCurrData != null)
  3114. {
  3115. translateCurrName = translateCurrData.Remark;
  3116. translateCurrCode = translateCurrData.Name;
  3117. }
  3118. #endregion
  3119. _detail.PriceNameContent = _ioa.InviterArea;
  3120. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3121. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3122. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3123. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3124. $@"备注:" + _ioa.Remark + "<br/>";
  3125. }
  3126. break;
  3127. case 82: //团组客户保险
  3128. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3129. if (customers != null)
  3130. {
  3131. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3132. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3133. }
  3134. break;
  3135. case 85: //机票预订
  3136. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3137. if (jpRes != null)
  3138. {
  3139. string FlightsDescription = jpRes.FlightsDescription;
  3140. string PriceDescription = jpRes.PriceDescription;
  3141. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3142. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3143. }
  3144. break;
  3145. case 98://其他款项
  3146. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3147. if (gdpRes != null)
  3148. {
  3149. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3150. _detail.PriceNameContent = gdpRes.PriceName;
  3151. }
  3152. break;
  3153. case 285://收款退还
  3154. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3155. if (refundAndOtherMoney != null)
  3156. {
  3157. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3158. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3159. }
  3160. break;
  3161. case 751://酒店早餐
  3162. break;
  3163. case 1015://超支费用
  3164. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3165. if (groupExtraCost != null)
  3166. {
  3167. _detail.PriceNameContent = groupExtraCost.PriceName;
  3168. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3169. }
  3170. break;
  3171. default:
  3172. break;
  3173. }
  3174. /*
  3175. * 申请人
  3176. */
  3177. string operatorName = " - ";
  3178. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3179. if (_opUser != null)
  3180. {
  3181. operatorName = _opUser.CnName;
  3182. }
  3183. _detail.OperatorName = operatorName;
  3184. /*
  3185. * 审核人
  3186. */
  3187. string auditOperatorName = "Unknown";
  3188. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3189. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3190. else
  3191. {
  3192. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3193. if (_adUser != null)
  3194. {
  3195. auditOperatorName = _adUser.CnName;
  3196. }
  3197. }
  3198. _detail.AuditOperatorName = auditOperatorName;
  3199. /*
  3200. * 超预算比例
  3201. */
  3202. string overBudgetStr = "";
  3203. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3204. else if (entity.ExceedBudget == 0)
  3205. {
  3206. if (entity.CTable == 76 || entity.CTable == 79)
  3207. {
  3208. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3209. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3210. }
  3211. else
  3212. {
  3213. overBudgetStr = "未超预算";
  3214. }
  3215. }
  3216. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3217. _detail.OverBudget = overBudgetStr;
  3218. decimal auditFee = 0.00M; //已审核金额 人名币
  3219. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3220. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3221. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3222. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3223. {
  3224. auditedFeeOriginal = entity.PayMoney;
  3225. auditFee = CurrPayStr;
  3226. }
  3227. else if (entity.IsAuditGM == 0)
  3228. {
  3229. unAuditFeeCNY = CurrPayStr;
  3230. unAuditFeeOriginal = OriginalCurrPay;
  3231. OriginalCurrPay = 0.00M;
  3232. }
  3233. /*
  3234. * 费用总计
  3235. */
  3236. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3237. {
  3238. CurrencyId = entity.PaymentCurrency,
  3239. CurrencyName = PaymentCurrency_WaitPay,
  3240. AmountPayable = entity.PayMoney,
  3241. ThisPayment = OriginalCurrPay,
  3242. BalancePayment = BalanceStr,
  3243. AuditedFunds = auditFee,
  3244. AuditedFundsOriginal = auditedFeeOriginal,
  3245. UnAuditFundsCNY = unAuditFeeCNY,
  3246. UnAuditFundsOriginal = unAuditFeeOriginal
  3247. });
  3248. _detail.IsAuditGM = entity.IsAuditGM;
  3249. detailList.Add(_detail);
  3250. }
  3251. #endregion
  3252. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3253. /*
  3254. * 下方描述处理
  3255. */
  3256. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3257. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3258. if (ccpCurrencyPrice != null)
  3259. {
  3260. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3261. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3262. }
  3263. else
  3264. {
  3265. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3266. }
  3267. string amountPayableStr = string.Format(@"应付款总金额: ");
  3268. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3269. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3270. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3271. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3272. foreach (var item in nonDuplicat)
  3273. {
  3274. var currencyName = item.CurrencyName;
  3275. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3276. if (strs.Count > 0)
  3277. {
  3278. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3279. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3280. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3281. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3282. //单独处理此次付款金额
  3283. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3284. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3285. //单独处理已审核费用
  3286. //if (item.CurrencyId == 836) //人民币
  3287. //{
  3288. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3289. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3290. //}
  3291. //else
  3292. //{
  3293. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3294. //}
  3295. if (currencyName.Equals("CNY"))
  3296. {
  3297. //已审核费用
  3298. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3299. //未审核费用
  3300. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3301. }
  3302. else
  3303. {
  3304. //已审核费用
  3305. 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"));
  3306. //未审核费用
  3307. 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"));
  3308. }
  3309. }
  3310. }
  3311. _view.TotalStr1 = amountPayableStr[..^1];
  3312. _view.TotalStr2 = thisPaymentStr[..^1];
  3313. _view.TotalStr3 = balancePaymentStr[..^1];
  3314. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3315. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3316. var _view1 = new
  3317. {
  3318. PageFuncAuth = pageFunAuthView,
  3319. Data = _view
  3320. };
  3321. return Ok(JsonView(_view1));
  3322. }
  3323. catch (Exception ex)
  3324. {
  3325. return Ok(JsonView(false, ex.Message));
  3326. }
  3327. }
  3328. /// <summary>
  3329. /// 费用审核
  3330. /// 修改团组费用审核状态
  3331. /// </summary>
  3332. /// <param name="_dto">参数Json字符串</param>
  3333. /// <returns></returns>
  3334. [HttpPost]
  3335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3336. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3337. {
  3338. #region 参数验证
  3339. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3340. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3341. #endregion
  3342. #region 页面操作权限验证
  3343. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3344. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3345. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3346. #endregion
  3347. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3348. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3349. DateTime dtNow = DateTime.Now;
  3350. _groupRepository.BeginTran();
  3351. int rst = 0;
  3352. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3353. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3354. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3355. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3356. List<dynamic> msgDatas = new List<dynamic>();
  3357. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3358. foreach (var item in idList)
  3359. {
  3360. int CreditId = int.Parse(item);
  3361. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3362. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3363. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3364. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3365. .Where(s => s.Id == CreditId)
  3366. .ExecuteCommandAsync();
  3367. if (result < 1)
  3368. {
  3369. rst = -1;
  3370. _groupRepository.RollbackTran();
  3371. return Ok(JsonView(false, "操作失败并回滚!"));
  3372. }
  3373. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3374. if (creditData != null)
  3375. {
  3376. #region 应用通知配置
  3377. try
  3378. {
  3379. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3380. }
  3381. catch (Exception ex)
  3382. {
  3383. }
  3384. #endregion
  3385. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3386. string groupNameStr = string.Empty;
  3387. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3388. if (groupData != null) groupNameStr = groupData.TeamName;
  3389. string creditTypeStr = string.Empty;
  3390. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3391. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3392. string creditCurrency = string.Empty;
  3393. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3394. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3395. if (creditCurrency.Equals("CNY"))
  3396. {
  3397. creditData.DayRate = 1.0000M;
  3398. }
  3399. if (creditData.PayPercentage == 0.00M)
  3400. {
  3401. creditData.PayPercentage = 100M;
  3402. }
  3403. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3404. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3405. string msgContent = "";
  3406. if (creditCurrency.Equals("CNY"))
  3407. {
  3408. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3409. }
  3410. else
  3411. {
  3412. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3413. }
  3414. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3415. }
  3416. }
  3417. if (rst == 0)
  3418. {
  3419. _groupRepository.CommitTran();
  3420. foreach (var item in msgDatas)
  3421. {
  3422. //发送消息
  3423. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3424. }
  3425. #region 应用推送
  3426. try
  3427. {
  3428. foreach (var ccpId in dic_ccp_user.Keys)
  3429. {
  3430. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3431. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3432. }
  3433. }
  3434. catch (Exception)
  3435. {
  3436. }
  3437. #endregion
  3438. return Ok(JsonView(true, "操作成功!"));
  3439. }
  3440. return Ok(JsonView(false, "操作失败!"));
  3441. }
  3442. #endregion
  3443. #region 机票费用录入
  3444. /// <summary>
  3445. /// 机票录入当前登录人可操作团组
  3446. /// </summary>
  3447. /// <param name="dto"></param>
  3448. /// <returns></returns>
  3449. [HttpPost]
  3450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3451. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3452. {
  3453. try
  3454. {
  3455. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3456. if (groupData.Code != 0)
  3457. {
  3458. return Ok(JsonView(false, groupData.Msg));
  3459. }
  3460. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3461. }
  3462. catch (Exception ex)
  3463. {
  3464. return Ok(JsonView(false, "程序错误!"));
  3465. throw;
  3466. }
  3467. }
  3468. /// <summary>
  3469. /// 机票费用录入列表
  3470. /// </summary>
  3471. /// <param name="dto"></param>
  3472. /// <returns></returns>
  3473. [HttpPost]
  3474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3475. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3476. {
  3477. try
  3478. {
  3479. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3480. if (groupData.Code != 0)
  3481. {
  3482. return Ok(JsonView(false, groupData.Msg));
  3483. }
  3484. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3485. }
  3486. catch (Exception ex)
  3487. {
  3488. return Ok(JsonView(false, ex.Message));
  3489. throw;
  3490. }
  3491. }
  3492. /// <summary>
  3493. /// 根据id查询费用录入信息
  3494. /// </summary>
  3495. /// <param name="dto"></param>
  3496. /// <returns></returns>
  3497. [HttpPost]
  3498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3499. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3500. {
  3501. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3502. if (groupData.Code != 0)
  3503. {
  3504. return Ok(JsonView(false, groupData.Msg));
  3505. }
  3506. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3507. }
  3508. /// <summary>
  3509. /// 机票费用录入操作(Status:1.新增,2.修改)
  3510. /// </summary>
  3511. /// <param name="dto"></param>
  3512. /// <returns></returns>
  3513. [HttpPost]
  3514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3515. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3516. {
  3517. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3518. if (groupData.Code != 0)
  3519. {
  3520. return Ok(JsonView(false, groupData.Msg));
  3521. }
  3522. #region 应用推送
  3523. try
  3524. {
  3525. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3526. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3527. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3528. //2024-10-21 新增LZ UID
  3529. var userIds = new List<int>() { 21 };
  3530. string title = $"系统通知";
  3531. string content = "";
  3532. var diId = dto.AirTicketResOpData.DiId;
  3533. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3534. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3535. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3536. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3537. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3538. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3539. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3540. }
  3541. catch (Exception ex)
  3542. {
  3543. }
  3544. #endregion
  3545. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3546. }
  3547. /// <summary>
  3548. /// 根据舱位类型查询接团客户名单信息
  3549. /// </summary>
  3550. /// <param name="dto"></param>
  3551. /// <returns></returns>
  3552. [HttpPost]
  3553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3554. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3555. {
  3556. try
  3557. {
  3558. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3559. if (crm_Groups.Count != 0)
  3560. {
  3561. List<dynamic> Customer = new List<dynamic>();
  3562. foreach (var item in crm_Groups)
  3563. {
  3564. var data = new
  3565. {
  3566. Id = item.Id,
  3567. Pinyin = item.Pinyin,
  3568. Name = item.LastName + item.FirstName
  3569. };
  3570. Customer.Add(data);
  3571. }
  3572. return Ok(JsonView(true, "查询成功!", Customer));
  3573. }
  3574. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3575. }
  3576. catch (Exception ex)
  3577. {
  3578. return Ok(JsonView(false, "程序错误!"));
  3579. throw;
  3580. }
  3581. }
  3582. /// <summary>
  3583. /// 根据团号获取客户信息
  3584. /// </summary>
  3585. /// <param name="dto"></param>
  3586. /// <returns></returns>
  3587. [HttpPost]
  3588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3589. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3590. {
  3591. var jw = JsonView(false);
  3592. if (dto.DIID < 1)
  3593. {
  3594. jw.Msg += "请输入正确的diid";
  3595. return Ok(jw);
  3596. }
  3597. var arr = getSimplClientList(dto.DIID);
  3598. jw = JsonView(true, "获取成功!", arr);
  3599. return Ok(jw);
  3600. }
  3601. private List<SimplClientInfo> getSimplClientList(int diId)
  3602. {
  3603. 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);
  3604. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3605. foreach (var item in arr)
  3606. {
  3607. EncryptionProcessor.DecryptProperties(item);
  3608. }
  3609. return arr;
  3610. }
  3611. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3612. {
  3613. string result = origin;
  3614. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3615. {
  3616. string[] temparr = origin.Split(',');
  3617. string fistrStr = temparr[0];
  3618. int count = temparr.Count();
  3619. int tempId;
  3620. bool success = int.TryParse(fistrStr, out tempId);
  3621. if (success)
  3622. {
  3623. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3624. if (tempInfo != null)
  3625. {
  3626. if (count > 1)
  3627. {
  3628. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3629. }
  3630. else
  3631. {
  3632. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3633. }
  3634. }
  3635. }
  3636. }
  3637. return result;
  3638. }
  3639. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3640. {
  3641. string result = origin;
  3642. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3643. {
  3644. string[] temparr = origin.Split(',');
  3645. result = "";
  3646. foreach (var item in temparr)
  3647. {
  3648. int tempId;
  3649. bool success = int.TryParse(item, out tempId);
  3650. if (success)
  3651. {
  3652. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3653. if (tempInfo != null)
  3654. {
  3655. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3656. }
  3657. }
  3658. }
  3659. }
  3660. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3661. return result;
  3662. }
  3663. /// <summary>
  3664. /// 机票费用录入,删除
  3665. /// </summary>
  3666. /// <param name="dto"></param>
  3667. /// <returns></returns>
  3668. [HttpPost]
  3669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3670. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3671. {
  3672. try
  3673. {
  3674. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3675. if (res)
  3676. {
  3677. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3678. {
  3679. IsDel = 1,
  3680. DeleteUserId = dto.DeleteUserId,
  3681. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3682. }).ExecuteCommandAsync();
  3683. return Ok(JsonView(true, "删除成功!"));
  3684. }
  3685. return Ok(JsonView(false, "删除失败!"));
  3686. }
  3687. catch (Exception ex)
  3688. {
  3689. return Ok(JsonView(false, "程序错误!"));
  3690. throw;
  3691. }
  3692. }
  3693. /// <summary>
  3694. /// 导出机票录入报表
  3695. /// </summary>
  3696. /// <param name="dto"></param>
  3697. /// <returns></returns>
  3698. [HttpPost]
  3699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3700. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3701. {
  3702. try
  3703. {
  3704. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3705. if (groupData.Code != 0)
  3706. {
  3707. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3708. }
  3709. else
  3710. {
  3711. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3712. if (AirTicketReservations.Count != 0)
  3713. {
  3714. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3715. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3716. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3717. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3718. WorkbookDesigner designer = new WorkbookDesigner();
  3719. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3720. decimal countCost = 0;
  3721. foreach (var item in AirTicketReservations)
  3722. {
  3723. #region 处理客人姓名
  3724. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3725. item.ClientName = clientNames;
  3726. #endregion
  3727. if (item.BankType == "其他")
  3728. {
  3729. item.BankNo = "--";
  3730. }
  3731. else
  3732. {
  3733. if (!string.IsNullOrEmpty(item.BankType))
  3734. {
  3735. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3736. }
  3737. }
  3738. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3739. item.Price = System.Decimal.Round(item.Price, 2);
  3740. countCost += Convert.ToDecimal(item.Price);
  3741. }
  3742. designer.SetDataSource("Export", AirTicketReservations);
  3743. designer.SetDataSource("ExportDiCode", diCode);
  3744. designer.SetDataSource("ExportDiName", diName);
  3745. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3746. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3747. designer.Process();
  3748. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3749. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3750. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3751. return Ok(JsonView(true, "成功", url = rst));
  3752. }
  3753. else
  3754. {
  3755. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3756. }
  3757. }
  3758. }
  3759. catch (Exception ex)
  3760. {
  3761. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3762. throw;
  3763. }
  3764. }
  3765. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3766. /// <summary>
  3767. /// 行程单导出
  3768. /// </summary>
  3769. /// <param name="dto"></param>
  3770. /// <returns></returns>
  3771. [HttpPost]
  3772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3773. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3774. {
  3775. try
  3776. {
  3777. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3778. if (groupData.Code != 0)
  3779. {
  3780. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3781. }
  3782. else
  3783. {
  3784. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3785. if (dto.Language == "CN")
  3786. {
  3787. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3788. DocumentBuilder builder = new DocumentBuilder(doc);
  3789. int tableIndex = 0;//表格索引
  3790. //得到文档中的第一个表格
  3791. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3792. foreach (var item in _AirTicketReservations)
  3793. {
  3794. #region 处理固定数据
  3795. string[] FlightsCode = item.FlightsCode.Split('/');
  3796. if (FlightsCode.Length != 0)
  3797. {
  3798. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3799. if (_AirCompany != null)
  3800. {
  3801. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3802. }
  3803. else
  3804. {
  3805. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3806. }
  3807. }
  3808. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3809. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3810. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3811. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3812. string name = "";
  3813. foreach (string clientName in nameArray)
  3814. {
  3815. if (!name.Contains(clientName))
  3816. {
  3817. name += clientName + ",";
  3818. }
  3819. }
  3820. if (!string.IsNullOrWhiteSpace(name))
  3821. {
  3822. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3823. }
  3824. else
  3825. {
  3826. table.Range.Bookmarks["ClientName"].Text = "--";
  3827. }
  3828. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3829. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3830. table.Range.Bookmarks["JointTicket"].Text = "--";
  3831. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3832. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3833. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3834. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3835. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3836. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3837. #endregion
  3838. #region 循环数据处理
  3839. List<AirInfo> airs = new List<AirInfo>();
  3840. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3841. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3842. for (int i = 0; i < FlightsCode.Length; i++)
  3843. {
  3844. AirInfo air = new AirInfo();
  3845. string[] tempstr = DayArray[i]
  3846. .Replace("\r\n", string.Empty)
  3847. .Replace("\\r\\n", string.Empty)
  3848. .TrimStart().TrimEnd()
  3849. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3850. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3851. string starCity = "";
  3852. if (star_Three != null)
  3853. {
  3854. starCity = star_Three.AirPort;
  3855. }
  3856. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3857. string EndCity = "";
  3858. if (End_Three != null)
  3859. {
  3860. EndCity = End_Three.AirPort;
  3861. }
  3862. air.Destination = starCity + "/" + EndCity;
  3863. air.Flight = FlightsCode[i];
  3864. air.SeatingClass = item.CTypeName;
  3865. string dateTime = tempstr[2];
  3866. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3867. air.FlightDate = DateTemp;
  3868. air.DepartureTime = tempstr[5];
  3869. air.LandingTime = tempstr[6];
  3870. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3871. air.TicketStatus = "--";
  3872. air.Luggage = "--";
  3873. air.DepartureTerminal = "--";
  3874. air.LandingTerminal = "--";
  3875. airs.Add(air);
  3876. }
  3877. int row = 13;
  3878. for (int i = 0; i < airs.Count; i++)
  3879. {
  3880. if (airs.Count > 2)
  3881. {
  3882. for (int j = 0; j < airs.Count - 2; j++)
  3883. {
  3884. var CopyRow = table.Rows[12].Clone(true);
  3885. table.Rows.Add(CopyRow);
  3886. }
  3887. }
  3888. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3889. int index = 0;
  3890. foreach (PropertyInfo property in properties)
  3891. {
  3892. string value = property.GetValue(airs[i]).ToString();
  3893. Cell ishcel0 = table.Rows[row].Cells[index];
  3894. Paragraph p = new Paragraph(doc);
  3895. string s = value;
  3896. p.AppendChild(new Run(doc, s));
  3897. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3898. ishcel0.AppendChild(p);
  3899. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3900. index++;
  3901. }
  3902. row++;
  3903. }
  3904. #endregion
  3905. Paragraph lastParagraph = new Paragraph(doc);
  3906. //第一个表格末尾加段落
  3907. table.ParentNode.InsertAfter(lastParagraph, table);
  3908. //复制第一个表格
  3909. Table cloneTable = (Table)table.Clone(true);
  3910. //在文档末尾段落后面加入复制的表格
  3911. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3912. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3913. {
  3914. int rownewsIndex = 13;
  3915. for (int i = 0; i < 2; i++)
  3916. {
  3917. var CopyRow = table.Rows[12].Clone(true);
  3918. table.Rows.RemoveAt(13);
  3919. table.Rows.Add(CopyRow);
  3920. rownewsIndex++;
  3921. }
  3922. }
  3923. else
  3924. {
  3925. table.Rows.RemoveAt(12);
  3926. }
  3927. cloneTable.Rows.RemoveAt(12);
  3928. }
  3929. if (_AirTicketReservations.Count != 0)
  3930. {
  3931. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3932. if (FlightsCode.Length != 0)
  3933. {
  3934. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3935. if (_AirCompany != null)
  3936. {
  3937. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3938. }
  3939. else
  3940. {
  3941. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3942. }
  3943. }
  3944. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3945. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3946. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3947. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3948. string name = "";
  3949. foreach (string clientName in nameArray)
  3950. {
  3951. if (!name.Contains(clientName))
  3952. {
  3953. name += clientName + ",";
  3954. }
  3955. }
  3956. if (!string.IsNullOrWhiteSpace(name))
  3957. {
  3958. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3959. }
  3960. else
  3961. {
  3962. table.Range.Bookmarks["ClientName"].Text = "--";
  3963. }
  3964. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3965. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3966. table.Range.Bookmarks["JointTicket"].Text = "--";
  3967. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3968. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3969. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3970. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3971. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3972. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3973. }
  3974. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3975. //保存合并后的文档
  3976. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3977. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3978. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3979. return Ok(JsonView(true, "成功!", rst));
  3980. }
  3981. else
  3982. {
  3983. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3984. DocumentBuilder builder = new DocumentBuilder(doc);
  3985. int tableIndex = 0;//表格索引
  3986. //得到文档中的第一个表格
  3987. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3988. List<string> texts = new List<string>();
  3989. foreach (var item in _AirTicketReservations)
  3990. {
  3991. string[] FlightsCode = item.FlightsCode.Split('/');
  3992. if (FlightsCode.Length != 0)
  3993. {
  3994. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3995. if (_AirCompany != null)
  3996. {
  3997. if (!transDic.ContainsKey(_AirCompany.CnName))
  3998. {
  3999. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4000. }
  4001. }
  4002. else
  4003. {
  4004. if (!transDic.ContainsKey("--"))
  4005. {
  4006. transDic.Add("--", "--");
  4007. }
  4008. }
  4009. }
  4010. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4011. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4012. string name = "";
  4013. foreach (string clientName in nameArray)
  4014. {
  4015. name += clientName + ",";
  4016. }
  4017. if (!texts.Contains(name))
  4018. {
  4019. texts.Add(name);
  4020. }
  4021. List<AirInfo> airs = new List<AirInfo>();
  4022. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4023. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4024. for (int i = 0; i < FlightsCode.Length; i++)
  4025. {
  4026. AirInfo air = new AirInfo();
  4027. string[] tempstr = DayArray[i]
  4028. .Replace("\r\n", string.Empty)
  4029. .Replace("\\r\\n", string.Empty)
  4030. .TrimStart().TrimEnd()
  4031. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4032. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4033. if (star_Three != null)
  4034. {
  4035. if (!transDic.ContainsKey(star_Three.AirPort))
  4036. {
  4037. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4038. }
  4039. }
  4040. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4041. if (End_Three != null)
  4042. {
  4043. if (!transDic.ContainsKey(End_Three.AirPort))
  4044. {
  4045. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4046. }
  4047. }
  4048. if (!texts.Contains(item.CTypeName))
  4049. {
  4050. texts.Add(item.CTypeName);
  4051. }
  4052. }
  4053. }
  4054. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4055. if (transData.Count > 0)
  4056. {
  4057. foreach (TranslateResult item in transData)
  4058. {
  4059. if (!transDic.ContainsKey(item.Query))
  4060. {
  4061. transDic.Add(item.Query, item.Translation);
  4062. }
  4063. }
  4064. }
  4065. foreach (var item in _AirTicketReservations)
  4066. {
  4067. #region 处理固定数据
  4068. string[] FlightsCode = item.FlightsCode.Split('/');
  4069. if (FlightsCode.Length != 0)
  4070. {
  4071. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4072. if (_AirCompany != null)
  4073. {
  4074. string str = "--";
  4075. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4076. if (!string.IsNullOrEmpty(translateResult))
  4077. {
  4078. str = translateResult;
  4079. str = _airTicketResRep.Processing(str);
  4080. }
  4081. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4082. }
  4083. else
  4084. {
  4085. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4086. }
  4087. }
  4088. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4089. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4090. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4091. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4092. string names = "";
  4093. foreach (string clientName in nameArray)
  4094. {
  4095. names += clientName + ",";
  4096. }
  4097. if (!string.IsNullOrWhiteSpace(names))
  4098. {
  4099. string str = "--";
  4100. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4101. if (!string.IsNullOrEmpty(translateResult))
  4102. {
  4103. str = translateResult;
  4104. str = _airTicketResRep.Processing(str);
  4105. }
  4106. table.Range.Bookmarks["ClientName"].Text = str;
  4107. }
  4108. else
  4109. {
  4110. table.Range.Bookmarks["ClientName"].Text = "--";
  4111. }
  4112. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4113. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4114. table.Range.Bookmarks["JointTicket"].Text = "--";
  4115. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4116. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4117. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4118. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4119. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4120. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4121. #endregion
  4122. #region 循环数据处理
  4123. List<AirInfo> airs = new List<AirInfo>();
  4124. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4125. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4126. for (int i = 0; i < FlightsCode.Length; i++)
  4127. {
  4128. AirInfo air = new AirInfo();
  4129. string[] tempstr = DayArray[i]
  4130. .Replace("\r\n", string.Empty)
  4131. .Replace("\\r\\n", string.Empty)
  4132. .TrimStart().TrimEnd()
  4133. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4134. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4135. string starCity = "";
  4136. if (star_Three != null)
  4137. {
  4138. string str2 = "--";
  4139. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4140. if (!string.IsNullOrEmpty(translateResult2))
  4141. {
  4142. str2 = translateResult2;
  4143. str2 = _airTicketResRep.Processing(str2);
  4144. }
  4145. starCity = str2;
  4146. }
  4147. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4148. string EndCity = "";
  4149. if (End_Three != null)
  4150. {
  4151. string str1 = "--";
  4152. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4153. if (!string.IsNullOrEmpty(translateResult1))
  4154. {
  4155. str1 = translateResult1;
  4156. str1 = _airTicketResRep.Processing(str1);
  4157. }
  4158. EndCity = str1;
  4159. }
  4160. air.Destination = starCity + "/" + EndCity;
  4161. air.Flight = FlightsCode[i];
  4162. string str = "--";
  4163. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4164. if (!string.IsNullOrEmpty(translateResult))
  4165. {
  4166. str = translateResult;
  4167. str = _airTicketResRep.Processing(str);
  4168. }
  4169. air.SeatingClass = str;
  4170. string dateTime = tempstr[2];
  4171. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4172. air.FlightDate = DateTemp;
  4173. air.DepartureTime = tempstr[5];
  4174. air.LandingTime = tempstr[6];
  4175. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4176. air.TicketStatus = "--";
  4177. air.Luggage = "--";
  4178. air.DepartureTerminal = "--";
  4179. air.LandingTerminal = "--";
  4180. airs.Add(air);
  4181. }
  4182. int row = 13;
  4183. for (int i = 0; i < airs.Count; i++)
  4184. {
  4185. if (airs.Count > 2)
  4186. {
  4187. for (int j = 0; j < airs.Count - 2; j++)
  4188. {
  4189. var CopyRow = table.Rows[12].Clone(true);
  4190. table.Rows.Add(CopyRow);
  4191. }
  4192. }
  4193. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4194. int index = 0;
  4195. foreach (PropertyInfo property in properties)
  4196. {
  4197. string value = property.GetValue(airs[i]).ToString();
  4198. Cell ishcel0 = table.Rows[row].Cells[index];
  4199. Paragraph p = new Paragraph(doc);
  4200. string s = value;
  4201. p.AppendChild(new Run(doc, s));
  4202. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4203. ishcel0.AppendChild(p);
  4204. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4205. //ishcel0.CellFormat.VerticalAlignment=
  4206. index++;
  4207. }
  4208. row++;
  4209. }
  4210. #endregion
  4211. Paragraph lastParagraph = new Paragraph(doc);
  4212. //第一个表格末尾加段落
  4213. table.ParentNode.InsertAfter(lastParagraph, table);
  4214. //复制第一个表格
  4215. Table cloneTable = (Table)table.Clone(true);
  4216. //在文档末尾段落后面加入复制的表格
  4217. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4218. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4219. {
  4220. int rownewsIndex = 13;
  4221. for (int i = 0; i < 2; i++)
  4222. {
  4223. var CopyRow = table.Rows[12].Clone(true);
  4224. table.Rows.RemoveAt(13);
  4225. table.Rows.Add(CopyRow);
  4226. rownewsIndex++;
  4227. }
  4228. }
  4229. else
  4230. {
  4231. table.Rows.RemoveAt(12);
  4232. }
  4233. cloneTable.Rows.RemoveAt(12);
  4234. }
  4235. if (_AirTicketReservations.Count != 0)
  4236. {
  4237. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4238. if (FlightsCode.Length != 0)
  4239. {
  4240. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4241. if (_AirCompany != null)
  4242. {
  4243. string str = "--";
  4244. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4245. if (!string.IsNullOrEmpty(translateResult))
  4246. {
  4247. str = translateResult;
  4248. str = _airTicketResRep.Processing(str);
  4249. }
  4250. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4251. }
  4252. else
  4253. {
  4254. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4255. }
  4256. }
  4257. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4258. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4259. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4260. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4261. string names = "";
  4262. foreach (string clientName in nameArray)
  4263. {
  4264. names += clientName + ",";
  4265. }
  4266. if (!string.IsNullOrWhiteSpace(names))
  4267. {
  4268. string str = "--";
  4269. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4270. if (!string.IsNullOrEmpty(translateResult))
  4271. {
  4272. str = translateResult;
  4273. str = _airTicketResRep.Processing(str);
  4274. }
  4275. table.Range.Bookmarks["ClientName"].Text = str;
  4276. }
  4277. else
  4278. {
  4279. table.Range.Bookmarks["ClientName"].Text = "--";
  4280. }
  4281. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4282. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4283. table.Range.Bookmarks["JointTicket"].Text = "--";
  4284. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4285. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4286. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4287. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4288. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4289. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4290. }
  4291. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4292. //保存合并后的文档
  4293. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4294. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4295. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4296. return Ok(JsonView(true, "成功!", rst));
  4297. }
  4298. }
  4299. }
  4300. catch (Exception ex)
  4301. {
  4302. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4303. throw;
  4304. }
  4305. }
  4306. #endregion
  4307. #region 团组增减款项 --> 其他款项
  4308. /// <summary>
  4309. /// 团组增减款项下拉框绑定
  4310. /// </summary>
  4311. /// <param name="dto"></param>
  4312. /// <returns></returns>
  4313. [HttpPost]
  4314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4315. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4316. {
  4317. #region 参数验证
  4318. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4319. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4320. #endregion
  4321. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4322. }
  4323. /// <summary>
  4324. /// 根据团组Id查询团组增减款项
  4325. /// </summary>
  4326. /// <param name="dto"></param>
  4327. /// <returns></returns>
  4328. [HttpPost]
  4329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4330. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4331. {
  4332. #region 参数验证
  4333. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4334. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4335. #endregion
  4336. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4337. }
  4338. /// <summary>
  4339. /// 团组增减款项操作(Status:1.新增,2.修改)
  4340. /// </summary>
  4341. /// <param name="dto"></param>
  4342. /// <returns></returns>
  4343. [HttpPost]
  4344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4345. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4346. {
  4347. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4348. if (groupData.Code != 200)
  4349. {
  4350. return Ok(JsonView(false, groupData.Msg));
  4351. }
  4352. #region 应用推送
  4353. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4354. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4355. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4356. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4357. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4358. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4359. //自动审核
  4360. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4361. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4362. //2024-10-21 新增LZ UID
  4363. var userIds = new List<int>() { 21 };
  4364. string title = $"系统通知";
  4365. string content = "";
  4366. var diId = dto.DiId;
  4367. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4368. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4369. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4370. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4371. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4372. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4373. #endregion
  4374. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4375. }
  4376. /// <summary>
  4377. /// 团组增减款项操作 自动审核test
  4378. /// </summary>
  4379. /// <param name="groupId"></param>
  4380. /// <param name="dataId"></param>
  4381. /// <returns></returns>
  4382. [HttpPost]
  4383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4384. public async Task<IActionResult> DecreaseFeeAutomaticAudit(int groupId,int dataId)
  4385. {
  4386. //自动审核
  4387. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, groupId, dataId);
  4388. return Ok(autoAdit);
  4389. }
  4390. /// <summary>
  4391. /// 团组增减款项操作 删除
  4392. /// </summary>
  4393. /// <param name="dto"></param>
  4394. /// <returns></returns>
  4395. [HttpPost]
  4396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4397. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4398. {
  4399. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4400. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4401. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4402. if (res.Code == 0)
  4403. {
  4404. return Ok(JsonView(true, "删除成功!"));
  4405. }
  4406. return Ok(JsonView(false, "删除失败!"));
  4407. }
  4408. /// <summary>
  4409. /// 根据团组增减款项Id查询
  4410. /// </summary>
  4411. /// <param name="dto"></param>
  4412. /// <returns></returns>
  4413. [HttpPost]
  4414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4415. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4416. {
  4417. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4418. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4419. }
  4420. /// <summary>
  4421. /// 查询供应商名称
  4422. /// </summary>
  4423. /// <param name="dto"></param>
  4424. /// <returns></returns>
  4425. [HttpPost]
  4426. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4427. {
  4428. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4429. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4430. ?? new List<Grp_DecreasePayments>();
  4431. dbResult = dbResult.Distinct(new
  4432. ProductComparer()).ToList();
  4433. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4434. {
  4435. x.Id,
  4436. x.SupplierAddress,
  4437. x.SupplierArea,
  4438. x.SupplierContact,
  4439. x.SupplierContactNumber,
  4440. x.SupplierEmail,
  4441. x.SupplierName,
  4442. x.SupplierSocialAccount,
  4443. x.SupplierTypeId,
  4444. }).ToList());
  4445. return Ok(jw);
  4446. }
  4447. /// <summary>
  4448. /// 团组增减款项 OTA匹配
  4449. /// </summary>
  4450. /// <param name="file"></param>
  4451. /// <returns></returns>
  4452. [HttpPost]
  4453. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4454. {
  4455. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4456. string fileName = file.FileName;
  4457. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4458. {
  4459. return Ok(JsonView(false, "请上传Excel文件!"));
  4460. }
  4461. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4462. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4463. if (!Directory.Exists(path))
  4464. {
  4465. Directory.CreateDirectory(path);
  4466. }
  4467. var filePath = @$"{path}/{fileName}";
  4468. //保存文件
  4469. using (FileStream fs = System.IO.File.Create(filePath))
  4470. {
  4471. file.CopyTo(fs);
  4472. fs.Flush();
  4473. }
  4474. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4475. //读取ExcelFile
  4476. DataTable dt = ConvertExcelToDataTable(filePath);
  4477. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4478. dt.TableName = "TB";
  4479. //修改table列名
  4480. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4481. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4482. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4483. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4484. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4485. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4486. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4487. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4488. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4489. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4490. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4491. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4492. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4493. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4494. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4495. var otaOrderNos = new List<string>();
  4496. foreach (DataRow item in dt.Rows)
  4497. {
  4498. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4499. }
  4500. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4501. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4502. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4503. .Select((dp, di) => new
  4504. {
  4505. dp.PriceName,
  4506. dp.OTAOrderNo,
  4507. dp.FeeTotal,
  4508. di.TeamName,
  4509. })
  4510. .ToListAsync();
  4511. foreach (DataRow item in dt.Rows)
  4512. {
  4513. var otaOrderNo = item["OTAOrderNo"].ToString();
  4514. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4515. if (oaData == null) continue;
  4516. item["GroupName"] = oaData.TeamName;
  4517. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4518. }
  4519. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4520. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4521. List<DataTable> datas = new List<DataTable>();
  4522. datas.Add(dt);
  4523. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4524. return Ok(JsonView(true, "操作成功", new { url = url }));
  4525. }
  4526. #region
  4527. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4528. {
  4529. // 创建Workbook对象
  4530. Workbook workbook = new Workbook(excelFilePath);
  4531. // 获取第一个工作表
  4532. Worksheet worksheet = workbook.Worksheets[0];
  4533. // 将工作表转换为DataTable
  4534. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4535. return dataTable;
  4536. }
  4537. #endregion
  4538. #endregion
  4539. #region 文件上传、删除
  4540. /// <summary>
  4541. /// region 文件上传 可以带参数
  4542. /// </summary>
  4543. /// <param name="file"></param>
  4544. /// <returns></returns>
  4545. [HttpPost]
  4546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4547. public async Task<IActionResult> UploadProject(IFormFile file)
  4548. {
  4549. //var TypeName = Request.Headers["TypeName"].ToString();
  4550. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4551. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4552. ////文件名称
  4553. //string projectFileName = file.FileName;
  4554. ////上传的文件的路径
  4555. //string filePath = $"{fileDir}/{projectFileName}";
  4556. //if (TypeName == "A")//A代表团组增减款项
  4557. //{
  4558. // filePath = fileDir + $@"\团组增减款项相关文件";
  4559. // if (!Directory.Exists(filePath))
  4560. // {
  4561. // Directory.CreateDirectory(filePath);
  4562. // }
  4563. // //上传的文件的路径
  4564. // filePath += $@"\{projectFileName}";
  4565. //}
  4566. //else if (TypeName == "B")//B代表商邀相关文件
  4567. //{
  4568. // //上传的文件的路径
  4569. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4570. // if (!Directory.Exists(filePath))
  4571. // {
  4572. // Directory.CreateDirectory(filePath);
  4573. // }
  4574. // //上传的文件的路径
  4575. // filePath = $@"\{projectFileName}";
  4576. //}
  4577. //try
  4578. //{
  4579. // using (FileStream fs = System.IO.File.Create(filePath))
  4580. // {
  4581. // file.CopyTo(fs);
  4582. // fs.Flush();
  4583. // }
  4584. //}
  4585. //catch (Exception ex)
  4586. //{
  4587. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4588. //}
  4589. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4590. try
  4591. {
  4592. var TypeName = Request.Headers["TypeName"].ToString();
  4593. if (file != null)
  4594. {
  4595. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4596. //文件名称
  4597. string projectFileName = file.FileName;
  4598. //上传的文件的路径
  4599. string filePath = $"{fileDir}/{projectFileName}";
  4600. if (TypeName == "A")//A代表团组增减款项
  4601. {
  4602. if (!Directory.Exists(fileDir))
  4603. {
  4604. Directory.CreateDirectory(fileDir);
  4605. }
  4606. //上传的文件的路径
  4607. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4608. }
  4609. else if (TypeName == "B")//B代表商邀相关文件
  4610. {
  4611. if (!Directory.Exists(fileDir))
  4612. {
  4613. Directory.CreateDirectory(fileDir);
  4614. }
  4615. //上传的文件的路径
  4616. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4617. }
  4618. using (FileStream fs = System.IO.File.Create(filePath))
  4619. {
  4620. file.CopyTo(fs);
  4621. fs.Flush();
  4622. }
  4623. return Ok(JsonView(true, "上传成功!", projectFileName));
  4624. }
  4625. else
  4626. {
  4627. return Ok(JsonView(false, "上传失败!"));
  4628. }
  4629. }
  4630. catch (Exception ex)
  4631. {
  4632. return Ok(JsonView(false, "程序错误!"));
  4633. }
  4634. }
  4635. /// <summary>
  4636. /// 删除指定文件
  4637. /// </summary>
  4638. /// <param name="dto"></param>
  4639. /// <returns></returns>
  4640. [HttpPost]
  4641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4642. public async Task<IActionResult> DelFile(DelFileDto dto)
  4643. {
  4644. try
  4645. {
  4646. var TypeName = Request.Headers["TypeName"].ToString();
  4647. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4648. string filePath = "";
  4649. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4650. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4651. int id = 0;
  4652. if (TypeName == "A")
  4653. {
  4654. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4655. // 删除该文件
  4656. System.IO.File.Delete(filePath);
  4657. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4658. .Where(a => a.Id == dto.Id)
  4659. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4660. .ExecuteCommandAsync();
  4661. }
  4662. else if (TypeName == "B")
  4663. {
  4664. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4665. // 删除该文件
  4666. System.IO.File.Delete(filePath);
  4667. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4668. if (info != null)
  4669. {
  4670. string[] files = new string[] { };
  4671. if (!string.IsNullOrEmpty(info.Attachment))
  4672. {
  4673. try
  4674. {
  4675. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4676. }
  4677. catch (Exception)
  4678. {
  4679. files = new List<string>() { info.Attachment }.ToArray();
  4680. }
  4681. }
  4682. if (files.Length > 0)
  4683. {
  4684. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4685. string filePath2 = string.Empty;
  4686. if (files1.Length > 0)
  4687. {
  4688. filePath2 = JsonConvert.SerializeObject(files1);
  4689. }
  4690. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4691. .Where(a => a.Id == dto.Id)
  4692. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4693. .ExecuteCommandAsync();
  4694. }
  4695. }
  4696. }
  4697. if (id != 0)
  4698. {
  4699. return Ok(JsonView(true, "成功!"));
  4700. }
  4701. else
  4702. {
  4703. return Ok(JsonView(false, "失败!"));
  4704. }
  4705. }
  4706. catch (Exception ex)
  4707. {
  4708. return Ok(JsonView(false, "程序错误!"));
  4709. throw;
  4710. }
  4711. }
  4712. /// <summary>
  4713. /// 文件上传多个文件 可以带参数
  4714. /// </summary>
  4715. /// <param name="files"></param>
  4716. /// <returns></returns>
  4717. [HttpPost]
  4718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4719. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4720. {
  4721. try
  4722. {
  4723. var TypeName = Request.Headers["TypeName"].ToString();
  4724. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4725. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4726. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4727. var filePahts = new List<string>();
  4728. foreach (var file in files)
  4729. {
  4730. //文件名称
  4731. string projectFileName = file.FileName;
  4732. //上传的文件的路径
  4733. string filePath = $"{fileDir}/{projectFileName}";
  4734. if (TypeName == "A")//A代表团组增减款项
  4735. {
  4736. if (!Directory.Exists(fileDir))
  4737. {
  4738. Directory.CreateDirectory(fileDir);
  4739. }
  4740. //上传的文件的路径
  4741. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4742. }
  4743. else if (TypeName == "B")//B代表商邀相关文件
  4744. {
  4745. if (!Directory.Exists(fileDir))
  4746. {
  4747. Directory.CreateDirectory(fileDir);
  4748. }
  4749. //上传的文件的路径
  4750. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4751. }
  4752. using (FileStream fs = System.IO.File.Create(filePath))
  4753. {
  4754. file.CopyTo(fs);
  4755. fs.Flush();
  4756. }
  4757. filePahts.Add(projectFileName);
  4758. }
  4759. return Ok(JsonView(true, "上传成功!", filePahts));
  4760. }
  4761. catch (Exception ex)
  4762. {
  4763. return Ok(JsonView(false, "程序错误!"));
  4764. }
  4765. }
  4766. #endregion
  4767. #region 商邀费用录入
  4768. /// <summary>
  4769. /// 根据团组Id查询商邀费用列表
  4770. /// </summary>
  4771. /// <param name="dto"></param>
  4772. /// <returns></returns>
  4773. [HttpPost]
  4774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4775. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4776. {
  4777. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4778. if (groupData.Code != 0)
  4779. {
  4780. return Ok(JsonView(false, groupData.Msg));
  4781. }
  4782. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4783. }
  4784. /// <summary>
  4785. /// 商邀费用列表
  4786. /// 下载文件
  4787. /// </summary>
  4788. /// <param name="id"></param>
  4789. /// <returns></returns>
  4790. [HttpGet("{id}")]
  4791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4792. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4793. {
  4794. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4795. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4796. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4797. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4798. var filePaths = new List<string>();
  4799. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4800. try
  4801. {
  4802. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4803. }
  4804. catch (Exception ex)
  4805. {
  4806. filePaths.Add(info.Attachment);
  4807. }
  4808. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4809. for (int i = 0; i < filePaths.Count; i++)
  4810. {
  4811. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4812. }
  4813. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4814. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4815. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4816. {
  4817. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4818. {
  4819. foreach (string filePath in filePaths)
  4820. {
  4821. if (System.IO.File.Exists(filePath))
  4822. {
  4823. // 获取文件名
  4824. string fileName = Path.GetFileName(filePath);
  4825. // 将文件添加到ZIP归档中
  4826. zipArchive.CreateEntryFromFile(filePath, fileName);
  4827. }
  4828. }
  4829. }
  4830. }
  4831. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4832. }
  4833. /// <summary>
  4834. /// 商邀费用 Info Page 基础数据源
  4835. /// </summary>
  4836. /// <returns></returns>
  4837. [HttpPost]
  4838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4839. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4840. {
  4841. try
  4842. {
  4843. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4844. if (groupData.Code != 0)
  4845. {
  4846. return Ok(JsonView(false, groupData.Msg));
  4847. }
  4848. return Ok(JsonView(true, "操作成功", groupData.Data));
  4849. }
  4850. catch (Exception ex)
  4851. {
  4852. return Ok(JsonView(false, ex.Message));
  4853. throw;
  4854. }
  4855. }
  4856. /// <summary>
  4857. /// 根据商邀费用ID查询C表和商邀费用数据
  4858. /// </summary>
  4859. /// <param name="dto"></param>
  4860. /// <returns></returns>
  4861. [HttpPost]
  4862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4863. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4864. {
  4865. try
  4866. {
  4867. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4868. if (groupData.Code != 0)
  4869. {
  4870. return Ok(JsonView(false, groupData.Msg));
  4871. }
  4872. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4873. }
  4874. catch (Exception ex)
  4875. {
  4876. return Ok(JsonView(false, ex.Message));
  4877. throw;
  4878. }
  4879. }
  4880. /// <summary>
  4881. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4882. /// </summary>
  4883. /// <param name="dto"></param>
  4884. /// <returns></returns>
  4885. [HttpPost]
  4886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4887. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4888. {
  4889. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4890. if (groupData.Code != 0)
  4891. {
  4892. return Ok(JsonView(false, groupData.Msg));
  4893. }
  4894. #region 应用推送
  4895. try
  4896. {
  4897. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4898. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4899. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4900. //2024-10-21 新增LZ UID
  4901. var userIds = new List<int>() { 21 };
  4902. string title = $"系统通知";
  4903. string content = "";
  4904. var diId = dto.DiId;
  4905. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4906. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4907. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4908. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4909. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4910. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  4911. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4912. }
  4913. catch (Exception ex)
  4914. {
  4915. }
  4916. #endregion
  4917. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4918. }
  4919. /// <summary>
  4920. /// 商邀删除
  4921. /// </summary>
  4922. /// <param name="dto"></param>
  4923. /// <returns></returns>
  4924. [HttpPost]
  4925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4926. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4927. {
  4928. try
  4929. {
  4930. _sqlSugar.BeginTran();
  4931. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4932. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4933. {
  4934. IsDel = 1,
  4935. DeleteUserId = dto.DeleteUserId,
  4936. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4937. })
  4938. .Where(it => it.Id == dto.Id)
  4939. .ExecuteCommand();
  4940. if (res1 > 0)
  4941. {
  4942. int _diId = 0;
  4943. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4944. if (_ioaInfo != null)
  4945. {
  4946. _diId = _ioaInfo.DiId;
  4947. }
  4948. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4949. .SetColumns(a => new Grp_CreditCardPayment()
  4950. {
  4951. IsDel = 1,
  4952. DeleteUserId = dto.DeleteUserId,
  4953. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4954. })
  4955. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4956. .ExecuteCommand();
  4957. if (res2 > 0)
  4958. {
  4959. _sqlSugar.CommitTran();
  4960. return Ok(JsonView(true, "删除成功!"));
  4961. }
  4962. }
  4963. _sqlSugar.RollbackTran();
  4964. return Ok(JsonView(false, "删除失败"));
  4965. }
  4966. catch (Exception ex)
  4967. {
  4968. _sqlSugar.RollbackTran();
  4969. return Ok(JsonView(false, ex.Message));
  4970. }
  4971. }
  4972. #endregion
  4973. #region 票据上传
  4974. /// <summary>
  4975. /// 团组模块文件上传
  4976. /// </summary>
  4977. /// <param name="dto"></param>
  4978. /// <returns></returns>
  4979. [HttpPost]
  4980. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4981. {
  4982. var jw = JsonView(false);
  4983. long M = 1024 * 1024;
  4984. if (dto.Files == null || dto.Files.Count == 0)
  4985. {
  4986. jw.Msg = "无文件信息!";
  4987. return Ok(jw);
  4988. }
  4989. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4990. {
  4991. jw.Msg = "文件大小超过20M!";
  4992. return Ok(jw);
  4993. }
  4994. //var nameSp = dto.File.FileName.Split(".");
  4995. //if (nameSp.Length < 2)
  4996. //{
  4997. // jw.Msg = "拓展名称有误!";
  4998. // return Ok(jw);
  4999. //}
  5000. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5001. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5002. //{
  5003. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5004. // return Ok(jw);
  5005. //}
  5006. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5007. if (Ctable == null)
  5008. {
  5009. jw.Msg = "Ctable指向有误!";
  5010. return Ok(jw);
  5011. }
  5012. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5013. if (groupInfo == null)
  5014. {
  5015. jw.Msg = "团组信息不存在!";
  5016. return Ok(jw);
  5017. }
  5018. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5019. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5020. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5021. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5022. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5023. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5024. try
  5025. {
  5026. if (!Directory.Exists(fileBase))
  5027. {
  5028. Directory.CreateDirectory(fileBase);
  5029. }
  5030. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5031. foreach (var fileStream in dto.Files)
  5032. {
  5033. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5034. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5035. {
  5036. Cid = dto.Cid,
  5037. CreateTime = DateTime.Now,
  5038. CreateUserId = dto.Userid,
  5039. Ctable = dto.Ctable,
  5040. Diid = dto.Diid,
  5041. IsDel = 0,
  5042. FilePath = saveFilePath,
  5043. FileName = fileStream.FileName
  5044. };
  5045. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5046. {
  5047. fileStream.CopyTo(fs);
  5048. fs.Flush();
  5049. }
  5050. saveArr.Add(file);
  5051. }
  5052. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5053. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5054. jw = JsonView(true, "保存成功!", new
  5055. {
  5056. count = addResult,
  5057. filesName = saveArr.Select(x => x.FileName)
  5058. });
  5059. }
  5060. catch (Exception ex)
  5061. {
  5062. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5063. {
  5064. count = 0,
  5065. filesName = new string[0],
  5066. });
  5067. }
  5068. return Ok(jw);
  5069. }
  5070. /// <summary>
  5071. /// 查询各模块已保存文件
  5072. /// </summary>
  5073. /// <param name="dto"></param>
  5074. /// <returns></returns>
  5075. [HttpPost]
  5076. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5077. {
  5078. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5079. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5080. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5081. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5082. {
  5083. expression = Expressionable.Create<Grp_GroupModelFile>()
  5084. .And(x => visaIds.Contains(x.CreateUserId));
  5085. }
  5086. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5087. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5088. .Where(expression.ToExpression())
  5089. .ToList();
  5090. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5091. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5092. {
  5093. x.FileName,
  5094. x.Id,
  5095. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5096. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5097. })));
  5098. }
  5099. /// <summary>
  5100. /// 下载该团组下的所有文件
  5101. /// </summary>
  5102. /// <param name="dto"></param>
  5103. /// <returns></returns>
  5104. [HttpPost]
  5105. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5106. {
  5107. var jw = JsonView(false);
  5108. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5109. if (groupInfo == null)
  5110. {
  5111. jw.Msg = "团组信息不存在!";
  5112. return Ok(jw);
  5113. }
  5114. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5115. var isModule = Convert.ToBoolean(dto.isModule);
  5116. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5117. IOOperatorHelper io = new IOOperatorHelper();
  5118. if (isModule)
  5119. {
  5120. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5121. foreach (var moduleArr in moduleGroup)
  5122. {
  5123. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5124. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5125. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5126. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5127. foreach (var item in moduleArr)
  5128. {
  5129. if (System.IO.File.Exists(item.FilePath))
  5130. {
  5131. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5132. {
  5133. byte[] bytes = new byte[fileStream.Length];
  5134. fileStream.Read(bytes, 0, bytes.Length);
  5135. fileStream.Close();
  5136. Stream stream = new MemoryStream(bytes);
  5137. chiZips.Add(item.FileName, stream);
  5138. }
  5139. }
  5140. }
  5141. if (chiZips.Count > 0)
  5142. {
  5143. var byts = io.ConvertZipStream(chiZips);
  5144. Stream stream = new MemoryStream(byts);
  5145. Zips.Add(key.Name + "_.zip", stream);
  5146. }
  5147. }
  5148. }
  5149. else
  5150. {
  5151. foreach (var item in dbQuery)
  5152. {
  5153. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5154. {
  5155. byte[] bytes = new byte[fileStream.Length];
  5156. fileStream.Read(bytes, 0, bytes.Length);
  5157. fileStream.Close();
  5158. Stream stream = new MemoryStream(bytes);
  5159. while (Zips.Keys.Contains(item.FileName))
  5160. {
  5161. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5162. }
  5163. Zips.Add(item.FileName, stream);
  5164. }
  5165. }
  5166. }
  5167. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5168. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5169. if (Zips.Count > 0)
  5170. {
  5171. var byts = io.ConvertZipStream(Zips);
  5172. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5173. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5174. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5175. }
  5176. else
  5177. {
  5178. jw.Msg = "暂无生成文件!";
  5179. }
  5180. return Ok(jw);
  5181. }
  5182. /// <summary>
  5183. /// 下载该团组下此模块的所有文件
  5184. /// </summary>
  5185. /// <param name="dto"></param>
  5186. /// <returns></returns>
  5187. [HttpPost]
  5188. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5189. {
  5190. var jw = JsonView(false);
  5191. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5192. if (groupInfo == null)
  5193. {
  5194. jw.Msg = "团组信息不存在!";
  5195. return Ok(jw);
  5196. }
  5197. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5198. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5199. && x.IsDel == 0);
  5200. if (key == null)
  5201. {
  5202. jw.Msg = "Ctable指向错误!";
  5203. return Ok(jw);
  5204. }
  5205. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5206. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5207. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5208. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5209. IOOperatorHelper io = new IOOperatorHelper();
  5210. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5211. foreach (var item in dbQuery)
  5212. {
  5213. if (System.IO.File.Exists(item.FilePath))
  5214. {
  5215. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5216. {
  5217. byte[] bytes = new byte[fileStream.Length];
  5218. fileStream.Read(bytes, 0, bytes.Length);
  5219. fileStream.Close();
  5220. Stream stream = new MemoryStream(bytes);
  5221. while (Zips.Keys.Contains(item.FileName))
  5222. {
  5223. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5224. }
  5225. Zips.Add(item.FileName, stream);
  5226. }
  5227. }
  5228. }
  5229. if (Zips.Count > 0)
  5230. {
  5231. var byts = io.ConvertZipStream(Zips);
  5232. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5233. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5234. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5235. }
  5236. else
  5237. {
  5238. jw.Msg = "暂无生成文件!";
  5239. }
  5240. return Ok(jw);
  5241. }
  5242. /// <summary>
  5243. /// 删除该团组下的指定文件
  5244. /// </summary>
  5245. /// <param name="dto"></param>
  5246. /// <returns></returns>
  5247. [HttpPost]
  5248. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5249. {
  5250. var jw = JsonView(false);
  5251. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5252. if (sing == null)
  5253. {
  5254. jw.Msg = "暂无";
  5255. return Ok(jw);
  5256. }
  5257. if (System.IO.File.Exists(sing.FilePath))
  5258. {
  5259. try
  5260. {
  5261. System.IO.File.Delete(sing.FilePath);
  5262. }
  5263. catch (Exception ex)
  5264. {
  5265. jw.Msg = "删除失败!" + ex.Message;
  5266. return Ok(jw);
  5267. }
  5268. }
  5269. sing.IsDel = 1;
  5270. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5271. sing.DeleteUserId = dto.UserId;
  5272. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5273. jw = JsonView(true, "删除成功!");
  5274. return Ok(jw);
  5275. }
  5276. #endregion
  5277. #region 共享文件上传
  5278. /// <summary>
  5279. /// 共享文件数据初始化
  5280. /// </summary>
  5281. /// <returns></returns>
  5282. [HttpGet]
  5283. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  5284. {
  5285. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  5286. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5287. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5288. .Select(x => x.Id)
  5289. .ToList()
  5290. .Contains(userid);
  5291. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5292. .Where(x => x.STid == 111 && x.IsDel == 0)
  5293. .Select(x => new
  5294. {
  5295. x.Name,
  5296. x.Id,
  5297. }).ToList();
  5298. if (isMarketingDepartment)
  5299. {
  5300. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5301. }
  5302. if (portType == 1)
  5303. {
  5304. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5305. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5306. .Where(x => x.IsDel == 0)
  5307. .OrderByDescending(x=> x.VisitDate )
  5308. .Select(x => new
  5309. {
  5310. x.TeamName,
  5311. x.Id,
  5312. x.CityId,
  5313. })
  5314. .ToList()
  5315. .Select(x=>
  5316. {
  5317. var provinceId = x.CityId;
  5318. var isDefualtVal = true;
  5319. if (provinceId > 0)
  5320. {
  5321. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5322. if (parentId != null)
  5323. {
  5324. isDefualtVal = false;
  5325. provinceId = (int)parentId;
  5326. }
  5327. }
  5328. if (isDefualtVal)
  5329. {
  5330. provinceId = 122; //默认四川
  5331. }
  5332. return new
  5333. {
  5334. x.TeamName,
  5335. x.Id,
  5336. provinceId,
  5337. };
  5338. })
  5339. .ToList();
  5340. return Ok(JsonView(true, "SUCCESS!", new
  5341. {
  5342. dropDownType,
  5343. dropDownGroupList,
  5344. isMarketingDepartment
  5345. }));
  5346. }
  5347. else if (portType == 2 || portType == 3)
  5348. {
  5349. return Ok(JsonView(true, "SUCCESS!", new
  5350. {
  5351. dropDownType,
  5352. isMarketingDepartment
  5353. }));
  5354. }
  5355. else
  5356. {
  5357. return Ok(JsonView(false, "portType有误!"));
  5358. }
  5359. }
  5360. /// <summary>
  5361. /// 共享文件上传
  5362. /// </summary>
  5363. /// <param name="dto"></param>
  5364. /// <returns></returns>
  5365. [HttpPost]
  5366. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5367. {
  5368. var isGroup = new List<int> { 1412 };
  5369. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5370. {
  5371. return Ok(JsonView(false, "该文件需要关联团组!"));
  5372. }
  5373. if (dto.Files == null || dto.Files.Count == 0)
  5374. {
  5375. return Ok(JsonView(false, "无文件信息!"));
  5376. }
  5377. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5378. {
  5379. return Ok(JsonView(false, "文件大小超过20M!"));
  5380. }
  5381. if (dto.Userid < 1)
  5382. {
  5383. return Ok(JsonView(false, "请传入有效的Userid!"));
  5384. }
  5385. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5386. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5387. .Select((u, j) => new
  5388. {
  5389. u.CnName,
  5390. UserId = u.Id,
  5391. j.JobName,
  5392. })
  5393. .First();
  5394. if (jobInfo == null)
  5395. {
  5396. return Ok(JsonView(false, "请传入有效的Userid!"));
  5397. }
  5398. List<string> commonFileExtensions = new List<string>
  5399. {
  5400. // 文本文件
  5401. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5402. // 图片文件
  5403. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5404. // 视频文件
  5405. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5406. // 音频文件
  5407. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5408. // 压缩文件
  5409. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5410. // 数据文件
  5411. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5412. };
  5413. try
  5414. {
  5415. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5416. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5417. commonFileExtensions.AddRange(settingExtend);
  5418. }
  5419. catch (Exception)
  5420. { }
  5421. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5422. if (setdata == null)
  5423. {
  5424. return Ok(JsonView(false, "请传入有效的FileType!"));
  5425. }
  5426. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5427. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5428. if (!Directory.Exists(winPath))
  5429. {
  5430. Directory.CreateDirectory(winPath);
  5431. }
  5432. foreach (var item in dto.Files)
  5433. {
  5434. var houzui = Path.GetExtension(item.FileName);
  5435. if (!commonFileExtensions.Contains(houzui))
  5436. {
  5437. return Ok(JsonView(false, "未知后缀名称!"));
  5438. }
  5439. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5440. var saveFilePath = winPath + fileName;
  5441. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5442. {
  5443. item.CopyTo(fs);
  5444. fs.Flush();
  5445. }
  5446. var fileDetail = new Grp_GroupShareFile()
  5447. {
  5448. CreateUserId = dto.Userid,
  5449. CreateTime = DateTime.Now,
  5450. UploadJob = jobInfo.JobName,
  5451. FileName = fileName,
  5452. FileType = dto.FileType,
  5453. Diid = dto.Diid,
  5454. FilePath = winPath + fileName,
  5455. };
  5456. insertList.Add(fileDetail);
  5457. }
  5458. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5459. return Ok(JsonView(true, "保存成功!"));
  5460. }
  5461. /// <summary>
  5462. /// 查询共享文件列表
  5463. /// </summary>
  5464. /// <param name="dto"></param>
  5465. /// <returns></returns>
  5466. [HttpPost]
  5467. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5468. {
  5469. var isGroup = new List<int> { 1412 };
  5470. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5471. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5472. .And(x => x.Diid == dto.Diid)
  5473. .And(x => x.FileType == dto.FileType)
  5474. .And(x => x.IsDel == 0)
  5475. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5476. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5477. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5478. int totalCount = 0;
  5479. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5480. .Where(queryExpression.ToExpression())
  5481. .OrderBy(x => x.UploadJob)
  5482. .Select(x => new
  5483. {
  5484. x.Id,
  5485. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5486. x.FileName,
  5487. x.FileType,
  5488. x.CreateTime,
  5489. })
  5490. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5491. return Ok(JsonView(true, "SUCCESS!", new
  5492. {
  5493. FileList = dbQuery,
  5494. dto.PageSize,
  5495. dto.PageIndex,
  5496. totalCount
  5497. }));
  5498. }
  5499. /// <summary>
  5500. /// 删除共享文件模块下的指定文件
  5501. /// </summary>
  5502. /// <param name="dto"></param>
  5503. /// <returns></returns>
  5504. [HttpPost]
  5505. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5506. {
  5507. var jw = JsonView(false);
  5508. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5509. if (sing == null)
  5510. {
  5511. jw.Msg = "暂无文件信息!";
  5512. return Ok(jw);
  5513. }
  5514. if (sing.CreateUserId != dto.UserId)
  5515. {
  5516. jw.Msg = "只能删除自己上传的文件!";
  5517. return Ok(jw);
  5518. }
  5519. if (System.IO.File.Exists(sing.FilePath))
  5520. {
  5521. try
  5522. {
  5523. System.IO.File.Delete(sing.FilePath);
  5524. }
  5525. catch (Exception ex)
  5526. {
  5527. jw.Msg = "删除失败!" + ex.Message;
  5528. return Ok(jw);
  5529. }
  5530. }
  5531. sing.IsDel = 1;
  5532. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5533. sing.DeleteUserId = dto.UserId;
  5534. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5535. jw = JsonView(true, "删除成功!");
  5536. return Ok(jw);
  5537. }
  5538. #endregion
  5539. #region 团组英文资料
  5540. /// <summary>
  5541. /// 查询团组英文所有资料
  5542. /// </summary>
  5543. /// <param name="dto"></param>
  5544. /// <returns></returns>
  5545. [HttpPost]
  5546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5547. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5548. {
  5549. try
  5550. {
  5551. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5552. if (groupData.Code != 0)
  5553. {
  5554. return Ok(JsonView(false, groupData.Msg));
  5555. }
  5556. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5557. }
  5558. catch (Exception ex)
  5559. {
  5560. return Ok(JsonView(false, "程序错误!"));
  5561. throw;
  5562. }
  5563. }
  5564. /// <summary>
  5565. /// 团组英文资料操作(Status:1.新增,2.修改)
  5566. /// </summary>
  5567. /// <param name="dto"></param>
  5568. /// <returns></returns>
  5569. [HttpPost]
  5570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5571. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5572. {
  5573. try
  5574. {
  5575. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5576. if (groupData.Code != 0)
  5577. {
  5578. return Ok(JsonView(false, groupData.Msg));
  5579. }
  5580. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5581. }
  5582. catch (Exception ex)
  5583. {
  5584. return Ok(JsonView(false, "程序错误!"));
  5585. throw;
  5586. }
  5587. }
  5588. /// <summary>
  5589. /// 团组英文资料Id查询数据
  5590. /// </summary>
  5591. /// <param name="dto"></param>
  5592. /// <returns></returns>
  5593. [HttpPost]
  5594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5595. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5596. {
  5597. try
  5598. {
  5599. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5600. if (_DelegationEnData != null)
  5601. {
  5602. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5603. }
  5604. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5605. }
  5606. catch (Exception ex)
  5607. {
  5608. return Ok(JsonView(false, "程序错误!"));
  5609. throw;
  5610. }
  5611. }
  5612. /// <summary>
  5613. /// 团组英文资料删除
  5614. /// </summary>
  5615. /// <param name="dto"></param>
  5616. /// <returns></returns>
  5617. [HttpPost]
  5618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5619. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5620. {
  5621. try
  5622. {
  5623. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5624. if (!res)
  5625. {
  5626. return Ok(JsonView(false, "删除失败"));
  5627. }
  5628. return Ok(JsonView(true, "删除成功!"));
  5629. }
  5630. catch (Exception ex)
  5631. {
  5632. return Ok(JsonView(false, "程序错误!"));
  5633. throw;
  5634. }
  5635. }
  5636. #endregion
  5637. #region 导出邀请函
  5638. /// <summary>
  5639. /// 导出邀请函页面初始化
  5640. /// </summary>
  5641. /// <param name="dto"></param>
  5642. /// <returns></returns>
  5643. [HttpPost]
  5644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5645. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5646. {
  5647. try
  5648. {
  5649. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5650. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5651. if (dto.DiId == 0)
  5652. {
  5653. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5654. }
  5655. else
  5656. {
  5657. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5658. }
  5659. return Ok(JsonView(true, "查询成功!", new
  5660. {
  5661. deleClient = crm_Deles,
  5662. delegations = grp_Delegations
  5663. }));
  5664. }
  5665. catch (Exception ex)
  5666. {
  5667. return Ok(JsonView(false, "程序错误!"));
  5668. throw;
  5669. }
  5670. }
  5671. /// <summary>
  5672. /// 导出邀请函
  5673. /// </summary>
  5674. /// <param name="dto"></param>
  5675. /// <returns></returns>
  5676. [HttpPost]
  5677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5678. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5679. {
  5680. #region 参数验证
  5681. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5682. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5683. #endregion
  5684. try
  5685. {
  5686. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5687. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5688. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5689. From Grp_TourClientList tcl
  5690. Left Join
  5691. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5692. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5693. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5694. From Crm_DeleClient dc
  5695. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5696. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5697. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5698. Where dc.IsDel = 0) temp
  5699. On temp.DcId =tcl.ClientId
  5700. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5701. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5702. List<string> texts = new List<string>();
  5703. if (datas.Count != 0)
  5704. {
  5705. foreach (TourClientListDetailsView item in datas)
  5706. {
  5707. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5708. {
  5709. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5710. }
  5711. else
  5712. {
  5713. string name = item.LastName + item.FirstName;
  5714. texts.Add(name);
  5715. }
  5716. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5717. {
  5718. if (!transDic.ContainsKey(item.Job))
  5719. {
  5720. texts.Add(item.Job);
  5721. }
  5722. }
  5723. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5724. {
  5725. texts.Add(item.CompanyFullName);
  5726. }
  5727. }
  5728. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5729. if (transData.Count > 0)
  5730. {
  5731. foreach (TranslateResult item in transData)
  5732. {
  5733. if (!transDic.ContainsKey(item.Query))
  5734. {
  5735. transDic.Add(item.Query, item.Translation);
  5736. }
  5737. }
  5738. }
  5739. List<GuestList> list = new List<GuestList>();
  5740. foreach (TourClientListDetailsView dele in datas)
  5741. {
  5742. GuestList guestList = new GuestList();
  5743. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5744. {
  5745. guestList.Name = dele.Pinyin;
  5746. }
  5747. else
  5748. {
  5749. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5750. guestList.Name = Name;
  5751. }
  5752. if (dele.Sex == 0)
  5753. {
  5754. guestList.Sex = "Male";
  5755. }
  5756. else if (dele.Sex == 1)
  5757. {
  5758. guestList.Sex = "Female";
  5759. }
  5760. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5761. if (!string.IsNullOrEmpty(dele.Job))
  5762. {
  5763. guestList.Job = dele.Job;
  5764. }
  5765. list.Add(guestList);
  5766. }
  5767. //载入模板
  5768. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5769. DocumentBuilder builder = new DocumentBuilder(doc);
  5770. //获取word里所有表格
  5771. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5772. //获取所填表格的序数
  5773. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5774. var rowStart = tableOne.Rows[0]; //获取第1行
  5775. //循环赋值
  5776. for (int i = 0; i < list.Count; i++)
  5777. {
  5778. builder.MoveToCell(0, i + 1, 0, 0);
  5779. builder.Write(list[i].Name.ToString());
  5780. builder.MoveToCell(0, i + 1, 1, 0);
  5781. builder.Write(list[i].Sex.ToString());
  5782. builder.MoveToCell(0, i + 1, 2, 0);
  5783. builder.Write(list[i].DOB.ToString());
  5784. builder.MoveToCell(0, i + 1, 3, 0);
  5785. builder.Write(list[i].Job.ToString());
  5786. }
  5787. //删除多余行
  5788. while (tableOne.Rows.Count > list.Count + 1)
  5789. {
  5790. tableOne.Rows.RemoveAt(list.Count + 1);
  5791. }
  5792. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5793. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5794. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5795. doc.Save(filePath);
  5796. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5797. return Ok(JsonView(true, "操作成功!", Url));
  5798. }
  5799. else
  5800. {
  5801. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5802. }
  5803. }
  5804. catch (Exception ex)
  5805. {
  5806. return Ok(JsonView(false, ex.Message));
  5807. throw;
  5808. }
  5809. }
  5810. #endregion
  5811. #region 团组经理模块 出入境费用
  5812. /// <summary>
  5813. /// 团组模块 - 出入境费用 - 省份基础数据源
  5814. /// </summary>
  5815. /// <returns></returns>
  5816. [HttpGet]
  5817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5818. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5819. {
  5820. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5821. }
  5822. /// <summary>
  5823. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5824. /// </summary>
  5825. /// <returns></returns>
  5826. [HttpPost]
  5827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5828. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5829. {
  5830. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5831. var groupNamFirst = groupNameData.FirstOrDefault();
  5832. //SetDataInfoView
  5833. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5834. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5835. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5836. //验证城市归属并给默认值
  5837. int provinceId = 122;
  5838. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5839. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5840. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5841. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5842. return Ok(JsonView(true, "查询成功!", new
  5843. {
  5844. GroupNameData = groupNameData,
  5845. CurrencyData = _CurrencyData,
  5846. WordTypeData = wordTypeData,
  5847. ExcelTypeData = excelTypeData,
  5848. CurrencyInit = _currencyInfos,
  5849. ViewPermissionData = viewPermissionData
  5850. }));
  5851. }
  5852. /// <summary>
  5853. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5854. /// </summary>
  5855. /// <returns></returns>
  5856. [HttpGet("{provinceId}")]
  5857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5858. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5859. {
  5860. //验证城市归属并给默认值
  5861. if (provinceId < 1) provinceId = 122;
  5862. /*
  5863. * 122 四川
  5864. * 108 贵州
  5865. * 103 重庆
  5866. * 132 云南
  5867. */
  5868. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5869. return Ok(JsonView(true, "查询成功!", new
  5870. {
  5871. WordTypeData = wordTypeData,
  5872. ExcelTypeData = excelTypeData,
  5873. }));
  5874. }
  5875. /// <summary>
  5876. /// 团组模块 - 出入境费用
  5877. /// 实时汇率 tips
  5878. /// 签证费用 tips
  5879. /// 机票费用 tips
  5880. /// </summary>
  5881. /// <returns></returns>
  5882. [HttpPost]
  5883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5884. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5885. {
  5886. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5887. //默认币种显示
  5888. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5889. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5890. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  5891. return Ok(JsonView(true, "查询成功!", new
  5892. {
  5893. //GroupNameData = groupNameData.Data,
  5894. visaData = visaData.Data,
  5895. airData = airData.Data,
  5896. reteInfos = reteInfos
  5897. }));
  5898. }
  5899. /// <summary>
  5900. /// 团组模块 - 出入境费用 - Info
  5901. /// </summary>
  5902. /// <returns></returns>
  5903. [HttpPost]
  5904. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5906. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5907. {
  5908. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5909. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5910. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5911. }
  5912. /// <summary>
  5913. /// 团组模块 - 出入境费用 - 设置view权限
  5914. /// </summary>
  5915. /// <returns></returns>
  5916. [HttpPost]
  5917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5918. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5919. {
  5920. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5921. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5922. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5923. var permissions = new List<Grp_EnterExitCostPermission>();
  5924. foreach (var userId in dto.UserIds)
  5925. {
  5926. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5927. }
  5928. if (permissions.Any())
  5929. {
  5930. _sqlSugar.BeginTran();
  5931. try
  5932. {
  5933. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5934. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5935. if (result < 1)
  5936. {
  5937. _sqlSugar.RollbackTran();
  5938. return Ok(JsonView(false));
  5939. }
  5940. }
  5941. catch (Exception ex)
  5942. {
  5943. _sqlSugar.RollbackTran();
  5944. return Ok(JsonView(false, ex.Message));
  5945. }
  5946. _sqlSugar.CommitTran();
  5947. return Ok(JsonView(true));
  5948. }
  5949. return Ok(JsonView(false));
  5950. }
  5951. /// <summary>
  5952. /// 团组模块 - 出入境费用 - Add And Update
  5953. /// </summary>
  5954. /// <returns></returns>
  5955. [HttpPost]
  5956. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5958. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5959. {
  5960. try
  5961. {
  5962. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5963. if (dto.DayOtherPriceData.Any())
  5964. {
  5965. var inserList = dto.DayOtherPriceData
  5966. .Where(x => x.Id == 0)
  5967. .Select(x => new Grp_DayOtherPrice
  5968. {
  5969. Cost = x.Cost,
  5970. Id = x.Id,
  5971. CreateTime = DateTime.Now,
  5972. CreateUserId = dto.UserId,
  5973. Currency = x.Currency,
  5974. Diid = x.DiId,
  5975. Index = x.Index,
  5976. IsDel = 0,
  5977. SetDataId = x.SetDataId,
  5978. SubTotal = x.SubTotal,
  5979. Remark = x.Remark
  5980. })
  5981. .ToList();
  5982. var updateList = dto.DayOtherPriceData
  5983. .Where(x => x.Id != 0)
  5984. .Select(x => new Grp_DayOtherPrice
  5985. {
  5986. Cost = x.Cost,
  5987. Id = x.Id,
  5988. CreateTime = DateTime.Now,
  5989. CreateUserId = dto.UserId,
  5990. Currency = x.Currency,
  5991. Diid = x.DiId,
  5992. Index = x.Index,
  5993. IsDel = 0,
  5994. SetDataId = x.SetDataId,
  5995. SubTotal = x.SubTotal,
  5996. Remark = x.Remark
  5997. })
  5998. .ToList();
  5999. //添加
  6000. _sqlSugar.BeginTran();
  6001. if (inserList.Any())
  6002. {
  6003. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6004. }
  6005. if (updateList.Any())
  6006. {
  6007. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6008. }
  6009. _sqlSugar.CommitTran();
  6010. }
  6011. if (data.Code != 0)
  6012. {
  6013. return Ok(JsonView(false, data.Msg));
  6014. }
  6015. //生成默认文件pdf并且通知人员
  6016. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6017. {
  6018. DiId = dto.DiId,
  6019. ExportType = 1,
  6020. SubTypeId = 1005
  6021. }, "pdf");
  6022. //发送通知
  6023. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6024. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6025. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6026. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6027. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6028. //汇率信息记录
  6029. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6030. return Ok(JsonView(true, data.Msg, data.Data));
  6031. }
  6032. catch (Exception ex)
  6033. {
  6034. return Ok(JsonView(false, ex.Message));
  6035. }
  6036. }
  6037. /// <summary>
  6038. /// 团组模块 - 出入境费用 - Confirm 费用
  6039. /// </summary>
  6040. /// <returns></returns>
  6041. [HttpPost]
  6042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6043. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6044. {
  6045. //TODO:测试完毕需把对应的用户ID更改
  6046. //1、数据表添加字段
  6047. //2、更改字段接口()
  6048. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6049. //3、确认成功 给财务发送消息
  6050. if (_view.Code == 200)
  6051. {
  6052. if (dto.Type == 1)
  6053. {
  6054. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6055. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6056. }
  6057. }
  6058. return Ok(_view);
  6059. }
  6060. /// <summary>
  6061. /// 团组模块 - 出入境费用 - File download
  6062. /// </summary>
  6063. /// <param name="dto"></param>
  6064. /// <returns></returns>
  6065. [HttpPost]
  6066. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6068. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6069. {
  6070. try
  6071. {
  6072. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6073. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6074. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6075. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6076. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6077. 3 团组成员名单 1 团组成员名单", ""));
  6078. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6079. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6080. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6081. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6082. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6083. //数据源
  6084. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6085. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6086. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6087. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6088. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6089. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6090. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6091. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6092. .Select((x, a, b) => new
  6093. {
  6094. x.Index,
  6095. itemName = a.Name,
  6096. CurrencyStr = b.Name,
  6097. x.Cost,
  6098. x.SubTotal,
  6099. x.Remark
  6100. })
  6101. .OrderBy((x) => x.Index)
  6102. .ToList(); //其他款项费用
  6103. var peiceItemCurrencys = new List<string>();
  6104. if (_DayAndCosts.Any())
  6105. {
  6106. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6107. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6108. }
  6109. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6110. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6111. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6112. {
  6113. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6114. }
  6115. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6116. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6117. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6118. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6119. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6120. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6121. .Select((tcl, dc, cc) => new ClientInfo
  6122. {
  6123. LastName = dc.LastName,
  6124. FirstName = dc.FirstName,
  6125. Sex = dc.Sex,
  6126. Birthday = dc.BirthDay,
  6127. Company = cc.CompanyFullName,
  6128. Job = dc.Job
  6129. })
  6130. .ToList();
  6131. foreach (var item in DeleClientList)
  6132. {
  6133. EncryptionProcessor.DecryptProperties(item);
  6134. }
  6135. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6136. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6137. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6138. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6139. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6140. if (dto.ExportType == 1) //明细表
  6141. {
  6142. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6143. {
  6144. //获取模板
  6145. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6146. //载入模板
  6147. Document doc = new Document(tempPath);
  6148. DocumentBuilder builder = new DocumentBuilder(doc);
  6149. //利用键值对存放数据
  6150. Dictionary<string, string> dic = new Dictionary<string, string>();
  6151. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6152. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6153. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6154. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6155. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6156. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6157. //境内费用(其他费用)
  6158. if (_EnterExitCosts.ChoiceOne == 1)
  6159. {
  6160. string row1_1 = "";
  6161. if (_EnterExitCosts.Visa > 0)
  6162. {
  6163. //insidePayTotal += _EnterExitCosts.Visa;
  6164. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6165. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6166. //{
  6167. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6168. //}
  6169. }
  6170. string row1_2 = "";
  6171. if (_EnterExitCosts.YiMiao > 0)
  6172. {
  6173. //insidePayTotal += _EnterExitCosts.YiMiao;
  6174. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6175. }
  6176. if (_EnterExitCosts.HeSuan > 0)
  6177. {
  6178. //insidePayTotal += _EnterExitCosts.HeSuan;
  6179. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6180. }
  6181. if (_EnterExitCosts.Service > 0)
  6182. {
  6183. //insidePayTotal += _EnterExitCosts.Service;
  6184. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6185. }
  6186. string row1_3 = "";
  6187. if (_EnterExitCosts.Safe > 0)
  6188. {
  6189. //insidePayTotal += _EnterExitCosts.Safe;
  6190. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6191. }
  6192. if (_EnterExitCosts.Ticket > 0)
  6193. {
  6194. //insidePayTotal += _EnterExitCosts.Ticket;
  6195. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6196. }
  6197. string row1 = "";
  6198. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6199. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6200. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6201. row1 += $"备注:{_EnterExitCosts.Remark}";
  6202. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6203. dic.Add("Row1Str", row1);
  6204. }
  6205. string airTotalStr = string.Empty,
  6206. airPriceStr = string.Empty;
  6207. //经济舱
  6208. if (_EnterExitCosts.SumJJC == 1)
  6209. {
  6210. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6211. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6212. }
  6213. //公务舱
  6214. if (_EnterExitCosts.SumGWC == 1)
  6215. {
  6216. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6217. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6218. }
  6219. //头等舱
  6220. if (_EnterExitCosts.SumTDC == 1)
  6221. {
  6222. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6223. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6224. }
  6225. //汇率描述
  6226. string rateStr = "";
  6227. if (peiceItemCurrencyInfos.Any())
  6228. {
  6229. rateStr = "\r\n汇率描述:";
  6230. foreach (var item in peiceItemCurrencyInfos)
  6231. {
  6232. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6233. }
  6234. }
  6235. string twoItemRemark = "备注:";
  6236. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6237. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6238. dic.Add("AirTotalStr", airTotalStr);
  6239. dic.Add("AirPriceStr", airPriceStr);
  6240. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6241. dic.Add("TwoItemRemark", twoItemRemark);
  6242. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6243. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6244. int table1Row = 0,
  6245. table2Row = 0,
  6246. table3Row = 0,
  6247. table4Row = 0,
  6248. table5Row = 0;
  6249. //住宿费
  6250. if (_EnterExitCosts.ChoiceThree == 1)
  6251. {
  6252. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6253. table1Row = dac1.Count;
  6254. #region 填充word表格内容
  6255. for (int i = 0; i < dac1.Count; i++)
  6256. {
  6257. Grp_DayAndCost dac = dac1[i];
  6258. if (dac == null) continue;
  6259. builder.MoveToCell(0, i, 0, 0);
  6260. builder.Write("第" + dac.Days.ToString() + "晚:");
  6261. builder.MoveToCell(0, i, 1, 0);
  6262. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6263. //builder.Write(dac.Place == null ? "" : dac.Place);
  6264. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6265. builder.MoveToCell(0, i, 2, 0);
  6266. builder.Write("费用标准:");
  6267. string curr = "";
  6268. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6269. if (currData != null)
  6270. {
  6271. curr = currData.Name;
  6272. }
  6273. builder.MoveToCell(0, i, 3, 0);
  6274. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6275. builder.MoveToCell(0, i, 4, 0);
  6276. builder.Write("费用小计:");
  6277. builder.MoveToCell(0, i, 5, 0);
  6278. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6279. }
  6280. #endregion
  6281. }
  6282. else dic.Add("SubZS", "0.00");
  6283. //删除多余行
  6284. while (table1.Rows.Count > table1Row)
  6285. {
  6286. table1.Rows.RemoveAt(table1Row);
  6287. }
  6288. //伙食费
  6289. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6290. if (_EnterExitCosts.ChoiceFour == 1)
  6291. {
  6292. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6293. table2Row = dac2.Count;
  6294. #region 填充word表格内容
  6295. for (int i = 0; i < dac2.Count; i++)
  6296. {
  6297. Grp_DayAndCost dac = dac2[i];
  6298. if (dac == null) continue;
  6299. builder.MoveToCell(1, i, 0, 0);
  6300. builder.Write("第" + dac.Days.ToString() + "天:");
  6301. builder.MoveToCell(1, i, 1, 0);
  6302. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6303. builder.MoveToCell(1, i, 2, 0);
  6304. builder.Write("费用标准:");
  6305. string curr = "";
  6306. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6307. if (currData != null)
  6308. {
  6309. curr = currData.Name;
  6310. }
  6311. builder.MoveToCell(1, i, 3, 0);
  6312. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6313. builder.MoveToCell(1, i, 4, 0);
  6314. builder.Write("费用小计:");
  6315. builder.MoveToCell(1, i, 5, 0);
  6316. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6317. }
  6318. #endregion
  6319. }
  6320. else dic.Add("SubHS", "0.00");
  6321. //删除多余行
  6322. while (table2.Rows.Count > table2Row)
  6323. {
  6324. table2.Rows.RemoveAt(table2Row);
  6325. }
  6326. //公杂费
  6327. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6328. if (_EnterExitCosts.ChoiceFive == 1)
  6329. {
  6330. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6331. table3Row = dac3.Count;
  6332. #region 填充word表格内容
  6333. for (int i = 0; i < dac3.Count; i++)
  6334. {
  6335. Grp_DayAndCost dac = dac3[i];
  6336. if (dac == null) continue;
  6337. builder.MoveToCell(2, i, 0, 0);
  6338. builder.Write("第" + dac.Days.ToString() + "天:");
  6339. builder.MoveToCell(2, i, 1, 0);
  6340. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6341. builder.MoveToCell(2, i, 2, 0);
  6342. builder.Write("费用标准:");
  6343. string curr = "";
  6344. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6345. if (currData != null)
  6346. {
  6347. curr = currData.Name;
  6348. }
  6349. builder.MoveToCell(2, i, 3, 0);
  6350. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6351. builder.MoveToCell(2, i, 4, 0);
  6352. builder.Write("费用小计:");
  6353. builder.MoveToCell(2, i, 5, 0);
  6354. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6355. }
  6356. //删除多余行
  6357. while (table3.Rows.Count > table3Row)
  6358. {
  6359. table3.Rows.RemoveAt(table3Row);
  6360. }
  6361. #endregion
  6362. }
  6363. else dic.Add("SubGZF", "0.00");
  6364. //删除多余行
  6365. while (table3.Rows.Count > table3Row)
  6366. {
  6367. table3.Rows.RemoveAt(table3Row);
  6368. }
  6369. //培训费
  6370. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6371. if (_EnterExitCosts.ChoiceSix == 1)
  6372. {
  6373. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6374. dic.Add("SubPX", pxStr);
  6375. table4Row = dac4.Count;
  6376. #region 填充word表格内容
  6377. for (int i = 0; i < dac4.Count; i++)
  6378. {
  6379. Grp_DayAndCost dac = dac4[i];
  6380. if (dac == null) continue;
  6381. builder.MoveToCell(3, i, 0, 0);
  6382. builder.Write("第" + dac.Days.ToString() + "天:");
  6383. builder.MoveToCell(3, i, 1, 0);
  6384. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6385. builder.MoveToCell(3, i, 2, 0);
  6386. builder.Write("费用标准:");
  6387. string curr = "";
  6388. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6389. if (currData != null)
  6390. {
  6391. curr = currData.Name;
  6392. }
  6393. builder.MoveToCell(3, i, 3, 0);
  6394. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6395. builder.MoveToCell(3, i, 4, 0);
  6396. builder.Write("费用小计:");
  6397. builder.MoveToCell(3, i, 5, 0);
  6398. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6399. }
  6400. #endregion
  6401. }
  6402. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6403. //删除多余行
  6404. while (table4.Rows.Count > table4Row)
  6405. {
  6406. table4.Rows.RemoveAt(table4Row);
  6407. }
  6408. //其他费用
  6409. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6410. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6411. {
  6412. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6413. dic.Add("titleQi", qtStr);
  6414. table5Row = dac5.Count;
  6415. #region 填充word表格内容
  6416. for (int i = 0; i < dac5.Count; i++)
  6417. {
  6418. var dac = dac5[i];
  6419. if (dac == null) continue;
  6420. builder.MoveToCell(4, i, 0, 0);
  6421. builder.Write("第" + dac.Index.ToString() + "项:");
  6422. builder.MoveToCell(4, i, 1, 0);
  6423. builder.Write(dac.itemName);
  6424. builder.MoveToCell(4, i, 2, 0);
  6425. builder.Write("费用标准:");
  6426. builder.MoveToCell(4, i, 3, 0);
  6427. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6428. builder.MoveToCell(4, i, 4, 0);
  6429. builder.Write("费用小计:");
  6430. builder.MoveToCell(4, i, 5, 0);
  6431. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6432. builder.MoveToCell(4, i, 6, 0);
  6433. builder.Write("备注:");
  6434. builder.MoveToCell(4, i, 7, 0);
  6435. builder.Write(dac.Remark);
  6436. }
  6437. #endregion
  6438. }
  6439. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6440. //删除多余行
  6441. while (table5.Rows.Count > table5Row)
  6442. {
  6443. table5.Rows.RemoveAt(table5Row);
  6444. }
  6445. //加上其他费用
  6446. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6447. decimal subJJC = 0.00M,
  6448. subGWC = 0.00M,
  6449. subTDC = 0.00M;
  6450. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6451. string totalLabel = string.Format("全部费用总计:");
  6452. //经济舱
  6453. if (_EnterExitCosts.SumJJC == 1)
  6454. {
  6455. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6456. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6457. }
  6458. //公务舱
  6459. if (_EnterExitCosts.SumGWC == 1)
  6460. {
  6461. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6462. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6463. }
  6464. //头等舱
  6465. if (_EnterExitCosts.SumTDC == 1)
  6466. {
  6467. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6468. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6469. }
  6470. //TotalLabel
  6471. dic.Add("TotalLabel", totalLabel);
  6472. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6473. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6474. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6475. #region 填充word模板书签内容
  6476. foreach (var key in dic.Keys)
  6477. {
  6478. Bookmark bookmark = doc.Range.Bookmarks[key];
  6479. if (bookmark != null)
  6480. {
  6481. builder.MoveToBookmark(key);
  6482. builder.Write(dic[key]);
  6483. }
  6484. }
  6485. #endregion
  6486. #region 设置页眉
  6487. string userLabel = string.Empty;
  6488. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6489. if (currUserInfo != null)
  6490. {
  6491. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6492. if (userInfo != null)
  6493. {
  6494. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6495. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6496. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6497. }
  6498. }
  6499. //设置页脚
  6500. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6501. #endregion
  6502. //文件名
  6503. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6504. AsposeHelper.removewatermark_v2180();
  6505. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6506. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6507. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6508. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6509. }
  6510. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6511. {
  6512. //获取模板
  6513. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6514. //载入模板
  6515. Document doc = new Document(tempPath);
  6516. DocumentBuilder builder = new DocumentBuilder(doc);
  6517. Dictionary<string, string> dic = new Dictionary<string, string>();
  6518. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6519. {
  6520. List<string> list = new List<string>();
  6521. try
  6522. {
  6523. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6524. foreach (var item in spilitArr)
  6525. {
  6526. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6527. var depCode = spDotandEmpty[2].Substring(0, 3);
  6528. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6529. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6530. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6531. list.Add(depName);
  6532. list.Add(arrName);
  6533. }
  6534. list = list.Distinct().ToList();
  6535. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6536. }
  6537. catch (Exception)
  6538. {
  6539. dic.Add("ReturnCode", "行程录入不正确!");
  6540. }
  6541. }
  6542. else
  6543. {
  6544. dic.Add("ReturnCode", "未录入行程!");
  6545. }
  6546. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6547. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6548. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6549. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6550. {
  6551. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6552. dic.Add("Day", sp.Days.ToString());
  6553. }
  6554. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6555. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6556. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6557. //dic.Add("Names", Names);
  6558. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6559. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6560. decimal dac1totalPrice = 0.00M;
  6561. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6562. foreach (var dac in dac1)
  6563. {
  6564. if (dac.SubTotal == 0.00M)
  6565. {
  6566. continue;
  6567. }
  6568. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6569. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6570. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6571. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6572. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6573. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6574. builder.Write(currency);//币种
  6575. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6576. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6577. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6578. builder.Write("");//人数
  6579. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6580. builder.Write("");//天数
  6581. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6582. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6583. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6584. decimal rate = 0.00M;
  6585. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6586. builder.Write(rate.ToString("#0.0000"));//汇率
  6587. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6588. decimal rbmPrice = dac.SubTotal;
  6589. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6590. accommodationStartIndex++;
  6591. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6592. }
  6593. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6594. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6595. {
  6596. table1.Rows.RemoveAt(i - 1);
  6597. foodandotherStartIndex--;
  6598. }
  6599. if (dac2.Count == dac3.Count)//国家 币种 金额
  6600. {
  6601. for (int i = 0; i < dac2.Count; i++)
  6602. {
  6603. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6604. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6605. }
  6606. }
  6607. decimal dac2totalPrice = 0.00M;
  6608. foreach (var dac in dac2)
  6609. {
  6610. if (dac.SubTotal == 0)
  6611. {
  6612. continue;
  6613. }
  6614. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6615. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6616. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6617. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6618. builder.Write(currency);//币种
  6619. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6620. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6621. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6622. builder.Write("");//人数
  6623. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6624. builder.Write("");//天数
  6625. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6626. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6627. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6628. decimal rate = 0.00M;
  6629. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6630. builder.Write(rate.ToString("#0.0000"));//汇率
  6631. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6632. decimal rbmPrice = dac.SubTotal;
  6633. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6634. foodandotherStartIndex++;
  6635. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6636. }
  6637. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6638. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6639. {
  6640. table1.Rows.RemoveAt(i - 1);
  6641. }
  6642. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6643. string otherFeeStr = "";
  6644. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6645. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6646. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6647. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6648. foreach (var otherInfo in dac5)
  6649. {
  6650. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6651. }
  6652. #endregion
  6653. if (otherFeeStr.Length > 0)
  6654. {
  6655. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6656. otherFeeStr = $"({otherFeeStr})";
  6657. dic.Add("OtherFeeStr", otherFeeStr);
  6658. }
  6659. //总计
  6660. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6661. //国际旅费
  6662. string outsideAir = string.Empty;
  6663. string allPriceAir = string.Empty;
  6664. if (_EnterExitCosts.SumJJC == 1)
  6665. {
  6666. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6667. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6668. }
  6669. if (_EnterExitCosts.SumGWC == 1)
  6670. {
  6671. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6672. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6673. }
  6674. if (_EnterExitCosts.SumTDC == 1)
  6675. {
  6676. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6677. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6678. }
  6679. dic.Add("InTravelPrice", $"({outsideAir})");
  6680. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6681. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6682. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6683. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6684. foreach (var key in dic.Keys)
  6685. {
  6686. builder.MoveToBookmark(key);
  6687. builder.Write(dic[key]);
  6688. }
  6689. //模板文件名
  6690. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6691. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6692. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6693. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6694. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6695. }
  6696. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6697. {
  6698. //获取模板
  6699. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6700. //载入模板
  6701. WorkbookDesigner designer = new WorkbookDesigner();
  6702. designer.Workbook = new Workbook(tempPath);
  6703. Dictionary<string, string> dic = new Dictionary<string, string>();
  6704. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6705. {
  6706. List<string> list = new List<string>();
  6707. try
  6708. {
  6709. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6710. foreach (var item in spilitArr)
  6711. {
  6712. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6713. var depCode = spDotandEmpty[2].Substring(0, 3);
  6714. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6715. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6716. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6717. list.Add(depName);
  6718. list.Add(arrName);
  6719. }
  6720. list = list.Distinct().ToList();
  6721. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6722. }
  6723. catch (Exception)
  6724. {
  6725. dic.Add("ReturnCode", "行程录入不正确!");
  6726. }
  6727. }
  6728. else
  6729. {
  6730. dic.Add("ReturnCode", "未录入行程!");
  6731. }
  6732. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6733. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6734. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6735. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6736. {
  6737. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6738. dic.Add("Day", sp.Days.ToString());
  6739. }
  6740. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6741. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6742. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6743. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6744. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6745. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6746. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6747. designer.SetDataSource("Name", Names);
  6748. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6749. designer.SetDataSource("Day", dic["Day"] + "天");
  6750. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6751. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6752. int startIndex = 10;
  6753. const int startIndexcopy = 10;
  6754. if (dac2.Count == dac3.Count)//国家 币种 金额
  6755. {
  6756. for (int i = 0; i < dac2.Count; i++)
  6757. {
  6758. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6759. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6760. }
  6761. }
  6762. DataTable dtdac1 = new DataTable();
  6763. List<string> place = new List<string>();
  6764. dtdac1.Columns.AddRange(new DataColumn[] {
  6765. new DataColumn(){ ColumnName = "city"},
  6766. new DataColumn(){ ColumnName = "curr"},
  6767. new DataColumn(){ ColumnName = "criterion"},
  6768. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6769. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6770. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6771. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6772. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6773. });
  6774. DataTable dtdac2 = new DataTable();
  6775. dtdac2.Columns.AddRange(new DataColumn[] {
  6776. new DataColumn(){ ColumnName = "city"},
  6777. new DataColumn(){ ColumnName = "curr"},
  6778. new DataColumn(){ ColumnName = "criterion"},
  6779. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6780. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6781. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6782. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6783. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6784. });
  6785. dtdac1.TableName = "tb1";
  6786. dtdac2.TableName = "tb2";
  6787. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6788. foreach (var item in dac1)
  6789. {
  6790. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6791. if (place.Contains(item.Place))
  6792. {
  6793. continue;
  6794. }
  6795. DataRow row = dtdac1.NewRow();
  6796. row["city"] = item.Place;
  6797. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6798. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6799. row["curr"] = currency;
  6800. row["rate"] = rate.ToString("#0.0000");
  6801. row["criterion"] = item.Cost.ToString("#0.00");
  6802. row["number"] = 1;
  6803. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6804. //row["costRMB"] = rbmPrice;
  6805. dtdac1.Rows.Add(row);
  6806. place.Add(item.Place);
  6807. }
  6808. place = new List<string>();
  6809. foreach (var item in dac2)
  6810. {
  6811. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6812. if (place.Contains(item.Place))
  6813. {
  6814. continue;
  6815. }
  6816. DataRow row = dtdac2.NewRow();
  6817. row["city"] = item.Place;
  6818. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6819. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6820. row["curr"] = currency;
  6821. row["rate"] = rate.ToString("#0.0000");
  6822. row["criterion"] = item.Cost.ToString("#0.00");
  6823. row["number"] = 1;
  6824. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6825. //row["cost"] = item.SubTotal;
  6826. //row["costRMB"] = rbmPrice;
  6827. dtdac2.Rows.Add(row);
  6828. place.Add(item.Place);
  6829. //dac2totalPrice += rbmPrice;
  6830. }
  6831. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6832. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6833. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6834. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6835. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6836. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6837. string cell4Str1 = string.Empty;
  6838. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6839. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6840. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6841. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6842. string cellStr = $" 5.其他费用(";
  6843. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6844. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6845. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6846. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6847. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6848. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6849. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6850. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6851. foreach (var otherInfo in dac5)
  6852. {
  6853. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6854. }
  6855. #endregion
  6856. if (cellStr.Length > 8)
  6857. {
  6858. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6859. }
  6860. cellStr += ")";
  6861. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6862. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6863. decimal pxFee = dac4.Sum(it => it.Cost);
  6864. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6865. string celllastStr1 = "";
  6866. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6867. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6868. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6869. celllastStr1 += $",国际旅费 元";
  6870. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6871. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6872. designer.SetDataSource("cell4Str", cell4Str);
  6873. designer.SetDataSource("cellStr", cellStr);
  6874. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6875. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6876. designer.SetDataSource("celllastStr", celllastStr);
  6877. Workbook wb = designer.Workbook;
  6878. var sheet = wb.Worksheets[0];
  6879. //绑定datatable数据集
  6880. designer.SetDataSource(dtdac1);
  6881. designer.SetDataSource(dtdac2);
  6882. designer.Process();
  6883. var rowStart = dtdac1.Rows.Count;
  6884. while (rowStart > 0)
  6885. {
  6886. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6887. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6888. startIndex++;
  6889. rowStart--;
  6890. }
  6891. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6892. startIndex += 1; //总计行
  6893. rowStart = dtdac2.Rows.Count;
  6894. while (rowStart > 0)
  6895. {
  6896. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6897. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6898. startIndex++;
  6899. rowStart--;
  6900. }
  6901. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6902. wb.CalculateFormula(true);
  6903. //模板文件名
  6904. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6905. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6906. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6907. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6908. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6909. }
  6910. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6911. {
  6912. //获取模板
  6913. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6914. //载入模板
  6915. Document doc = new Document(tempPath);
  6916. DocumentBuilder builder = new DocumentBuilder(doc);
  6917. Dictionary<string, string> dic = new Dictionary<string, string>();
  6918. dic.Add("GroupName", _DelegationInfo.TeamName);
  6919. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6920. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6921. string missionLeaderJob = "";//负责人job
  6922. //int groupNumber = 0; //团人数
  6923. if (DeleClientList.Count > 0)
  6924. {
  6925. missionLeader = DeleClientList[0]?.Name ?? "";
  6926. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6927. }
  6928. dic.Add("MissionLeader", missionLeader); //团负责人
  6929. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6930. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6931. #region MyRegion
  6932. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6933. //{
  6934. // List<string> list = new List<string>();
  6935. // try
  6936. // {
  6937. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6938. // foreach (var item in spilitArr)
  6939. // {
  6940. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6941. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6942. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6943. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6944. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6945. // list.Add(depName);
  6946. // list.Add(arrName);
  6947. // }
  6948. // list = list.Distinct().ToList();
  6949. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6950. // }
  6951. // catch (Exception)
  6952. // {
  6953. // dic.Add("ReturnCode", "行程录入不正确!");
  6954. // }
  6955. //}
  6956. //else
  6957. //{
  6958. // dic.Add("ReturnCode", "未录入行程!");
  6959. //}
  6960. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6961. dic.Add("ReturnCode", string.Join("、", countrys));
  6962. #endregion
  6963. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6964. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6965. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6966. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6967. //{
  6968. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6969. // dic.Add("Day", sp.Days.ToString());
  6970. //}
  6971. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6972. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6973. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6974. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6975. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6976. //培训人员名单
  6977. int cultivateRowIndex = 7;
  6978. foreach (var item in DeleClientList)
  6979. {
  6980. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6981. builder.Write(item.Name);
  6982. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6983. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6984. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6985. string birthDay = "";
  6986. if (item.Birthday != null)
  6987. {
  6988. DateTime dt = Convert.ToDateTime(item.Birthday);
  6989. birthDay = $"{dt.Year}.{dt.Month}";
  6990. }
  6991. builder.Write(birthDay);
  6992. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6993. builder.Write(item.Company);
  6994. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6995. builder.Write(item.Job);
  6996. cultivateRowIndex++;
  6997. }
  6998. //删除多余行
  6999. //cultivateRowIndex -= 2;
  7000. int delRows = 10 + 7 - cultivateRowIndex;
  7001. if (delRows > 0)
  7002. {
  7003. for (int i = 0; i < delRows; i++)
  7004. {
  7005. table1.Rows.RemoveAt(cultivateRowIndex);
  7006. //cultivateRowIndex++;
  7007. }
  7008. }
  7009. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7010. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7011. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7012. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7013. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7014. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7015. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7016. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7017. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7018. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7019. //其他费用
  7020. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7021. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7022. //其他费用合计
  7023. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7024. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7025. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7026. //公务舱合计
  7027. //国际旅费
  7028. //string outsideJJ = "";
  7029. //string allPriceJJ = "";
  7030. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7031. {
  7032. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7033. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7034. }
  7035. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7036. {
  7037. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7038. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7039. }
  7040. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7041. {
  7042. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7043. dic.Add("AirFeeTotal", airFeeTotalStr);
  7044. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7045. dic.Add("FeeTotal", feeTotalStr);
  7046. }
  7047. foreach (var key in dic.Keys)
  7048. {
  7049. builder.MoveToBookmark(key);
  7050. builder.Write(dic[key]);
  7051. }
  7052. //模板文件名
  7053. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7054. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7055. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7056. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7057. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7058. }
  7059. }
  7060. else if (dto.ExportType == 2) //表格
  7061. {
  7062. //利用键值对存放数据
  7063. Dictionary<string, string> dic = new Dictionary<string, string>();
  7064. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7065. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7066. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7067. dic.Add("Day", sp.Days.ToString());
  7068. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7069. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7070. {
  7071. //获取模板
  7072. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7073. //载入模板
  7074. Document doc = new Document(tempPath);
  7075. DocumentBuilder builder = new DocumentBuilder(doc);
  7076. dic.Add("TeamName", _DelegationInfo.TeamName);
  7077. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7078. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7079. string missionLeaderName = "",
  7080. missionLeaderJob = "";
  7081. if (DeleClientList.Count > 0)
  7082. {
  7083. missionLeaderName = DeleClientList[0].Name;
  7084. missionLeaderJob = DeleClientList[0].Job;
  7085. }
  7086. dic.Add("MissionLeaderName", missionLeaderName);
  7087. dic.Add("MissionLeaderJob", missionLeaderJob);
  7088. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7089. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7090. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7091. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7092. int rowCount = 10;//总人数行
  7093. int startRowIndex = 7; //起始行
  7094. for (int i = 0; i < DeleClientList.Count; i++)
  7095. {
  7096. builder.MoveToCell(0, startRowIndex, 0, 0);
  7097. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7098. builder.MoveToCell(0, startRowIndex, 1, 0);
  7099. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7100. builder.Write(sex);//性别
  7101. builder.MoveToCell(0, startRowIndex, 2, 0);
  7102. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7103. builder.MoveToCell(0, startRowIndex, 3, 0);
  7104. builder.Write(DeleClientList[i].Company);//工作单位
  7105. builder.MoveToCell(0, startRowIndex, 4, 0);
  7106. builder.Write(DeleClientList[i].Job);//职务及级别
  7107. builder.MoveToCell(0, startRowIndex, 5, 0);
  7108. builder.Write("");//人员属性
  7109. builder.MoveToCell(0, startRowIndex, 6, 0);
  7110. builder.Write("");//上次出国时间
  7111. startRowIndex++;
  7112. }
  7113. int nullRow = rowCount - DeleClientList.Count;//空行
  7114. for (int i = 0; i < nullRow; i++)
  7115. {
  7116. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7117. }
  7118. foreach (var key in dic.Keys)
  7119. {
  7120. builder.MoveToBookmark(key);
  7121. builder.Write(dic[key]);
  7122. }
  7123. //模板文件名
  7124. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7125. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7126. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7127. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7128. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7129. }
  7130. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7131. {
  7132. //获取模板
  7133. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7134. //载入模板
  7135. Document doc = new Document(tempPath);
  7136. DocumentBuilder builder = new DocumentBuilder(doc);
  7137. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7138. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7139. dic.Add("Names", Names);
  7140. int accommodationRows = 12;
  7141. //int foodandotherRows = 12;
  7142. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7143. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7144. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7145. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7146. int accommodationStartIndex = 6;
  7147. decimal dac1totalPrice = 0.00M;
  7148. foreach (var dac in dac1)
  7149. {
  7150. if (dac.SubTotal == 0)
  7151. {
  7152. continue;
  7153. }
  7154. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7155. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7156. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7157. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7158. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7159. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7160. builder.Write(currency);//币种
  7161. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7162. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7163. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7164. builder.Write("");//人数
  7165. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7166. builder.Write("");//天数
  7167. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7168. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7169. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7170. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7171. builder.Write(rate.ToString("#0.0000"));//汇率
  7172. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7173. decimal rbmPrice = rate * dac.SubTotal;
  7174. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7175. accommodationStartIndex++;
  7176. dac1totalPrice += rbmPrice;
  7177. }
  7178. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7179. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7180. builder.Write("小计");
  7181. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7182. builder.Write(dac1totalPrice.ToString("#0.00"));
  7183. accommodationStartIndex++;
  7184. int nullRow = accommodationRows - dac1.Count;
  7185. //删除空行
  7186. //if (nullRow > 0)
  7187. //{
  7188. // int rowIndex = accommodationStartIndex;
  7189. // for (int i = 0; i < nullRow; i++)
  7190. // {
  7191. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7192. // row.Remove();
  7193. // rowIndex++;
  7194. // }
  7195. //}
  7196. if (dac2.Count == dac3.Count)//国家 币种 金额
  7197. {
  7198. for (int i = 0; i < dac2.Count; i++)
  7199. {
  7200. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7201. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7202. }
  7203. }
  7204. int foodandotherStartIndex = 19;//
  7205. decimal dac2totalPrice = 0.00M;
  7206. foreach (var dac in dac2)
  7207. {
  7208. if (dac.SubTotal == 0)
  7209. {
  7210. continue;
  7211. }
  7212. //foodandotherStartIndex = 12;
  7213. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7214. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7215. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7216. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7217. builder.Write(currency);//币种
  7218. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7219. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7220. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7221. builder.Write("");//人数
  7222. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7223. builder.Write("");//天数
  7224. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7225. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7226. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7227. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7228. builder.Write(rate.ToString("#0.0000"));//汇率
  7229. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7230. decimal rbmPrice = rate * dac.SubTotal;
  7231. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7232. foodandotherStartIndex++;
  7233. dac2totalPrice += rbmPrice;
  7234. }
  7235. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7236. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7237. //删除空行
  7238. //if (dac2.Count < foodandotherRows)
  7239. //{
  7240. // while (table2.Rows.Count > dac2.Count)
  7241. // {
  7242. // table2.Rows.RemoveAt(dac2.Count);
  7243. // }
  7244. //}
  7245. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7246. string otherFeeStr = "";
  7247. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7248. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7249. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7250. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7251. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7252. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7253. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7254. foreach (var otherInfo in dac5)
  7255. {
  7256. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7257. }
  7258. #endregion
  7259. if (otherFeeStr.Length > 0)
  7260. {
  7261. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7262. otherFeeStr = $"({otherFeeStr})";
  7263. dic.Add("OtherFeeStr", otherFeeStr);
  7264. }
  7265. foreach (var key in dic.Keys)
  7266. {
  7267. builder.MoveToBookmark(key);
  7268. builder.Write(dic[key]);
  7269. }
  7270. //模板文件名
  7271. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7272. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7273. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7274. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7275. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7276. }
  7277. }
  7278. else if (dto.ExportType == 3)
  7279. {
  7280. if (dto.SubTypeId == 1) //团组成员名单
  7281. {
  7282. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7283. //获取模板
  7284. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7285. //载入模板
  7286. Document doc = new Document(tempPath);
  7287. DocumentBuilder builder = new DocumentBuilder(doc);
  7288. //获取word里所有表格
  7289. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7290. //获取所填表格的序数
  7291. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7292. var rowStart = tableOne.Rows[0]; //获取第1行
  7293. //循环赋值
  7294. for (int i = 0; i < DeleClientList.Count; i++)
  7295. {
  7296. builder.MoveToCell(0, i + 1, 0, 0);
  7297. builder.Write(DeleClientList[i].Name);
  7298. builder.MoveToCell(0, i + 1, 1, 0);
  7299. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7300. builder.Write(sex);
  7301. builder.MoveToCell(0, i + 1, 2, 0);
  7302. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7303. builder.MoveToCell(0, i + 1, 3, 0);
  7304. builder.Write(DeleClientList[i].Company);
  7305. builder.MoveToCell(0, i + 1, 4, 0);
  7306. builder.Write(DeleClientList[i].Job);
  7307. }
  7308. //删除多余行
  7309. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7310. {
  7311. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7312. }
  7313. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7314. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7315. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7316. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7317. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7318. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7319. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7320. }
  7321. }
  7322. return Ok(JsonView(400, "操作失败!", ""));
  7323. }
  7324. catch (Exception ex)
  7325. {
  7326. return Ok(JsonView(400, ex.Message, ""));
  7327. }
  7328. }
  7329. /// <summary>
  7330. /// 获取三公费用标准city
  7331. /// </summary>
  7332. /// <param name="placeData"></param>
  7333. /// <param name="nationalTravelFeeId"></param>
  7334. /// <returns></returns>
  7335. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7336. {
  7337. string _city = string.Empty;
  7338. if (placeData.Count < 1) return _city;
  7339. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7340. if (data == null) return _city;
  7341. string country = data.Country;
  7342. string city = data.City;
  7343. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7344. else _city = city;
  7345. return _city;
  7346. }
  7347. ///// <summary>
  7348. ///// 团组模块 - 出入境费用 - 明细表导出
  7349. ///// </summary>
  7350. ///// <returns></returns>
  7351. //[HttpPost]
  7352. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7353. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7354. //{
  7355. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7356. // if (data.Code != 0)
  7357. // {
  7358. // return Ok(JsonView(false, data.Msg));
  7359. // }
  7360. // return Ok(JsonView(true, data.Msg, data.Data));
  7361. //}
  7362. /// <summary>
  7363. /// 团组模块 - 出入境费用 - 一键清空
  7364. /// </summary>
  7365. /// <returns></returns>
  7366. [HttpPost]
  7367. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7369. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7370. {
  7371. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7372. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7373. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7374. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7375. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7376. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7377. .SetColumns(x => new Grp_DayOtherPrice
  7378. {
  7379. IsDel = 1,
  7380. DeleteUserId = dto.UserId,
  7381. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7382. })
  7383. .ExecuteCommandAsync();
  7384. if (_view.Code == 0)
  7385. {
  7386. return Ok(JsonView(true, "操作成功"));
  7387. }
  7388. return Ok(JsonView(false, "操作失败"));
  7389. }
  7390. /// <summary>
  7391. /// 团组模块 - 出入境费用 - 子项删除
  7392. /// </summary>
  7393. /// <returns></returns>
  7394. [HttpPost]
  7395. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7397. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7398. {
  7399. try
  7400. {
  7401. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7402. if (data.Code != 0)
  7403. {
  7404. return Ok(JsonView(false, data.Msg));
  7405. }
  7406. return Ok(JsonView(true, "操作成功!", data.Data));
  7407. }
  7408. catch (Exception ex)
  7409. {
  7410. return Ok(JsonView(false, ex.Message));
  7411. }
  7412. }
  7413. /// <summary>
  7414. /// 删除三公其他费用
  7415. /// </summary>
  7416. /// <param name="dto"></param>
  7417. /// <returns></returns>
  7418. [HttpPost]
  7419. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7420. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7421. {
  7422. var jw = JsonView(false, "删除失败!");
  7423. var data = new Grp_DayOtherPrice()
  7424. {
  7425. Id = dto.Id,
  7426. IsDel = 1,
  7427. DeleteUserId = dto.DeleteUserId,
  7428. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7429. };
  7430. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7431. if (del > 0)
  7432. {
  7433. jw.Code = 200;
  7434. jw.Msg = "删除成功!";
  7435. }
  7436. return Ok(jw);
  7437. }
  7438. /// <summary>
  7439. /// 团组模块 - 出入境国家费用标准 List
  7440. /// </summary>
  7441. /// <returns></returns>
  7442. [HttpPost]
  7443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7444. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7445. {
  7446. int provinceId = dto.ProvinceId;
  7447. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7448. var nftData = await _sqlSugar
  7449. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7450. JoinType.Left, ntf.Currency == sd1.Id,
  7451. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7452. JoinType.Left, ntf.ProvinceId == c.Id
  7453. ))
  7454. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7455. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7456. {
  7457. Id = ntf.Id,
  7458. ProvinceId = ntf.ProvinceId,
  7459. ProvinceName = c.Name_CN,
  7460. Continent = ntf.Continent,
  7461. Country = ntf.Country,
  7462. City = ntf.City,
  7463. Currency = ntf.Currency,
  7464. CurrencyCode = sd1.Name,
  7465. CurrencyName = sd1.Remark,
  7466. RoomCost = ntf.RoomCost,
  7467. FoodCost = ntf.FoodCost,
  7468. PublicCost = ntf.PublicCost,
  7469. LastUpdateUserId = ntf.LastUpdateUserId,
  7470. LastUpdateUserName = u.CnName,
  7471. LastUpdateTime = ntf.LastUpdateTime
  7472. })
  7473. .ToListAsync();
  7474. return Ok(JsonView(true, "查询成功!", nftData));
  7475. }
  7476. /// <summary>
  7477. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7478. /// </summary>
  7479. /// <returns></returns>
  7480. [HttpPost]
  7481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7482. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7483. {
  7484. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7485. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7486. List<string> countryData = new List<string>();
  7487. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7488. countryData = countryData.Distinct().ToList();
  7489. List<dynamic> dataSource = new List<dynamic>();
  7490. foreach (var item in countryData)
  7491. {
  7492. var cityData1 = new List<string>();
  7493. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7494. var countryData2 = new
  7495. {
  7496. CountryName = item,
  7497. CityData = cityData1
  7498. };
  7499. if (!dataSource.Contains(countryData2))
  7500. {
  7501. dataSource.Add(countryData2);
  7502. }
  7503. }
  7504. return Ok(JsonView(true, "查询成功!", dataSource));
  7505. }
  7506. /// <summary>
  7507. /// 团组模块 - 出入境国家费用标准 Page List
  7508. /// </summary>
  7509. /// <returns></returns>
  7510. [HttpPost]
  7511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7512. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7513. {
  7514. int portId = dto.PortType,
  7515. pageIndex = dto.PageIndex,
  7516. pageSize = dto.PageSize;
  7517. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7518. if (pageIndex == 0) pageIndex = 1;
  7519. if (pageSize == 0) pageSize = 10;
  7520. RefAsync<int> total = 0;
  7521. var nationalTravelFeeData = await _sqlSugar
  7522. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7523. JoinType.Left, ntf.Currency == sd1.Id,
  7524. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7525. JoinType.Left, ntf.ProvinceId == sd2.Id
  7526. ))
  7527. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7528. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7529. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7530. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7531. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7532. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7533. {
  7534. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7535. Id = ntf.Id,
  7536. ProvinceId = ntf.ProvinceId,
  7537. ProvinceName = sd2.Name_CN,
  7538. Continent = ntf.Continent,
  7539. Country = ntf.Country,
  7540. City = ntf.City,
  7541. Currency = ntf.Currency,
  7542. CurrencyCode = sd1.Name,
  7543. CurrencyName = sd1.Remark,
  7544. RoomCost = ntf.RoomCost,
  7545. FoodCost = ntf.FoodCost,
  7546. PublicCost = ntf.PublicCost,
  7547. LastUpdateUserId = ntf.LastUpdateUserId,
  7548. LastUpdateUserName = u.CnName,
  7549. LastUpdateTime = ntf.LastUpdateTime,
  7550. Remark = ntf.Remark
  7551. })
  7552. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7553. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7554. }
  7555. /// <summary>
  7556. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7557. /// </summary>
  7558. /// <returns></returns>
  7559. [HttpPost]
  7560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7561. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7562. {
  7563. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7564. int portId = dto.PortType;
  7565. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7566. string whereSql = string.Empty;
  7567. if (!string.IsNullOrEmpty(dto.Country))
  7568. {
  7569. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7570. }
  7571. if (!string.IsNullOrEmpty(dto.City))
  7572. {
  7573. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7574. }
  7575. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7576. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7577. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7578. From Grp_NationalTravelFee gntf
  7579. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7580. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7581. Where gntf.Isdel = 0 {0} ", whereSql);
  7582. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7583. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7584. }
  7585. /// <summary>
  7586. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7587. /// </summary>
  7588. /// <returns></returns>
  7589. [HttpPost]
  7590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7591. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7592. {
  7593. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7594. }
  7595. /// <summary>
  7596. /// 团组模块 - 出入境国家费用标准 - Del
  7597. /// </summary>
  7598. /// <returns></returns>
  7599. [HttpPost]
  7600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7601. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7602. {
  7603. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7604. {
  7605. Id = dto.Id,
  7606. DeleteUserId = dto.DeleteUserId,
  7607. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7608. IsDel = 1
  7609. };
  7610. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7611. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7612. .WhereColumns(it => new { it.Id })
  7613. .ExecuteCommandAsync();
  7614. if (delStatus <= 0)
  7615. {
  7616. return Ok(JsonView(false, "删除失败!"));
  7617. }
  7618. return Ok(JsonView(true, "操作成功!"));
  7619. }
  7620. /// <summary>
  7621. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7622. /// 注:Get 请求Headers 加 Token
  7623. /// </summary>
  7624. /// <param name="groupId"></param>
  7625. /// <returns></returns>
  7626. [HttpGet("{groupId}")]
  7627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7628. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7629. {
  7630. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7631. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7632. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7633. data.ForEach(x =>
  7634. {
  7635. x.CreateUserId = _currUserInfo.UserId;
  7636. });
  7637. if (data.Any())
  7638. {
  7639. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7640. if (add > 0)
  7641. {
  7642. return Ok(JsonView(true, "操作成功!"));
  7643. }
  7644. }
  7645. return Ok(JsonView(false, "未操作!"));
  7646. }
  7647. #endregion
  7648. #region 团组经理模块 出入境费用-草稿
  7649. /// <summary>
  7650. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7651. /// </summary>
  7652. /// <returns></returns>
  7653. [HttpGet]
  7654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7655. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7656. {
  7657. var provData = await _groupRepository.ProvinceBasicSource();
  7658. return Ok(JsonView(true, "查询成功!", provData));
  7659. }
  7660. /// <summary>
  7661. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7662. /// </summary>
  7663. /// <returns></returns>
  7664. [HttpGet("{provinceId}")]
  7665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7666. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7667. {
  7668. //验证城市归属并给默认值
  7669. if (provinceId < 1) provinceId = 122;
  7670. /*
  7671. * 122 四川
  7672. * 108 贵州
  7673. * 103 重庆
  7674. * 132 云南
  7675. */
  7676. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7677. return Ok(JsonView(true, "查询成功!", new
  7678. {
  7679. WordTypeData = wordTypeData,
  7680. ExcelTypeData = excelTypeData,
  7681. }));
  7682. }
  7683. /// <summary>
  7684. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7685. /// </summary>
  7686. /// <returns></returns>
  7687. [HttpPost]
  7688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7689. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7690. {
  7691. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7692. .Where(x => x.IsDel == 0)
  7693. .OrderByDescending(x => x.CreateTime)
  7694. .Select(x => new { x.Id, x.DraftName })
  7695. .ToListAsync();
  7696. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7697. //SetDataInfoView
  7698. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7699. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7700. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7701. int provinceId = dto.ProvinceId;
  7702. if (provinceId < 1) provinceId = 122;
  7703. /*
  7704. * 122 四川
  7705. * 108 贵州
  7706. * 103 重庆
  7707. * 132 云南
  7708. */
  7709. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7710. //默认币种显示
  7711. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7712. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7713. return Ok(JsonView(true, "查询成功!", new
  7714. {
  7715. DraftNameDatas = draftNameDatas,
  7716. CurrencyData = _CurrencyData,
  7717. WordTypeData = wordTypeData,
  7718. ExcelTypeData = excelTypeData,
  7719. CurrencyInit = _currencyInfos,
  7720. ViewPermissionData = viewPermissionData
  7721. }));
  7722. }
  7723. /// <summary>
  7724. /// 团组模块 - 出入境费用-草稿
  7725. /// 实时汇率 tips
  7726. /// 机票费用 tips
  7727. /// </summary>
  7728. /// <returns></returns>
  7729. [HttpPost]
  7730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7731. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7732. {
  7733. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7734. return Ok(JsonView(true, "查询成功!", new
  7735. {
  7736. //GroupNameData = groupNameData.Data,
  7737. //visaData = visaData.Data,
  7738. //airData = airData.Data,
  7739. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7740. }));
  7741. }
  7742. /// <summary>
  7743. /// 团组模块 - 出入境费用-草稿
  7744. /// 签证费用 tips
  7745. /// </summary>
  7746. /// <returns></returns>
  7747. [HttpPost]
  7748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7749. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7750. {
  7751. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7752. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7753. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7754. .Select(x => x.NationalTravelFeeId)
  7755. .Distinct()
  7756. .ToListAsync();
  7757. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7758. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7759. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7760. .Select(x => x.Country)
  7761. .Distinct()
  7762. .ToArrayAsync();
  7763. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7764. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7765. return Ok(JsonView(true, "查询成功!", new
  7766. {
  7767. totalAmt = totalAmt,
  7768. remark = remark
  7769. }));
  7770. }
  7771. /// <summary>
  7772. /// 团组模块 - 出入境费用-草稿 - Info
  7773. /// </summary>
  7774. /// <returns></returns>
  7775. [HttpPost]
  7776. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7778. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7779. {
  7780. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7781. }
  7782. /// <summary>
  7783. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7784. /// </summary>
  7785. /// <returns></returns>
  7786. [HttpPost]
  7787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7788. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7789. {
  7790. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7791. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7792. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7793. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7794. foreach (var userId in dto.UserIds)
  7795. {
  7796. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7797. }
  7798. if (permissions.Any())
  7799. {
  7800. _sqlSugar.BeginTran();
  7801. try
  7802. {
  7803. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7804. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7805. if (result < 1)
  7806. {
  7807. _sqlSugar.RollbackTran();
  7808. return Ok(JsonView(false));
  7809. }
  7810. }
  7811. catch (Exception ex)
  7812. {
  7813. _sqlSugar.RollbackTran();
  7814. return Ok(JsonView(false, ex.Message));
  7815. }
  7816. _sqlSugar.CommitTran();
  7817. return Ok(JsonView(true));
  7818. }
  7819. return Ok(JsonView(false));
  7820. }
  7821. /// <summary>
  7822. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7823. /// </summary>
  7824. /// <returns></returns>
  7825. [HttpPost]
  7826. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7828. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7829. {
  7830. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7831. if (data.Code != 0)
  7832. {
  7833. return Ok(JsonView(false, data.Msg));
  7834. }
  7835. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7836. //汇率信息记录
  7837. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7838. return Ok(JsonView(true, data.Msg, data.Data));
  7839. }
  7840. /// <summary>
  7841. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7842. /// </summary>
  7843. /// <param name="dto"></param>
  7844. /// <returns></returns>
  7845. [HttpPost]
  7846. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7848. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7849. {
  7850. try
  7851. {
  7852. var id = dto.Id;
  7853. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7854. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7855. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7856. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7857. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7858. 3 团组成员名单 1 团组成员名单", ""));
  7859. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7860. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7861. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7862. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7863. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7864. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7865. //数据源
  7866. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7867. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7868. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7869. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7870. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7871. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7872. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7873. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7874. .Select((x, a, b) => new
  7875. {
  7876. x.Index,
  7877. itemName = a.Name,
  7878. CurrencyStr = b.Name,
  7879. x.Cost,
  7880. x.SubTotal,
  7881. x.Remark
  7882. })
  7883. .OrderBy((x) => x.Index)
  7884. .ToList(); //其他款项费用
  7885. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7886. var peiceItemCurrencys = new List<string>();
  7887. if (_DayAndCosts.Any())
  7888. {
  7889. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7890. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7891. }
  7892. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7893. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7894. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7895. {
  7896. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7897. }
  7898. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7899. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7900. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7901. if (dto.ExportType == 1) //明细表
  7902. {
  7903. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7904. {
  7905. //获取模板
  7906. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7907. //载入模板
  7908. Document doc = new Document(tempPath);
  7909. DocumentBuilder builder = new DocumentBuilder(doc);
  7910. //利用键值对存放数据
  7911. Dictionary<string, string> dic = new Dictionary<string, string>();
  7912. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7913. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7914. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7915. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7916. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7917. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7918. //境内费用(其他费用)
  7919. if (_EnterExitCosts.ChoiceOne == 1)
  7920. {
  7921. string row1_1 = "";
  7922. if (_EnterExitCosts.Visa > 0)
  7923. {
  7924. //insidePayTotal += _EnterExitCosts.Visa;
  7925. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7926. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7927. //{
  7928. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7929. //}
  7930. }
  7931. string row1_2 = "";
  7932. if (_EnterExitCosts.YiMiao > 0)
  7933. {
  7934. //insidePayTotal += _EnterExitCosts.YiMiao;
  7935. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7936. }
  7937. if (_EnterExitCosts.HeSuan > 0)
  7938. {
  7939. //insidePayTotal += _EnterExitCosts.HeSuan;
  7940. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7941. }
  7942. if (_EnterExitCosts.Service > 0)
  7943. {
  7944. //insidePayTotal += _EnterExitCosts.Service;
  7945. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7946. }
  7947. string row1_3 = "";
  7948. if (_EnterExitCosts.Safe > 0)
  7949. {
  7950. //insidePayTotal += _EnterExitCosts.Safe;
  7951. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7952. }
  7953. if (_EnterExitCosts.Ticket > 0)
  7954. {
  7955. //insidePayTotal += _EnterExitCosts.Ticket;
  7956. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7957. }
  7958. string row1 = "";
  7959. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7960. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7961. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7962. row1 += $"备注:{_EnterExitCosts.Remark}";
  7963. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7964. dic.Add("Row1Str", row1);
  7965. }
  7966. string airTotalStr = string.Empty,
  7967. airPriceStr = string.Empty;
  7968. //经济舱
  7969. if (_EnterExitCosts.SumJJC == 1)
  7970. {
  7971. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  7972. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  7973. }
  7974. //公务舱
  7975. if (_EnterExitCosts.SumGWC == 1)
  7976. {
  7977. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  7978. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  7979. }
  7980. //头等舱
  7981. if (_EnterExitCosts.SumTDC == 1)
  7982. {
  7983. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7984. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7985. }
  7986. //汇率描述
  7987. string rateStr = "";
  7988. if (peiceItemCurrencyInfos.Any())
  7989. {
  7990. rateStr = "\r\n汇率描述:";
  7991. foreach (var item in peiceItemCurrencyInfos)
  7992. {
  7993. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7994. }
  7995. }
  7996. string twoItemRemark = "备注:";
  7997. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7998. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7999. dic.Add("AirTotalStr", airTotalStr);
  8000. dic.Add("AirPriceStr", airPriceStr);
  8001. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8002. dic.Add("TwoItemRemark", twoItemRemark);
  8003. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8004. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8005. int table1Row = 0,
  8006. table2Row = 0,
  8007. table3Row = 0,
  8008. table4Row = 0,
  8009. table5Row = 0;
  8010. //住宿费
  8011. if (_EnterExitCosts.ChoiceThree == 1)
  8012. {
  8013. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8014. table1Row = dac1.Count;
  8015. #region 填充word表格内容
  8016. for (int i = 0; i < dac1.Count; i++)
  8017. {
  8018. var dac = dac1[i];
  8019. if (dac == null) continue;
  8020. builder.MoveToCell(0, i, 0, 0);
  8021. builder.Write("第" + dac.Days.ToString() + "晚:");
  8022. builder.MoveToCell(0, i, 1, 0);
  8023. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8024. //builder.Write(dac.Place == null ? "" : dac.Place);
  8025. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8026. builder.MoveToCell(0, i, 2, 0);
  8027. builder.Write("费用标准:");
  8028. string curr = "";
  8029. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8030. if (currData != null)
  8031. {
  8032. curr = currData.Name;
  8033. }
  8034. builder.MoveToCell(0, i, 3, 0);
  8035. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8036. builder.MoveToCell(0, i, 4, 0);
  8037. builder.Write("费用小计:");
  8038. builder.MoveToCell(0, i, 5, 0);
  8039. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8040. }
  8041. #endregion
  8042. }
  8043. else dic.Add("SubZS", "0.00");
  8044. //删除多余行
  8045. while (table1.Rows.Count > table1Row)
  8046. {
  8047. table1.Rows.RemoveAt(table1Row);
  8048. }
  8049. //伙食费
  8050. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8051. if (_EnterExitCosts.ChoiceFour == 1)
  8052. {
  8053. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8054. table2Row = dac2.Count;
  8055. #region 填充word表格内容
  8056. for (int i = 0; i < dac2.Count; i++)
  8057. {
  8058. var dac = dac2[i];
  8059. if (dac == null) continue;
  8060. builder.MoveToCell(1, i, 0, 0);
  8061. builder.Write("第" + dac.Days.ToString() + "天:");
  8062. builder.MoveToCell(1, i, 1, 0);
  8063. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8064. builder.MoveToCell(1, i, 2, 0);
  8065. builder.Write("费用标准:");
  8066. string curr = "";
  8067. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8068. if (currData != null)
  8069. {
  8070. curr = currData.Name;
  8071. }
  8072. builder.MoveToCell(1, i, 3, 0);
  8073. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8074. builder.MoveToCell(1, i, 4, 0);
  8075. builder.Write("费用小计:");
  8076. builder.MoveToCell(1, i, 5, 0);
  8077. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8078. }
  8079. #endregion
  8080. }
  8081. else dic.Add("SubHS", "0.00");
  8082. //删除多余行
  8083. while (table2.Rows.Count > table2Row)
  8084. {
  8085. table2.Rows.RemoveAt(table2Row);
  8086. }
  8087. //公杂费
  8088. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8089. if (_EnterExitCosts.ChoiceFive == 1)
  8090. {
  8091. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8092. table3Row = dac3.Count;
  8093. #region 填充word表格内容
  8094. for (int i = 0; i < dac3.Count; i++)
  8095. {
  8096. var dac = dac3[i];
  8097. if (dac == null) continue;
  8098. builder.MoveToCell(2, i, 0, 0);
  8099. builder.Write("第" + dac.Days.ToString() + "天:");
  8100. builder.MoveToCell(2, i, 1, 0);
  8101. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8102. builder.MoveToCell(2, i, 2, 0);
  8103. builder.Write("费用标准:");
  8104. string curr = "";
  8105. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8106. if (currData != null)
  8107. {
  8108. curr = currData.Name;
  8109. }
  8110. builder.MoveToCell(2, i, 3, 0);
  8111. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8112. builder.MoveToCell(2, i, 4, 0);
  8113. builder.Write("费用小计:");
  8114. builder.MoveToCell(2, i, 5, 0);
  8115. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8116. }
  8117. //删除多余行
  8118. while (table3.Rows.Count > table3Row)
  8119. {
  8120. table3.Rows.RemoveAt(table3Row);
  8121. }
  8122. #endregion
  8123. }
  8124. else dic.Add("SubGZF", "0.00");
  8125. //删除多余行
  8126. while (table3.Rows.Count > table3Row)
  8127. {
  8128. table3.Rows.RemoveAt(table3Row);
  8129. }
  8130. //培训费
  8131. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8132. if (_EnterExitCosts.ChoiceSix == 1)
  8133. {
  8134. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8135. dic.Add("SubPX", pxStr);
  8136. table4Row = dac4.Count;
  8137. #region 填充word表格内容
  8138. for (int i = 0; i < dac4.Count; i++)
  8139. {
  8140. var dac = dac4[i];
  8141. if (dac == null) continue;
  8142. builder.MoveToCell(3, i, 0, 0);
  8143. builder.Write("第" + dac.Days.ToString() + "天:");
  8144. builder.MoveToCell(3, i, 1, 0);
  8145. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8146. builder.MoveToCell(3, i, 2, 0);
  8147. builder.Write("费用标准:");
  8148. string curr = "";
  8149. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8150. if (currData != null)
  8151. {
  8152. curr = currData.Name;
  8153. }
  8154. builder.MoveToCell(3, i, 3, 0);
  8155. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8156. builder.MoveToCell(3, i, 4, 0);
  8157. builder.Write("费用小计:");
  8158. builder.MoveToCell(3, i, 5, 0);
  8159. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8160. }
  8161. #endregion
  8162. }
  8163. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8164. //删除多余行
  8165. while (table4.Rows.Count > table4Row)
  8166. {
  8167. table4.Rows.RemoveAt(table4Row);
  8168. }
  8169. //其他费用
  8170. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8171. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8172. {
  8173. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8174. dic.Add("titleQi", qtStr);
  8175. table5Row = dac5.Count;
  8176. #region 填充word表格内容
  8177. for (int i = 0; i < dac5.Count; i++)
  8178. {
  8179. var dac = dac5[i];
  8180. if (dac == null) continue;
  8181. builder.MoveToCell(4, i, 0, 0);
  8182. builder.Write("第" + dac.Index.ToString() + "项:");
  8183. builder.MoveToCell(4, i, 1, 0);
  8184. builder.Write(dac.itemName);
  8185. builder.MoveToCell(4, i, 2, 0);
  8186. builder.Write("费用标准:");
  8187. builder.MoveToCell(4, i, 3, 0);
  8188. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8189. builder.MoveToCell(4, i, 4, 0);
  8190. builder.Write("费用小计:");
  8191. builder.MoveToCell(4, i, 5, 0);
  8192. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8193. builder.MoveToCell(4, i, 6, 0);
  8194. builder.Write("备注:");
  8195. builder.MoveToCell(4, i, 7, 0);
  8196. builder.Write(dac.Remark);
  8197. }
  8198. #endregion
  8199. }
  8200. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8201. //删除多余行
  8202. while (table5.Rows.Count > table5Row)
  8203. {
  8204. table5.Rows.RemoveAt(table5Row);
  8205. }
  8206. //加上其他费用
  8207. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8208. decimal subJJC = 0.00M,
  8209. subGWC = 0.00M,
  8210. subTDC = 0.00M;
  8211. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8212. string totalLabel = string.Format("全部费用总计:");
  8213. //经济舱
  8214. if (_EnterExitCosts.SumJJC == 1)
  8215. {
  8216. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8217. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8218. }
  8219. //公务舱
  8220. if (_EnterExitCosts.SumGWC == 1)
  8221. {
  8222. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8223. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8224. }
  8225. //头等舱
  8226. if (_EnterExitCosts.SumTDC == 1)
  8227. {
  8228. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8229. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8230. }
  8231. //TotalLabel
  8232. dic.Add("TotalLabel", totalLabel);
  8233. #region 填充word模板书签内容
  8234. foreach (var key in dic.Keys)
  8235. {
  8236. Bookmark bookmark = doc.Range.Bookmarks[key];
  8237. if (bookmark != null)
  8238. {
  8239. builder.MoveToBookmark(key);
  8240. builder.Write(dic[key]);
  8241. }
  8242. }
  8243. #endregion
  8244. //文件名
  8245. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8246. strFileName = CommonFun.ValidFileName(strFileName);
  8247. AsposeHelper.removewatermark_v2180();
  8248. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8249. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8250. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8251. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8252. }
  8253. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8254. {
  8255. //获取模板
  8256. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8257. //载入模板
  8258. Document doc = new Document(tempPath);
  8259. DocumentBuilder builder = new DocumentBuilder(doc);
  8260. Dictionary<string, string> dic = new Dictionary<string, string>();
  8261. string returnCodeLabel = string.Empty;
  8262. if (nationalTravelFeeData.Any())
  8263. {
  8264. List<string> list = new List<string>();
  8265. foreach (var item in nationalTravelFeeData)
  8266. {
  8267. list.Add($"{item.Country}({item.City})");
  8268. }
  8269. list = list.Distinct().ToList();
  8270. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8271. }
  8272. var countryLabel = string.Empty;
  8273. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8274. if (countryData.Any())
  8275. {
  8276. countryLabel = string.Join("、", countryData);
  8277. }
  8278. dic.Add("ReturnCodeAir", returnCodeLabel);
  8279. dic.Add("VisitStartDate", "-");
  8280. dic.Add("VisitEndDate", "-");
  8281. dic.Add("Day", "-");
  8282. dic.Add("VisitCountry", countryLabel);
  8283. dic.Add("ClientUnit", "-");
  8284. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8285. //dic.Add("Names", Names);
  8286. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8287. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8288. decimal dac1totalPrice = 0.00M;
  8289. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8290. foreach (var dac in dac1)
  8291. {
  8292. if (dac.SubTotal == 0.00M)
  8293. {
  8294. continue;
  8295. }
  8296. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8297. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8298. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8299. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8300. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8301. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8302. builder.Write(currency);//币种
  8303. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8304. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8305. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8306. builder.Write("");//人数
  8307. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8308. builder.Write("");//天数
  8309. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8310. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8311. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8312. decimal rate = 0.00M;
  8313. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8314. builder.Write(rate.ToString("#0.0000"));//汇率
  8315. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8316. decimal rbmPrice = dac.SubTotal;
  8317. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8318. accommodationStartIndex++;
  8319. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8320. }
  8321. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8322. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8323. {
  8324. table1.Rows.RemoveAt(i - 1);
  8325. foodandotherStartIndex--;
  8326. }
  8327. if (dac2.Count == dac3.Count)//国家 币种 金额
  8328. {
  8329. for (int i = 0; i < dac2.Count; i++)
  8330. {
  8331. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8332. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8333. }
  8334. }
  8335. decimal dac2totalPrice = 0.00M;
  8336. foreach (var dac in dac2)
  8337. {
  8338. if (dac.SubTotal == 0)
  8339. {
  8340. continue;
  8341. }
  8342. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8343. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8344. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8345. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8346. builder.Write(currency);//币种
  8347. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8348. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8349. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8350. builder.Write("");//人数
  8351. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8352. builder.Write("");//天数
  8353. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8354. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8355. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8356. decimal rate = 0.00M;
  8357. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8358. builder.Write(rate.ToString("#0.0000"));//汇率
  8359. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8360. decimal rbmPrice = dac.SubTotal;
  8361. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8362. foodandotherStartIndex++;
  8363. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8364. }
  8365. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8366. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8367. {
  8368. table1.Rows.RemoveAt(i - 1);
  8369. }
  8370. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8371. string otherFeeStr = "";
  8372. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8373. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8374. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8375. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8376. foreach (var otherInfo in dac5)
  8377. {
  8378. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8379. }
  8380. #endregion
  8381. if (otherFeeStr.Length > 0)
  8382. {
  8383. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8384. otherFeeStr = $"({otherFeeStr})";
  8385. dic.Add("OtherFeeStr", otherFeeStr);
  8386. }
  8387. //总计
  8388. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8389. //国际旅费
  8390. string outsideAir = string.Empty;
  8391. string allPriceAir = string.Empty;
  8392. if (_EnterExitCosts.SumJJC == 1)
  8393. {
  8394. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8395. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8396. }
  8397. if (_EnterExitCosts.SumGWC == 1)
  8398. {
  8399. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8400. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8401. }
  8402. if (_EnterExitCosts.SumTDC == 1)
  8403. {
  8404. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8405. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8406. }
  8407. dic.Add("InTravelPrice", $"({outsideAir})");
  8408. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8409. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8410. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8411. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8412. foreach (var key in dic.Keys)
  8413. {
  8414. builder.MoveToBookmark(key);
  8415. builder.Write(dic[key]);
  8416. }
  8417. //模板文件名
  8418. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8419. strFileName = CommonFun.ValidFileName(strFileName);
  8420. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8421. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8422. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8423. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8424. }
  8425. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8426. {
  8427. //获取模板
  8428. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8429. //载入模板
  8430. WorkbookDesigner designer = new WorkbookDesigner();
  8431. designer.Workbook = new Workbook(tempPath);
  8432. Dictionary<string, string> dic = new Dictionary<string, string>();
  8433. string returnCodeLabel = string.Empty;
  8434. if (nationalTravelFeeData.Any())
  8435. {
  8436. List<string> list = new List<string>();
  8437. foreach (var item in nationalTravelFeeData)
  8438. {
  8439. list.Add($"{item.Country}({item.City})");
  8440. }
  8441. list = list.Distinct().ToList();
  8442. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8443. }
  8444. var countryLabel = string.Empty;
  8445. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8446. if (countryData.Any())
  8447. {
  8448. countryLabel = string.Join("、", countryData);
  8449. }
  8450. dic.Add("ReturnCodeAir", returnCodeLabel);
  8451. dic.Add("VisitStartDate", "-");
  8452. dic.Add("VisitEndDate", "-");
  8453. dic.Add("Day", "0");
  8454. dic.Add("VisitCountry", countryLabel);
  8455. dic.Add("ClientUnit", "-");
  8456. designer.SetDataSource("ClientUnit", "-");
  8457. designer.SetDataSource("VisitCountry", countryLabel);
  8458. designer.SetDataSource("Group", "-");
  8459. designer.SetDataSource("ClientUnitTitle", "-");
  8460. designer.SetDataSource("Name", "-");
  8461. designer.SetDataSource("VisitStartDate", "-");
  8462. designer.SetDataSource("Day", "0");
  8463. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8464. designer.SetDataSource("ReturnCodeAir", "-");
  8465. int startIndex = 10;
  8466. const int startIndexcopy = 10;
  8467. if (dac2.Count == dac3.Count)//国家 币种 金额
  8468. {
  8469. for (int i = 0; i < dac2.Count; i++)
  8470. {
  8471. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8472. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8473. }
  8474. }
  8475. DataTable dtdac1 = new DataTable();
  8476. List<string> place = new List<string>();
  8477. dtdac1.Columns.AddRange(new DataColumn[] {
  8478. new DataColumn(){ ColumnName = "city"},
  8479. new DataColumn(){ ColumnName = "curr"},
  8480. new DataColumn(){ ColumnName = "criterion"},
  8481. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8482. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8483. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8484. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8485. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8486. });
  8487. DataTable dtdac2 = new DataTable();
  8488. dtdac2.Columns.AddRange(new DataColumn[] {
  8489. new DataColumn(){ ColumnName = "city"},
  8490. new DataColumn(){ ColumnName = "curr"},
  8491. new DataColumn(){ ColumnName = "criterion"},
  8492. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8493. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8494. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8495. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8496. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8497. });
  8498. dtdac1.TableName = "tb1";
  8499. dtdac2.TableName = "tb2";
  8500. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8501. foreach (var item in dac1)
  8502. {
  8503. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8504. if (place.Contains(item.Place))
  8505. {
  8506. continue;
  8507. }
  8508. DataRow row = dtdac1.NewRow();
  8509. row["city"] = item.Place;
  8510. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8511. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8512. row["curr"] = currency;
  8513. row["rate"] = rate.ToString("#0.0000");
  8514. row["criterion"] = item.Cost.ToString("#0.00");
  8515. row["number"] = 1;
  8516. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8517. //row["costRMB"] = rbmPrice;
  8518. dtdac1.Rows.Add(row);
  8519. place.Add(item.Place);
  8520. }
  8521. place = new List<string>();
  8522. foreach (var item in dac2)
  8523. {
  8524. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8525. if (place.Contains(item.Place))
  8526. {
  8527. continue;
  8528. }
  8529. DataRow row = dtdac2.NewRow();
  8530. row["city"] = item.Place;
  8531. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8532. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8533. row["curr"] = currency;
  8534. row["rate"] = rate.ToString("#0.0000");
  8535. row["criterion"] = item.Cost.ToString("#0.00");
  8536. row["number"] = 1;
  8537. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8538. //row["cost"] = item.SubTotal;
  8539. //row["costRMB"] = rbmPrice;
  8540. dtdac2.Rows.Add(row);
  8541. place.Add(item.Place);
  8542. //dac2totalPrice += rbmPrice;
  8543. }
  8544. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8545. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8546. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8547. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8548. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8549. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8550. string cell4Str1 = string.Empty;
  8551. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8552. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8553. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8554. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8555. string cellStr = $" 5.其他费用(";
  8556. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8557. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8558. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8559. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8560. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8561. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8562. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8563. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8564. foreach (var otherInfo in dac5)
  8565. {
  8566. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8567. }
  8568. #endregion
  8569. if (cellStr.Length > 8)
  8570. {
  8571. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8572. }
  8573. cellStr += ")";
  8574. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8575. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8576. decimal pxFee = dac4.Sum(it => it.Cost);
  8577. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8578. string celllastStr1 = "";
  8579. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8580. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8581. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8582. celllastStr1 += $",国际旅费 元";
  8583. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8584. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8585. designer.SetDataSource("cell4Str", cell4Str);
  8586. designer.SetDataSource("cellStr", cellStr);
  8587. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8588. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8589. designer.SetDataSource("celllastStr", celllastStr);
  8590. Workbook wb = designer.Workbook;
  8591. var sheet = wb.Worksheets[0];
  8592. //绑定datatable数据集
  8593. designer.SetDataSource(dtdac1);
  8594. designer.SetDataSource(dtdac2);
  8595. designer.Process();
  8596. var rowStart = dtdac1.Rows.Count;
  8597. while (rowStart > 0)
  8598. {
  8599. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8600. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8601. startIndex++;
  8602. rowStart--;
  8603. }
  8604. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8605. startIndex += 1; //总计行
  8606. rowStart = dtdac2.Rows.Count;
  8607. while (rowStart > 0)
  8608. {
  8609. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8610. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8611. startIndex++;
  8612. rowStart--;
  8613. }
  8614. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8615. wb.CalculateFormula(true);
  8616. //模板文件名
  8617. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8618. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8619. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8620. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8621. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8622. }
  8623. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8624. {
  8625. //获取模板
  8626. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8627. //载入模板
  8628. Document doc = new Document(tempPath);
  8629. DocumentBuilder builder = new DocumentBuilder(doc);
  8630. Dictionary<string, string> dic = new Dictionary<string, string>();
  8631. dic.Add("GroupName", "-");
  8632. dic.Add("ClientUnit", "-");
  8633. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8634. //string missionLeaderJob = "";//负责人job
  8635. //int groupNumber = 0; //团人数
  8636. dic.Add("MissionLeader", "-"); //团负责人
  8637. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8638. dic.Add("GroupNumber", "0"); //团人数
  8639. dic.Add("Day", "0");
  8640. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8641. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8642. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8643. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8644. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8645. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8646. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8647. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8648. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8649. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8650. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8651. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8652. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8653. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8654. //其他费用
  8655. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8656. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8657. //其他费用合计
  8658. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8659. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8660. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8661. //公务舱合计
  8662. //国际旅费
  8663. //string outsideJJ = "";
  8664. //string allPriceJJ = "";
  8665. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8666. {
  8667. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8668. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8669. }
  8670. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8671. {
  8672. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8673. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8674. }
  8675. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8676. {
  8677. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8678. dic.Add("AirFeeTotal", airFeeTotalStr);
  8679. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8680. dic.Add("FeeTotal", feeTotalStr);
  8681. }
  8682. foreach (var key in dic.Keys)
  8683. {
  8684. builder.MoveToBookmark(key);
  8685. builder.Write(dic[key]);
  8686. }
  8687. //模板文件名
  8688. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8689. strFileName = CommonFun.ValidFileName(strFileName);
  8690. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8691. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8692. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8693. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8694. }
  8695. }
  8696. else if (dto.ExportType == 2) //表格
  8697. {
  8698. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8699. }
  8700. else if (dto.ExportType == 3)
  8701. {
  8702. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8703. }
  8704. return Ok(JsonView(400, "只可导出明细表!", ""));
  8705. }
  8706. catch (Exception ex)
  8707. {
  8708. return Ok(JsonView(400, ex.Message, ""));
  8709. }
  8710. }
  8711. /// <summary>
  8712. /// 获取三公费用标准city
  8713. /// </summary>
  8714. /// <param name="placeData"></param>
  8715. /// <param name="nationalTravelFeeId"></param>
  8716. /// <returns></returns>
  8717. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8718. {
  8719. string _city = string.Empty;
  8720. if (!placeData.Any()) return _city;
  8721. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8722. if (data == null) return _city;
  8723. string country = data.Country;
  8724. string city = data.City;
  8725. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8726. else _city = city;
  8727. return _city;
  8728. }
  8729. /// <summary>
  8730. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8731. /// </summary>
  8732. /// <returns></returns>
  8733. [HttpPost]
  8734. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8736. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8737. {
  8738. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8739. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8740. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8741. if (_view.Code == 0)
  8742. {
  8743. return Ok(JsonView(true, "操作成功"));
  8744. }
  8745. return Ok(JsonView(false, "操作失败"));
  8746. }
  8747. /// <summary>
  8748. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8749. /// </summary>
  8750. /// <returns></returns>
  8751. [HttpPost]
  8752. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8754. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8755. {
  8756. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8757. if (data.Code != 0)
  8758. {
  8759. return Ok(JsonView(false, data.Msg));
  8760. }
  8761. return Ok(JsonView(true, "操作成功!", data.Data));
  8762. }
  8763. /// <summary>
  8764. /// 三公其他费用草稿 删除
  8765. /// </summary>
  8766. /// <param name="dto"></param>
  8767. /// <returns></returns>
  8768. [HttpPost]
  8769. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8770. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8771. {
  8772. var jw = JsonView(false, "删除失败!");
  8773. var data = new Grp_DayOtherPriceDraft()
  8774. {
  8775. Id = dto.Id,
  8776. IsDel = 1,
  8777. DeleteUserId = dto.DeleteUserId,
  8778. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8779. };
  8780. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8781. if (del > 0)
  8782. {
  8783. jw.Code = 200;
  8784. jw.Msg = "删除成功!";
  8785. }
  8786. return Ok(jw);
  8787. }
  8788. /// <summary>
  8789. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8790. /// </summary>
  8791. /// <returns></returns>
  8792. [HttpPost]
  8793. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8794. {
  8795. var jw = JsonView(false);
  8796. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8797. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8798. jw.Code = StatusCodes.Status200OK;
  8799. jw.Msg = "操作成功!";
  8800. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8801. return Ok(jw);
  8802. }
  8803. /// <summary>
  8804. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8805. /// </summary>
  8806. /// <param name="dto"></param>
  8807. /// <returns></returns>
  8808. [HttpPost]
  8809. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8810. {
  8811. int userId = dto.UserId,
  8812. portId = dto.PortType,
  8813. groupId = dto.GroupId,
  8814. draftId = dto.DraftId;
  8815. _portTypeData.Add(1);
  8816. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8817. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8818. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8819. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8820. _sqlSugar.BeginTran();
  8821. try
  8822. {
  8823. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8824. if (draftDatas == null)
  8825. {
  8826. _sqlSugar.RollbackTran();
  8827. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8828. }
  8829. //验证可覆盖已有数据 两边创建人需为同一人;
  8830. int draftCreateUserId = draftDatas.CreateUserId,
  8831. formalCreateUserId = 0;
  8832. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8833. if (formalData != null)
  8834. {
  8835. formalCreateUserId = formalData.CreateUserId;
  8836. if (draftCreateUserId != formalCreateUserId)
  8837. {
  8838. _sqlSugar.RollbackTran();
  8839. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8840. }
  8841. }
  8842. //默认添加查看、编辑权限(创建人、自己)
  8843. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8844. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8845. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8846. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8847. newExterData.DiId = groupId;
  8848. newExterData.CreateUserId = userId;
  8849. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8850. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8851. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8852. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8853. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8854. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8855. //数据如果存在执行删除
  8856. if (enterExitCostInfo != null)
  8857. {
  8858. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8859. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8860. .Where(x => x.Id == enterExitCostInfo.Id)
  8861. .ExecuteCommand();
  8862. _sqlSugar.Updateable<Grp_DayAndCost>()
  8863. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8864. .Where(x => x.DiId == groupId)
  8865. .ExecuteCommand();
  8866. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8867. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8868. .Where(x => x.Diid == groupId)
  8869. .ExecuteCommand();
  8870. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8871. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8872. .Where(x => x.GroupId == groupId)
  8873. .ExecuteCommand();
  8874. }
  8875. //执行insert
  8876. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8877. if (insertId < 1)
  8878. {
  8879. _sqlSugar.RollbackTran();
  8880. return Ok(JsonView(false, "草稿数据导入失败!"));
  8881. }
  8882. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8883. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8884. #region 默认添加权限
  8885. #endregion
  8886. _sqlSugar.CommitTran();
  8887. //执行操作之后
  8888. //生成默认文件pdf并且通知人员
  8889. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8890. {
  8891. DiId = groupId,
  8892. ExportType = 1,
  8893. SubTypeId = 1005
  8894. }, "pdf");
  8895. //发送通知
  8896. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8897. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8898. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8899. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8900. //汇率信息记录
  8901. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8902. return Ok(JsonView(true));
  8903. }
  8904. catch (Exception ex)
  8905. {
  8906. _sqlSugar.RollbackTran();
  8907. return Ok(JsonView(false, ex.Message));
  8908. }
  8909. }
  8910. #endregion
  8911. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8912. /// <summary>
  8913. /// 获取币种基础数据(含逻辑处理)
  8914. /// </summary>
  8915. /// <returns></returns>
  8916. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8917. {
  8918. return await GeneralMethod.EnterExitCostInitRate();
  8919. }
  8920. /// <summary>
  8921. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8922. /// </summary>
  8923. /// <returns></returns>
  8924. [HttpPost]
  8925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8926. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8927. {
  8928. //验证城市归属并给默认值
  8929. int provinceId = dto.ProvinceId;
  8930. if (provinceId < 1) provinceId = 122;
  8931. var dataSource = await _sqlSugar
  8932. .Queryable<Sys_SetData>()
  8933. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8934. .ToListAsync();
  8935. var fileTypes = new List<EecSetDataInfoView>();
  8936. //三公费用-Word明细类型
  8937. var wordTypeData = dataSource
  8938. .Where(it => it.STid == 72)
  8939. .Select(x => new EecSetDataInfoView
  8940. {
  8941. ParentId = 1,
  8942. Id = x.Id,
  8943. Name = x.Name
  8944. })
  8945. .ToArray();
  8946. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8947. var excelTypeData = dataSource
  8948. .Where(it => it.STid == 73)
  8949. .Select(x => new EecSetDataInfoView
  8950. {
  8951. ParentId = 2,
  8952. Id = x.Id,
  8953. Name = x.Name
  8954. })
  8955. .ToArray();
  8956. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8957. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8958. fileTypes.Add(groupNameList);
  8959. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  8960. //默认币种显示
  8961. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8962. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8963. return Ok(JsonView(true, "查询成功!", new
  8964. {
  8965. FileTypeData = fileTypes,
  8966. CurrencyInit = _currencyInfos,
  8967. viewPermissionData = viewPermissionData
  8968. }));
  8969. }
  8970. /// <summary>
  8971. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  8972. /// </summary>
  8973. /// <returns></returns>
  8974. [HttpPost]
  8975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8976. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  8977. {
  8978. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8979. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8980. RefAsync<int> total = 0;
  8981. int diId = 0;
  8982. var status = int.TryParse(dto.GroupName, out diId);
  8983. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  8984. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8985. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8986. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8987. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8988. .OrderByDescending(x => x.VisitStartDate)
  8989. .Select(x => new EnterExitCostMobileGroupView()
  8990. {
  8991. Id = x.Id,
  8992. GroupName = x.TeamName,
  8993. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8994. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8995. ProvinceId = x.CityId
  8996. })
  8997. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8998. //处理省份Id
  8999. if (data.Any())
  9000. {
  9001. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9002. if (provCityDatas.Any())
  9003. {
  9004. foreach (var item in data)
  9005. {
  9006. var provinceId = item.ProvinceId;
  9007. var isDefualtVal = true;
  9008. if (provinceId > 0)
  9009. {
  9010. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9011. if (parentId != null)
  9012. {
  9013. isDefualtVal = false;
  9014. item.ProvinceId = (int)parentId;
  9015. }
  9016. }
  9017. if (isDefualtVal)
  9018. {
  9019. item.ProvinceId = 122; //默认四川
  9020. }
  9021. }
  9022. }
  9023. }
  9024. //处理是否显示
  9025. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9026. {
  9027. foreach (var item in data)
  9028. {
  9029. item.IsView = true;
  9030. }
  9031. }
  9032. return Ok(JsonView(true, "查询成功!", data, total));
  9033. }
  9034. /// <summary>
  9035. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9036. /// </summary>
  9037. /// <returns></returns>
  9038. [HttpPost]
  9039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9040. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9041. {
  9042. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9043. RefAsync<int> total = 0;
  9044. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9045. .Where(x => x.IsDel == 0 && x.STid == 66)
  9046. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9047. .Select(x => new
  9048. {
  9049. id = x.Id,
  9050. name = x.Name,
  9051. remark = x.Remark,
  9052. })
  9053. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9054. return Ok(JsonView(true, "查询成功!", data, total));
  9055. }
  9056. /// <summary>
  9057. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9058. /// </summary>
  9059. /// <returns></returns>
  9060. [HttpPost]
  9061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9062. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9063. {
  9064. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9065. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9066. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9067. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9068. var groupOtherRateData = groupRateData.TeamRates;
  9069. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9070. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9071. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9072. groupOtherRateData = groupOtherRateData
  9073. .Select(x => new TeamRateDescAddCurrencyIdView
  9074. {
  9075. CurrencyId = x.CurrencyId,
  9076. CurrencyName = x.CurrencyName,
  9077. CurrencyCode = x.CurrencyCode,
  9078. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9079. }).ToList();
  9080. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9081. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9082. }
  9083. /// <summary>
  9084. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9085. /// </summary>
  9086. /// <returns></returns>
  9087. [HttpPost]
  9088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9089. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9090. {
  9091. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9092. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9093. var tipsData = new List<int>() { 1, 2, 3 };
  9094. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9095. if (dto.TipsType == 1)
  9096. {
  9097. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9098. }
  9099. else if (dto.TipsType == 2)
  9100. {
  9101. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9102. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9103. }
  9104. else if (dto.TipsType == 3)
  9105. {
  9106. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  9107. return Ok(JsonView(true, "查询成功!", airData.Data));
  9108. }
  9109. return Ok(JsonView(false));
  9110. }
  9111. /// <summary>
  9112. /// 团组模块 - 出入境国家费用标准-移动端 List
  9113. /// </summary>
  9114. /// <returns></returns>
  9115. [HttpPost]
  9116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9117. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9118. {
  9119. Stopwatch sw = new Stopwatch();
  9120. sw.Start();
  9121. int provinceId = dto.ProvinceId;
  9122. if (provinceId < 1) provinceId = 122; // 默认四川
  9123. RefAsync<int> total = 0;
  9124. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9125. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9126. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9127. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9128. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9129. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9130. .Select((ntf, sd, u, sd1) => new
  9131. {
  9132. Id = ntf.Id,
  9133. Area = $"{ntf.Country}-{ntf.City}",
  9134. Currency = ntf.Currency,
  9135. CurrencyCode = sd.Name,
  9136. CurrencyName = sd.Remark,
  9137. RoomCost = ntf.RoomCost,
  9138. FoodCost = ntf.FoodCost,
  9139. PublicCost = ntf.PublicCost,
  9140. TrainCost = ntf.TrainCost,
  9141. LastUpdateUserId = ntf.LastUpdateUserId,
  9142. LastUpdateUserName = u.CnName,
  9143. LastUpdateTime = ntf.LastUpdateTime
  9144. })
  9145. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9146. sw.Stop();
  9147. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9148. }
  9149. /// <summary>
  9150. /// 团组模块 - 出入境费用-移动端 - Info
  9151. /// </summary>
  9152. /// <returns></returns>
  9153. [HttpPost]
  9154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9155. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9156. {
  9157. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9158. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9159. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9160. return Ok(data);
  9161. }
  9162. /// <summary>
  9163. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9164. /// </summary>
  9165. /// <returns></returns>
  9166. [HttpPost]
  9167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9168. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9169. {
  9170. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9171. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9172. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9173. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9174. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9175. mobileInfo.DiId = dto.DiId;
  9176. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9177. if (eecInfo == null) return Ok(mobileInfo);
  9178. //验证查看权限
  9179. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9180. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9181. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9182. mobileInfo.IsAssignPerm = isSet;
  9183. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9184. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9185. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9186. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9187. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9188. {
  9189. SubId = dac.Id,
  9190. DiId = dac.DiId,
  9191. Type = dac.Type,
  9192. Days = dac.Days,
  9193. NationalTravelFeeId = dac.NationalTravelFeeId,
  9194. Arae = $"{ntf.Country}-{ntf.City}",
  9195. Cost = dac.Cost,
  9196. Currency = dac.Currency,
  9197. CurrencyName = sd.Name,
  9198. SubTotal = dac.SubTotal,
  9199. })
  9200. .ToList();
  9201. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9202. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9203. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9204. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9205. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9206. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9207. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9208. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9209. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9210. //其他款项
  9211. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9212. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9213. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9214. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9215. .OrderBy((dop, sd1, sd2) => dop.Index)
  9216. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9217. {
  9218. SubId = dop.Id,
  9219. DiId = dop.Diid,
  9220. Index = dop.Index,
  9221. SetDataId = dop.SetDataId,
  9222. SetDataName = sd1.Name,
  9223. Cost = dop.Cost,
  9224. Currency = dop.Currency,
  9225. CurrencyName = sd2.Remark,
  9226. SubTotal = dop.SubTotal,
  9227. Remark = dop.Remark,
  9228. })
  9229. .ToArray();
  9230. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9231. return Ok(mobileInfo);
  9232. }
  9233. /// <summary>
  9234. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9235. /// </summary>
  9236. /// <returns></returns>
  9237. [HttpPost]
  9238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9239. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9240. {
  9241. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9242. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9243. //验证查看权限
  9244. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9245. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9246. var userIds = await _sqlSugar
  9247. .Queryable<Grp_EnterExitCostPermission>()
  9248. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9249. .Select(x => x.UserId)
  9250. .ToArrayAsync();
  9251. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9252. var perUsersView = new List<dynamic>();
  9253. foreach (var item in perUsers)
  9254. {
  9255. bool isView1 = false;
  9256. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9257. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9258. }
  9259. return Ok(JsonView(perUsersView));
  9260. }
  9261. /// <summary>
  9262. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9263. /// </summary>
  9264. /// <returns></returns>
  9265. [HttpPost]
  9266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9267. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9268. {
  9269. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9270. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9271. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9272. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9273. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9274. //验证查看权限
  9275. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9276. //if (!isView) return Ok(JsonView(false, msg));
  9277. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9278. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9279. var subType = dto.SubType;
  9280. if (subType == 1) //1:境内费用
  9281. {
  9282. var oneData = new ChoiceOneMobileSubInfoView()
  9283. {
  9284. Id = eecInfo.Id,
  9285. ChoiceOne = eecInfo.ChoiceOne,
  9286. ChoiceOneTotalCost = eecInfo.InsidePay,
  9287. Visa = eecInfo.Visa,
  9288. VisaRemark = eecInfo.VisaRemark,
  9289. YiMiao = eecInfo.YiMiao,
  9290. HeSuan = eecInfo.HeSuan,
  9291. Service = eecInfo.Service,
  9292. Ticket = eecInfo.Ticket,
  9293. Safe = eecInfo.Safe,
  9294. FirstItemRemark = eecInfo.FirstItemRemark
  9295. };
  9296. return Ok(JsonView(oneData));
  9297. }
  9298. else if (subType == 2) //2:国际旅费
  9299. {
  9300. var twoData = new ChoiceTwoMobileSubInfoView()
  9301. {
  9302. Id = eecInfo.Id,
  9303. ChoiceTwoJJ = eecInfo.SumJJC,
  9304. OutsideJJPay = eecInfo.OutsideJJPay,
  9305. ChoiceTwoGW = eecInfo.SumGWC,
  9306. OutsideGWPay = eecInfo.OutsideGWPay,
  9307. ChoiceTwoTD = eecInfo.SumTDC,
  9308. OutsideTDPay = eecInfo.OutsideTDPay,
  9309. AirJJ = eecInfo.AirJJ,
  9310. AirGW = eecInfo.AirGW,
  9311. AirTD = eecInfo.AirTD,
  9312. CityTranffic = eecInfo.CityTranffic,
  9313. TwoItemRemark = eecInfo.TwoItemRemark
  9314. };
  9315. return Ok(JsonView(twoData));
  9316. }
  9317. else if (subType == 3) //3:住宿费
  9318. {
  9319. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9320. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9321. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9322. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9323. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9324. {
  9325. SubId = dac.Id,
  9326. DiId = dac.DiId,
  9327. Type = dac.Type,
  9328. Days = dac.Days,
  9329. NationalTravelFeeId = dac.NationalTravelFeeId,
  9330. Arae = $"{ntf.Country}-{ntf.City}",
  9331. Cost = dac.Cost,
  9332. Currency = dac.Currency,
  9333. CurrencyName = sd.Name,
  9334. SubTotal = dac.SubTotal,
  9335. })
  9336. .ToArray();
  9337. var data = new ChoiceMobileSubInfo3To6View()
  9338. {
  9339. ParentId = eecInfo.Id,
  9340. Choice = eecInfo.ChoiceThree,
  9341. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9342. Details = dayAndCostDatas
  9343. };
  9344. return Ok(JsonView(data));
  9345. }
  9346. else if (subType == 4) //4:伙食费
  9347. {
  9348. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9349. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9350. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9351. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9352. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9353. {
  9354. SubId = dac.Id,
  9355. DiId = dac.DiId,
  9356. Type = dac.Type,
  9357. Days = dac.Days,
  9358. NationalTravelFeeId = dac.NationalTravelFeeId,
  9359. Arae = $"{ntf.Country}-{ntf.City}",
  9360. Cost = dac.Cost,
  9361. Currency = dac.Currency,
  9362. CurrencyName = sd.Name,
  9363. SubTotal = dac.SubTotal,
  9364. })
  9365. .ToArray();
  9366. var data = new ChoiceMobileSubInfo3To6View()
  9367. {
  9368. ParentId = eecInfo.Id,
  9369. Choice = eecInfo.ChoiceFour,
  9370. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9371. Details = dayAndCostDatas
  9372. };
  9373. return Ok(JsonView(data));
  9374. }
  9375. else if (subType == 5) //5:公杂费
  9376. {
  9377. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9378. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9379. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9380. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9381. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9382. {
  9383. SubId = dac.Id,
  9384. DiId = dac.DiId,
  9385. Type = dac.Type,
  9386. Days = dac.Days,
  9387. NationalTravelFeeId = dac.NationalTravelFeeId,
  9388. Arae = $"{ntf.Country}-{ntf.City}",
  9389. Cost = dac.Cost,
  9390. Currency = dac.Currency,
  9391. CurrencyName = sd.Name,
  9392. SubTotal = dac.SubTotal,
  9393. })
  9394. .ToArray();
  9395. var data = new ChoiceMobileSubInfo3To6View()
  9396. {
  9397. ParentId = eecInfo.Id,
  9398. Choice = eecInfo.ChoiceFive,
  9399. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9400. Details = dayAndCostDatas
  9401. };
  9402. return Ok(JsonView(data));
  9403. }
  9404. else if (subType == 6) //6:培训费
  9405. {
  9406. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9407. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9408. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9409. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9410. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9411. {
  9412. SubId = dac.Id,
  9413. DiId = dac.DiId,
  9414. Type = dac.Type,
  9415. Days = dac.Days,
  9416. NationalTravelFeeId = dac.NationalTravelFeeId,
  9417. Arae = $"{ntf.Country}-{ntf.City}",
  9418. Cost = dac.Cost,
  9419. Currency = dac.Currency,
  9420. CurrencyName = sd.Name,
  9421. SubTotal = dac.SubTotal,
  9422. })
  9423. .ToArray();
  9424. var data = new ChoiceMobileSubInfo3To6View()
  9425. {
  9426. ParentId = eecInfo.Id,
  9427. Choice = eecInfo.ChoiceSix,
  9428. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9429. Details = dayAndCostDatas
  9430. };
  9431. return Ok(JsonView(data));
  9432. }
  9433. else if (subType == 7) //7:其他
  9434. {
  9435. //其他款项
  9436. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9437. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9438. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9439. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9440. .OrderBy((dop, sd1, sd2) => dop.Index)
  9441. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9442. {
  9443. SubId = dop.Id,
  9444. DiId = dop.Diid,
  9445. Index = dop.Index,
  9446. SetDataId = dop.SetDataId,
  9447. SetDataName = sd1.Name,
  9448. Cost = dop.Cost,
  9449. Currency = dop.Currency,
  9450. CurrencyName = sd2.Name,
  9451. SubTotal = dop.SubTotal,
  9452. Remark = dop.Remark,
  9453. })
  9454. .ToArray();
  9455. var data = new ChoiceSevenMobileSubInfoView()
  9456. {
  9457. ParentId = eecInfo.Id,
  9458. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9459. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9460. Details = otherData
  9461. };
  9462. return Ok(JsonView(data));
  9463. }
  9464. return Ok(JsonView(false));
  9465. }
  9466. #region op
  9467. /// <summary>
  9468. /// 移动端更新费用消息通知
  9469. /// </summary>
  9470. /// <param name="diid"></param>
  9471. /// <param name="id"></param>
  9472. /// <param name="currUserId"></param>
  9473. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9474. {
  9475. try
  9476. {
  9477. ////生成默认文件pdf并且通知人员
  9478. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9479. //{
  9480. // DiId = diid,
  9481. // ExportType = 1,
  9482. // SubTypeId = 1005
  9483. //}, "pdf");
  9484. ////发送通知
  9485. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9486. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9487. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9488. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9489. ////汇率信息记录
  9490. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9491. }
  9492. catch (Exception ex)
  9493. {
  9494. //记录日志
  9495. throw;
  9496. }
  9497. }
  9498. /// <summary>
  9499. /// 验证出入境费用数据是否存在
  9500. /// 不存在添加
  9501. /// </summary>
  9502. /// <param name="diId"></param>
  9503. /// <param name="currUserId"></param>
  9504. /// <returns></returns>
  9505. /// <exception cref="CustomException"></exception>
  9506. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9507. {
  9508. var parentId = 0;
  9509. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9510. if (info != null)
  9511. {
  9512. parentId = info.Id;
  9513. }
  9514. else
  9515. {
  9516. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9517. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9518. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9519. parentId = addId;
  9520. }
  9521. return parentId;
  9522. }
  9523. /// <summary>
  9524. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9525. /// </summary>
  9526. /// <returns></returns>
  9527. [HttpPost]
  9528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9529. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9530. {
  9531. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9532. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9533. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9534. //验证编辑权限
  9535. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9536. //if (!isEdit) return Ok(JsonView(false, msg));
  9537. var permissions = new List<Grp_EnterExitCostPermission>();
  9538. foreach (var userId in dto.UserIds)
  9539. {
  9540. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9541. }
  9542. if (permissions.Any())
  9543. {
  9544. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9545. {
  9546. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9547. }
  9548. _sqlSugar.BeginTran();
  9549. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9550. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9551. if (result < 1)
  9552. {
  9553. _sqlSugar.RollbackTran();
  9554. return Ok(JsonView(false));
  9555. }
  9556. _sqlSugar.CommitTran();
  9557. return Ok(JsonView(true));
  9558. }
  9559. return Ok(JsonView(false));
  9560. }
  9561. /// <summary>
  9562. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9563. /// </summary>
  9564. /// <returns></returns>
  9565. [HttpPost]
  9566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9567. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9568. {
  9569. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9570. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9571. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9572. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9573. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9574. int id = dto.Id;
  9575. if (id <= 0) //add
  9576. {
  9577. //int provinceId = dto.ProvinceId;
  9578. int groupId = dto.DiId;
  9579. //if (provinceId < 1) provinceId = 122;
  9580. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9581. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9582. if (add < 1) return Ok(JsonView(false));
  9583. id = add;
  9584. }
  9585. else //update
  9586. {
  9587. ////验证编辑权限
  9588. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9589. //if (!isEdit) return Ok(JsonView(false, msg));
  9590. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9591. if (upd < 1) return Ok(JsonView(false));
  9592. }
  9593. #region 汇率变更时更改币种相关费用
  9594. var opDayCosts = new List<Grp_DayAndCost>();
  9595. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9596. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9597. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9598. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9599. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9600. .Select((dac, sd) => new
  9601. {
  9602. dac.Id,
  9603. dac.DiId,
  9604. CurrencyCode = sd.Name,
  9605. dac.Cost
  9606. })
  9607. .ToList();
  9608. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9609. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9610. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9611. .Select((dop, sd) => new
  9612. {
  9613. dop.Id,
  9614. dop.Diid,
  9615. CurrencyCode = sd.Name,
  9616. dop.Cost
  9617. })
  9618. .ToList();
  9619. if (dayCosts.Count > 0)
  9620. {
  9621. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9622. foreach (var dc in new_dayCosts)
  9623. {
  9624. var thisCurrency = dc.Key.ToUpper();
  9625. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9626. if (thisRate == 0.00M) continue;
  9627. foreach (var dcSub in dc)
  9628. {
  9629. opDayCosts.Add(new Grp_DayAndCost()
  9630. {
  9631. Id = dcSub.Id,
  9632. DiId = dcSub.DiId,
  9633. Cost = dcSub.Cost,
  9634. SubTotal = dcSub.Cost * thisRate,
  9635. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9636. });
  9637. }
  9638. }
  9639. if (opDayCosts.Count > 0)
  9640. {
  9641. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9642. }
  9643. }
  9644. if (dayOtherCosts.Count > 0)
  9645. {
  9646. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9647. foreach (var dc in new_dayOtherCosts)
  9648. {
  9649. var thisCurrency = dc.Key.ToUpper();
  9650. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9651. if (thisRate == 0.00M) continue;
  9652. foreach (var dcSub in dc)
  9653. {
  9654. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9655. {
  9656. Id = dcSub.Id,
  9657. Diid = dcSub.Diid,
  9658. Cost = dcSub.Cost,
  9659. SubTotal = dcSub.Cost * thisRate,
  9660. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9661. });
  9662. }
  9663. }
  9664. if (opDayOtherCosts.Count > 0)
  9665. {
  9666. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9667. }
  9668. }
  9669. #endregion
  9670. //消息通知
  9671. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9672. //汇率信息记录
  9673. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9674. return Ok(JsonView(new { parentId = id }));
  9675. }
  9676. /// <summary>
  9677. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9678. /// </summary>
  9679. /// <returns></returns>
  9680. [HttpPost]
  9681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9682. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9683. {
  9684. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9685. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9686. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9687. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9688. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9689. int id = dto.Id;
  9690. if (id <= 0) //add
  9691. {
  9692. checkboxInfo.CreateUserId = dto.CurrUserId;
  9693. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9694. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9695. if (add < 1) return Ok(JsonView(false));
  9696. }
  9697. else //update
  9698. {
  9699. ////验证编辑权限
  9700. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9701. //if (!isEdit) return Ok(JsonView(false, msg));
  9702. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9703. .UpdateColumns(x => new
  9704. {
  9705. x.ChoiceOne,
  9706. x.ChoiceTwo,
  9707. x.SumJJC,
  9708. x.SumGWC,
  9709. x.SumTDC,
  9710. x.ChoiceThree,
  9711. x.ChoiceFour,
  9712. x.ChoiceFive,
  9713. x.ChoiceSix,
  9714. x.OtherExpenses_Checked
  9715. })
  9716. .Where(x => x.Id == id)
  9717. .ExecuteCommandAsync();
  9718. if (upd < 1) return Ok(JsonView(false));
  9719. }
  9720. return Ok(JsonView(new { parentId = id }));
  9721. }
  9722. /// <summary>
  9723. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9724. /// </summary>
  9725. /// <returns></returns>
  9726. [HttpPost]
  9727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9728. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9729. {
  9730. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9731. // if (provinceId < 1) provinceId = 122;
  9732. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9733. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9734. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9735. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9736. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9737. var checkboxInfo = new Grp_EnterExitCost()
  9738. {
  9739. Id = id,
  9740. //ProvinceId = provinceId,
  9741. DiId = diId,
  9742. CreateUserId = currUserId
  9743. };
  9744. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9745. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9746. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9747. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9748. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9749. if (id <= 0) //add
  9750. {
  9751. checkboxInfo.CreateUserId = dto.CurrUserId;
  9752. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9753. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9754. if (add < 1) return Ok(JsonView(false));
  9755. }
  9756. else //update
  9757. {
  9758. ////验证编辑权限
  9759. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9760. //if (!isEdit) return Ok(JsonView(false, msg));
  9761. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9762. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9763. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9764. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9765. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9766. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9767. .Where(x => x.Id == id)
  9768. .ExecuteCommandAsync();
  9769. if (upd < 1) return Ok(JsonView(false));
  9770. }
  9771. return Ok(JsonView(new { parentId = id }));
  9772. }
  9773. /// <summary>
  9774. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9775. /// </summary>
  9776. /// <returns></returns>
  9777. [HttpPost]
  9778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9779. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9780. {
  9781. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9782. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9783. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9784. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9785. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9786. info.FirstItemRemark = dto.FirstItemRemark;
  9787. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9788. int id = dto.Id;
  9789. if (id <= 0) //add
  9790. {
  9791. info.CreateUserId = dto.CurrUserId;
  9792. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9793. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9794. if (add < 1) return Ok(JsonView(false));
  9795. id = add;
  9796. }
  9797. else //update
  9798. {
  9799. ////验证编辑权限
  9800. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9801. //if (!isEdit) return Ok(JsonView(false, msg));
  9802. var upd = await _sqlSugar.Updateable(info)
  9803. .UpdateColumns(x => new
  9804. {
  9805. x.ChoiceOne,
  9806. x.InsidePay,
  9807. x.VisaRemark,
  9808. x.Visa,
  9809. x.Service,
  9810. x.Safe,
  9811. x.Ticket,
  9812. x.HeSuan,
  9813. x.YiMiao,
  9814. x.FirstItemRemark
  9815. })
  9816. .Where(x => x.Id == id)
  9817. .ExecuteCommandAsync();
  9818. if (upd < 1) return Ok(JsonView(false));
  9819. }
  9820. //消息通知
  9821. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9822. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9823. }
  9824. /// <summary>
  9825. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9826. /// </summary>
  9827. /// <returns></returns>
  9828. [HttpPost]
  9829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9830. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9831. {
  9832. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9833. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9834. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9835. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9836. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9837. info.DiId = dto.DiId;
  9838. //info.ProvinceId = dto.ProvinceId;
  9839. info.OutsideJJPay = dto.OutsideJJPay;
  9840. info.OutsideGWPay = dto.OutsideGWPay;
  9841. info.OutsideTDPay = dto.OutsideTDPay;
  9842. info.AirJJ = dto.AirJJ;
  9843. info.AirGW = dto.AirGW;
  9844. info.AirTD = dto.AirTD;
  9845. info.CityTranffic = dto.CityTranffic;
  9846. info.TwoItemRemark = dto.TwoItemRemark;
  9847. info.SumJJC = dto.ChoiceTwoJJ;
  9848. info.SumGWC = dto.ChoiceTwoGW;
  9849. info.SumTDC = dto.ChoiceTwoTD;
  9850. int id = dto.Id;
  9851. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9852. if (id <= 0) //add
  9853. {
  9854. info.CreateUserId = dto.CurrUserId;
  9855. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9856. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9857. if (addId <= 0) return Ok(JsonView(false));
  9858. id = addId;
  9859. }
  9860. else //update
  9861. {
  9862. ////验证编辑权限
  9863. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9864. //if (!isEdit) return Ok(JsonView(false, msg));
  9865. var upd = await _sqlSugar.Updateable(info)
  9866. .UpdateColumns(x => new
  9867. {
  9868. x.SumJJC,
  9869. x.OutsideJJPay,
  9870. x.SumGWC,
  9871. x.OutsideGWPay,
  9872. x.SumTDC,
  9873. x.OutsideTDPay,
  9874. x.AirJJ,
  9875. x.AirGW,
  9876. x.AirTD,
  9877. x.CityTranffic,
  9878. x.TwoItemRemark
  9879. })
  9880. .Where(x => x.Id == id)
  9881. .ExecuteCommandAsync();
  9882. if (upd < 1) return Ok(JsonView(false));
  9883. }
  9884. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9885. gwcItemTotal = info.AirGW + info.CityTranffic;
  9886. tdcItemTotal = info.AirTD + info.CityTranffic;
  9887. //消息通知
  9888. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9889. return Ok(JsonView(new
  9890. {
  9891. parentId = id,
  9892. choiceTwoJJ = dto.ChoiceTwoJJ,
  9893. jjcItemTotal = jjcItemTotal,
  9894. choiceTwoGW = dto.ChoiceTwoGW,
  9895. gwcItemTotal = gwcItemTotal,
  9896. choiceTwoTD = dto.ChoiceTwoTD,
  9897. tdcItemTotal = tdcItemTotal
  9898. }));
  9899. }
  9900. /// <summary>
  9901. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9902. /// </summary>
  9903. /// <returns></returns>
  9904. [HttpPost]
  9905. [ApiExplorerSettings(IgnoreApi = true)]
  9906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9907. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9908. {
  9909. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9910. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9911. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9912. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9913. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9914. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9915. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9916. var infos = infos1.Select(x => new Grp_DayAndCost
  9917. {
  9918. Id = x.Id,
  9919. DiId = dto.DiId,
  9920. Type = dto.FeeType,
  9921. Days = x.Days,
  9922. NationalTravelFeeId = x.NationalTravelFeeId,
  9923. Cost = x.Cost,
  9924. Currency = x.Currency,
  9925. SubTotal = x.SubTotal,
  9926. CreateUserId = dto.CurrUserId
  9927. })
  9928. .ToList();
  9929. var adds = infos.Where(x => x.Id <= 0).ToList();
  9930. var upds = infos.Where(x => x.Id > 0).ToList();
  9931. if (adds.Count > 0)
  9932. {
  9933. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9934. if (add < 1) return Ok(JsonView(false));
  9935. }
  9936. if (upds.Count > 0)
  9937. {
  9938. var upd = await _sqlSugar.Updateable(adds)
  9939. .UpdateColumns(x => new
  9940. {
  9941. x.Days,
  9942. x.NationalTravelFeeId,
  9943. x.Cost,
  9944. x.Currency,
  9945. x.SubTotal
  9946. })
  9947. .WhereColumns(x => new { x.Id })
  9948. .ExecuteCommandAsync();
  9949. if (upd < 1) return Ok(JsonView(false));
  9950. }
  9951. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9952. //消息通知
  9953. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9954. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9955. return Ok(JsonView(new { itemTotal = itemTotal }));
  9956. }
  9957. /// <summary>
  9958. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9959. /// </summary>
  9960. /// <returns></returns>
  9961. [HttpPost]
  9962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9963. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9964. {
  9965. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9966. int subId = dto.SubId, feeType = dto.FeeType;
  9967. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9968. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9969. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9970. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9971. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9972. subInfo.Id = subId;
  9973. subInfo.DiId = dto.DiId;
  9974. if (feeType == 3) subInfo.Type = 1;
  9975. else if (feeType == 4) subInfo.Type = 2;
  9976. else if (feeType == 5) subInfo.Type = 3;
  9977. else if (feeType == 6) subInfo.Type = 4;
  9978. subInfo.CreateUserId = dto.CurrUserId;
  9979. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9980. if (parentId < 1) return Ok(JsonView(false));
  9981. //子表op
  9982. if (subId < 1)
  9983. {
  9984. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9985. if (subAdd < 1) return Ok(JsonView(false));
  9986. }
  9987. else
  9988. {
  9989. ////验证编辑权限
  9990. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9991. //if (!isEdit) return Ok(JsonView(false, msg));
  9992. var subUpd = await _sqlSugar.Updateable(subInfo)
  9993. .UpdateColumns(x => new
  9994. {
  9995. x.Days,
  9996. x.NationalTravelFeeId,
  9997. x.Cost,
  9998. x.Currency,
  9999. x.SubTotal
  10000. })
  10001. .WhereColumns(x => new { x.Id })
  10002. .ExecuteCommandAsync();
  10003. if (subUpd < 1) return Ok(JsonView(false));
  10004. }
  10005. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10006. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10007. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10008. }
  10009. /// <summary>
  10010. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10011. /// </summary>
  10012. /// <returns></returns>
  10013. [HttpPost]
  10014. [ApiExplorerSettings(IgnoreApi = true)]
  10015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10016. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10017. {
  10018. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10019. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10020. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10021. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10022. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10023. {
  10024. Id = x.Id,
  10025. Diid = dto.DiId,
  10026. SetDataId = x.SetDataId,
  10027. Index = x.Index,
  10028. Cost = x.Cost,
  10029. Currency = x.Currency,
  10030. SubTotal = x.SubTotal,
  10031. CreateUserId = dto.CurrUserId,
  10032. Remark = x.Remark
  10033. }).ToList();
  10034. var adds = infos.Where(x => x.Id <= 0).ToList();
  10035. var upds = infos.Where(x => x.Id > 0).ToList();
  10036. if (adds.Count > 0)
  10037. {
  10038. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10039. if (add < 1) return Ok(JsonView(false));
  10040. }
  10041. if (upds.Count > 0)
  10042. {
  10043. var upd = await _sqlSugar.Updateable(adds)
  10044. .UpdateColumns(x => new
  10045. {
  10046. x.Index,
  10047. x.SetDataId,
  10048. x.Cost,
  10049. x.Currency,
  10050. x.SubTotal,
  10051. x.Remark
  10052. })
  10053. .WhereColumns(x => new { x.Id })
  10054. .ExecuteCommandAsync();
  10055. if (upd < 1) return Ok(JsonView(false));
  10056. }
  10057. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10058. //消息通知
  10059. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10060. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10061. return Ok(JsonView(new { itemTotal = itemTotal }));
  10062. }
  10063. /// <summary>
  10064. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10065. /// </summary>
  10066. /// <returns></returns>
  10067. [HttpPost]
  10068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10069. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10070. {
  10071. int subId = dto.SubId;
  10072. int diId = dto.Diid;
  10073. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10074. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10075. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10076. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10077. subInfo.Id = subId;
  10078. subInfo.Diid = dto.Diid;
  10079. subInfo.CreateUserId = dto.CurrUserId;
  10080. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10081. if (parentId < 1) return Ok(JsonView(false));
  10082. #region 子表op
  10083. if (subId < 1)//add
  10084. {
  10085. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10086. if (subAdd < 1) return Ok(JsonView(false));
  10087. }
  10088. else //upd
  10089. {
  10090. ////验证编辑权限
  10091. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10092. //if (!isEdit) return Ok(JsonView(false, msg));
  10093. var subUpd = await _sqlSugar.Updateable(subInfo)
  10094. .UpdateColumns(x => new
  10095. {
  10096. x.Index,
  10097. x.SetDataId,
  10098. x.Cost,
  10099. x.Currency,
  10100. x.SubTotal,
  10101. x.Remark
  10102. })
  10103. .WhereColumns(x => new { x.Id })
  10104. .ExecuteCommandAsync();
  10105. if (subUpd < 1) return Ok(JsonView(false));
  10106. }
  10107. #endregion
  10108. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10109. //消息通知
  10110. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10111. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10112. }
  10113. /// <summary>
  10114. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10115. /// </summary>
  10116. /// <returns></returns>
  10117. [HttpPost]
  10118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10119. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10120. {
  10121. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10122. if (data.Code != 0)
  10123. {
  10124. return Ok(JsonView(false, data.Msg));
  10125. }
  10126. return Ok(JsonView(true, "操作成功!", data.Data));
  10127. }
  10128. /// <summary>
  10129. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10130. /// </summary>
  10131. /// <param name="dto"></param>
  10132. /// <returns></returns>
  10133. [HttpPost]
  10134. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10135. {
  10136. var data = new Grp_DayOtherPrice()
  10137. {
  10138. Id = dto.Id,
  10139. IsDel = 1,
  10140. DeleteUserId = dto.DeleteUserId,
  10141. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10142. };
  10143. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10144. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10145. return Ok(JsonView(false, "删除失败!"));
  10146. }
  10147. #endregion
  10148. #endregion
  10149. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10150. /// <summary>
  10151. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10152. /// </summary>
  10153. /// <returns></returns>
  10154. [HttpGet]
  10155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10156. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10157. {
  10158. var provData = await _groupRepository.ProvinceBasicSource();
  10159. return Ok(JsonView(true, "查询成功!", provData));
  10160. }
  10161. /// <summary>
  10162. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10163. /// </summary>
  10164. /// <returns></returns>
  10165. [HttpPost]
  10166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10167. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10168. {
  10169. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10170. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10171. RefAsync<int> total = 0;
  10172. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10173. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10174. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10175. .Select(x => new
  10176. {
  10177. Id = x.Id,
  10178. DraftName = x.DraftName,
  10179. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10180. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10181. .Any()
  10182. })
  10183. .OrderByDescending(x => x.Id)
  10184. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10185. return Ok(JsonView(true, "查询成功!", data, total));
  10186. }
  10187. /// <summary>
  10188. /// 出入境费用-草稿 移动端
  10189. /// 获取币种基础数据(含逻辑处理)
  10190. /// </summary>
  10191. /// <returns></returns>
  10192. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10193. {
  10194. return await GeneralMethod.EnterExitCostInitRate();
  10195. }
  10196. /// <summary>
  10197. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10198. /// </summary>
  10199. /// <returns></returns>
  10200. [HttpPost]
  10201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10202. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10203. {
  10204. //验证城市归属并给默认值
  10205. int provinceId = dto.ProvinceId;
  10206. if (provinceId < 1) provinceId = 122;
  10207. var dataSource = await _sqlSugar
  10208. .Queryable<Sys_SetData>()
  10209. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10210. .ToListAsync();
  10211. //三公费用-Word明细类型
  10212. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10213. .Select(x => new SetDataInfoView
  10214. {
  10215. Id = x.Id,
  10216. Name = x.Name,
  10217. Remark = x.Remark
  10218. })
  10219. .ToList();
  10220. //三公费用-Excel明细类型
  10221. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10222. .Select(x => new SetDataInfoView
  10223. {
  10224. Id = x.Id,
  10225. Name = x.Name,
  10226. Remark = x.Remark
  10227. })
  10228. .ToList();
  10229. //默认币种显示
  10230. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10231. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10232. return Ok(JsonView(true, "查询成功!", new
  10233. {
  10234. WordTypeData = wordTypeData,
  10235. ExcelTypeData = excelTypeData,
  10236. CurrencyInit = _currencyInfos,
  10237. viewPermissionData = viewPermissionData
  10238. }));
  10239. }
  10240. /// <summary>
  10241. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10242. /// </summary>
  10243. /// <returns></returns>
  10244. [HttpPost]
  10245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10246. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10247. {
  10248. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10249. RefAsync<int> total = 0;
  10250. int diId = 0;
  10251. var status = int.TryParse(dto.GroupName, out diId);
  10252. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10253. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10254. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10255. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10256. .OrderByDescending(x => x.VisitStartDate)
  10257. .Select(x => new
  10258. {
  10259. Id = x.Id,
  10260. GroupName = x.TeamName
  10261. })
  10262. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10263. return Ok(JsonView(true, "查询成功!", data, total));
  10264. }
  10265. /// <summary>
  10266. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10267. /// </summary>
  10268. /// <returns></returns>
  10269. [HttpPost]
  10270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10271. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10272. {
  10273. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10274. RefAsync<int> total = 0;
  10275. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10276. .Where(x => x.IsDel == 0 && x.STid == 66)
  10277. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10278. .Select(x => new
  10279. {
  10280. id = x.Id,
  10281. name = x.Name,
  10282. remark = x.Remark,
  10283. })
  10284. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10285. return Ok(JsonView(true, "查询成功!", data, total));
  10286. }
  10287. /// <summary>
  10288. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10289. /// </summary>
  10290. /// <returns></returns>
  10291. [HttpPost]
  10292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10293. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10294. {
  10295. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10296. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10297. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10298. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10299. var groupOtherRateData = groupRateData.TeamRates;
  10300. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10301. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10302. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10303. groupOtherRateData = groupOtherRateData
  10304. .Select(x => new TeamRateDescAddCurrencyIdView
  10305. {
  10306. CurrencyId = x.CurrencyId,
  10307. CurrencyName = x.CurrencyName,
  10308. CurrencyCode = x.CurrencyCode,
  10309. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10310. }).ToList();
  10311. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10312. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10313. }
  10314. /// <summary>
  10315. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10316. /// </summary>
  10317. /// <returns></returns>
  10318. [HttpPost]
  10319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10320. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10321. {
  10322. int portType = dto.PortType;
  10323. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10324. var tipsData = new List<int>() { 1, 2, 3 };
  10325. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10326. if (dto.TipsType == 1)
  10327. {
  10328. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10329. }
  10330. else if (dto.TipsType == 2)
  10331. {
  10332. if (portType == 2)
  10333. {
  10334. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10335. }
  10336. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10337. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10338. .Select(x => x.NationalTravelFeeId)
  10339. .Distinct()
  10340. .ToListAsync();
  10341. if (portType == 2)
  10342. {
  10343. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10344. }
  10345. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10346. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10347. .Select(x => x.Country)
  10348. .Distinct()
  10349. .ToArrayAsync();
  10350. if (portType == 2)
  10351. {
  10352. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10353. }
  10354. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10355. return Ok(JsonView(true, "查询成功!", new
  10356. {
  10357. totalAmt = totalAmt,
  10358. remark = remark
  10359. }));
  10360. }
  10361. else if (dto.TipsType == 3)
  10362. {
  10363. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10364. }
  10365. return Ok(JsonView(false));
  10366. }
  10367. /// <summary>
  10368. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10369. /// </summary>
  10370. /// <returns></returns>
  10371. [HttpPost]
  10372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10373. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10374. {
  10375. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10376. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10377. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10378. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10379. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10380. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10381. var info = new Grp_EnterExitCostDraft()
  10382. {
  10383. ProvinceId = dto.ProvinceId,
  10384. DraftName = dto.DraftName,
  10385. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10386. CreateUserId = dto.CurrUserId
  10387. };
  10388. _sqlSugar.BeginTran();
  10389. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10390. if (draftId < 1)
  10391. {
  10392. _sqlSugar.RollbackTran();
  10393. return Ok(JsonView(false, "草稿创建失败!"));
  10394. }
  10395. //添加默认权限
  10396. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10397. _sqlSugar.CommitTran();
  10398. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10399. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10400. mobileInfo.Id = draftId;
  10401. mobileInfo.DraftName = dto.DraftName;
  10402. mobileInfo.Currencys = rateInfos;
  10403. mobileInfo.IsAssignPerm = assignPerm;
  10404. return Ok(JsonView(mobileInfo));
  10405. }
  10406. /// <summary>
  10407. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10408. /// </summary>
  10409. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10410. /// <summary>
  10411. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10412. /// </summary>
  10413. /// <returns></returns>
  10414. [HttpPost]
  10415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10416. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10417. {
  10418. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10419. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10420. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10421. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10422. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10423. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10424. //验证查看编辑权限
  10425. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10426. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10427. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10428. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10429. mobileInfo.IsAssignPerm = assignPerm;
  10430. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10431. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10432. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10433. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10434. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10435. {
  10436. ParentId = dac.ParentId,
  10437. SubId = dac.Id,
  10438. Type = dac.Type,
  10439. Days = dac.Days,
  10440. NationalTravelFeeId = dac.NationalTravelFeeId,
  10441. Arae = $"{ntf.Country}-{ntf.City}",
  10442. Cost = dac.Cost,
  10443. Currency = dac.Currency,
  10444. CurrencyName = sd.Name,
  10445. SubTotal = dac.SubTotal,
  10446. })
  10447. .ToList();
  10448. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10449. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10450. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10451. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10452. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10453. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10454. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10455. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10456. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10457. //其他款项
  10458. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10459. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10460. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10461. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10462. .OrderBy((dop, sd1, sd2) => dop.Index)
  10463. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10464. {
  10465. ParentId = dop.ParentId,
  10466. SubId = dop.Id,
  10467. Index = dop.Index,
  10468. SetDataId = dop.SetDataId,
  10469. SetDataName = sd1.Name,
  10470. Cost = dop.Cost,
  10471. Currency = dop.Currency,
  10472. CurrencyName = sd2.Remark,
  10473. SubTotal = dop.SubTotal,
  10474. Remark = dop.Remark,
  10475. })
  10476. .ToArray();
  10477. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10478. return Ok(mobileInfo);
  10479. }
  10480. /// <summary>
  10481. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10482. /// </summary>
  10483. /// <returns></returns>
  10484. [HttpPost]
  10485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10486. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10487. {
  10488. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10489. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10490. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10491. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10492. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10493. //验证查看编辑权限
  10494. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10495. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10496. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10497. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10498. var subType = dto.SubType;
  10499. if (subType == 1) //1:境内费用
  10500. {
  10501. var oneData = new ChoiceOneMobileSubInfoView()
  10502. {
  10503. Id = eecInfo.Id,
  10504. ChoiceOne = eecInfo.ChoiceOne,
  10505. ChoiceOneTotalCost = eecInfo.InsidePay,
  10506. Visa = eecInfo.Visa,
  10507. VisaRemark = eecInfo.VisaRemark,
  10508. YiMiao = eecInfo.YiMiao,
  10509. HeSuan = eecInfo.HeSuan,
  10510. Service = eecInfo.Service,
  10511. Ticket = eecInfo.Ticket,
  10512. Safe = eecInfo.Safe,
  10513. FirstItemRemark = eecInfo.FirstItemRemark
  10514. };
  10515. return Ok(JsonView(oneData));
  10516. }
  10517. else if (subType == 2) //2:国际旅费
  10518. {
  10519. var twoData = new ChoiceTwoMobileSubInfoView()
  10520. {
  10521. Id = eecInfo.Id,
  10522. ChoiceTwoJJ = eecInfo.SumJJC,
  10523. OutsideJJPay = eecInfo.OutsideJJPay,
  10524. ChoiceTwoGW = eecInfo.SumGWC,
  10525. OutsideGWPay = eecInfo.OutsideGWPay,
  10526. ChoiceTwoTD = eecInfo.SumTDC,
  10527. OutsideTDPay = eecInfo.OutsideTDPay,
  10528. AirJJ = eecInfo.AirJJ,
  10529. AirGW = eecInfo.AirGW,
  10530. AirTD = eecInfo.AirTD,
  10531. CityTranffic = eecInfo.CityTranffic,
  10532. TwoItemRemark = eecInfo.TwoItemRemark
  10533. };
  10534. return Ok(JsonView(twoData));
  10535. }
  10536. else if (subType == 3) //3:住宿费
  10537. {
  10538. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10539. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10540. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10541. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10542. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10543. {
  10544. ParentId = dac.ParentId,
  10545. SubId = dac.Id,
  10546. Type = dac.Type,
  10547. Days = dac.Days,
  10548. NationalTravelFeeId = dac.NationalTravelFeeId,
  10549. Arae = $"{ntf.Country}-{ntf.City}",
  10550. Cost = dac.Cost,
  10551. Currency = dac.Currency,
  10552. CurrencyName = sd.Name,
  10553. SubTotal = dac.SubTotal,
  10554. })
  10555. .ToArray();
  10556. var data = new ChoiceDraftMobileSubInfo3To6View()
  10557. {
  10558. ParentId = eecInfo.Id,
  10559. Choice = eecInfo.ChoiceThree,
  10560. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10561. Details = dayAndCostDatas
  10562. };
  10563. return Ok(JsonView(data));
  10564. }
  10565. else if (subType == 4) //4:伙食费
  10566. {
  10567. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10568. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10569. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10570. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10571. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10572. {
  10573. ParentId = dac.ParentId,
  10574. SubId = dac.Id,
  10575. Type = dac.Type,
  10576. Days = dac.Days,
  10577. NationalTravelFeeId = dac.NationalTravelFeeId,
  10578. Arae = $"{ntf.Country}-{ntf.City}",
  10579. Cost = dac.Cost,
  10580. Currency = dac.Currency,
  10581. CurrencyName = sd.Name,
  10582. SubTotal = dac.SubTotal,
  10583. })
  10584. .ToArray();
  10585. var data = new ChoiceDraftMobileSubInfo3To6View()
  10586. {
  10587. ParentId = eecInfo.Id,
  10588. Choice = eecInfo.ChoiceFour,
  10589. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10590. Details = dayAndCostDatas
  10591. };
  10592. return Ok(JsonView(data));
  10593. }
  10594. else if (subType == 5) //5:公杂费
  10595. {
  10596. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10597. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10598. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10599. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10600. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10601. {
  10602. ParentId = dac.ParentId,
  10603. SubId = dac.Id,
  10604. Type = dac.Type,
  10605. Days = dac.Days,
  10606. NationalTravelFeeId = dac.NationalTravelFeeId,
  10607. Arae = $"{ntf.Country}-{ntf.City}",
  10608. Cost = dac.Cost,
  10609. Currency = dac.Currency,
  10610. CurrencyName = sd.Name,
  10611. SubTotal = dac.SubTotal,
  10612. })
  10613. .ToArray();
  10614. var data = new ChoiceDraftMobileSubInfo3To6View()
  10615. {
  10616. ParentId = eecInfo.Id,
  10617. Choice = eecInfo.ChoiceFive,
  10618. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10619. Details = dayAndCostDatas
  10620. };
  10621. return Ok(JsonView(data));
  10622. }
  10623. else if (subType == 6) //6:培训费
  10624. {
  10625. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10626. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10627. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10628. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10629. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10630. {
  10631. ParentId = dac.ParentId,
  10632. SubId = dac.Id,
  10633. Type = dac.Type,
  10634. Days = dac.Days,
  10635. NationalTravelFeeId = dac.NationalTravelFeeId,
  10636. Arae = $"{ntf.Country}-{ntf.City}",
  10637. Cost = dac.Cost,
  10638. Currency = dac.Currency,
  10639. CurrencyName = sd.Name,
  10640. SubTotal = dac.SubTotal,
  10641. })
  10642. .ToArray();
  10643. var data = new ChoiceDraftMobileSubInfo3To6View()
  10644. {
  10645. ParentId = eecInfo.Id,
  10646. Choice = eecInfo.ChoiceSix,
  10647. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10648. Details = dayAndCostDatas
  10649. };
  10650. return Ok(JsonView(data));
  10651. }
  10652. else if (subType == 7) //7:其他
  10653. {
  10654. //其他款项
  10655. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10656. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10657. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10658. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10659. .OrderBy((dop, sd1, sd2) => dop.Index)
  10660. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10661. {
  10662. ParentId = dop.ParentId,
  10663. SubId = dop.Id,
  10664. Index = dop.Index,
  10665. SetDataId = dop.SetDataId,
  10666. SetDataName = sd1.Name,
  10667. Cost = dop.Cost,
  10668. Currency = dop.Currency,
  10669. CurrencyName = sd2.Name,
  10670. SubTotal = dop.SubTotal,
  10671. Remark = dop.Remark,
  10672. })
  10673. .ToArray();
  10674. var data = new ChoiceSevenDraftMobileSubInfoView()
  10675. {
  10676. ParentId = eecInfo.Id,
  10677. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10678. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10679. Details = otherData
  10680. };
  10681. return Ok(JsonView(data));
  10682. }
  10683. return Ok(JsonView(false));
  10684. }
  10685. #region op
  10686. /// <summary>
  10687. /// 移动端更新费用消息通知
  10688. /// </summary>
  10689. /// <param name="draftId"></param>
  10690. /// <param name="id"></param>
  10691. /// <param name="currUserId"></param>
  10692. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10693. {
  10694. try
  10695. {
  10696. ////生成默认文件pdf并且通知人员
  10697. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10698. //{
  10699. // DiId = draftId,
  10700. // ExportType = 1,
  10701. // SubTypeId = 1005
  10702. //}, "pdf");
  10703. ////发送通知
  10704. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10705. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10706. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10707. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10708. ////汇率信息记录
  10709. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10710. }
  10711. catch (Exception ex)
  10712. {
  10713. //记录日志
  10714. throw;
  10715. }
  10716. }
  10717. /// <summary>
  10718. /// 验证出入境费用数据是否存在
  10719. /// 不存在添加
  10720. /// </summary>
  10721. /// <param name="draftId"></param>
  10722. /// <param name="currUserId"></param>
  10723. /// <returns></returns>
  10724. /// <exception cref="CustomException"></exception>
  10725. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10726. {
  10727. var parentId = 0;
  10728. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10729. if (info != null) parentId = info.Id;
  10730. else
  10731. {
  10732. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10733. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10734. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10735. parentId = addId;
  10736. }
  10737. return parentId;
  10738. }
  10739. /// <summary>
  10740. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10741. /// </summary>
  10742. /// <returns></returns>
  10743. [HttpPost]
  10744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10745. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10746. {
  10747. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10748. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10749. //验证查看权限
  10750. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10751. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10752. var userIds = await _sqlSugar
  10753. .Queryable<Grp_EnterExitCostDraftPermission>()
  10754. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10755. .Select(x => x.UserId)
  10756. .ToArrayAsync();
  10757. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10758. var perUsersView = new List<dynamic>();
  10759. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10760. var viewPermissionData = new List<PermissionViewUserview>();
  10761. if (feeBasePerm.Any())
  10762. {
  10763. foreach (var item in feeBasePerm)
  10764. {
  10765. if (item.Users.Any())
  10766. {
  10767. viewPermissionData.AddRange(item.Users);
  10768. }
  10769. }
  10770. }
  10771. foreach (var item in perUsers)
  10772. {
  10773. bool isView1 = false;
  10774. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10775. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10776. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10777. }
  10778. return Ok(JsonView(perUsersView));
  10779. }
  10780. /// <summary>
  10781. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10782. /// </summary>
  10783. /// <returns></returns>
  10784. [HttpPost]
  10785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10786. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10787. {
  10788. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10789. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10790. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10791. //验证查看编辑权限
  10792. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10793. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10794. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10795. foreach (var userId in dto.UserIds)
  10796. {
  10797. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10798. }
  10799. if (permissions.Any())
  10800. {
  10801. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10802. {
  10803. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10804. }
  10805. _sqlSugar.BeginTran();
  10806. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10807. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10808. if (result < 1)
  10809. {
  10810. _sqlSugar.RollbackTran();
  10811. return Ok(JsonView(false));
  10812. }
  10813. _sqlSugar.CommitTran();
  10814. return Ok(JsonView(true));
  10815. }
  10816. return Ok(JsonView(false));
  10817. }
  10818. /// <summary>
  10819. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10820. /// </summary>
  10821. /// <returns></returns>
  10822. [HttpPost]
  10823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10824. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10825. {
  10826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10827. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10828. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10829. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10830. int id = dto.DraftId;
  10831. if (id <= 0) //add
  10832. {
  10833. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10834. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10835. if (add < 1) return Ok(JsonView(false));
  10836. id = add;
  10837. }
  10838. else //update
  10839. {
  10840. //验证查看编辑权限
  10841. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10842. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10843. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10844. if (upd < 1) return Ok(JsonView(false));
  10845. }
  10846. return Ok(JsonView(new { parentId = id }));
  10847. }
  10848. /// <summary>
  10849. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10850. /// </summary>
  10851. /// <returns></returns>
  10852. [HttpPost]
  10853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10854. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10855. {
  10856. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10857. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10858. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10859. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10860. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10861. int id = dto.DraftId;
  10862. if (id <= 0) //add
  10863. {
  10864. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10865. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10866. if (add < 1) return Ok(JsonView(false));
  10867. id = add;
  10868. }
  10869. else //update
  10870. {
  10871. //验证查看编辑权限
  10872. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10873. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10874. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10875. if (upd < 1) return Ok(JsonView(false));
  10876. }
  10877. #region 汇率变更时更改币种相关费用
  10878. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10879. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10880. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10881. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10882. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10883. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10884. .Select((dac, sd) => new
  10885. {
  10886. dac.Id,
  10887. dac.ParentId,
  10888. CurrencyCode = sd.Name,
  10889. dac.Cost
  10890. })
  10891. .ToList();
  10892. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10893. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10894. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10895. .Select((dop, sd) => new
  10896. {
  10897. dop.Id,
  10898. dop.ParentId,
  10899. CurrencyCode = sd.Name,
  10900. dop.Cost
  10901. })
  10902. .ToList();
  10903. if (dayCosts.Count > 0)
  10904. {
  10905. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10906. foreach (var dc in new_dayCosts)
  10907. {
  10908. var thisCurrency = dc.Key.ToUpper();
  10909. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10910. if (thisRate == 0.00M) continue;
  10911. foreach (var dcSub in dc)
  10912. {
  10913. opDayCosts.Add(new Grp_DayAndCostDraft()
  10914. {
  10915. Id = dcSub.Id,
  10916. ParentId = dcSub.ParentId,
  10917. Cost = dcSub.Cost,
  10918. SubTotal = dcSub.Cost * thisRate,
  10919. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10920. });
  10921. }
  10922. }
  10923. if (opDayCosts.Count > 0)
  10924. {
  10925. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10926. }
  10927. }
  10928. if (dayOtherCosts.Count > 0)
  10929. {
  10930. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10931. foreach (var dc in new_dayOtherCosts)
  10932. {
  10933. var thisCurrency = dc.Key.ToUpper();
  10934. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10935. if (thisRate == 0.00M) continue;
  10936. foreach (var dcSub in dc)
  10937. {
  10938. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10939. {
  10940. Id = dcSub.Id,
  10941. ParentId = dcSub.ParentId,
  10942. Cost = dcSub.Cost,
  10943. SubTotal = dcSub.Cost * thisRate,
  10944. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10945. });
  10946. }
  10947. }
  10948. if (opDayOtherCosts.Count > 0)
  10949. {
  10950. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10951. }
  10952. }
  10953. #endregion
  10954. ////消息通知
  10955. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10956. ////汇率信息记录
  10957. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10958. return Ok(JsonView(new { parentId = id }));
  10959. }
  10960. /// <summary>
  10961. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  10962. /// </summary>
  10963. /// <returns></returns>
  10964. [HttpPost]
  10965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10966. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  10967. {
  10968. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10969. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10970. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10971. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10972. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10973. int id = dto.DraftId;
  10974. if (id <= 0) //add
  10975. {
  10976. checkboxInfo.ProvinceId = dto.ProvinceId;
  10977. checkboxInfo.CreateUserId = dto.CurrUserId;
  10978. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  10979. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10980. if (add < 1) return Ok(JsonView(false));
  10981. }
  10982. else //update
  10983. {
  10984. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10985. .UpdateColumns(x => new
  10986. {
  10987. x.ChoiceOne,
  10988. x.ChoiceTwo,
  10989. x.SumJJC,
  10990. x.SumGWC,
  10991. x.SumTDC,
  10992. x.ChoiceThree,
  10993. x.ChoiceFour,
  10994. x.ChoiceFive,
  10995. x.ChoiceSix,
  10996. x.OtherExpenses_Checked
  10997. })
  10998. .Where(x => x.Id == id)
  10999. .ExecuteCommandAsync();
  11000. if (upd < 1) return Ok(JsonView(false));
  11001. }
  11002. return Ok(JsonView(new { parentId = id }));
  11003. }
  11004. /// <summary>
  11005. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11006. /// </summary>
  11007. /// <returns></returns>
  11008. [HttpPost]
  11009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11010. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11011. {
  11012. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11013. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11014. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11015. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11016. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11017. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11018. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11019. var checkboxInfo = new Grp_EnterExitCostDraft()
  11020. {
  11021. Id = draftId,
  11022. ProvinceId = dto.ProvinceId,
  11023. CreateUserId = currUserId
  11024. };
  11025. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11026. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11027. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11028. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11029. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11030. if (draftId <= 0) //add
  11031. {
  11032. checkboxInfo.CreateUserId = dto.CurrUserId;
  11033. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11034. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11035. if (add < 1) return Ok(JsonView(false));
  11036. }
  11037. else //update
  11038. {
  11039. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11040. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11041. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11042. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11043. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11044. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11045. .Where(x => x.Id == draftId)
  11046. .ExecuteCommandAsync();
  11047. if (upd < 1) return Ok(JsonView(false));
  11048. }
  11049. return Ok(JsonView(new { parentId = draftId }));
  11050. }
  11051. /// <summary>
  11052. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11053. /// </summary>
  11054. /// <returns></returns>
  11055. [HttpPost]
  11056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11057. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11058. {
  11059. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11060. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11061. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11062. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11063. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11064. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11065. info.ProvinceId = dto.ProvinceId;
  11066. info.FirstItemRemark = dto.FirstItemRemark;
  11067. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11068. if (id <= 0) //add
  11069. {
  11070. info.CreateUserId = dto.CurrUserId;
  11071. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11072. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11073. if (add < 1) return Ok(JsonView(false));
  11074. id = add;
  11075. }
  11076. else //update
  11077. {
  11078. var upd = await _sqlSugar.Updateable(info)
  11079. .UpdateColumns(x => new
  11080. {
  11081. x.ChoiceOne,
  11082. x.InsidePay,
  11083. x.VisaRemark,
  11084. x.Visa,
  11085. x.Service,
  11086. x.Safe,
  11087. x.Ticket,
  11088. x.HeSuan,
  11089. x.YiMiao,
  11090. x.FirstItemRemark
  11091. })
  11092. .Where(x => x.Id == id)
  11093. .ExecuteCommandAsync();
  11094. if (upd < 1) return Ok(JsonView(false));
  11095. }
  11096. ////消息通知
  11097. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11098. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11099. }
  11100. /// <summary>
  11101. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11102. /// </summary>
  11103. /// <returns></returns>
  11104. [HttpPost]
  11105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11106. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11107. {
  11108. int id = dto.DraftId;
  11109. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11110. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11111. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11112. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11113. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11114. info.ProvinceId = dto.ProvinceId;
  11115. info.OutsideJJPay = dto.OutsideJJPay;
  11116. info.OutsideGWPay = dto.OutsideGWPay;
  11117. info.OutsideTDPay = dto.OutsideTDPay;
  11118. info.AirJJ = dto.AirJJ;
  11119. info.AirGW = dto.AirGW;
  11120. info.AirTD = dto.AirTD;
  11121. info.CityTranffic = dto.CityTranffic;
  11122. info.TwoItemRemark = dto.TwoItemRemark;
  11123. info.SumJJC = dto.ChoiceTwoJJ;
  11124. info.SumGWC = dto.ChoiceTwoGW;
  11125. info.SumTDC = dto.ChoiceTwoTD;
  11126. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11127. if (id <= 0) //add
  11128. {
  11129. info.CreateUserId = dto.CurrUserId;
  11130. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11131. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11132. if (addId <= 0) return Ok(JsonView(false));
  11133. id = addId;
  11134. }
  11135. else //update
  11136. {
  11137. var upd = await _sqlSugar.Updateable(info)
  11138. .UpdateColumns(x => new
  11139. {
  11140. x.SumJJC,
  11141. x.OutsideJJPay,
  11142. x.SumGWC,
  11143. x.OutsideGWPay,
  11144. x.SumTDC,
  11145. x.OutsideTDPay,
  11146. x.AirJJ,
  11147. x.AirGW,
  11148. x.AirTD,
  11149. x.CityTranffic,
  11150. x.TwoItemRemark
  11151. })
  11152. .Where(x => x.Id == id)
  11153. .ExecuteCommandAsync();
  11154. if (upd < 1) return Ok(JsonView(false));
  11155. }
  11156. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11157. gwcItemTotal = info.AirGW + info.CityTranffic;
  11158. tdcItemTotal = info.AirTD + info.CityTranffic;
  11159. ////消息通知
  11160. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11161. return Ok(JsonView(new
  11162. {
  11163. parentId = id,
  11164. choiceTwoJJ = dto.ChoiceTwoJJ,
  11165. jjcItemTotal = jjcItemTotal,
  11166. choiceTwoGW = dto.ChoiceTwoGW,
  11167. gwcItemTotal = gwcItemTotal,
  11168. choiceTwoTD = dto.ChoiceTwoTD,
  11169. tdcItemTotal = tdcItemTotal
  11170. }));
  11171. }
  11172. /// <summary>
  11173. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11174. /// </summary>
  11175. /// <returns></returns>
  11176. [HttpPost]
  11177. [ApiExplorerSettings(IgnoreApi = true)]
  11178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11179. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11180. {
  11181. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11182. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11183. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11184. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11185. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11186. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11187. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11188. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11189. {
  11190. Id = x.Id,
  11191. ParentId = dto.DraftId,
  11192. Type = dto.FeeType,
  11193. Days = x.Days,
  11194. NationalTravelFeeId = x.NationalTravelFeeId,
  11195. Cost = x.Cost,
  11196. Currency = x.Currency,
  11197. SubTotal = x.SubTotal,
  11198. CreateUserId = dto.CurrUserId
  11199. })
  11200. .ToList();
  11201. var adds = infos.Where(x => x.Id <= 0).ToList();
  11202. var upds = infos.Where(x => x.Id > 0).ToList();
  11203. if (adds.Count > 0)
  11204. {
  11205. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11206. if (add < 1) return Ok(JsonView(false));
  11207. }
  11208. if (upds.Count > 0)
  11209. {
  11210. var upd = await _sqlSugar.Updateable(adds)
  11211. .UpdateColumns(x => new
  11212. {
  11213. x.Days,
  11214. x.NationalTravelFeeId,
  11215. x.Cost,
  11216. x.Currency,
  11217. x.SubTotal
  11218. })
  11219. .WhereColumns(x => new { x.Id })
  11220. .ExecuteCommandAsync();
  11221. if (upd < 1) return Ok(JsonView(false));
  11222. }
  11223. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11224. ////消息通知
  11225. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11226. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11227. return Ok(JsonView(new { itemTotal = itemTotal }));
  11228. }
  11229. /// <summary>
  11230. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11231. /// </summary>
  11232. /// <returns></returns>
  11233. [HttpPost]
  11234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11235. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11236. {
  11237. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11238. int subId = dto.SubId, feeType = dto.FeeType;
  11239. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11240. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11241. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11242. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11243. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11244. subInfo.Id = subId;
  11245. subInfo.ParentId = dto.DraftId;
  11246. if (feeType == 3) subInfo.Type = 1;
  11247. else if (feeType == 4) subInfo.Type = 2;
  11248. else if (feeType == 5) subInfo.Type = 3;
  11249. else if (feeType == 6) subInfo.Type = 4;
  11250. subInfo.CreateUserId = dto.CurrUserId;
  11251. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11252. if (parentId < 1) return Ok(JsonView(false));
  11253. //子表op
  11254. if (subId < 1)
  11255. {
  11256. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11257. if (subAdd < 1) return Ok(JsonView(false));
  11258. }
  11259. else
  11260. {
  11261. var subUpd = await _sqlSugar.Updateable(subInfo)
  11262. .UpdateColumns(x => new
  11263. {
  11264. x.Days,
  11265. x.NationalTravelFeeId,
  11266. x.Cost,
  11267. x.Currency,
  11268. x.SubTotal
  11269. })
  11270. .WhereColumns(x => new { x.Id })
  11271. .ExecuteCommandAsync();
  11272. if (subUpd < 1) return Ok(JsonView(false));
  11273. }
  11274. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11275. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11276. }
  11277. /// <summary>
  11278. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11279. /// </summary>
  11280. /// <returns></returns>
  11281. [HttpPost]
  11282. [ApiExplorerSettings(IgnoreApi = true)]
  11283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11284. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11285. {
  11286. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11287. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11288. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11289. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11290. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11291. {
  11292. Id = x.Id,
  11293. ParentId = dto.DraftId,
  11294. SetDataId = x.SetDataId,
  11295. Index = x.Index,
  11296. Cost = x.Cost,
  11297. Currency = x.Currency,
  11298. SubTotal = x.SubTotal,
  11299. CreateUserId = dto.CurrUserId,
  11300. Remark = x.Remark
  11301. }).ToList();
  11302. var adds = infos.Where(x => x.Id <= 0).ToList();
  11303. var upds = infos.Where(x => x.Id > 0).ToList();
  11304. if (adds.Count > 0)
  11305. {
  11306. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11307. if (add < 1) return Ok(JsonView(false));
  11308. }
  11309. if (upds.Count > 0)
  11310. {
  11311. var upd = await _sqlSugar.Updateable(adds)
  11312. .UpdateColumns(x => new
  11313. {
  11314. x.Index,
  11315. x.SetDataId,
  11316. x.Cost,
  11317. x.Currency,
  11318. x.SubTotal,
  11319. x.Remark
  11320. })
  11321. .WhereColumns(x => new { x.Id })
  11322. .ExecuteCommandAsync();
  11323. if (upd < 1) return Ok(JsonView(false));
  11324. }
  11325. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11326. //消息通知
  11327. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11328. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11329. return Ok(JsonView(new { itemTotal = itemTotal }));
  11330. }
  11331. /// <summary>
  11332. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11333. /// </summary>
  11334. /// <returns></returns>
  11335. [HttpPost]
  11336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11337. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11338. {
  11339. int subId = dto.SubId, id = dto.DraftId;
  11340. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11341. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11342. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11343. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11344. subInfo.Id = subId;
  11345. subInfo.ParentId = id;
  11346. subInfo.CreateUserId = dto.CurrUserId;
  11347. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11348. if (parentId < 1) return Ok(JsonView(false));
  11349. #region 子表op
  11350. if (subId < 1)//add
  11351. {
  11352. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11353. if (subAdd < 1) return Ok(JsonView(false));
  11354. }
  11355. else //upd
  11356. {
  11357. var subUpd = await _sqlSugar.Updateable(subInfo)
  11358. .UpdateColumns(x => new
  11359. {
  11360. x.Index,
  11361. x.SetDataId,
  11362. x.Cost,
  11363. x.Currency,
  11364. x.SubTotal,
  11365. x.Remark
  11366. })
  11367. .WhereColumns(x => new { x.Id })
  11368. .ExecuteCommandAsync();
  11369. if (subUpd < 1) return Ok(JsonView(false));
  11370. }
  11371. #endregion
  11372. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11373. ////消息通知
  11374. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11375. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11376. }
  11377. /// <summary>
  11378. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11379. /// </summary>
  11380. /// <returns></returns>
  11381. [HttpPost]
  11382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11383. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11384. {
  11385. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11386. if (data.Code != 0)
  11387. {
  11388. return Ok(JsonView(false, data.Msg));
  11389. }
  11390. return Ok(JsonView(true, "操作成功!", data.Data));
  11391. }
  11392. /// <summary>
  11393. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11394. /// </summary>
  11395. /// <param name="dto"></param>
  11396. /// <returns></returns>
  11397. [HttpPost]
  11398. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11399. {
  11400. var data = new Grp_DayOtherPriceDraft()
  11401. {
  11402. Id = dto.Id,
  11403. IsDel = 1,
  11404. DeleteUserId = dto.DeleteUserId,
  11405. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11406. };
  11407. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11408. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11409. return Ok(JsonView(false, "删除失败!"));
  11410. }
  11411. #endregion
  11412. #endregion
  11413. #region 团组经理模块 出入境费用报价表
  11414. /// <summary>
  11415. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11416. /// </summary>
  11417. /// <returns></returns>
  11418. [HttpPost]
  11419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11420. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11421. {
  11422. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11423. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11424. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11425. initRates.Insert(0, cnyInfo);
  11426. liveRates.Insert(0, cnyInfo);
  11427. return Ok(JsonView(true, "查询成功!", new
  11428. {
  11429. InitRates = initRates,
  11430. LiveRates = liveRates
  11431. }));
  11432. }
  11433. /// <summary>
  11434. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11435. /// </summary>
  11436. /// <returns></returns>
  11437. [HttpPost]
  11438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11439. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  11440. {
  11441. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11442. }
  11443. /// <summary>
  11444. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11445. /// </summary>
  11446. /// <returns></returns>
  11447. [HttpPost]
  11448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11449. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  11450. {
  11451. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11452. }
  11453. /// <summary>
  11454. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11455. /// </summary>
  11456. /// <returns></returns>
  11457. [HttpPost]
  11458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11459. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11460. {
  11461. int groupId = dto.DiId,
  11462. currUserId = dto.CurrUserId;
  11463. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11464. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11465. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11466. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  11467. var infoView = info.Data as EnterExitCostInfoView;
  11468. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11469. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11470. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11471. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11472. var eecRates = infoView.Currencys;
  11473. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11474. int pplNum = 1;
  11475. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11476. var views = new List<QuoteSubItemInfo>();
  11477. #region 数据填充
  11478. var intTravelCosts = new List<QuoteSubItemInfo>();
  11479. #region 机票费用 1354
  11480. int intTravelIndex = 1;
  11481. if (infoView.SumJJC == 1)
  11482. {
  11483. intTravelCosts.Add(new QuoteSubItemInfo
  11484. {
  11485. ItemId = 1354,
  11486. Index = intTravelIndex,
  11487. FeeName = "经济舱",
  11488. UnitPrice = infoView.AirJJ,
  11489. Currency = "CNY",
  11490. Quantity = 1,
  11491. PplNum = 1,
  11492. TotalAmt = infoView.AirJJ,
  11493. Remark = "",
  11494. });
  11495. intTravelIndex++;
  11496. }
  11497. if (infoView.SumGWC == 1)
  11498. {
  11499. intTravelCosts.Add(new QuoteSubItemInfo
  11500. {
  11501. ItemId = 1354,
  11502. Index = intTravelIndex,
  11503. FeeName = "公务舱",
  11504. UnitPrice = infoView.AirGW,
  11505. Currency = "CNY",
  11506. Quantity = 1,
  11507. PplNum = 1,
  11508. TotalAmt = infoView.AirGW,
  11509. Remark = "",
  11510. });
  11511. intTravelIndex++;
  11512. }
  11513. if (infoView.SumTDC == 1)
  11514. {
  11515. intTravelCosts.Add(new QuoteSubItemInfo
  11516. {
  11517. ItemId = 1354,
  11518. Index = intTravelIndex,
  11519. FeeName = "头等舱",
  11520. UnitPrice = infoView.AirTD,
  11521. Currency = "CNY",
  11522. Quantity = 1,
  11523. PplNum = 1,
  11524. TotalAmt = infoView.AirTD,
  11525. Remark = "",
  11526. });
  11527. intTravelIndex++;
  11528. }
  11529. intTravelCosts.Add(new QuoteSubItemInfo
  11530. {
  11531. ItemId = 1354,
  11532. Index = intTravelIndex,
  11533. FeeName = "城市间交通费用",
  11534. UnitPrice = infoView.CityTranffic,
  11535. Currency = "CNY",
  11536. Quantity = 1,
  11537. PplNum = pplNum,
  11538. TotalAmt = infoView.CityTranffic * pplNum,
  11539. Remark = "",
  11540. });
  11541. views.AddRange(intTravelCosts);
  11542. #endregion
  11543. var accomCosts = new List<QuoteSubItemInfo>();
  11544. #region 住宿费 1355
  11545. if (infoView.QuarterageData.Any())
  11546. {
  11547. int accomIndex = 1;
  11548. int accomItemTypeId = 1355;
  11549. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11550. foreach (var item in groupData)
  11551. {
  11552. string feeName = string.Empty;
  11553. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11554. if (countryInfo != null)
  11555. {
  11556. feeName = countryInfo.Country;
  11557. var city = countryInfo.City;
  11558. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11559. {
  11560. feeName += $"-{city}";
  11561. }
  11562. }
  11563. var hotelInfo = item.FirstOrDefault();
  11564. if (hotelInfo == null) continue;
  11565. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11566. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11567. int quantity = item.ToList().Count;
  11568. accomCosts.Add(new QuoteSubItemInfo
  11569. {
  11570. ItemId = accomItemTypeId,
  11571. Index = accomIndex,
  11572. FeeName = feeName,
  11573. UnitPrice = hotelInfo.Cost,
  11574. Currency = thisCurrency,
  11575. Quantity = quantity,
  11576. PplNum = pplNum,
  11577. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11578. Remark = "",
  11579. });
  11580. accomIndex++;
  11581. }
  11582. views.AddRange(accomCosts);
  11583. }
  11584. #endregion
  11585. var mealCosts = new List<QuoteSubItemInfo>();
  11586. #region 餐饮费 1356
  11587. if (infoView.BoardWagesData.Any())
  11588. {
  11589. var mealIndex = 1;
  11590. int mealItemTypeId = 1356;
  11591. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11592. foreach (var item in groupData)
  11593. {
  11594. string feeName = string.Empty;
  11595. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11596. if (countryInfo != null)
  11597. {
  11598. feeName = countryInfo.Country;
  11599. var city = countryInfo.City;
  11600. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11601. {
  11602. feeName += $"-{city}";
  11603. }
  11604. }
  11605. var mealInfo = item.FirstOrDefault();
  11606. if (mealInfo == null) continue;
  11607. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11608. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11609. int quantity = item.ToList().Count;
  11610. mealCosts.Add(new QuoteSubItemInfo
  11611. {
  11612. ItemId = mealItemTypeId,
  11613. Index = mealIndex,
  11614. FeeName = feeName,
  11615. UnitPrice = mealInfo.Cost,
  11616. Currency = thisCurrency,
  11617. Quantity = quantity,
  11618. PplNum = pplNum,
  11619. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11620. Remark = "",
  11621. });
  11622. mealIndex++;
  11623. }
  11624. views.AddRange(mealCosts);
  11625. }
  11626. #endregion
  11627. var miscCosts = new List<QuoteSubItemInfo>();
  11628. #region 公杂费 1364
  11629. if (infoView.MiscellaneousFeeData.Any())
  11630. {
  11631. var miscIndex = 1;
  11632. int miscItemTypeId = 1364;
  11633. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11634. foreach (var item in groupData)
  11635. {
  11636. string feeName = string.Empty;
  11637. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11638. if (countryInfo != null)
  11639. {
  11640. feeName = countryInfo.Country;
  11641. var city = countryInfo.City;
  11642. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11643. {
  11644. feeName += $"-{city}";
  11645. }
  11646. }
  11647. var miscInfo = item.FirstOrDefault();
  11648. if (miscInfo == null) continue;
  11649. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11650. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11651. int quantity = item.ToList().Count;
  11652. mealCosts.Add(new QuoteSubItemInfo
  11653. {
  11654. ItemId = miscItemTypeId,
  11655. Index = miscIndex,
  11656. FeeName = feeName,
  11657. UnitPrice = miscInfo.Cost,
  11658. Currency = thisCurrency,
  11659. Quantity = quantity,
  11660. PplNum = pplNum,
  11661. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11662. Remark = "",
  11663. });
  11664. miscIndex++;
  11665. }
  11666. views.AddRange(mealCosts);
  11667. }
  11668. #endregion
  11669. #region 签证+保险 1362
  11670. int visaInsIndex = 1;
  11671. int visaInsItemTypeId = 1362;
  11672. if (infoView.Visa > 0)
  11673. {
  11674. views.Add(new QuoteSubItemInfo()
  11675. {
  11676. ItemId = visaInsItemTypeId,
  11677. Index = visaInsIndex,
  11678. FeeName = $"签证",
  11679. UnitPrice = infoView.Visa,
  11680. Currency = $"CNY",
  11681. Quantity = 1,
  11682. PplNum = pplNum,
  11683. TotalAmt = infoView.Visa * pplNum,
  11684. Remark = "",
  11685. });
  11686. visaInsIndex++;
  11687. }
  11688. if (infoView.Safe > 0)
  11689. {
  11690. views.Add(new QuoteSubItemInfo()
  11691. {
  11692. ItemId = visaInsItemTypeId,
  11693. Index = visaInsIndex,
  11694. FeeName = $"保险",
  11695. UnitPrice = infoView.Safe,
  11696. Currency = $"CNY",
  11697. Quantity = 1,
  11698. PplNum = pplNum,
  11699. TotalAmt = infoView.Safe * pplNum,
  11700. Remark = "",
  11701. });
  11702. }
  11703. #endregion
  11704. #region 服务费 1363
  11705. int serviceFeeIndex = 1;
  11706. int serviceFeeItemTypeId = 1363;
  11707. if (infoView.Service > 0)
  11708. {
  11709. views.Add(new QuoteSubItemInfo()
  11710. {
  11711. ItemId = serviceFeeItemTypeId,
  11712. Index = serviceFeeIndex,
  11713. FeeName = $"服务费",
  11714. UnitPrice = infoView.Service,
  11715. Currency = $"CNY",
  11716. Quantity = 1,
  11717. PplNum = pplNum,
  11718. TotalAmt = infoView.Service * pplNum,
  11719. Remark = "",
  11720. });
  11721. }
  11722. #endregion
  11723. #endregion
  11724. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  11725. result.Rates = eecRates.ToArray();
  11726. if (result.FeeItems.Any())
  11727. {
  11728. result.FeeItems.Select(x =>
  11729. {
  11730. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11731. if (feeInfos.Any()) x.Infos = feeInfos;
  11732. return x;
  11733. }
  11734. )
  11735. .OrderBy(x => x.Index)
  11736. .ToList();
  11737. }
  11738. return Ok(JsonView(result));
  11739. }
  11740. /// <summary>
  11741. /// 团组模块 - 出入境费用报价表 - Info
  11742. /// </summary>
  11743. /// <returns></returns>
  11744. [HttpPost]
  11745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11746. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11747. {
  11748. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11749. if (!info.Rates.Any())
  11750. {
  11751. var rates = await GeneralMethod.EnterExitCostInitRate();
  11752. info.Rates = rates.ToArray();
  11753. }
  11754. return Ok(JsonView(info));
  11755. }
  11756. /// <summary>
  11757. /// 团组模块 - 出入境费用报价表 - OP
  11758. /// </summary>
  11759. /// <returns></returns>
  11760. [HttpPost]
  11761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11762. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11763. {
  11764. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11765. }
  11766. /// <summary>
  11767. /// 团组模块 - 出入境费用报价表 - 删除 项
  11768. /// </summary>
  11769. /// <returns></returns>
  11770. [HttpPost]
  11771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11772. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11773. {
  11774. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11775. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11776. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11777. }
  11778. /// <summary>
  11779. /// 团组模块 - 出入境费用报价表 - 导出
  11780. /// </summary>
  11781. /// <returns></returns>
  11782. [HttpPost]
  11783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11784. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11785. {
  11786. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11787. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11788. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11789. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11790. var rates = info.Rates;
  11791. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11792. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11793. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11794. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11795. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11796. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11797. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  11798. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  11799. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  11800. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  11801. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  11802. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  11803. //获取模板
  11804. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11805. var designer = new WorkbookDesigner();
  11806. designer.Workbook = new Workbook(tempPath);
  11807. designer.SetDataSource("QuoteName", info.Name);
  11808. designer.SetDataSource("CompanyTitle", "公司名称");
  11809. designer.SetDataSource("CompanyLabel", "");
  11810. #region 国际旅费
  11811. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  11812. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  11813. {
  11814. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11815. StringBuilder label = new StringBuilder();
  11816. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11817. if (infos.Any())
  11818. {
  11819. label.Append(infos.Sum(x => x.PplNum));
  11820. label.Append("人全程机票:");
  11821. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11822. label.AppendLine("元");
  11823. }
  11824. foreach (var item in intTravelCosts.Infos)
  11825. {
  11826. label.Append(item.FeeName);
  11827. label.Append(":");
  11828. label.Append(item.UnitPrice.TruncDecimals(2));
  11829. label.Append("元/人*");
  11830. label.Append(item.PplNum);
  11831. label.AppendLine("人");
  11832. }
  11833. if (label.HasValue())
  11834. {
  11835. label.Append("\r\n以上小计:");
  11836. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11837. label.Append("元");
  11838. }
  11839. designer.SetDataSource("IntTravelLabel", label.ToString());
  11840. }
  11841. #endregion
  11842. #region 住宿费
  11843. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  11844. if (accomCosts!=null && accomCosts.Infos.Any())
  11845. {
  11846. string currencyName = string.Empty,
  11847. countryName = string.Empty;
  11848. decimal rate = 1.0000M;
  11849. StringBuilder label = new StringBuilder();
  11850. label.AppendLine("全程五星酒店,每人1间房");
  11851. foreach (var item in accomCosts.Infos)
  11852. {
  11853. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  11854. string name = string.Empty, thisCountryName = string.Empty;
  11855. if (item.FeeName.Contains("-"))
  11856. {
  11857. var feeName = item.FeeName.Split('-');
  11858. thisCountryName = feeName[0];
  11859. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  11860. name = feeName[1];
  11861. }
  11862. else name = item.FeeName;
  11863. string thisFeeName = string.Empty;
  11864. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  11865. else thisFeeName = $"\r\n{name}:";
  11866. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11867. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11868. rate = rateInfo?.Rate ?? 1.0000M;
  11869. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  11870. label.AppendLine(subLabel);
  11871. }
  11872. if (label.HasValue())
  11873. {
  11874. //以上小计:52440元(美金汇率:7.5 )
  11875. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  11876. label.AppendLine(subLabel);
  11877. }
  11878. designer.SetDataSource("AccomLabel", label.ToString());
  11879. }
  11880. #endregion
  11881. #region 餐饮费
  11882. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  11883. if (mealCosts != null && mealCosts.Infos.Any())
  11884. {
  11885. string currencyName = string.Empty;
  11886. decimal rate = 1.0000M;
  11887. StringBuilder label = new StringBuilder();
  11888. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  11889. foreach (var item in mealCosts.Infos)
  11890. {
  11891. string name = string.Empty;
  11892. if (item.FeeName.Contains("-"))
  11893. {
  11894. var feeName = item.FeeName.Split('-');
  11895. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11896. }
  11897. else name = $"\r\n{item.FeeName}:";
  11898. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11899. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11900. rate = rateInfo?.Rate ?? 1.0000M;
  11901. label.Append(name);
  11902. label.Append(item.UnitPrice.TruncDecimals(2));
  11903. label.Append(currencyName);
  11904. label.Append("/天*");
  11905. label.Append(item.Quantity.ToString("#0"));
  11906. label.Append("*");
  11907. label.Append(item.PplNum);
  11908. label.Append("人\r\n");
  11909. }
  11910. if (label.HasValue())
  11911. {
  11912. label.Append("\r\n以上小计:");
  11913. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11914. label.Append("元\r\n(");
  11915. label.Append("汇率:");
  11916. label.Append(rate.TruncDecimals(4));
  11917. label.Append(")");
  11918. }
  11919. designer.SetDataSource("MealLabel", label.ToString());
  11920. }
  11921. #endregion
  11922. #region 车辆安排
  11923. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  11924. if (vehArranges!=null&&vehArranges.Infos.Any())
  11925. {
  11926. string currencyName = string.Empty;
  11927. //decimal rate = 1.0000M;
  11928. StringBuilder label = new StringBuilder();
  11929. foreach (var item in vehArranges.Infos)
  11930. {
  11931. label.Append(item.Remark);
  11932. label.AppendLine();
  11933. label.AppendLine();
  11934. label.Append(item.FeeName);
  11935. label.Append("\r\n\r\n费用:");
  11936. label.Append(item.FeeName);
  11937. label.Append(item.TotalAmt.TruncDecimals(2));
  11938. }
  11939. designer.SetDataSource("VehArrangeLabel", label.ToString());
  11940. }
  11941. #endregion
  11942. #region 邀请函发放对象
  11943. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  11944. designer.SetDataSource("InviteToContent", "");
  11945. #endregion
  11946. #region 邀请函费
  11947. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  11948. StringBuilder is_label = new StringBuilder();
  11949. if (inviteCosts != null&&inviteCosts.Infos.Any())
  11950. {
  11951. string currencyName = string.Empty;
  11952. decimal rate = 1.0000M;
  11953. foreach (var item in inviteCosts.Infos)
  11954. {
  11955. //乌兹别克斯坦:2000美金
  11956. currencyName = item.Currency;
  11957. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  11958. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  11959. is_label.AppendLine(label);
  11960. }
  11961. if (is_label.HasValue())
  11962. {
  11963. //以上小计:28500元(美金汇率:7.5)
  11964. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2),"元", currencyName, rate.TruncDecimals(4));
  11965. is_label.AppendLine(label);
  11966. }
  11967. }
  11968. designer.SetDataSource("InviteCostContent", is_label.ToString());
  11969. #endregion
  11970. #region 邀请函发放时间
  11971. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  11972. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  11973. #endregion
  11974. #region 公务活动(含翻译)
  11975. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  11976. StringBuilder oa_label = new StringBuilder();
  11977. if (officialActs != null && officialActs.Infos.Any())
  11978. {
  11979. string currencyName = string.Empty;
  11980. decimal rate = 1.0000M;
  11981. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  11982. foreach (var item in officialActs.Infos)
  11983. {
  11984. //乌兹别克斯坦:1000美金/场
  11985. currencyName = item.Currency;
  11986. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  11987. string label_remark = string.Empty;
  11988. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  11989. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  11990. }
  11991. label_content += "*总费用中未含超出公务活动价格";
  11992. //8场公务活动(以上小计:60000元)
  11993. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  11994. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  11995. oa_label.AppendLine(label_title);
  11996. oa_label.AppendLine(label_content);
  11997. }
  11998. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  11999. #endregion
  12000. #region 签证+保险
  12001. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12002. StringBuilder vi_label = new StringBuilder();
  12003. if (visaIns != null && visaIns.Infos.Any())
  12004. {
  12005. foreach (var item in visaIns.Infos)
  12006. {
  12007. //签证:500元/人
  12008. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12009. vi_label.AppendLine(label);
  12010. }
  12011. if (vi_label.HasValue())
  12012. {
  12013. //以上小计:6000元
  12014. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12015. vi_label.AppendLine(label);
  12016. }
  12017. designer.SetDataSource("AccomLabel", vi_label.ToString());
  12018. }
  12019. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12020. #endregion
  12021. #region 服务费
  12022. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12023. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12024. #endregion
  12025. #region 公杂费
  12026. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12027. StringBuilder pm_label = new StringBuilder();
  12028. if (pubMiscs != null && pubMiscs.Infos.Any())
  12029. {
  12030. string currencyName = string.Empty,
  12031. countryName = string.Empty;
  12032. decimal rate = 1.0000M;
  12033. foreach (var item in pubMiscs.Infos)
  12034. {
  12035. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12036. string name = string.Empty, thisCountryName = string.Empty;
  12037. if (item.FeeName.Contains("-"))
  12038. {
  12039. var feeName = item.FeeName.Split('-');
  12040. thisCountryName = feeName[0];
  12041. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12042. name = feeName[1];
  12043. }
  12044. else name = item.FeeName;
  12045. string thisFeeName = string.Empty;
  12046. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12047. else thisFeeName = $"\r\n{name}:";
  12048. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12049. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12050. rate = rateInfo?.Rate ?? 1.0000M;
  12051. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12052. vi_label.AppendLine(label);
  12053. }
  12054. if (vi_label.HasValue())
  12055. {
  12056. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12057. vi_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12058. vi_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12059. vi_label.AppendLine(string.Format("部分发放成员"));
  12060. }
  12061. designer.SetDataSource("AccomLabel", vi_label.ToString());
  12062. }
  12063. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12064. #endregion
  12065. #region 税费
  12066. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12067. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12068. #endregion
  12069. #region 合计(单位:元)
  12070. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12071. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12072. #endregion
  12073. #region 汇率 Remark
  12074. var rate_label = new StringBuilder();
  12075. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12076. foreach (var item in rateGroups)
  12077. {
  12078. //美元汇率按\r\n1:7.5
  12079. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12080. rate_label.AppendLine(label);
  12081. }
  12082. designer.SetDataSource("RateLabel", rate_label.ToString());
  12083. #endregion
  12084. designer.Process();
  12085. //文件名
  12086. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12087. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12088. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12089. return Ok(JsonView(true, "成功", url));
  12090. }
  12091. #endregion
  12092. #region 签证费用录入
  12093. /// <summary>
  12094. /// 根据diid查询签证费用列表
  12095. /// </summary>
  12096. /// <param name="dto"></param>
  12097. /// <returns></returns>
  12098. [HttpPost]
  12099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12100. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12101. {
  12102. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12103. if (groupData.Code != 0)
  12104. {
  12105. return Ok(JsonView(false, groupData.Msg));
  12106. }
  12107. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12108. }
  12109. /// <summary>
  12110. /// 根据签证费用Id查询单条数据及c表数据
  12111. /// </summary>
  12112. /// <param name="dto"></param>
  12113. /// <returns></returns>
  12114. [HttpPost]
  12115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12116. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12117. {
  12118. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12119. if (groupData.Code != 0)
  12120. {
  12121. return Ok(JsonView(false, groupData.Msg));
  12122. }
  12123. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12124. }
  12125. /// <summary>
  12126. /// 签证费用删除
  12127. /// </summary>
  12128. /// <param name="dto"></param>
  12129. /// <returns></returns>
  12130. [HttpPost]
  12131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12132. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12133. {
  12134. _sqlSugar.BeginTran();
  12135. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12136. if (!res)
  12137. {
  12138. _sqlSugar.RollbackTran();
  12139. return Ok(JsonView(false, "删除失败"));
  12140. }
  12141. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12142. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12143. .SetColumns(a => new Grp_CreditCardPayment()
  12144. {
  12145. IsDel = 1,
  12146. DeleteUserId = dto.DeleteUserId,
  12147. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12148. })
  12149. .ExecuteCommand();
  12150. if (resSub < 1)
  12151. {
  12152. _sqlSugar.RollbackTran();
  12153. return Ok(JsonView(false, "删除失败"));
  12154. }
  12155. _sqlSugar.CommitTran();
  12156. return Ok(JsonView(true, "删除成功!"));
  12157. }
  12158. /// <summary>
  12159. /// 签证费用录入下拉框初始化
  12160. /// </summary>
  12161. /// <returns></returns>
  12162. [HttpPost]
  12163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12164. public async Task<IActionResult> VisaPriceAddSelect()
  12165. {
  12166. //支付方式
  12167. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12168. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12169. //币种
  12170. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12171. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12172. //乘客类型
  12173. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12174. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12175. //卡类型
  12176. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12177. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12178. //代办费类型
  12179. var agencyFeeTypeData = new List<dynamic>() {
  12180. new { id = 0 , Text = "未选择" },
  12181. new { id = 1 , Text = "小公务" },
  12182. new { id = 2 , Text = "大公务" },
  12183. };
  12184. //签证费用标准国家Data
  12185. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12186. var data = new
  12187. {
  12188. Payment = _Payment,
  12189. CurrencyList = _CurrencyList,
  12190. PassengerType = _PassengerType,
  12191. BankCard = _BankCard,
  12192. AgencyFeeType = agencyFeeTypeData,
  12193. CountryFeeData = visaCountryFeeData
  12194. };
  12195. return Ok(JsonView(true, "查询成功!", data));
  12196. }
  12197. /// <summary>
  12198. /// 签证费用录入操作(Status:1.新增,2.修改)
  12199. /// </summary>
  12200. /// <param name="dto"></param>
  12201. /// <returns></returns>
  12202. [HttpPost]
  12203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12204. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12205. {
  12206. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12207. if (groupData.Code != 0)
  12208. {
  12209. return Ok(JsonView(false, groupData.Msg));
  12210. }
  12211. #region 应用推送
  12212. try
  12213. {
  12214. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12215. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12216. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12217. //2024-10-21 新增LZ UID
  12218. var userIds = new List<int>() { 21 };
  12219. string title = $"系统通知";
  12220. string content = "";
  12221. var diId = dto.DiId;
  12222. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12223. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12224. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12225. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12226. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12227. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12228. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12229. }
  12230. catch (Exception ex)
  12231. {
  12232. }
  12233. #endregion
  12234. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12235. }
  12236. #endregion
  12237. #region 签证提成录入
  12238. /// <summary>
  12239. /// 签证提成录入
  12240. /// 基础数据
  12241. /// </summary>
  12242. /// <returns></returns>
  12243. [HttpGet]
  12244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12245. public async Task<IActionResult> VisaCommissionInit()
  12246. {
  12247. return Ok(await _visaCommissionRep.Init());
  12248. }
  12249. /// <summary>
  12250. /// 签证提成录入
  12251. /// Item
  12252. /// </summary>
  12253. /// <param name="_dto"></param>
  12254. /// <returns></returns>
  12255. [HttpPost]
  12256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12257. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12258. {
  12259. var validator = new VisaCommissionItemDtoValidator();
  12260. var validatorRes = await validator.ValidateAsync(_dto);
  12261. if (!validatorRes.IsValid)
  12262. {
  12263. StringBuilder sb = new StringBuilder();
  12264. foreach (var item in validatorRes.Errors)
  12265. {
  12266. sb.AppendLine(item.ErrorMessage);
  12267. }
  12268. return Ok(JsonView(false, sb.ToString()));
  12269. }
  12270. return Ok(await _visaCommissionRep.Item(_dto));
  12271. }
  12272. /// <summary>
  12273. /// 签证提成录入
  12274. /// Save
  12275. /// </summary>
  12276. /// <param name="_dto"></param>
  12277. /// <returns></returns>
  12278. [HttpPost]
  12279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12280. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12281. {
  12282. //参数验证
  12283. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12284. foreach (var item in _dto.Items)
  12285. {
  12286. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12287. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12288. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12289. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12290. }
  12291. return Ok(await _visaCommissionRep.Save(_dto));
  12292. }
  12293. /// <summary>
  12294. /// 签证提成录入
  12295. /// Create
  12296. /// </summary>
  12297. /// <param name="_dto"></param>
  12298. /// <returns></returns>
  12299. [HttpPost]
  12300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12301. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12302. {
  12303. var validator = new VisaCommissionCreateDtoValidator();
  12304. var validatorRes = await validator.ValidateAsync(_dto);
  12305. if (!validatorRes.IsValid)
  12306. {
  12307. StringBuilder sb = new StringBuilder();
  12308. foreach (var item in validatorRes.Errors)
  12309. {
  12310. sb.AppendLine(item.ErrorMessage);
  12311. }
  12312. return Ok(JsonView(false, sb.ToString()));
  12313. }
  12314. return Ok(await _visaCommissionRep.Create(_dto));
  12315. }
  12316. /// <summary>
  12317. /// 签证提成录入
  12318. /// Put(编辑)
  12319. /// </summary>
  12320. /// <param name="id"></param>
  12321. /// <param name="_dto"></param>
  12322. /// <returns></returns>
  12323. [HttpPut]
  12324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12325. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12326. {
  12327. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12328. var validator = new VisaCommissionCreateDtoValidator();
  12329. var validatorRes = await validator.ValidateAsync(_dto);
  12330. if (!validatorRes.IsValid)
  12331. {
  12332. StringBuilder sb = new StringBuilder();
  12333. foreach (var item in validatorRes.Errors)
  12334. {
  12335. sb.AppendLine(item.ErrorMessage);
  12336. }
  12337. return Ok(JsonView(false, sb.ToString()));
  12338. }
  12339. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12340. }
  12341. /// <summary>
  12342. /// 签证提成录入
  12343. /// Del
  12344. /// </summary>
  12345. /// <param name="id"></param>
  12346. /// <param name="currUserId"></param>
  12347. /// <returns></returns>
  12348. [HttpPost]
  12349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12350. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12351. {
  12352. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12353. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12354. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12355. }
  12356. #endregion
  12357. #region op费用录入
  12358. /// <summary>
  12359. /// 根据diid查询op费用列表
  12360. /// </summary>
  12361. /// <param name="dto"></param>
  12362. /// <returns></returns>
  12363. [HttpPost]
  12364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12365. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12366. {
  12367. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12368. if (groupData.Code != 0)
  12369. {
  12370. return Ok(JsonView(false, groupData.Msg));
  12371. }
  12372. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12373. }
  12374. /// <summary>
  12375. /// 根据op费用Id查询单条数据及c表数据
  12376. /// </summary>
  12377. /// <param name="dto"></param>
  12378. /// <returns></returns>
  12379. [HttpPost]
  12380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12381. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12382. {
  12383. try
  12384. {
  12385. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12386. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12387. var data = new
  12388. {
  12389. CarTouristGuideGround = _groupData,
  12390. CreditCardPayment = _creditCardPayment
  12391. };
  12392. return Ok(JsonView(true, "查询成功!", data));
  12393. }
  12394. catch (Exception ex)
  12395. {
  12396. return Ok(JsonView(false, "程序错误!"));
  12397. }
  12398. }
  12399. /// <summary>
  12400. /// op费用删除
  12401. /// </summary>
  12402. /// <param name="dto"></param>
  12403. /// <returns></returns>
  12404. [HttpPost]
  12405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12406. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12407. {
  12408. try
  12409. {
  12410. _sqlSugar.BeginTran();
  12411. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12412. if (!res)
  12413. {
  12414. return Ok(JsonView(false, "删除失败"));
  12415. }
  12416. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12417. {
  12418. IsDel = 1,
  12419. DeleteUserId = dto.DeleteUserId,
  12420. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12421. }).ExecuteCommandAsync();
  12422. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12423. {
  12424. IsDel = 1,
  12425. DeleteUserId = dto.DeleteUserId,
  12426. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12427. }).ExecuteCommandAsync();
  12428. #region 删除超支相关数据
  12429. //删除导入的超支数据
  12430. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12431. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12432. {
  12433. IsDel = 1,
  12434. DeleteUserId = dto.DeleteUserId,
  12435. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12436. }).ExecuteCommand();
  12437. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12438. {
  12439. IsDel = 1,
  12440. DeleteUserId = dto.DeleteUserId,
  12441. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12442. }).ExecuteCommand();
  12443. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12444. {
  12445. IsDel = 1,
  12446. DeleteUserId = dto.DeleteUserId,
  12447. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12448. }).ExecuteCommand();
  12449. #endregion
  12450. _sqlSugar.CommitTran();
  12451. return Ok(JsonView(true, "删除成功!"));
  12452. }
  12453. catch (Exception ex)
  12454. {
  12455. _sqlSugar.RollbackTran();
  12456. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12457. }
  12458. }
  12459. /// <summary>
  12460. /// op费用录入操作(Status:1.新增,2.修改)
  12461. /// </summary>
  12462. /// <param name="dto"></param>
  12463. /// <returns></returns>
  12464. [HttpPost]
  12465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12466. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12467. {
  12468. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12469. if (groupData.Code != 0)
  12470. {
  12471. return Ok(JsonView(false, groupData.Msg));
  12472. }
  12473. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12474. }
  12475. /// <summary>
  12476. /// 填写费用详细页面初始化绑定
  12477. /// </summary>
  12478. /// <param name="dto"></param>
  12479. /// <returns></returns>
  12480. [HttpPost]
  12481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12482. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12483. {
  12484. try
  12485. {
  12486. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12487. if (groupData.Code != 0)
  12488. {
  12489. return Ok(JsonView(false, groupData.Msg));
  12490. }
  12491. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12492. }
  12493. catch (Exception ex)
  12494. {
  12495. return Ok(JsonView(false, ex.Message));
  12496. }
  12497. }
  12498. /// <summary>
  12499. /// 根据op费用Id查询详细数据
  12500. /// </summary>
  12501. /// <param name="dto"></param>
  12502. /// <returns></returns>
  12503. [HttpPost]
  12504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12505. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12506. {
  12507. try
  12508. {
  12509. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12510. if (groupData.Code != 0)
  12511. {
  12512. return Ok(JsonView(false, groupData.Msg));
  12513. }
  12514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12515. }
  12516. catch (Exception ex)
  12517. {
  12518. return Ok(JsonView(false, ex.Message));
  12519. }
  12520. }
  12521. /// <summary>
  12522. /// OP费用录入填写详情
  12523. /// </summary>
  12524. /// <param name="dto"></param>
  12525. /// <returns></returns>
  12526. [HttpPost]
  12527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12528. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12529. {
  12530. try
  12531. {
  12532. #region 参数校验
  12533. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12534. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12535. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12536. #endregion
  12537. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12538. if (groupData.Code != 0)
  12539. {
  12540. return Ok(JsonView(false, groupData.Msg));
  12541. }
  12542. //自动审核
  12543. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12544. #region 应用推送
  12545. try
  12546. {
  12547. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12548. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12549. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12550. //2024-10-21 新增LZ UID
  12551. var userIds = new List<int>() { 21 };
  12552. string title = $"系统通知";
  12553. var diId = dto.DiId;
  12554. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12555. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12556. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12557. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12558. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12559. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12560. }
  12561. catch (Exception ex)
  12562. {
  12563. }
  12564. #endregion
  12565. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12566. }
  12567. catch (Exception ex)
  12568. {
  12569. return Ok(JsonView(false, ex.Message));
  12570. }
  12571. }
  12572. /// <summary>
  12573. /// 获取三公详细所有城市
  12574. /// </summary>
  12575. /// <returns></returns>
  12576. [HttpGet]
  12577. public IActionResult OpCarCityResult()
  12578. {
  12579. var jw = JsonView(false);
  12580. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12581. {
  12582. x.Id,
  12583. x.Country,
  12584. x.City,
  12585. }).ToList();
  12586. if (data.Count > 0)
  12587. {
  12588. jw = JsonView(true, "获取成功!", data);
  12589. }
  12590. else
  12591. {
  12592. jw.Msg = "城市数据为空!";
  12593. jw.Data = new string[0];
  12594. }
  12595. return Ok(jw);
  12596. }
  12597. /// <summary>
  12598. /// 导出地接费用明细
  12599. /// </summary>
  12600. /// <param name="dto"></param>
  12601. /// <returns></returns>
  12602. [HttpPost]
  12603. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12604. {
  12605. var jw = JsonView(false);
  12606. if (dto.Diid < 1)
  12607. {
  12608. jw.Msg = "请输入正确的diid!";
  12609. return Ok(jw);
  12610. }
  12611. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12612. if (group == null)
  12613. {
  12614. jw.Msg = "未找到团组信息!";
  12615. return Ok(jw);
  12616. }
  12617. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12618. if (localGuideArr.Count == 0)
  12619. {
  12620. jw.Msg = "该团组暂无地接信息!";
  12621. return Ok(jw);
  12622. }
  12623. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12624. var overspendSoure = new Dictionary<int, int>
  12625. {
  12626. { 91, 982 }, //车
  12627. { 92 , 1059} ,//导游
  12628. { 994 , 1073}, //翻译
  12629. { 988 , 1074 }, //早餐
  12630. { 93 , 1075 }, //午餐
  12631. { 989 , 1076 }, //晚餐
  12632. };
  12633. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12634. foreach (var groupArr in localGroup)
  12635. {
  12636. var keyValue = groupArr.Key;
  12637. if (int.TryParse(keyValue, out int cityid))
  12638. {
  12639. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12640. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12641. }
  12642. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12643. foreach (var item in groupArr)
  12644. {
  12645. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12646. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12647. new Grp_CarTouristGuideGroundReservationsContentExtend
  12648. {
  12649. Count = a.Count,
  12650. CreateTime = a.CreateTime,
  12651. CreateUserId = a.CreateUserId,
  12652. CTGGRId = a.CTGGRId,
  12653. Currency = a.Currency,
  12654. DatePrice = a.DatePrice,
  12655. DeleteTime = a.DeleteTime,
  12656. DeleteUserId = a.DeleteUserId,
  12657. DiId = a.DiId,
  12658. Id = a.Id,
  12659. IsDel = a.IsDel,
  12660. Price = a.Price,
  12661. PriceContent = a.PriceContent,
  12662. Remark = a.Remark,
  12663. SId = a.SId,
  12664. SidName = b.Name,
  12665. Units = a.Units,
  12666. }
  12667. ).ToList();
  12668. if (content.Count > 0)
  12669. {
  12670. contentArr.Add(content);
  12671. }
  12672. }
  12673. //open excel
  12674. //set excel
  12675. //save excel
  12676. try
  12677. {
  12678. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12679. IWorkbook workbook;
  12680. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12681. {
  12682. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12683. }
  12684. else
  12685. {
  12686. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12687. }
  12688. ISheet sheet = workbook.GetSheetAt(0);
  12689. var rowStartIndex = 2;
  12690. var clounmCount = 10;
  12691. var initStyleRow = sheet.GetRow(2);
  12692. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12693. //var overspendArrDetail =
  12694. var existsId = new List<CarCompare>();
  12695. var lastElem = arr.Last();
  12696. var thisSid = -1;
  12697. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12698. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12699. {
  12700. Name = "未知币种!",
  12701. Remark = "未知币种!",
  12702. };
  12703. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12704. Action cloneRowFn = () =>
  12705. {
  12706. rowStartIndex++;
  12707. var cloneRow = sheet.CreateRow(rowStartIndex);
  12708. // 复制样式
  12709. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12710. {
  12711. ICell sourceCell = initStyleRow.GetCell(i);
  12712. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12713. // 确保单元格存在样式
  12714. if (sourceCell.CellStyle != null)
  12715. {
  12716. targetCell.CellStyle = sourceCell.CellStyle;
  12717. }
  12718. }
  12719. };
  12720. var mergeRow = () =>
  12721. {
  12722. for (int i = 2; i < sheet.LastRowNum; i++)
  12723. {
  12724. var row = sheet.GetRow(i);
  12725. var cellFirst = row.GetCell(0);
  12726. var thisIndex = i + 1;
  12727. while (thisIndex < sheet.LastRowNum)
  12728. {
  12729. var nextRow = sheet.GetRow(thisIndex);
  12730. var nextCellFirst = nextRow.GetCell(0);
  12731. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12732. {
  12733. thisIndex++;
  12734. }
  12735. else
  12736. {
  12737. break;
  12738. }
  12739. }
  12740. thisIndex--;
  12741. if (thisIndex != i)
  12742. {
  12743. //合并row
  12744. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12745. i, // 起始行索引(0-based)
  12746. thisIndex, // 结束行索引(0-based)
  12747. 0, // 起始列索引(0-based)
  12748. 0 // 结束列索引(0-based)
  12749. );
  12750. sheet.AddMergedRegion(cellRangeAddress);
  12751. i = thisIndex;
  12752. }
  12753. }
  12754. };
  12755. var chaoshiNumber = 0;
  12756. var totalNumber = 0.00M;
  12757. string lastStr = "";
  12758. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12759. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12760. {
  12761. b.IsAuditGM,
  12762. x.Id,
  12763. x.Area,
  12764. b.PayPercentage,
  12765. b.PayMoney,
  12766. }).ToList();
  12767. string yesPayment = "", noPayment = "";
  12768. foreach (var item in queryCarArrByCityAndDiid)
  12769. {
  12770. if (item.IsAuditGM == 1)
  12771. {
  12772. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12773. }
  12774. else
  12775. {
  12776. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12777. }
  12778. }
  12779. lastStr = yesPayment + noPayment;
  12780. foreach (var item in arr)
  12781. {
  12782. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12783. {
  12784. if (thisSid != item.SId)
  12785. {
  12786. if (thisSid == -1)
  12787. {
  12788. thisSid = item.SId;
  12789. }
  12790. else
  12791. {
  12792. //合并小计行
  12793. //创建合并区域的实例
  12794. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12795. rowStartIndex, // 起始行索引(0-based)
  12796. rowStartIndex, // 结束行索引(0-based)
  12797. 0, // 起始列索引(0-based)
  12798. 3 // 结束列索引(0-based)
  12799. );
  12800. sheet.AddMergedRegion(cellRangeAddress);
  12801. var CellStyle = workbook.CreateCellStyle();
  12802. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12803. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12804. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12805. for (int i = 0; i <= clounmCount; i++)
  12806. {
  12807. if (i > 6)
  12808. {
  12809. var CellStyle1 = workbook.CreateCellStyle();
  12810. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12811. IFont Font = workbook.CreateFont(); // 创建字体
  12812. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12813. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12814. CellStyle1.SetFont(Font);
  12815. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12816. }
  12817. else
  12818. {
  12819. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12820. }
  12821. }
  12822. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12823. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12824. //超时合计
  12825. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12826. //超时数
  12827. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12828. //超时合计费用
  12829. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12830. thisSid = item.SId;
  12831. cloneRowFn();
  12832. chaoshiNumber = 0;
  12833. totalNumber = 0;
  12834. }
  12835. }
  12836. IRow row = sheet.GetRow(rowStartIndex);
  12837. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12838. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12839. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12840. if (isOpenOverspendSoure)
  12841. {
  12842. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12843. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12844. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12845. }
  12846. for (int i = 0; i <= clounmCount; i++)
  12847. {
  12848. var cell = row.GetCell(i);
  12849. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12850. if (cell == null)
  12851. {
  12852. cell = row.CreateCell(i);
  12853. }
  12854. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12855. fontRed.CloneStyleFrom(cell.CellStyle);
  12856. IFont Font = workbook.CreateFont(); // 创建字体
  12857. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  12858. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12859. fontRed.SetFont(Font);
  12860. byte[] rgb = new byte[3] { 255, 242, 204 };
  12861. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  12862. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  12863. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  12864. if (workbook is XSSFWorkbook)
  12865. {
  12866. BackgroundColor255_242_204.FillForegroundColor = 0;
  12867. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  12868. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12869. }
  12870. else
  12871. {
  12872. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  12873. }
  12874. if (i == 1 || i > 6)
  12875. {
  12876. if (i > 6)
  12877. {
  12878. fontRed.FillForegroundColor = 0;
  12879. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  12880. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12881. }
  12882. cell.CellStyle = fontRed;
  12883. }
  12884. if (i > 2 && i < 7)
  12885. {
  12886. cell.CellStyle = BackgroundColor255_242_204;
  12887. }
  12888. cell.SetCellValue(setCellValue); //写入单元格
  12889. }
  12890. if (overspendSoure.ContainsKey(thisSid))
  12891. {
  12892. var overspendId = overspendSoure[thisSid];
  12893. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12894. }
  12895. cloneRowFn();
  12896. existsId.Add(new CarCompare
  12897. {
  12898. DataPrice = item.DatePrice.ObjToDate(),
  12899. Sid = item.SId
  12900. });
  12901. }
  12902. if (item.Equals(lastElem))
  12903. {
  12904. //合并小计行
  12905. //创建合并区域的实例
  12906. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12907. rowStartIndex, // 起始行索引(0-based)
  12908. rowStartIndex, // 结束行索引(0-based)
  12909. 0, // 起始列索引(0-based)
  12910. 3 // 结束列索引(0-based)
  12911. );
  12912. sheet.AddMergedRegion(cellRangeAddress);
  12913. var CellStyle = workbook.CreateCellStyle();
  12914. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12915. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12916. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12917. for (int i = 0; i <= clounmCount; i++)
  12918. {
  12919. if (i > 6)
  12920. {
  12921. var CellStyle1 = workbook.CreateCellStyle();
  12922. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12923. IFont Font = workbook.CreateFont(); // 创建字体
  12924. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12925. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12926. CellStyle1.SetFont(Font);
  12927. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12928. }
  12929. else
  12930. {
  12931. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12932. }
  12933. }
  12934. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12935. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12936. //超时合计
  12937. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12938. //超时数
  12939. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12940. //超时合计费用
  12941. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12942. cloneRowFn();
  12943. // 创建合并区域的实例
  12944. cellRangeAddress = new CellRangeAddress(
  12945. rowStartIndex, // 起始行索引(0-based)
  12946. rowStartIndex, // 结束行索引(0-based)
  12947. 0, // 起始列索引(0-based)
  12948. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  12949. );
  12950. // 添加合并区域
  12951. sheet.AddMergedRegion(cellRangeAddress);
  12952. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  12953. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  12954. }
  12955. }
  12956. mergeRow();
  12957. // 保存修改后的Excel文件到新文件
  12958. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  12959. // new FileStream(newFilePath, FileMode.CreateNew)
  12960. using (var stream = new MemoryStream())
  12961. {
  12962. workbook.Write(stream, true);
  12963. stream.Flush();
  12964. stream.Seek(0, SeekOrigin.Begin);
  12965. MemoryStream memoryStream = new MemoryStream();
  12966. stream.CopyTo(memoryStream);
  12967. memoryStream.Seek(0, SeekOrigin.Begin);
  12968. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  12969. }
  12970. workbook.Close();
  12971. workbook.Dispose();
  12972. }
  12973. catch (Exception ex)
  12974. {
  12975. jw.Msg = "出现异常!" + ex.Message;
  12976. return Ok(jw);
  12977. }
  12978. }
  12979. if (Zips.Count > 0)
  12980. {
  12981. IOOperatorHelper io = new IOOperatorHelper();
  12982. var byts = io.ConvertZipStream(Zips);
  12983. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  12984. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  12985. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  12986. }
  12987. else
  12988. {
  12989. jw.Msg = "暂无生成文件!";
  12990. }
  12991. return Ok(jw);
  12992. }
  12993. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  12994. {
  12995. string outStr = string.Empty;
  12996. switch (i)
  12997. {
  12998. case 0:
  12999. outStr = arr[0].SidName;
  13000. break;
  13001. case 1:
  13002. outStr = arr[0].DataPriceStr;
  13003. break;
  13004. case 2:
  13005. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13006. break;
  13007. case 4:
  13008. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13009. break;
  13010. case 7:
  13011. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13012. {
  13013. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13014. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13015. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13016. }
  13017. break;
  13018. case 8:
  13019. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13020. {
  13021. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13022. }
  13023. break;
  13024. case 9:
  13025. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13026. {
  13027. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13028. }
  13029. break;
  13030. case 10:
  13031. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13032. {
  13033. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13034. }
  13035. break;
  13036. }
  13037. return outStr;
  13038. }
  13039. #region OP行程单
  13040. /// <summary>
  13041. /// OP行程单初始化
  13042. /// </summary>
  13043. /// <param name="dto"></param>
  13044. /// <returns></returns>
  13045. [HttpPost]
  13046. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13047. {
  13048. var jw = JsonView(false);
  13049. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13050. var group = groupList.First();
  13051. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13052. if (group == null)
  13053. {
  13054. jw.Msg = "暂无团组!";
  13055. return Ok(jw);
  13056. }
  13057. group = groupList.Find(x => x.Id == diid);
  13058. if (group == null)
  13059. {
  13060. jw.Msg = "请输入正确的团组ID!";
  13061. return Ok(jw);
  13062. }
  13063. string city = string.Empty;
  13064. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13065. if (blackCode.Count > 0)
  13066. {
  13067. var black = blackCode.First();
  13068. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13069. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13070. if (blackSp.Length > 0)
  13071. {
  13072. try
  13073. {
  13074. var cityArrCode = new List<string>(20);
  13075. foreach (var item in blackSp)
  13076. {
  13077. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13078. var IndexSelect = itemSp[2];
  13079. var cityArrCodeLength = cityArrCode.Count - 1;
  13080. var startCity = IndexSelect.Substring(0, 3);
  13081. if (cityArrCodeLength > 0)
  13082. {
  13083. var arrEndCity = cityArrCode[cityArrCodeLength];
  13084. if (arrEndCity != startCity)
  13085. {
  13086. cityArrCode.Add(startCity.ToUpper());
  13087. }
  13088. }
  13089. else
  13090. {
  13091. cityArrCode.Add(startCity.ToUpper());
  13092. }
  13093. var endCity = IndexSelect.Substring(3, 3);
  13094. cityArrCode.Add(endCity.ToUpper());
  13095. }
  13096. var cityThree = string.Empty;
  13097. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13098. cityThree = cityThree.TrimEnd(',');
  13099. if (string.IsNullOrWhiteSpace(cityThree))
  13100. {
  13101. throw new
  13102. Exception("error");
  13103. }
  13104. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13105. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13106. foreach (var item in cityArrCode)
  13107. {
  13108. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13109. if (find != null)
  13110. {
  13111. city += find.City + "/";
  13112. }
  13113. else
  13114. {
  13115. city += item + "三字码未收入/";
  13116. }
  13117. }
  13118. city = city.TrimEnd('/');
  13119. }
  13120. catch (Exception e)
  13121. {
  13122. city = "黑屏代码格式不正确!";
  13123. }
  13124. }
  13125. }
  13126. else
  13127. {
  13128. city = "未录入黑屏代码";
  13129. }
  13130. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13131. {
  13132. Date = x.Date,
  13133. Days = x.Days,
  13134. Diffgroup = x.Diffgroup,
  13135. Diid = x.Diid,
  13136. Traffic_First = x.Traffic_First,
  13137. Traffic_Second = x.Traffic_Second,
  13138. Trip = x.Trip,
  13139. WeekDay = x.WeekDay,
  13140. Id = x.Id
  13141. }).ToList();
  13142. jw.Data = new
  13143. {
  13144. groupList = groupList.Select(x => new
  13145. {
  13146. x.Id,
  13147. x.TeamName,
  13148. x.TourCode
  13149. }).ToList(),
  13150. groupInfo = new
  13151. {
  13152. group.VisitDays,
  13153. group.TourCode,
  13154. group.VisitPNumber,
  13155. group.TeamName,
  13156. city
  13157. },
  13158. OpTravelList
  13159. };
  13160. jw.Code = 200;
  13161. jw.Msg = "操作成功!";
  13162. return Ok(jw);
  13163. }
  13164. /// <summary>
  13165. /// 删除团组行程单
  13166. /// </summary>
  13167. /// <returns></returns>
  13168. [HttpPost]
  13169. public IActionResult DelTravel(DelOpTravelDto dto)
  13170. {
  13171. var jw = JsonView(false);
  13172. if (dto.UserId <= 0 || dto.Diid <= 0)
  13173. {
  13174. jw.Msg = "请输入正确的参数!";
  13175. return Ok(jw);
  13176. }
  13177. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13178. .SetColumns(x => new Grp_TravelList
  13179. {
  13180. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13181. DeleteUserId = dto.UserId,
  13182. IsDel = 1,
  13183. }).ExecuteCommand();
  13184. jw = JsonView(true);
  13185. return Ok(jw);
  13186. }
  13187. /// <summary>
  13188. /// 行程单保存
  13189. /// </summary>
  13190. /// <returns></returns>
  13191. [HttpPost]
  13192. public IActionResult TravelSave(TravelSaveDto dto)
  13193. {
  13194. var jw = JsonView(false);
  13195. if (dto.Arr.Count > 0)
  13196. {
  13197. try
  13198. {
  13199. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13200. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13201. .ToList();
  13202. _sqlSugar.BeginTran();
  13203. foreach (var item in dto.Arr)
  13204. {
  13205. if (item.Id == 0)
  13206. {
  13207. throw new Exception("请传入正确的Id");
  13208. }
  13209. //比较上一次的差异
  13210. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13211. if (findTravel != null)
  13212. {
  13213. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13214. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13215. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13216. }
  13217. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13218. .SetColumns(x => new Grp_TravelList
  13219. {
  13220. Trip = item.Trip
  13221. }).ExecuteCommand();
  13222. }
  13223. _sqlSugar.CommitTran();
  13224. jw = JsonView(true);
  13225. }
  13226. catch (Exception ex)
  13227. {
  13228. _sqlSugar.RollbackTran();
  13229. jw.Msg = "程序异常!" + ex.Message;
  13230. }
  13231. }
  13232. else
  13233. {
  13234. jw.Msg = "请传入正确的参数!";
  13235. }
  13236. return Ok(jw);
  13237. }
  13238. private string CheckStr(string original, string changed)
  13239. {
  13240. // 创建diff_match_patch对象
  13241. var dmp = new diff_match_patch();
  13242. // 计算差异
  13243. List<Diff> diffs = dmp.diff_main(original, changed);
  13244. // 清理和合并差异
  13245. dmp.diff_cleanupSemantic(diffs);
  13246. // 使用StringBuilder构建最终的字符串
  13247. StringBuilder finalString = new StringBuilder();
  13248. // 输出差异结果,并构建变动后的字符串
  13249. foreach (Diff diff in diffs)
  13250. {
  13251. switch (diff.operation)
  13252. {
  13253. case Operation.EQUAL:
  13254. // 相等的部分,直接添加到最终字符串
  13255. finalString.Append(diff.text);
  13256. break;
  13257. case Operation.INSERT:
  13258. // 插入的部分,添加标记并添加到最终字符串
  13259. finalString.Append("[++]" + diff.text + "[++]");
  13260. break;
  13261. case Operation.DELETE:
  13262. // 删除的部分,不添加到最终字符串
  13263. //finalString.Append("[++]" + diff.text + "[++]");
  13264. break;
  13265. }
  13266. }
  13267. // 输出变动后的字符串
  13268. return finalString.ToString();
  13269. }
  13270. private class tagContent
  13271. {
  13272. public DateTime Date { get; set; }
  13273. public string StartTag { get; set; }
  13274. public string EndTag { get; set; }
  13275. public string Content { get; set; }
  13276. public static int tagLength { get { return 3; } }
  13277. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13278. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13279. public bool IsFinally { get; set; }
  13280. }
  13281. private List<string> ExtractContentBetweenTags(string input, string tag)
  13282. {
  13283. List<string> results = new List<string>();
  13284. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13285. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13286. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13287. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13288. string[] strValueArr = new string[1];
  13289. foreach (System.Text.RegularExpressions.Match match in matches)
  13290. {
  13291. var strValue = match.Groups[1].Value;
  13292. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13293. }
  13294. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13295. return results;
  13296. }
  13297. /// <summary>
  13298. /// 导出行程单
  13299. /// </summary>
  13300. /// <param name="dto"></param>
  13301. /// <returns></returns>
  13302. [HttpPost]
  13303. public IActionResult ExportTravel(ExportTravelDto dto)
  13304. {
  13305. var jw = JsonView(false);
  13306. jw.Data = "";
  13307. int diid = 0;
  13308. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13309. if (Find == null)
  13310. {
  13311. jw.Msg = "请选择正确的团组!";
  13312. return Ok(jw);
  13313. }
  13314. else
  13315. {
  13316. diid = Find.Id;
  13317. }
  13318. //数据源
  13319. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13320. DataTable dtBlack = null;
  13321. try
  13322. {
  13323. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13324. }
  13325. catch (Exception)
  13326. {
  13327. jw.Msg = "机票黑屏代码有误!";
  13328. return Ok(jw);
  13329. }
  13330. string CityStr = string.Empty;
  13331. if (dtBlack.Rows.Count == 0)
  13332. {
  13333. jw.Msg = "机票黑屏代码有误!";
  13334. return Ok(jw);
  13335. }
  13336. else
  13337. {
  13338. foreach (DataRow row in dtBlack.Rows)
  13339. {
  13340. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13341. {
  13342. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13343. return Ok(jw);
  13344. }
  13345. }
  13346. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13347. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13348. }
  13349. // 指定的文字
  13350. var targetTextDic = new Dictionary<string, List<string>>();
  13351. //创建数据源Table
  13352. DataTable dtSource = new DataTable();
  13353. dtSource.Columns.Add("Days", typeof(string));
  13354. dtSource.Columns.Add("Date", typeof(string));
  13355. dtSource.Columns.Add("Week", typeof(string));
  13356. dtSource.Columns.Add("Traffic", typeof(string));
  13357. dtSource.Columns.Add("Trip", typeof(string));
  13358. //获取数据,放到datatable
  13359. foreach (var item in _travelList)
  13360. {
  13361. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13362. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13363. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13364. .Replace("[++]", string.Empty);
  13365. DataRow dr = dtSource.NewRow();
  13366. dr["Days"] = item.Days;
  13367. dr["Date"] = item.Date;
  13368. dr["Week"] = item.WeekDay;
  13369. dr["Traffic"] = item.Traffic_First
  13370. + "\r\n"
  13371. + item.Traffic_Second;
  13372. dr["Trip"] = item.Trip;
  13373. dtSource.Rows.Add(dr);
  13374. }
  13375. Dictionary<string, string> dic = new Dictionary<string, string>();
  13376. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13377. dic.Add("City", CityStr);
  13378. dic.Add("Days", Find.VisitDays.ToString());
  13379. dic.Add("DeleCode", Find.TourCode);
  13380. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13381. //模板路径
  13382. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13383. //载入模板
  13384. Document doc = null;
  13385. DocumentBuilder builder = null;
  13386. try
  13387. {
  13388. //载入模板
  13389. doc = new Document(tempPath);
  13390. builder = new DocumentBuilder(doc);
  13391. }
  13392. catch (Exception)
  13393. {
  13394. jw.Msg = "模板位置不存在!";
  13395. return Ok(jw);
  13396. }
  13397. foreach (var key in dic.Keys)
  13398. {
  13399. Bookmark bookmark = doc.Range.Bookmarks[key];
  13400. if (bookmark != null)
  13401. {
  13402. builder.MoveToBookmark(key);
  13403. builder.Write(dic[key]);
  13404. }
  13405. }
  13406. //获取word里所有表格
  13407. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13408. //获取所填表格的序数
  13409. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13410. try
  13411. {
  13412. //循环赋值
  13413. for (int i = 0; i < dtSource.Rows.Count; i++)
  13414. {
  13415. builder.MoveToCell(0, i + 1, 0, 0);
  13416. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13417. builder.MoveToCell(0, i + 1, 1, 0);
  13418. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13419. builder.MoveToCell(0, i + 1, 2, 0);
  13420. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13421. var trip = dtSource.Rows[i]["Trip"].ToString();
  13422. builder.MoveToCell(0, i + 1, 3, 0);
  13423. builder.Write(trip);
  13424. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13425. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13426. // 获取特定索引的段落
  13427. Paragraph paragraph = (Paragraph)paragraphs[0];
  13428. Run run = paragraph.Runs[0];
  13429. Aspose.Words.Font font = run.Font;
  13430. font.Name = "黑体";
  13431. //设置双休红色
  13432. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13433. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13434. paragraph = (Paragraph)paragraphs[1];
  13435. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13436. {
  13437. run = paragraph.Runs[0];
  13438. font = run.Font;
  13439. font.Color = Color.Red;
  13440. }
  13441. }
  13442. }
  13443. catch (Exception ex)
  13444. {
  13445. }
  13446. //删除多余行
  13447. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13448. {
  13449. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13450. }
  13451. var targetTextList = new List<string>();
  13452. // 遍历文档中的表格
  13453. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13454. {
  13455. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13456. {
  13457. var cellIndex = 0;
  13458. foreach (Cell cell in row.Cells)
  13459. {
  13460. if (cellIndex == 1 && row.Cells.Count == 4)
  13461. {
  13462. foreach (var target in targetTextDic.Keys)
  13463. {
  13464. if (cell.GetText().Contains(target))
  13465. {
  13466. targetTextList = targetTextDic[target];
  13467. break;
  13468. }
  13469. }
  13470. }
  13471. // 遍历单元格中的所有段落
  13472. foreach (Paragraph paragraph in cell.Paragraphs)
  13473. {
  13474. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13475. List<Run> runs = new List<Run>();
  13476. foreach (Run run in paragraph.Runs)
  13477. {
  13478. runs.Add(run);
  13479. }
  13480. foreach (Run run in runs)
  13481. {
  13482. foreach (var targetText in targetTextList)
  13483. {
  13484. // 检查文字是否包含指定文字
  13485. if (run.Text.Contains(targetText))
  13486. {
  13487. // 将包含的部分设置为红色
  13488. HighlightText(run, targetText, Color.Red);
  13489. }
  13490. }
  13491. }
  13492. }
  13493. cellIndex++;
  13494. }
  13495. }
  13496. }
  13497. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13498. if (!Directory.Exists(savePath))
  13499. {
  13500. try
  13501. {
  13502. Directory.CreateDirectory(savePath);
  13503. }
  13504. catch
  13505. {
  13506. }
  13507. }
  13508. string path = savePath + Find.TeamName + "出访日程";
  13509. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13510. try
  13511. {
  13512. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13513. string postfix = ".docx";
  13514. if (dto.IsPDF == 1)
  13515. {
  13516. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13517. postfix = ".pdf";
  13518. }
  13519. doc.Save(path + postfix, saveFormat);
  13520. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13521. }
  13522. catch (Exception)
  13523. {
  13524. jw = JsonView(false);
  13525. }
  13526. return Ok(jw);
  13527. }
  13528. /// <summary>
  13529. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13530. /// </summary>
  13531. /// <param name="num"></param>
  13532. /// <returns></returns>
  13533. string GetNum(string num)
  13534. {
  13535. string str = "";
  13536. switch (num)
  13537. {
  13538. case "1":
  13539. str = "一";
  13540. break;
  13541. case "2":
  13542. str = "二";
  13543. break;
  13544. case "3":
  13545. str = "三";
  13546. break;
  13547. case "4":
  13548. str = "四";
  13549. break;
  13550. case "5":
  13551. str = "五";
  13552. break;
  13553. case "6":
  13554. str = "六";
  13555. break;
  13556. case "7":
  13557. str = "七";
  13558. break;
  13559. case "8":
  13560. str = "八";
  13561. break;
  13562. case "9":
  13563. str = "九";
  13564. break;
  13565. case "10":
  13566. str = "十";
  13567. break;
  13568. case "11":
  13569. str = "十一";
  13570. break;
  13571. case "12":
  13572. str = "十二";
  13573. break;
  13574. case "一":
  13575. str = "1";
  13576. break;
  13577. case "二":
  13578. str = "2";
  13579. break;
  13580. case "三":
  13581. str = "3";
  13582. break;
  13583. case "四":
  13584. str = "4";
  13585. break;
  13586. case "五":
  13587. str = "5";
  13588. break;
  13589. case "六":
  13590. str = "6";
  13591. break;
  13592. case "七":
  13593. str = "7";
  13594. break;
  13595. case "八":
  13596. str = "8";
  13597. break;
  13598. case "九":
  13599. str = "9";
  13600. break;
  13601. case "十":
  13602. str = "10";
  13603. break;
  13604. case "十一":
  13605. str = "11";
  13606. break;
  13607. case "十二":
  13608. str = "12";
  13609. break;
  13610. }
  13611. return str;
  13612. }
  13613. // 高亮包含指定文字的部分
  13614. void HighlightText(Run run, string targetText, Color color)
  13615. {
  13616. string text = run.Text;
  13617. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13618. if (startIndex >= 0)
  13619. {
  13620. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13621. // 前部分
  13622. if (startIndex > 0)
  13623. {
  13624. Run beforeRun = (Run)run.Clone(true);
  13625. beforeRun.Text = text.Substring(0, startIndex);
  13626. parentParagraph.InsertBefore(beforeRun, run);
  13627. }
  13628. // 匹配部分
  13629. Run matchRun = (Run)run.Clone(true);
  13630. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13631. matchRun.Font.Color = color;
  13632. parentParagraph.InsertBefore(matchRun, run);
  13633. // 后部分
  13634. if (startIndex + targetText.Length < text.Length)
  13635. {
  13636. Run afterRun = (Run)run.Clone(true);
  13637. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13638. parentParagraph.InsertBefore(afterRun, run);
  13639. }
  13640. // 删除原始Run
  13641. run.Remove();
  13642. }
  13643. }
  13644. #endregion
  13645. #endregion
  13646. #region 团组成本
  13647. /// <summary>
  13648. /// 团组成本数据初始化
  13649. /// </summary>
  13650. /// <param name="dto"></param>
  13651. /// <returns></returns>
  13652. [HttpPost]
  13653. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13654. {
  13655. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13656. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13657. WHEN COUNT(*) >= 0 THEN 'True'
  13658. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13659. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13660. ").ToList(); //团组列表
  13661. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13662. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13663. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13664. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13665. if (groupinfoValue != null)
  13666. {
  13667. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13668. var spArr = new string[1] { countryArr };
  13669. if (countryArr.Contains("|"))
  13670. {
  13671. spArr = countryArr.Split("|");
  13672. }
  13673. else if (countryArr.Contains("、"))
  13674. {
  13675. spArr = countryArr.Split("、");
  13676. }
  13677. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13678. {
  13679. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13680. if (dbQueryCountry != null)
  13681. {
  13682. visaCountryInfoArr.Add(dbQueryCountry);
  13683. }
  13684. }
  13685. }
  13686. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13687. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13688. #region 屏蔽黑屏代码生成
  13689. //var create = _GroupCostRepository.
  13690. // CreateGroupCostByBlackCode(dto.Diid);
  13691. //if (groupCost.Count == 0 && create.Code == 0)
  13692. //{
  13693. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13694. //}
  13695. #endregion
  13696. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13697. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13698. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13699. groupCostMap = groupCostMap.Select(x =>
  13700. {
  13701. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13702. {
  13703. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13704. }
  13705. return x;
  13706. }).ToList();
  13707. //GroupCostParameter.Add(new
  13708. // Grp_GroupCostParameter());
  13709. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13710. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13711. return Ok(JsonView(new
  13712. {
  13713. groupList,
  13714. groupInfo,
  13715. groupChecks,
  13716. groupCost = groupCostMap,
  13717. hotelNumber,
  13718. GroupCostParameter = GroupCostParameterMap,
  13719. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13720. {
  13721. x.VisaCountry,
  13722. x.VisaPrice,
  13723. x.Id,
  13724. }).ToList(),
  13725. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13726. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  13727. hotelIsTrue = hotelIsTrue,
  13728. }));
  13729. }
  13730. /// <summary>
  13731. /// 团组成本信息保存
  13732. /// </summary>
  13733. /// <param name="dto"></param>
  13734. /// <returns></returns>
  13735. [HttpPost]
  13736. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13737. {
  13738. if (dto.Diid <= 0 || dto.Userid <= 0)
  13739. {
  13740. return Ok(JsonView(false));
  13741. }
  13742. JsonView jw = null;
  13743. bool isTrue = false;
  13744. #region 复制团组成本
  13745. //if (dto.Diid == 2581)
  13746. //{
  13747. // dto.Diid = 2599;
  13748. // dto.CheckBoxs.ForEach(x =>
  13749. // {
  13750. // x.Diid = 2599;
  13751. // });
  13752. // dto.GroupCosts.ForEach(x =>
  13753. // {
  13754. // x.Diid = 2599;
  13755. // });
  13756. // dto.CostTypeHotelNumbers.ForEach(x =>
  13757. // {
  13758. // x.Diid = 2599;
  13759. // });
  13760. // dto.GroupCostParameters.ForEach(x =>
  13761. // {
  13762. // x.DiId = 2599;
  13763. // });
  13764. //}
  13765. #endregion
  13766. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13767. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13768. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13769. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13770. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13771. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13772. try
  13773. {
  13774. _sqlSugar.BeginTran();
  13775. isTrue = await _GroupCostRepository.
  13776. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13777. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13778. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13779. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13780. _sqlSugar.CommitTran();
  13781. jw = JsonView(true, "保存成功!", isTrue);
  13782. }
  13783. catch (Exception)
  13784. {
  13785. _sqlSugar.RollbackTran();
  13786. jw = JsonView(false);
  13787. }
  13788. return Ok(jw);
  13789. }
  13790. /// <summary>
  13791. /// 司兼导数据
  13792. /// </summary>
  13793. /// <param name="dto"></param>
  13794. /// <returns></returns>
  13795. [HttpPost]
  13796. public IActionResult GetCarGuides(CarGuidesDto dto)
  13797. {
  13798. JsonView jw = null;
  13799. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13800. jw = JsonView(true, "获取成功!", Data);
  13801. return Ok(jw);
  13802. }
  13803. /// <summary>
  13804. /// 导游数据
  13805. /// </summary>
  13806. /// <param name="dto"></param>
  13807. /// <returns></returns>
  13808. [HttpPost]
  13809. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  13810. {
  13811. JsonView jw = null;
  13812. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  13813. // 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
  13814. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  13815. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  13816. jw = JsonView(true, "获取成功!", Data);
  13817. return Ok(jw);
  13818. }
  13819. /// <summary>
  13820. /// 成本车数据
  13821. /// </summary>
  13822. /// <param name="dto"></param>
  13823. /// <returns></returns>
  13824. [HttpPost]
  13825. public IActionResult GetCarInfo(CarGuidesDto dto)
  13826. {
  13827. JsonView jw = null;
  13828. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  13829. jw = JsonView(true, "获取成功!", Data);
  13830. return Ok(jw);
  13831. }
  13832. /// <summary>
  13833. /// 景点数据
  13834. /// </summary>
  13835. /// <param name="dto"></param>
  13836. /// <returns></returns>
  13837. [HttpPost]
  13838. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  13839. {
  13840. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  13841. return Ok(JsonView(true, "获取成功!", Data));
  13842. }
  13843. /// <summary>
  13844. /// 成本通知
  13845. /// </summary>
  13846. /// <param name="dto"></param>
  13847. /// <returns></returns>
  13848. [HttpPost]
  13849. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  13850. {
  13851. if (dto.Diid < 0)
  13852. {
  13853. return Ok(JsonView(false));
  13854. }
  13855. JsonView jw = null;
  13856. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  13857. if (GroupCostParameter != null)
  13858. {
  13859. int IsShare = 0;
  13860. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  13861. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  13862. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  13863. string msg = string.Empty;
  13864. if (isTrue)
  13865. {
  13866. if (IsShare == 0)
  13867. {
  13868. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  13869. }
  13870. else
  13871. {
  13872. #region 企微通知对应岗位用户
  13873. try
  13874. {
  13875. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  13876. }
  13877. catch (Exception ex)
  13878. {
  13879. }
  13880. #endregion
  13881. msg = "通知成功,其他模块操作人员可见此成本信息!";
  13882. }
  13883. jw = JsonView(isTrue, msg, new { IsShare });
  13884. }
  13885. else
  13886. {
  13887. msg = "修改失败!";
  13888. jw = JsonView(isTrue, msg);
  13889. }
  13890. }
  13891. else
  13892. {
  13893. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  13894. }
  13895. return Ok(jw);
  13896. }
  13897. /// <summary>
  13898. /// 导出报价单
  13899. /// </summary>
  13900. /// <param name="dto"></param>
  13901. /// <returns></returns>
  13902. [HttpPost]
  13903. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  13904. {
  13905. if (dto.Diid == 0)
  13906. {
  13907. return Ok(JsonView(false, "请传递团组id"));
  13908. }
  13909. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13910. if (deleInfo.Code != 0)
  13911. {
  13912. return Ok(JsonView(false, "团组信息查询失败!"));
  13913. }
  13914. var di = deleInfo.Data as DelegationInfoWebView;
  13915. if (di != null)
  13916. {
  13917. di.TeamName = di.TeamName.Replace("|", "、");
  13918. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  13919. //文件名
  13920. string strFileName = di.TeamName + "-收款账单.doc";
  13921. //获取模板
  13922. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  13923. //载入模板
  13924. Document doc = new Document(tmppath);
  13925. decimal TotalPrice = 0.00M;
  13926. string itemStr = string.Empty;
  13927. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  13928. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13929. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13930. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  13931. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  13932. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  13933. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  13934. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  13935. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  13936. foreach (var cost in groupCostType)
  13937. {
  13938. var List = cost.ToList();
  13939. if (cost.Key == "A")
  13940. {
  13941. foreach (var ListItem in List)
  13942. {
  13943. if (ListItem.number > 0)
  13944. {
  13945. if (ListItem.code.Contains("TBR"))
  13946. {
  13947. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13948. }
  13949. else
  13950. {
  13951. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13952. }
  13953. TotalPrice += (ListItem.number * ListItem.price);
  13954. }
  13955. }
  13956. }
  13957. else
  13958. {
  13959. itemStr = itemStr.Insert(0, "A段\r\n");
  13960. itemStr += "B段\r\n";
  13961. foreach (var ListItem in List)
  13962. {
  13963. if (ListItem.number > 0)
  13964. {
  13965. if (ListItem.code.Contains("TBR"))
  13966. {
  13967. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13968. }
  13969. else
  13970. {
  13971. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13972. }
  13973. TotalPrice += (ListItem.number * ListItem.price);
  13974. }
  13975. }
  13976. }
  13977. }
  13978. #region 替换Word模板书签内容
  13979. Dictionary<string, string> marks = new Dictionary<string, string>();
  13980. marks.Add("To", di.ClientUnit);//付款方
  13981. marks.Add("ToTel", di.TellPhone);//付款方电话
  13982. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  13983. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  13984. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  13985. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  13986. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  13987. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  13988. marks.Add("PayItemContent", itemStr);//详细信息
  13989. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  13990. #endregion
  13991. ////注
  13992. //if (doc.Range.Bookmarks["Attention"] != null)
  13993. //{
  13994. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  13995. // mark.Text = frList[0].Attention;
  13996. //}
  13997. foreach (var item in marks.Keys)
  13998. {
  13999. if (doc.Range.Bookmarks[item] != null)
  14000. {
  14001. Bookmark mark = doc.Range.Bookmarks[item];
  14002. mark.Text = marks[item];
  14003. }
  14004. }
  14005. byte[] bytes = null;
  14006. using (MemoryStream stream = new MemoryStream())
  14007. {
  14008. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14009. bytes = stream.ToArray();
  14010. }
  14011. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14012. return Ok(JsonView(true, "", new
  14013. {
  14014. Data = bytes,
  14015. strFileName,
  14016. }));
  14017. }
  14018. else
  14019. {
  14020. return Ok(JsonView(false, "团组信息不存在!"));
  14021. }
  14022. }
  14023. /// <summary>
  14024. /// 导出团组成本
  14025. /// </summary>
  14026. /// <param name="dto"></param>
  14027. /// <returns></returns>
  14028. [HttpPost]
  14029. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14030. {
  14031. var jw = JsonView(false);
  14032. if (dto.Diid == 0)
  14033. {
  14034. return Ok(JsonView(false, "请传递团组id"));
  14035. }
  14036. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14037. if (deleInfo.Code != 0)
  14038. {
  14039. return Ok(JsonView(false, "团组信息查询失败!"));
  14040. }
  14041. var di = deleInfo.Data as DelegationInfoWebView;
  14042. if (di == null)
  14043. {
  14044. return Ok(JsonView(false, "团组信息查询失败!"));
  14045. }
  14046. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14047. WorkbookDesigner designer = new WorkbookDesigner();
  14048. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14049. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14050. for (int i = 0; i < List_GC.Count; i++)
  14051. {
  14052. GroupCost_Excel gc = new GroupCost_Excel();
  14053. gc.Id = List_GC[i].Id;
  14054. gc.Diid = List_GC[i].Diid.ToString();
  14055. gc.DAY = List_GC[i].DAY;
  14056. string week = "";
  14057. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14058. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14059. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14060. gc.ITIN = List_GC[i].ITIN;
  14061. gc.CarType = List_GC[i].CarType;
  14062. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14063. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14064. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14065. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14066. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14067. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14068. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14069. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14070. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14071. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14072. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14073. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14074. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14075. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14076. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14077. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14078. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14079. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14080. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14081. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14082. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14083. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14084. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14085. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14086. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14087. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14088. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14089. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14090. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14091. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14092. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14093. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14094. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14095. List_GC1.Add(gc);
  14096. }
  14097. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14098. dt.TableName = "TB";
  14099. //报表标题等不用dt的值
  14100. designer.SetDataSource("TeamName", dto.title.TeamName);
  14101. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14102. designer.SetDataSource("Tax", dto.title.Tax);
  14103. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14104. designer.SetDataSource("Currency", dto.title.Currency);
  14105. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14106. designer.SetDataSource("Rate", dto.title.Rate);
  14107. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14108. var Aparams = hotels.Find(x => x.Type == "Default");
  14109. if (Aparams == null)
  14110. {
  14111. return Ok(jw);
  14112. }
  14113. //酒店数量
  14114. var txtSGRNumber = Aparams.SGR.ToString();
  14115. var txtTBRNumber = Aparams.TBR.ToString();
  14116. var txtJSESNumber = Aparams.JSES.ToString();
  14117. var txtSUITENumbe = Aparams.SUITE.ToString();
  14118. if (dto.costType == "B")
  14119. {
  14120. Aparams = hotels.Find(x => x.Type == "A");
  14121. var Bparams = hotels.Find(x => x.Type == "B");
  14122. if (Aparams == null || Bparams == null)
  14123. {
  14124. return Ok(jw);
  14125. }
  14126. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14127. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14128. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14129. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14130. }
  14131. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14132. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14133. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14134. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14135. var ws = designer.Workbook.Worksheets[0];
  14136. int Row = List_GC.Count;
  14137. int startIndex = 11;
  14138. int HideRows = 0;
  14139. List<int> hideRowsList = new List<int>();
  14140. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14141. #region A段left数据
  14142. var left = dto.leftInfo.Find(x => x.Type == "A");
  14143. if (left == null)
  14144. {
  14145. return Ok(jw);
  14146. }
  14147. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14148. if (leftBindData != null)
  14149. {
  14150. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14151. designer.SetDataSource("VisaRS", leftBindData.rs);
  14152. designer.SetDataSource("VisaXS", leftBindData.xs);
  14153. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14154. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14155. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14156. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14157. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14158. }
  14159. else
  14160. {
  14161. hideRowsList.Add(Row + startIndex + HideRows);
  14162. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14163. }
  14164. HideRows += 2;
  14165. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14166. if (leftBindData != null)
  14167. {
  14168. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14169. designer.SetDataSource("BXRS", leftBindData.rs);
  14170. designer.SetDataSource("BXXS", leftBindData.xs);
  14171. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14172. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14173. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14174. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14175. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14176. }
  14177. else
  14178. {
  14179. hideRowsList.Add(Row + startIndex + HideRows);
  14180. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14181. }
  14182. HideRows += 2;
  14183. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14184. if (leftBindData != null)
  14185. {
  14186. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14187. designer.SetDataSource("HSRS", leftBindData.rs);
  14188. designer.SetDataSource("HSXS", leftBindData.xs);
  14189. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14190. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14191. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14192. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14193. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14194. }
  14195. else
  14196. {
  14197. hideRowsList.Add(Row + startIndex + HideRows);
  14198. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14199. }
  14200. HideRows += 2;
  14201. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14202. if (leftBindData != null)
  14203. {
  14204. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14205. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14206. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14207. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14208. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14209. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14210. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14211. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14212. }
  14213. else
  14214. {
  14215. hideRowsList.Add(Row + startIndex + HideRows);
  14216. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14217. }
  14218. HideRows += 2;
  14219. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14220. if (leftBindData != null)
  14221. {
  14222. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14223. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14224. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14225. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14226. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14227. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14228. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14229. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14230. }
  14231. else
  14232. {
  14233. hideRowsList.Add(Row + startIndex + HideRows);
  14234. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14235. }
  14236. HideRows += 2;
  14237. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14238. if (leftBindData != null)
  14239. {
  14240. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14241. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14242. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14243. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14244. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14245. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14246. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14247. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14248. }
  14249. else
  14250. {
  14251. hideRowsList.Add(Row + startIndex + HideRows);
  14252. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14253. }
  14254. HideRows += 2;
  14255. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14256. if (leftBindData != null)
  14257. {
  14258. ////TBR
  14259. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14260. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14261. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14262. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14263. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14264. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14265. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14266. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14267. }
  14268. else
  14269. {
  14270. hideRowsList.Add(Row + startIndex + HideRows);
  14271. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14272. }
  14273. HideRows += 2;
  14274. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14275. if (leftBindData != null)
  14276. {
  14277. ////SGR
  14278. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14279. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14280. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14281. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14282. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14283. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14284. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14285. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14286. }
  14287. else
  14288. {
  14289. hideRowsList.Add(Row + startIndex + HideRows);
  14290. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14291. }
  14292. HideRows += 2;
  14293. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14294. if (leftBindData != null)
  14295. {
  14296. ////JS/ES
  14297. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14298. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14299. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14300. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14301. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14302. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14303. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14304. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14305. }
  14306. else
  14307. {
  14308. hideRowsList.Add(Row + startIndex + HideRows);
  14309. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14310. }
  14311. HideRows += 2;
  14312. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14313. if (leftBindData != null)
  14314. {
  14315. ////SUITE
  14316. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14317. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14318. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14319. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14320. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14321. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14322. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14323. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14324. }
  14325. else
  14326. {
  14327. hideRowsList.Add(Row + startIndex + HideRows);
  14328. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14329. }
  14330. HideRows += 2;
  14331. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14332. if (leftBindData != null)
  14333. {
  14334. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14335. designer.SetDataSource("DJRS", leftBindData.rs);
  14336. designer.SetDataSource("DJXS", leftBindData.xs);
  14337. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14338. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14339. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14340. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14341. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14342. }
  14343. else
  14344. {
  14345. hideRowsList.Add(Row + startIndex + HideRows);
  14346. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14347. }
  14348. HideRows += 2;
  14349. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14350. if (leftBindData != null)
  14351. {
  14352. designer.SetDataSource("HCPCB", leftBindData.cb);
  14353. designer.SetDataSource("HCPRS", leftBindData.rs);
  14354. designer.SetDataSource("HCPXS", leftBindData.xs);
  14355. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14356. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14357. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14358. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14359. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14360. }
  14361. else
  14362. {
  14363. hideRowsList.Add(Row + startIndex + HideRows);
  14364. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14365. }
  14366. HideRows += 2;
  14367. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14368. if (leftBindData != null)
  14369. {
  14370. designer.SetDataSource("CPCB", leftBindData.cb);
  14371. designer.SetDataSource("CPRS", leftBindData.rs);
  14372. designer.SetDataSource("CPXS", leftBindData.xs);
  14373. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14374. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14375. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14376. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14377. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14378. }
  14379. else
  14380. {
  14381. hideRowsList.Add(Row + startIndex + HideRows);
  14382. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14383. }
  14384. HideRows += 2;
  14385. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14386. if (leftBindData != null)
  14387. {
  14388. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14389. designer.SetDataSource("GWRS", leftBindData.rs);
  14390. designer.SetDataSource("GWXS", leftBindData.xs);
  14391. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14392. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14393. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14394. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14395. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14396. }
  14397. else
  14398. {
  14399. hideRowsList.Add(Row + startIndex + HideRows);
  14400. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14401. }
  14402. HideRows += 2;
  14403. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14404. if (leftBindData != null)
  14405. {
  14406. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14407. designer.SetDataSource("LYJRS", leftBindData.rs);
  14408. designer.SetDataSource("LYJXS", leftBindData.xs);
  14409. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14410. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14411. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14412. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14413. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14414. }
  14415. else
  14416. {
  14417. hideRowsList.Add(Row + startIndex + HideRows);
  14418. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14419. }
  14420. #endregion
  14421. #region A段Right信息
  14422. var right = dto.rightInfo.Find(x => x.Type == "A");
  14423. if (right == null)
  14424. {
  14425. return Ok(jw);
  14426. }
  14427. HideRows += 4;
  14428. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14429. if (rightBindData != null)
  14430. {
  14431. //经济舱 + 双人间 TBR
  14432. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14433. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14434. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14435. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14436. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14437. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14438. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14439. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14440. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14441. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14442. }
  14443. else
  14444. {
  14445. hideRowsList.Add(Row + startIndex + HideRows);
  14446. }
  14447. HideRows += 2;
  14448. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14449. if (rightBindData != null)
  14450. {
  14451. //经济舱 + 单人间 SGR
  14452. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14453. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14454. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14455. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14456. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14457. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14458. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14459. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14460. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14461. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14462. }
  14463. else
  14464. {
  14465. hideRowsList.Add(Row + startIndex + HideRows);
  14466. }
  14467. HideRows += 2;
  14468. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14469. if (rightBindData != null)
  14470. {
  14471. //公务舱 + 单人间 SGR
  14472. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14473. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14474. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14475. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14476. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14477. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14478. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14479. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14480. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14481. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14482. }
  14483. else
  14484. {
  14485. hideRowsList.Add(Row + startIndex + HideRows);
  14486. }
  14487. HideRows += 2;
  14488. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14489. if (rightBindData != null)
  14490. {
  14491. //公务舱 + 小套房 JSES
  14492. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14493. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14494. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14495. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14496. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14497. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14498. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14499. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14500. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14501. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14502. }
  14503. else
  14504. {
  14505. hideRowsList.Add(Row + startIndex + HideRows);
  14506. }
  14507. HideRows += 2;
  14508. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14509. if (rightBindData != null)
  14510. {
  14511. //公务舱 + 小套房 JSES
  14512. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14513. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14514. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14515. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14516. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14517. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14518. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14519. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14520. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14521. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14522. }
  14523. else
  14524. {
  14525. hideRowsList.Add(Row + startIndex + HideRows);
  14526. }
  14527. HideRows += 2;
  14528. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14529. if (rightBindData != null)
  14530. {
  14531. //经济舱 + 大套房
  14532. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14533. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14534. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14535. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14536. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14537. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14538. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14539. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14540. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14541. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14542. }
  14543. else
  14544. {
  14545. hideRowsList.Add(Row + startIndex + HideRows);
  14546. }
  14547. HideRows += 2;
  14548. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14549. if (rightBindData != null)
  14550. {
  14551. //头等舱 + 小套房 JSES
  14552. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14553. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14554. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14555. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14556. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14557. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14558. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14559. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14560. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14561. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14562. }
  14563. else
  14564. {
  14565. hideRowsList.Add(Row + startIndex + HideRows);
  14566. }
  14567. HideRows += 2;
  14568. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14569. if (rightBindData != null)
  14570. {
  14571. //头等舱 + 大套房
  14572. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14573. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14574. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14575. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14576. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14577. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14578. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14579. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14580. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14581. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14582. }
  14583. else
  14584. {
  14585. hideRowsList.Add(Row + startIndex + HideRows);
  14586. }
  14587. #endregion
  14588. #region B段标题清空
  14589. designer.SetDataSource("CostBDRCB", "");
  14590. designer.SetDataSource("CostBRS", "");
  14591. designer.SetDataSource("CostBXS", "");
  14592. designer.SetDataSource("CostBZCB", "");
  14593. designer.SetDataSource("CostBDRBJ", "");
  14594. designer.SetDataSource("CostBZBJ", "");
  14595. designer.SetDataSource("CostBDRLR", "");
  14596. designer.SetDataSource("CostBZLR", "");
  14597. designer.SetDataSource("CostBDRCBOM", "");
  14598. designer.SetDataSource("CostBRSOM", "");
  14599. designer.SetDataSource("CostBZCBOM", "");
  14600. designer.SetDataSource("CostBDRBJOM", "");
  14601. designer.SetDataSource("CostBZBJOM", "");
  14602. designer.SetDataSource("CostBDRLROM", "");
  14603. designer.SetDataSource("CostBZLROM", "");
  14604. #endregion
  14605. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14606. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14607. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14608. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14609. designer.SetDataSource("DJName", "地接(CNY)");
  14610. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14611. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14612. designer.SetDataSource("GWName", "公务(CNY)");
  14613. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14614. designer.SetDataSource("LYJName", "零用金(CNY)");
  14615. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14616. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14617. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14618. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14619. designer.SetDataSource("BXName", "保险(CNY)");
  14620. designer.SetDataSource("VisaName", "签证(CNY)");
  14621. #region B段基本数据
  14622. if (dto.costType == "B")
  14623. {
  14624. left = dto.leftInfo.Find(x => x.Type == "B");
  14625. if (left == null)
  14626. {
  14627. return Ok(jw);
  14628. }
  14629. #region B段left数据
  14630. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14631. if (leftBindData != null)
  14632. {
  14633. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14634. designer.SetDataSource("BHSRS", leftBindData.rs);
  14635. designer.SetDataSource("BHSXS", leftBindData.xs);
  14636. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14637. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14638. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14639. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14640. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14641. }
  14642. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14643. if (leftBindData != null)
  14644. {
  14645. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14646. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14647. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14648. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14649. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14650. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14651. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14652. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14653. }
  14654. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14655. if (leftBindData != null)
  14656. {
  14657. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14658. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14659. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14660. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14661. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14662. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14663. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14664. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14665. }
  14666. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14667. if (leftBindData != null)
  14668. {
  14669. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14670. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14671. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14672. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14673. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14674. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14675. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14676. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14677. }
  14678. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14679. if (leftBindData != null)
  14680. {
  14681. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14682. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14683. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14684. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14685. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14686. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14687. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14688. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14689. }
  14690. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14691. if (leftBindData != null)
  14692. {
  14693. designer.SetDataSource("BCPCB", leftBindData.cb);
  14694. designer.SetDataSource("BCPRS", leftBindData.rs);
  14695. designer.SetDataSource("BCPXS", leftBindData.xs);
  14696. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14697. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14698. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14699. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14700. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14701. }
  14702. //TBR
  14703. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14704. if (leftBindData != null)
  14705. {
  14706. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14707. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14708. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14709. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14710. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14711. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14712. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14713. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14714. }
  14715. //SGR
  14716. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14717. if (leftBindData != null)
  14718. {
  14719. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  14720. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  14721. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  14722. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14723. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14724. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14725. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14726. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14727. }
  14728. //JS/ES
  14729. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14730. if (leftBindData != null)
  14731. {
  14732. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  14733. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14734. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14735. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14736. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14737. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14738. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14739. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14740. }
  14741. //SUITE
  14742. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14743. if (leftBindData != null)
  14744. {
  14745. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14746. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14747. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14748. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14749. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14750. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14751. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14752. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14753. }
  14754. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14755. if (leftBindData != null)
  14756. {
  14757. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14758. designer.SetDataSource("BDJRS", leftBindData.rs);
  14759. designer.SetDataSource("BDJXS", leftBindData.xs);
  14760. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14761. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14762. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14763. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14764. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14765. }
  14766. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14767. if (leftBindData != null)
  14768. {
  14769. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14770. designer.SetDataSource("BGWRS", leftBindData.rs);
  14771. designer.SetDataSource("BGWXS", leftBindData.xs);
  14772. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14773. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14774. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14775. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14776. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14777. }
  14778. #region 优化方案
  14779. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14780. //excelBind.Add("零用金", new {
  14781. //cb="",
  14782. //rs="",
  14783. //xs ="",
  14784. //zcb = "",
  14785. //});
  14786. #endregion
  14787. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14788. if (leftBindData != null)
  14789. {
  14790. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14791. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14792. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14793. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14794. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14795. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14796. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14797. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14798. }
  14799. #endregion
  14800. #region B段Right信息
  14801. right = dto.rightInfo.Find(x => x.Type == "B");
  14802. if (right == null)
  14803. {
  14804. return Ok(jw);
  14805. }
  14806. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14807. if (rightBindData != null)
  14808. {
  14809. //经济舱 + 双人间 TBR
  14810. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  14811. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  14812. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14813. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  14814. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14815. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14816. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14817. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14818. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14819. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14820. }
  14821. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14822. if (rightBindData != null)
  14823. {
  14824. //经济舱 + 单人间 SGR
  14825. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  14826. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  14827. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14828. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  14829. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14830. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14831. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14832. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14833. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14834. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14835. }
  14836. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14837. if (rightBindData != null)
  14838. {
  14839. //公务舱 + 单人间 SGR
  14840. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  14841. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  14842. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14843. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  14844. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14845. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14846. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14847. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14848. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14849. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14850. }
  14851. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14852. if (rightBindData != null)
  14853. {
  14854. //公务舱 + 小套房 JSES
  14855. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  14856. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  14857. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14858. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  14859. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14860. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14861. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14862. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14863. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14864. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14865. }
  14866. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14867. if (rightBindData != null)
  14868. {
  14869. //公务舱 + 小套房 JSES
  14870. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  14871. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  14872. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14873. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  14874. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14875. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14876. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14877. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14878. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14879. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14880. }
  14881. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14882. if (rightBindData != null)
  14883. {
  14884. //经济舱 + 大套房
  14885. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  14886. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  14887. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14888. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  14889. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14890. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14891. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14892. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14893. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14894. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14895. }
  14896. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14897. if (rightBindData != null)
  14898. {
  14899. //头等舱 + 小套房 JSES
  14900. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  14901. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  14902. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14903. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  14904. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14905. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14906. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14907. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14908. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14909. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14910. }
  14911. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14912. if (rightBindData != null)
  14913. {
  14914. //头等舱 + 大套房
  14915. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  14916. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  14917. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14918. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  14919. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14920. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14921. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14922. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14923. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14924. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14925. }
  14926. #endregion
  14927. #region 标题
  14928. designer.SetDataSource("CostBDRCB", "单人成本");
  14929. designer.SetDataSource("CostBRS", "人数");
  14930. designer.SetDataSource("CostBXS", "系数");
  14931. designer.SetDataSource("CostBZCB", "总成本");
  14932. designer.SetDataSource("CostBDRBJ", "单人报价");
  14933. designer.SetDataSource("CostBZBJ", "总报价");
  14934. designer.SetDataSource("CostBDRLR", "单人利润");
  14935. designer.SetDataSource("CostBZLR", "总利润");
  14936. designer.SetDataSource("CostBDRCBOM", "单人成本");
  14937. designer.SetDataSource("CostBRSOM", "人数");
  14938. designer.SetDataSource("CostBZCBOM", "总成本");
  14939. designer.SetDataSource("CostBDRBJOM", "单人报价");
  14940. designer.SetDataSource("CostBZBJOM", "总报价");
  14941. designer.SetDataSource("CostBDRLROM", "单人利润");
  14942. designer.SetDataSource("CostBZLROM", "总利润");
  14943. #endregion
  14944. }
  14945. #endregion
  14946. designer.SetDataSource("TzZCB2", TzZCB2);
  14947. designer.SetDataSource("TzZBJ2", TzZBJ2);
  14948. designer.SetDataSource("TzZLR2", TzZLR2);
  14949. string[] dataSourceKeys = new string[]
  14950. {
  14951. "VF",
  14952. "TGS",
  14953. "TGOF",
  14954. "TGM",
  14955. "TGA",
  14956. "TGTF",
  14957. "TGEF",
  14958. "CFM",
  14959. "CFOF",
  14960. "B",
  14961. "L",
  14962. "D",
  14963. "TBR",
  14964. "SGR",
  14965. "JSES",
  14966. "Suite",
  14967. "TV",
  14968. "1L",
  14969. "IF",
  14970. "EF",
  14971. "BRF",
  14972. "TE",
  14973. "TGT",
  14974. "DRVT",
  14975. "PC",
  14976. "TLF",
  14977. "ECT"
  14978. };
  14979. foreach (var item in dataSourceKeys)
  14980. {
  14981. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  14982. if (find != null)
  14983. {
  14984. designer.SetDataSource(item, find.text);
  14985. }
  14986. else
  14987. {
  14988. designer.SetDataSource(item, 0);
  14989. }
  14990. }
  14991. designer.SetDataSource(dt);
  14992. //根据数据源处理生成报表内容
  14993. designer.Process();
  14994. designer.Workbook.Worksheets[0].Name = "清单";
  14995. Worksheet sheet = designer.Workbook.Worksheets[0];
  14996. foreach (var Rowindex in hideRowsList)
  14997. {
  14998. ws.Cells.HideRows(Rowindex, 2);
  14999. }
  15000. byte[] bytes = null;
  15001. string strFileName = di.TeamName + "-团组-成本.xls";
  15002. using (MemoryStream stream = new MemoryStream())
  15003. {
  15004. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15005. bytes = stream.ToArray();
  15006. }
  15007. return Ok(JsonView(true, "", new
  15008. {
  15009. Data = bytes,
  15010. strFileName,
  15011. }));
  15012. }
  15013. /// <summary>
  15014. /// 导出客户报表
  15015. /// </summary>
  15016. /// <returns></returns>
  15017. [HttpPost]
  15018. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15019. {
  15020. var jw = JsonView(false);
  15021. if (dto.Diid == 0)
  15022. {
  15023. return Ok(JsonView(false, "请传递团组id"));
  15024. }
  15025. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15026. if (deleInfo.Code != 0)
  15027. {
  15028. return Ok(JsonView(false, "团组信息查询失败!"));
  15029. }
  15030. var di = deleInfo.Data as DelegationInfoWebView;
  15031. if (di == null)
  15032. {
  15033. return Ok(JsonView(false, "团组信息查询失败!"));
  15034. }
  15035. //文件名
  15036. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15037. //获取模板
  15038. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15039. //载入模板
  15040. Document doc = new Document(tmppath);
  15041. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15042. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15043. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15044. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15045. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15046. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15047. if (AParameter == null)
  15048. {
  15049. return Ok(JsonView(false, "系数不存在!"));
  15050. }
  15051. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15052. , TzAirDesc, TzZCost;
  15053. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15054. = TzAirDesc = TzZCost = string.Empty;
  15055. TzNumber = AParameter.CostTypenumber.ToString();
  15056. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15057. CarGuides1 = dto.CarGuides1;
  15058. Meal = dto.Meal;
  15059. SubsidizedMeals = dto.SubsidizedMeals;
  15060. NightRepair = dto.NightRepair;
  15061. AttractionsTickets = dto.AttractionsTickets;
  15062. MiscellaneousFees = dto.MiscellaneousFees;
  15063. ATip = dto.ATip;
  15064. TzHotelDesc = "";
  15065. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15066. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15067. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15068. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15069. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15070. TzAirDesc = "";
  15071. TzZCost = dto.TzZCost;
  15072. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15073. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15074. var index = 1;
  15075. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15076. foreach (var item in TzHotelDescArr)
  15077. {
  15078. if (AinfoArr != null)
  15079. {
  15080. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15081. if (Ainfo != null)
  15082. {
  15083. if (int.Parse(Ainfo.rs) <= 0)
  15084. {
  15085. continue;
  15086. }
  15087. var hotelText = string.Empty;
  15088. switch (item)
  15089. {
  15090. case "SGR":
  15091. hotelText = "单人间";
  15092. break;
  15093. case "JSES":
  15094. hotelText = "小套房";
  15095. break;
  15096. case "SUITE":
  15097. hotelText = "套房";
  15098. break;
  15099. case "TBR":
  15100. hotelText = "双人间";
  15101. break;
  15102. }
  15103. if (item != "TBR")
  15104. {
  15105. 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";
  15106. }
  15107. else
  15108. {
  15109. 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";
  15110. }
  15111. index++;
  15112. }
  15113. }
  15114. }
  15115. index = 1;
  15116. foreach (var item in TzAirDescArr)
  15117. {
  15118. if (AinfoArr != null)
  15119. {
  15120. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15121. if (Ainfo != null)
  15122. {
  15123. if (int.Parse(Ainfo.rs) <= 0)
  15124. {
  15125. continue;
  15126. }
  15127. 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";
  15128. index++;
  15129. }
  15130. }
  15131. }
  15132. if (dto.costType == "B")
  15133. {
  15134. if (BParameter == null)
  15135. {
  15136. return Ok(JsonView(false, "B段系数不存在!"));
  15137. }
  15138. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15139. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15140. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15141. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15142. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15143. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15144. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15145. foreach (var item in TzHotelDescArr)
  15146. {
  15147. if (AinfoArr != null)
  15148. {
  15149. TzHotelDesc += "B段信息 \r\n";
  15150. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15151. if (Ainfo != null)
  15152. {
  15153. if (int.Parse(Ainfo.rs) <= 0)
  15154. {
  15155. continue;
  15156. }
  15157. var hotelText = string.Empty;
  15158. switch (item)
  15159. {
  15160. case "SGR":
  15161. hotelText = "单人间";
  15162. break;
  15163. case "JSES":
  15164. hotelText = "小套房";
  15165. break;
  15166. case "SUITE":
  15167. hotelText = "套房";
  15168. break;
  15169. case "TBR":
  15170. hotelText = "双人间";
  15171. break;
  15172. }
  15173. if (item != "TBR")
  15174. {
  15175. 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";
  15176. }
  15177. else
  15178. {
  15179. 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";
  15180. }
  15181. index++;
  15182. }
  15183. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15184. }
  15185. }
  15186. index = 1;
  15187. foreach (var item in TzAirDescArr)
  15188. {
  15189. if (AinfoArr != null)
  15190. {
  15191. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15192. if (Ainfo != null)
  15193. {
  15194. if (int.Parse(Ainfo.rs) <= 0)
  15195. {
  15196. continue;
  15197. }
  15198. 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";
  15199. index++;
  15200. }
  15201. }
  15202. }
  15203. }
  15204. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15205. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15206. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15207. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15208. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15209. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15210. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15211. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15212. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15213. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15214. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15215. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15216. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15217. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15218. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15219. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15220. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15221. DickeyValue.Add("TzZCost", TzZCost);
  15222. foreach (var key in DickeyValue.Keys)
  15223. {
  15224. if (doc.Range.Bookmarks[key] != null)
  15225. {
  15226. Bookmark mark = doc.Range.Bookmarks[key];
  15227. mark.Text = DickeyValue[key];
  15228. }
  15229. }
  15230. byte[] bytes = null;
  15231. string strFileName = di.TeamName + "-客户报价.doc";
  15232. using (MemoryStream stream = new MemoryStream())
  15233. {
  15234. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15235. bytes = stream.ToArray();
  15236. }
  15237. return Ok(JsonView(true, "", new
  15238. {
  15239. Data = bytes,
  15240. strFileName,
  15241. }));
  15242. }
  15243. /// <summary>
  15244. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15245. /// </summary>
  15246. /// <param name="dto"></param>
  15247. /// <returns></returns>
  15248. [HttpPost]
  15249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15250. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15251. {
  15252. try
  15253. {
  15254. #region 参数验证
  15255. if (dto.DiId < 0)
  15256. {
  15257. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15258. }
  15259. List<int> cTableIds = new List<int>() {
  15260. 76 ,//酒店预订
  15261. 77 ,//行程
  15262. 79 ,//车/导游地接
  15263. 80 ,//签证
  15264. 81 ,//邀请/公务活
  15265. 82 ,//团组客户保险
  15266. 85 ,//机票预订
  15267. 98 ,//其他款项
  15268. 285 ,//收款退还
  15269. 751 ,//酒店早餐
  15270. 1015 // 超支费用
  15271. };
  15272. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15273. {
  15274. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15275. }
  15276. #endregion
  15277. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15278. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15279. if (_GroupCostParameters.Count <= 0)
  15280. {
  15281. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15282. }
  15283. if (_GroupCostParameters[0].IsShare == 0)
  15284. {
  15285. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15286. }
  15287. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15288. //处理date为空问题
  15289. if (_GroupCosts.Count > 0)
  15290. {
  15291. for (int i = 0; i < _GroupCosts.Count; i++)
  15292. {
  15293. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15294. {
  15295. if (i > 0)
  15296. {
  15297. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15298. }
  15299. }
  15300. }
  15301. }
  15302. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15303. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15304. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15305. string currCode = "";
  15306. #region currCode 验证
  15307. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15308. if (isInt)
  15309. {
  15310. var currData = currDatas.Find(it => it.Id == intCurrency);
  15311. if (currData != null)
  15312. {
  15313. currCode = currData.Name;
  15314. }
  15315. }
  15316. else
  15317. {
  15318. currCode = _GroupCostParameters[0].Currency.Trim();
  15319. }
  15320. #endregion
  15321. //op,酒店单段模式存储
  15322. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15323. {
  15324. CurrencyCode = currCode,
  15325. Rate = _GroupCostParameters[0].Rate,
  15326. CostType = _GroupCostParameters[0].CostType,
  15327. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15328. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15329. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15330. };
  15331. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15332. if (_GroupCostParameters.Count == 2)
  15333. {
  15334. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15335. }
  15336. foreach (var item in _GroupCostParameters)
  15337. {
  15338. decimal _rate = 1;
  15339. decimal _rate1 = item.Rate;
  15340. decimal _scale = 1;
  15341. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15342. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15343. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15344. //if (userInfo != null)
  15345. //{
  15346. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15347. // {
  15348. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15349. // {
  15350. // _scale = 1.00M;
  15351. // }
  15352. // }
  15353. //}
  15354. #endregion
  15355. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15356. {
  15357. CurrencyCode = currCode,
  15358. Rate = _rate1,
  15359. CostType = item.CostType,
  15360. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15361. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15362. CostTypeNumber = item.CostTypenumber
  15363. };
  15364. if (_GroupCostParameters.Count > 1)
  15365. {
  15366. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15367. }
  15368. else
  15369. {
  15370. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15371. }
  15372. if (dto.CTable == 79)//
  15373. {
  15374. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15375. modulePromptInfo.TotalCost = item.DJCB;
  15376. }
  15377. List<string> costTypes = new List<string>() { "A", "B" };
  15378. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15379. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15380. if (_GroupCostsDuplicates.Count() == 1)
  15381. {
  15382. _GroupCostsTypeData = _GroupCosts;
  15383. }
  15384. else
  15385. {
  15386. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15387. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15388. }
  15389. /*
  15390. * 76 酒店预订
  15391. * 77 行程
  15392. * 79 车/导游地接
  15393. * 80 签证
  15394. * 81 邀请/公务活动
  15395. * 82 团组客户保险
  15396. * 85 机票预订
  15397. * 98 其他款项
  15398. * 285 收款退还
  15399. * 751 酒店早餐
  15400. * 1015 超支费用
  15401. */
  15402. switch (dto.CTable)
  15403. {
  15404. case 76: // 酒店预订
  15405. _ModuleSubPromptInfo.AddRange(
  15406. _GroupCostsTypeData.Select(it => new
  15407. {
  15408. it.DAY,
  15409. it.Date,
  15410. it.ACCON,
  15411. it.ITIN,
  15412. it.SGR,
  15413. it.TBR,
  15414. it.JS_ES,
  15415. it.Suite
  15416. })
  15417. );
  15418. break;
  15419. case 79: // 车/导游地接
  15420. _ModuleSubPromptInfo.AddRange(
  15421. _GroupCostsTypeData.Select(it => new
  15422. {
  15423. Date = it.Date, //日期
  15424. CarFee = it.CarCost * _rate * _scale, //车费用
  15425. CarType = it.CarType, //车型
  15426. DriverFee = it.CFS * _rate * _scale, //司机工资
  15427. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15428. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15429. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15430. GuideFee = it.TGS * _rate * _scale, //导游费用
  15431. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15432. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15433. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15434. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15435. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15436. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15437. Breakfast = it.B * _rate * _scale, //早餐费
  15438. Lunch = it.L * _rate * _scale, //午餐费
  15439. Dinner = it.D * _rate * _scale, //晚餐费
  15440. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15441. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15442. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15443. TicketFee = it.EF * _rate * _scale, //门票费
  15444. TicketRemark = it.EFR, //门票费描述
  15445. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15446. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15447. SpentCash = it.PC * _rate * _scale, //零用金
  15448. LeadersFee = it.TLF * _rate * _scale, //领队费
  15449. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15450. })
  15451. );
  15452. break;
  15453. case 85: // 机票
  15454. List<dynamic> datas = new List<dynamic>();
  15455. datas.Add(
  15456. new
  15457. {
  15458. AirType = "经济舱",
  15459. AirNum = item.JJCRS,
  15460. AirDRCB = item.JJCCB,
  15461. AirZCB = (item.JJCRS * item.JJCCB)
  15462. }
  15463. );
  15464. datas.Add(
  15465. new
  15466. {
  15467. AirType = "公务舱",
  15468. AirNum = item.GWCRS,
  15469. AirDRCB = item.GWCCB,
  15470. AirZCB = (item.GWCRS * item.GWCCB)
  15471. }
  15472. );
  15473. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15474. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15475. modulePromptInfo.Data = new
  15476. {
  15477. airFeeData = datas,
  15478. airInitData = initDatas
  15479. };
  15480. _ModulePromptInfos.Add(modulePromptInfo);
  15481. break;
  15482. default:
  15483. break;
  15484. }
  15485. }
  15486. if (dto.CTable != 85)
  15487. {
  15488. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15489. _ModulePromptInfos.Add(_ModulePromptInfo);
  15490. }
  15491. _view.ModulePromptInfos = _ModulePromptInfos;
  15492. return Ok(JsonView(true, "操作成功!", _view));
  15493. }
  15494. catch (Exception ex)
  15495. {
  15496. return Ok(JsonView(false, ex.Message));
  15497. }
  15498. }
  15499. /// <summary>
  15500. /// 根据黑屏代码重新生成行程
  15501. /// </summary>
  15502. /// <param name="dto"></param>
  15503. /// <returns></returns>
  15504. [HttpPost]
  15505. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15506. {
  15507. var jw = JsonView(false,"Error");
  15508. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15509. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15510. .Select(x=> new
  15511. {
  15512. x.Id,
  15513. x.Title
  15514. })
  15515. .ToList();
  15516. if (Create.Any())
  15517. {
  15518. jw.Msg = "获取成功!";
  15519. jw.Code = 200;
  15520. jw.Data = new
  15521. {
  15522. BlackCodeListSelect = Create,
  15523. blackCodeIsTrue = true
  15524. };
  15525. }
  15526. else
  15527. {
  15528. jw.Code = 400;
  15529. jw.Data = new
  15530. {
  15531. BlackCodeListSelect = Create,
  15532. blackCodeIsTrue = false,
  15533. };
  15534. }
  15535. return Ok(jw);
  15536. }
  15537. /// <summary>
  15538. /// 根据黑屏代码Id重新生成行程
  15539. /// </summary>
  15540. /// <param name="dto"></param>
  15541. /// <returns></returns>
  15542. [HttpPost]
  15543. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15544. {
  15545. var jw = JsonView(false, "Error");
  15546. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15547. if (result.Code == 0)
  15548. {
  15549. jw.Msg = "获取成功!";
  15550. jw.Code = 200;
  15551. jw.Data = new
  15552. {
  15553. groupCost = result.Data,
  15554. blackCodeIsTrue = true
  15555. };
  15556. }
  15557. else
  15558. {
  15559. jw.Code = 400;
  15560. jw.Data = new
  15561. {
  15562. groupCost = result.Data,
  15563. blackCodeIsTrue = false,
  15564. };
  15565. }
  15566. return Ok(jw);
  15567. }
  15568. /// <summary>
  15569. /// 成本获取OP历史车费用
  15570. /// </summary>
  15571. /// <param name="dto"></param>
  15572. /// <returns></returns>
  15573. [HttpPost]
  15574. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15575. {
  15576. var jw = JsonView(false);
  15577. try
  15578. {
  15579. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15580. //获取现有所有车的数据
  15581. if (!dto.Param.IsNullOrWhiteSpace())
  15582. {
  15583. string sql = $@"
  15584. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15585. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15586. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15587. 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
  15588. AND gctggr.ServiceEndTime is not NULL
  15589. ORDER by gctggrc.id DESC
  15590. ";
  15591. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15592. var numeberResult = await Task.Run(() =>
  15593. {
  15594. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15595. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15596. return numberArr;
  15597. });
  15598. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15599. foreach (var item in numeberResult)
  15600. {
  15601. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15602. {
  15603. Country = "数据异常!",
  15604. City = string.Empty,
  15605. };
  15606. item.Area = find.Country + " " + find.City;
  15607. }
  15608. dbResult.AddRange(numeberResult);
  15609. if (dto.Param.Contains("、"))
  15610. {
  15611. var sp = dto.Param.Split("、");
  15612. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15613. .Where(x =>
  15614. {
  15615. return System.Array.Exists(sp, e =>
  15616. {
  15617. bool where = false;
  15618. if (x.Area != null)
  15619. {
  15620. where = x.Area.Contains(e);
  15621. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15622. {
  15623. return false;
  15624. }
  15625. }
  15626. if (x.PriceName != null && !where)
  15627. {
  15628. where = x.PriceName.Contains(e);
  15629. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15630. {
  15631. return false;
  15632. }
  15633. }
  15634. return where;
  15635. });
  15636. }).ToList();
  15637. }
  15638. else
  15639. {
  15640. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15641. .Where(x =>
  15642. {
  15643. bool where = false;
  15644. if (x.Area != null)
  15645. {
  15646. where = x.Area.Contains(dto.Param);
  15647. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15648. {
  15649. return false;
  15650. }
  15651. }
  15652. if (x.PriceName != null && !where)
  15653. {
  15654. where = x.PriceName.Contains(dto.Param);
  15655. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15656. {
  15657. return false;
  15658. }
  15659. }
  15660. return where;
  15661. }
  15662. )
  15663. .ToList();
  15664. }
  15665. }
  15666. var view = dbResult.Select(x =>
  15667. {
  15668. decimal dp = 0.00M;
  15669. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15670. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15671. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15672. {
  15673. if (startB && endB)
  15674. {
  15675. var timesp = endD.Subtract(startD);
  15676. if ((timesp.Days + 1) != 0)
  15677. {
  15678. dp = x.Price / (timesp.Days + 1);
  15679. }
  15680. }
  15681. }
  15682. else
  15683. {
  15684. dp = x.Price;
  15685. }
  15686. return new
  15687. {
  15688. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15689. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15690. x.Area,
  15691. x.id,
  15692. price = x.Price.ToString("F2"),
  15693. x.PriceName,
  15694. x.PriceContent,
  15695. x.TeamName,
  15696. x.DatePrice,
  15697. dayPrice = dp.ToString("F2"),
  15698. };
  15699. }).OrderByDescending(x => x.id).ToList();
  15700. jw = JsonView(true, "获取成功!", view);
  15701. }
  15702. catch (Exception e)
  15703. {
  15704. jw = JsonView(false, e.Message);
  15705. }
  15706. return Ok(jw);
  15707. }
  15708. [HttpPost]
  15709. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15710. {
  15711. var jw = JsonView(true);
  15712. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15713. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15714. {
  15715. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15716. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15717. WHEN COUNT(*) >= 0 THEN 'True'
  15718. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15719. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15720. ")
  15721. .ToList();
  15722. }
  15723. else
  15724. {
  15725. string likeKey = string.Empty;
  15726. foreach (var item in dto.Keyword)
  15727. {
  15728. likeKey += "%" + item;
  15729. }
  15730. likeKey += "%";
  15731. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15732. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15733. WHEN COUNT(*) >= 0 THEN 'True'
  15734. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15735. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15736. ")
  15737. .ToList();
  15738. }
  15739. if (matches.Any())
  15740. {
  15741. jw.Data = matches;
  15742. }
  15743. else
  15744. {
  15745. jw.Code = 201;
  15746. jw.Msg = "empty list";
  15747. jw.Data = new List<string>(1);
  15748. }
  15749. return Ok(jw);
  15750. }
  15751. /// <summary>
  15752. /// 报价Word下载
  15753. /// </summary>
  15754. /// <param name="dto"></param>
  15755. /// <returns></returns>
  15756. [HttpPost]
  15757. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  15758. {
  15759. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  15760. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  15761. if (di == null)
  15762. {
  15763. return Ok(JsonView(false, "团组不存在!"));
  15764. }
  15765. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15766. if (mainPrice == null || mainPrice.IsShare == 0)
  15767. {
  15768. return Ok(JsonView(false, "团组成本不存在!"));
  15769. }
  15770. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  15771. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  15772. if (costTypeHotelNumbers == null)
  15773. {
  15774. return Ok(JsonView(false, "团组成本不存在!"));
  15775. }
  15776. //文件名
  15777. string strFileName = di.TeamName + "-收款账单.doc";
  15778. //获取模板
  15779. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15780. //载入模板
  15781. Document doc = new Document(tmppath);
  15782. decimal allPrice = 0.00M;
  15783. string itemStr = string.Empty;
  15784. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15785. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  15786. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  15787. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  15788. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  15789. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  15790. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  15791. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  15792. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  15793. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  15794. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  15795. {
  15796. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  15797. ("BXRS", "BXCB", "BXXS", "bx"),
  15798. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  15799. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  15800. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  15801. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  15802. ("CPRS", "CPCB", "CPXS", "cp") ,
  15803. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  15804. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  15805. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  15806. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  15807. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  15808. ("DJRS", "DJCB", "DJXS", "dj") ,
  15809. ("GWRS", "GWCB", "GWXS", "gw") ,
  15810. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  15811. };
  15812. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  15813. var rightSum = 0.00M;
  15814. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  15815. {
  15816. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  15817. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  15818. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  15819. if (prefix == "tbr")
  15820. {
  15821. rsValue *= 2;
  15822. cbValue /= 2;
  15823. }
  15824. if (OtherCostPropertyBJ.Contains(prefix))
  15825. {
  15826. rightSum += cbValue * xsValue;
  15827. }
  15828. }
  15829. var hotelRooms = new Dictionary<string, int>
  15830. {
  15831. { "SGR", costTypeHotelNumbers.SGR },
  15832. { "TBR", costTypeHotelNumbers.TBR },
  15833. { "JSES", costTypeHotelNumbers.JSES },
  15834. { "SUITE", costTypeHotelNumbers.SUITE }
  15835. };
  15836. var flights = new Dictionary<string, int>
  15837. {
  15838. { "经济舱", mainPrice.JJCRS },
  15839. { "公务舱", mainPrice.GWCRS },
  15840. { "头等舱", mainPrice.TDCRS }
  15841. };
  15842. var flightRoomMatchingRules = new Dictionary<string, string[]>
  15843. {
  15844. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  15845. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  15846. { "头等舱", new[] { "SUITE", "JSES" } }
  15847. };
  15848. var result = new Dictionary<string, int>();
  15849. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  15850. foreach (var flight in flights.Keys)
  15851. {
  15852. // 获取当前舱位的匹配规则
  15853. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  15854. {
  15855. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  15856. }
  15857. }
  15858. #region right计算
  15859. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  15860. {
  15861. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  15862. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  15863. airHotelPriceList.Add(new
  15864. AirHotelPrice
  15865. {
  15866. Name = "经济舱TBR",
  15867. Price = rightSum + air + hotel,
  15868. Count = result["经济舱TBR"] * 2
  15869. });
  15870. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  15871. }
  15872. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  15873. {
  15874. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  15875. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  15876. airHotelPriceList.Add(new
  15877. AirHotelPrice
  15878. {
  15879. Name = "经济舱SGR",
  15880. Price = rightSum + air + hotel,
  15881. Count = result["经济舱SGR"]
  15882. });
  15883. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  15884. }
  15885. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  15886. {
  15887. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  15888. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  15889. airHotelPriceList.Add(new
  15890. AirHotelPrice
  15891. {
  15892. Name = "公务舱SGR",
  15893. Price = rightSum + air + hotel,
  15894. Count = result["公务舱SGR"]
  15895. });
  15896. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  15897. }
  15898. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  15899. {
  15900. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  15901. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  15902. airHotelPriceList.Add(new
  15903. AirHotelPrice
  15904. {
  15905. Name = "公务舱JSES",
  15906. Price = rightSum + air + hotel,
  15907. Count = result["公务舱JSES"]
  15908. });
  15909. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  15910. }
  15911. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  15912. {
  15913. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  15914. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  15915. airHotelPriceList.Add(new
  15916. AirHotelPrice
  15917. {
  15918. Name = "公务舱SUITE",
  15919. Price = rightSum + air + hotel,
  15920. Count = result["公务舱SUITE"]
  15921. });
  15922. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  15923. }
  15924. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  15925. {
  15926. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  15927. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  15928. airHotelPriceList.Add(new
  15929. AirHotelPrice
  15930. {
  15931. Name = "经济舱SUITE",
  15932. Price = rightSum + air + hotel,
  15933. Count = result["经济舱SUITE"]
  15934. });
  15935. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  15936. }
  15937. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  15938. {
  15939. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  15940. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  15941. airHotelPriceList.Add(new
  15942. AirHotelPrice
  15943. {
  15944. Name = "头等舱JSES",
  15945. Price = rightSum + air + hotel,
  15946. Count = result["头等舱JSES"]
  15947. });
  15948. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  15949. }
  15950. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  15951. {
  15952. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  15953. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  15954. airHotelPriceList.Add(new
  15955. AirHotelPrice
  15956. {
  15957. Name = "头等舱SUITE",
  15958. Price = rightSum + air + hotel,
  15959. Count = result["头等舱SUITE"]
  15960. });
  15961. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  15962. }
  15963. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  15964. {
  15965. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  15966. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  15967. airHotelPriceList.Add(new
  15968. AirHotelPrice
  15969. {
  15970. Name = "经济舱JSES",
  15971. Price = rightSum + air + hotel,
  15972. Count = result["经济舱JSES"]
  15973. });
  15974. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  15975. }
  15976. #endregion
  15977. foreach (var item in airSouer.Keys)
  15978. {
  15979. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  15980. if (find != null && find.Count > 0)
  15981. {
  15982. if (item.Contains("TBR"))
  15983. {
  15984. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  15985. }
  15986. else
  15987. {
  15988. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  15989. }
  15990. }
  15991. }
  15992. #region 替换Word模板书签内容
  15993. Dictionary<string, string> marks = new Dictionary<string, string>();
  15994. marks.Add("To", di.ClientUnit);//付款方
  15995. marks.Add("ToTel", di.TellPhone);//付款方电话
  15996. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  15997. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  15998. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  15999. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16000. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16001. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16002. marks.Add("PayItemContent", itemStr);//详细信息
  16003. marks.Add("Total", allPrice.ToString("F2"));//合计
  16004. #endregion
  16005. foreach (var item in marks.Keys)
  16006. {
  16007. if (doc.Range.Bookmarks[item] != null)
  16008. {
  16009. Bookmark mark = doc.Range.Bookmarks[item];
  16010. mark.Text = marks[item];
  16011. }
  16012. }
  16013. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16014. doc.Save(savePaht);
  16015. var jw = new JsonView();
  16016. jw.Msg = "生成成功!";
  16017. jw.Code = 200;
  16018. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16019. return Ok(jw);
  16020. }
  16021. /// <summary>
  16022. /// 详细报价费用Excel下载
  16023. /// </summary>
  16024. /// <param name="dto"></param>
  16025. /// <returns></returns>
  16026. [HttpPost]
  16027. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16028. {
  16029. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16030. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16031. if (di == null)
  16032. {
  16033. return Ok(JsonView(false, "团组不存在!"));
  16034. }
  16035. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16036. if (mainPrice == null || mainPrice.IsShare == 0)
  16037. {
  16038. return Ok(JsonView(false, "团组成本不存在!"));
  16039. }
  16040. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16041. .FirstAsync(x=>x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16042. if (costTypeHotelNumbers == null)
  16043. {
  16044. return Ok(JsonView(false, "团组成本不存在!"));
  16045. }
  16046. WorkbookDesigner designer = new WorkbookDesigner();
  16047. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16048. List<int> hideRowsList = new List<int>();
  16049. int conterStartIndex = 3;
  16050. int rowIndex = conterStartIndex;
  16051. designer.SetDataSource("GroupName", di.TeamName);
  16052. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16053. {
  16054. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16055. ("BXRS", "BXCB", "BXXS", "bx"),
  16056. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16057. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16058. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16059. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16060. ("CPRS", "CPCB", "CPXS", "cp") ,
  16061. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16062. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16063. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16064. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16065. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16066. ("DJRS", "DJCB", "DJXS", "dj") ,
  16067. ("GWRS", "GWCB", "GWXS", "gw") ,
  16068. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16069. };
  16070. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16071. var rightSum = 0.00M;
  16072. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16073. {
  16074. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16075. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16076. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16077. if (prefix == "tbr")
  16078. {
  16079. rsValue *= 2;
  16080. cbValue /= 2;
  16081. }
  16082. if (OtherCostPropertyBJ.Contains(prefix))
  16083. {
  16084. rightSum += cbValue * xsValue;
  16085. }
  16086. if (rsValue == 0)
  16087. {
  16088. hideRowsList.Add(rowIndex);
  16089. }
  16090. else
  16091. {
  16092. designer.SetDataSource($"{prefix}rs", rsValue);
  16093. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16094. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16095. }
  16096. rowIndex += 2;
  16097. }
  16098. var hotelRooms = new Dictionary<string, int>
  16099. {
  16100. { "SGR", costTypeHotelNumbers.SGR },
  16101. { "TBR", costTypeHotelNumbers.TBR },
  16102. { "JSES", costTypeHotelNumbers.JSES },
  16103. { "SUITE", costTypeHotelNumbers.SUITE }
  16104. };
  16105. var flights = new Dictionary<string, int>
  16106. {
  16107. { "经济舱", mainPrice.JJCRS },
  16108. { "公务舱", mainPrice.GWCRS },
  16109. { "头等舱", mainPrice.TDCRS }
  16110. };
  16111. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16112. {
  16113. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16114. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16115. { "头等舱", new[] { "SUITE", "JSES" } }
  16116. };
  16117. var result = new Dictionary<string, int>();
  16118. foreach (var flight in flights.Keys)
  16119. {
  16120. // 获取当前舱位的匹配规则
  16121. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16122. {
  16123. MatchRooms(ref hotelRooms,ref flights, roomTypes, flight,ref result);
  16124. }
  16125. }
  16126. var allPrice = 0.00M;
  16127. #region right计算
  16128. int airRowIndex = 35;
  16129. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16130. {
  16131. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16132. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16133. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16134. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16135. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16136. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16137. }
  16138. else
  16139. {
  16140. hideRowsList.Add(airRowIndex);
  16141. }
  16142. airRowIndex += 2;
  16143. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16144. {
  16145. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16146. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16147. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16148. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16149. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16150. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16151. }
  16152. else
  16153. {
  16154. hideRowsList.Add(airRowIndex);
  16155. }
  16156. airRowIndex += 2;
  16157. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16158. {
  16159. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16160. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16161. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16162. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16163. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16164. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16165. }
  16166. else
  16167. {
  16168. hideRowsList.Add(airRowIndex);
  16169. }
  16170. airRowIndex += 2;
  16171. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16172. {
  16173. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16174. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16175. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16176. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16177. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16178. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16179. }
  16180. else
  16181. {
  16182. hideRowsList.Add(airRowIndex);
  16183. }
  16184. airRowIndex += 2;
  16185. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16186. {
  16187. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16188. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16189. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16190. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16191. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16192. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16193. }
  16194. else
  16195. {
  16196. hideRowsList.Add(airRowIndex);
  16197. }
  16198. airRowIndex += 2;
  16199. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16200. {
  16201. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16202. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16203. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16204. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16205. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16206. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16207. }
  16208. else
  16209. {
  16210. hideRowsList.Add(airRowIndex);
  16211. }
  16212. airRowIndex += 2;
  16213. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16214. {
  16215. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16216. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16217. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16218. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16219. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16220. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16221. }
  16222. else
  16223. {
  16224. hideRowsList.Add(airRowIndex);
  16225. }
  16226. airRowIndex += 2;
  16227. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16228. {
  16229. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16230. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16231. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16232. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16233. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16234. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16235. }
  16236. else
  16237. {
  16238. hideRowsList.Add(airRowIndex);
  16239. }
  16240. airRowIndex += 2;
  16241. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16242. {
  16243. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16244. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16245. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16246. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16247. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16248. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16249. }
  16250. else
  16251. {
  16252. hideRowsList.Add(airRowIndex);
  16253. }
  16254. #endregion
  16255. designer.SetDataSource("AllPrice","总金额:" + allPrice.ToString("#0.00"));
  16256. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName +"_详细报批费用.xls";
  16257. var ws = designer.Workbook.Worksheets[0];
  16258. foreach (var Rowindex in hideRowsList)
  16259. {
  16260. ws.Cells.HideRows(Rowindex, 2);
  16261. }
  16262. designer.Process();
  16263. designer.Workbook.Save(savePaht);
  16264. return Ok(JsonView(true, "生成成功!", new
  16265. {
  16266. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16267. }));
  16268. }
  16269. private void MatchRooms(ref Dictionary<string, int> hotelRooms,ref Dictionary<string, int> flights, string[] roomTypes, string flightType,ref Dictionary<string, int> result)
  16270. {
  16271. foreach (var roomType in roomTypes)
  16272. {
  16273. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16274. {
  16275. hotelRooms[roomType]--;
  16276. flights[flightType]--;
  16277. if (roomType == "TBR")
  16278. {
  16279. flights[flightType]--; // 双人间在减少1
  16280. }
  16281. string key = flightType + roomType;
  16282. if (result.Keys.Contains(key))
  16283. {
  16284. result[key]++;
  16285. }
  16286. else
  16287. {
  16288. result.Add(key, 1);
  16289. }
  16290. }
  16291. }
  16292. }
  16293. private class AirHotelPrice
  16294. {
  16295. public string Name { get; set; }
  16296. public decimal Price { get; set; }
  16297. public int Count { get; set; }
  16298. }
  16299. #endregion
  16300. #region 酒店预订 新 雷怡 2023-12-28 17:45
  16301. /// <summary>
  16302. /// 酒店预订
  16303. /// 酒店费用列表 根据团组Id查询
  16304. /// </summary>
  16305. /// <param name="_dto"></param>
  16306. /// <returns></returns>
  16307. [HttpPost]
  16308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16309. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16310. {
  16311. #region 参数验证
  16312. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16313. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16314. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16315. #region 团组操作权限验证 76 酒店预定模块
  16316. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16317. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16318. #endregion
  16319. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16320. #region 页面操作权限验证
  16321. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16322. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16323. #endregion
  16324. #endregion
  16325. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16326. }
  16327. /// <summary>
  16328. /// 酒店预订
  16329. /// 基础数据
  16330. /// </summary>
  16331. /// <param name="_dto"></param>
  16332. /// <returns></returns>
  16333. [HttpPost]
  16334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16335. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16336. {
  16337. #region 参数验证
  16338. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16339. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16340. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16341. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16342. #region 页面操作权限验证
  16343. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16344. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16345. #endregion
  16346. #region 团组操作权限验证 76 酒店预定模块
  16347. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16348. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16349. #endregion
  16350. #endregion
  16351. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16352. }
  16353. /// <summary>
  16354. /// 酒店预订
  16355. /// 创建 入住卷号码
  16356. /// </summary>
  16357. /// <param name="_dto"></param>
  16358. /// <returns></returns>
  16359. [HttpPost]
  16360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16361. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16362. {
  16363. #region 参数验证
  16364. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16365. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16366. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16367. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16368. #region 页面操作权限验证
  16369. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16370. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16371. #endregion
  16372. #region 团组操作权限验证 76 酒店预定模块
  16373. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16374. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16375. #endregion
  16376. #endregion
  16377. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16378. if (data.Code != 0)
  16379. {
  16380. return Ok(JsonView(false, data.Msg));
  16381. }
  16382. return Ok(JsonView(true, data.Msg, data.Data));
  16383. }
  16384. /// <summary>
  16385. /// 酒店预订
  16386. /// 详情
  16387. /// </summary>
  16388. /// <param name="_dto"></param>
  16389. /// <returns></returns>
  16390. [HttpPost]
  16391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16392. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16393. {
  16394. #region 参数验证
  16395. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16396. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16397. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16398. #region 团组操作权限验证 76 酒店预定模块
  16399. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16400. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16401. #endregion
  16402. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16403. #region 页面操作权限验证
  16404. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16405. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16406. #endregion
  16407. #endregion
  16408. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16409. }
  16410. /// <summary>
  16411. /// 酒店预订
  16412. /// Add Or Edit
  16413. /// </summary>
  16414. /// <param name="_dto"></param>
  16415. /// <returns></returns>
  16416. [HttpPost]
  16417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16418. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16419. {
  16420. #region 参数验证
  16421. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16422. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16423. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16424. #region 团组操作权限验证 76 酒店预定模块
  16425. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16426. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16427. #endregion
  16428. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16429. #region 页面操作权限验证
  16430. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16431. if (_dto.Id == 0) // Add
  16432. {
  16433. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16434. }
  16435. else if (_dto.Id > 1) // Edit
  16436. {
  16437. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16438. }
  16439. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16440. #endregion
  16441. #endregion
  16442. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16443. if (_view.Code != 200)
  16444. {
  16445. return Ok(_view);
  16446. }
  16447. #region 成本无酒店价格数据进入超支
  16448. _sqlSugar.BeginTran();
  16449. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16450. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16451. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16452. for (int i = 0; i < groupCost.Count; i++)
  16453. {
  16454. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16455. {
  16456. groupCost[i].Date = groupCost[i - 1].Date;
  16457. }
  16458. }
  16459. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16460. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16461. List<Fin_GroupExtraCostDto_OP>();
  16462. if (start_Bool && end_Bool)
  16463. {
  16464. while (start_Time < end_Time)
  16465. {
  16466. foreach (var item in groupCost_Grp)
  16467. {
  16468. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16469. {
  16470. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16471. {
  16472. extraCostList.Add(new
  16473. Fin_GroupExtraCostDto_OP
  16474. {
  16475. Area = _dto.AreaId,
  16476. coefficient = 1.5M,
  16477. createUser = _dto.UserId,
  16478. currency = _dto.CardPriceCurrency,
  16479. diId = _dto.DiId,
  16480. ManagerConfirm = 0,
  16481. SupervisorConfirm = 0,
  16482. SYsupervisorConfirm = 0,
  16483. editType = 1,
  16484. PortType = 1,
  16485. price = _dto.CardPrice,
  16486. PriceCount = 1,
  16487. priceType = 1027,
  16488. priceDetailType = 1044,
  16489. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16490. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16491. });
  16492. }
  16493. }
  16494. }
  16495. start_Time = start_Time.AddDays(1);
  16496. }
  16497. }
  16498. if (extraCostList.Any())
  16499. {
  16500. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16501. }
  16502. _sqlSugar.CommitTran();
  16503. #endregion
  16504. #region 应用推送
  16505. try
  16506. {
  16507. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16508. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16509. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16510. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16511. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16512. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16513. var diId = _dto.DiId;
  16514. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16515. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16516. #region 操作记录
  16517. var opInfo = new Crm_TableOperationRecord()
  16518. {
  16519. TableName = "Grp_HotelReservations",
  16520. PortType = _dto.PortType,
  16521. DataId = hotelId,
  16522. CreateUserId = _dto.UserId
  16523. };
  16524. //var opStatus = OperationEnum.NoOperation;
  16525. if (_dto.Id < 1) //添加操作
  16526. {
  16527. opInfo.OperationItem = OperationEnum.Add;
  16528. }
  16529. else if (_dto.Id > 0)
  16530. {
  16531. opInfo.OperationItem = OperationEnum.Edit;
  16532. }
  16533. string opRemark = string.Empty;
  16534. if (ccpInfo != null)
  16535. {
  16536. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16537. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16538. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16539. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16540. }
  16541. opInfo.Remark = opRemark;
  16542. await _tableorRep.AddAsync(opInfo);
  16543. #endregion
  16544. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16545. //2024-10-21 新增LZ UID
  16546. var userIds = new List<int>() { 21 };
  16547. string title = $"费用审核";
  16548. string content = "";
  16549. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16550. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16551. try
  16552. {
  16553. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  16554. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  16555. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  16556. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  16557. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  16558. }
  16559. catch (Exception ex)
  16560. {
  16561. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  16562. }
  16563. }
  16564. catch (Exception ex)
  16565. {
  16566. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  16567. }
  16568. try
  16569. {
  16570. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16571. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16572. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16573. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16574. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16575. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16576. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16577. //自动审核
  16578. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  16579. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  16580. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  16581. //2024-10-21 新增LZ UID
  16582. var userIds = new List<int>() { 21 };
  16583. string title = $"系统通知";
  16584. var diId = _dto.DiId;
  16585. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16586. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16587. string content = "";
  16588. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16589. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16590. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16591. }
  16592. catch (Exception ex)
  16593. {
  16594. }
  16595. #endregion
  16596. return Ok(_view);
  16597. }
  16598. /// <summary>
  16599. /// 酒店自动审核测试
  16600. /// Add Or Edit
  16601. /// </summary>
  16602. /// <param name="diid"></param>
  16603. /// <param name="dataId"></param>
  16604. /// <returns></returns>
  16605. [HttpPost]
  16606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16607. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  16608. {
  16609. #region 应用推送
  16610. try
  16611. {
  16612. //自动审核
  16613. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  16614. }
  16615. catch (Exception ex)
  16616. {
  16617. return Ok(JsonView(false, "操作失败"));
  16618. }
  16619. #endregion
  16620. return Ok(JsonView(false, "操作成功"));
  16621. }
  16622. /// <summary>
  16623. /// 酒店预订
  16624. /// Del
  16625. /// </summary>
  16626. /// <param name="_dto"></param>
  16627. /// <returns></returns>
  16628. [HttpPost]
  16629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16630. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  16631. {
  16632. #region 参数验证
  16633. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16634. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16635. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16636. #region 团组操作权限验证 76 酒店预定模块
  16637. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16638. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16639. #endregion
  16640. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16641. #region 页面操作权限验证
  16642. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16643. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16644. #endregion
  16645. #endregion
  16646. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  16647. #region 操作记录
  16648. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  16649. {
  16650. TableName = "Grp_HotelReservations",
  16651. PortType = _dto.PortType,
  16652. OperationItem = OperationEnum.Del,
  16653. DataId = _dto.Id,
  16654. CreateUserId = _dto.UserId
  16655. });
  16656. #endregion
  16657. return Ok(data);
  16658. }
  16659. /// <summary>
  16660. /// 酒店预订
  16661. /// 生成VOUCHER
  16662. /// 2024.05.06 之前版本
  16663. /// </summary>
  16664. /// <param name="_dto"></param>
  16665. /// <returns></returns>
  16666. [HttpPost]
  16667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16668. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  16669. {
  16670. try
  16671. {
  16672. #region 参数验证
  16673. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16674. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16675. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16676. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  16677. #region 团组操作权限验证 76 酒店预定模块
  16678. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16679. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16680. #endregion
  16681. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16682. #region 页面操作权限验证
  16683. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16684. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16685. #endregion
  16686. #endregion
  16687. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  16688. //判断数据是否完整
  16689. if (hr != null)
  16690. {
  16691. if (!string.IsNullOrEmpty(hr.DetermineNo))
  16692. {
  16693. string strFileName = "HotelStatement/";
  16694. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16695. if (dele != null)
  16696. strFileName += dele.TourCode;
  16697. //载入模板
  16698. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  16699. Document doc = new Document(sss);
  16700. DocumentBuilder builder = new DocumentBuilder(doc);
  16701. #region 替换Word模板书签内容
  16702. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  16703. //入住卷预定号码
  16704. if (doc.Range.Bookmarks["VNO"] != null)
  16705. {
  16706. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16707. mark.Text = hr.CheckNumber;
  16708. }
  16709. //酒店时间
  16710. if (doc.Range.Bookmarks["Date"] != null)
  16711. {
  16712. Bookmark mark = doc.Range.Bookmarks["Date"];
  16713. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16714. }
  16715. //团号
  16716. if (doc.Range.Bookmarks["TNo"] != null)
  16717. {
  16718. Bookmark mark = doc.Range.Bookmarks["TNo"];
  16719. mark.Text = dele.TourCode;
  16720. }
  16721. //预定号码
  16722. if (doc.Range.Bookmarks["BookingId"] != null)
  16723. {
  16724. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  16725. mark.Text = hr.ReservationsNo;
  16726. }
  16727. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  16728. {
  16729. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  16730. mark.Text = hr.DetermineNo;
  16731. }
  16732. //酒店城市
  16733. if (doc.Range.Bookmarks["City"] != null)
  16734. {
  16735. Bookmark mark = doc.Range.Bookmarks["City"];
  16736. mark.Text = hr.City;
  16737. }
  16738. //酒店名称
  16739. if (doc.Range.Bookmarks["HName"] != null)
  16740. {
  16741. Bookmark mark = doc.Range.Bookmarks["HName"];
  16742. mark.Text = hr.HotelName;
  16743. }
  16744. //酒店地址
  16745. if (doc.Range.Bookmarks["Address"] != null)
  16746. {
  16747. Bookmark mark = doc.Range.Bookmarks["Address"];
  16748. mark.Text = hr.HotelAddress;
  16749. }
  16750. //酒店电话
  16751. if (doc.Range.Bookmarks["Tel"] != null)
  16752. {
  16753. Bookmark mark = doc.Range.Bookmarks["Tel"];
  16754. mark.Text = hr.HotelTel;
  16755. }
  16756. //酒店传真
  16757. if (doc.Range.Bookmarks["Fax"] != null)
  16758. {
  16759. Bookmark mark = doc.Range.Bookmarks["Fax"];
  16760. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  16761. {
  16762. mark.Text = hr.HotelFax;
  16763. }
  16764. }
  16765. //入住时间
  16766. if (doc.Range.Bookmarks["CIn"] != null)
  16767. {
  16768. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16769. Bookmark mark = doc.Range.Bookmarks["CIn"];
  16770. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  16771. }
  16772. //退房时间
  16773. if (doc.Range.Bookmarks["COut"] != null)
  16774. {
  16775. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16776. Bookmark mark = doc.Range.Bookmarks["COut"];
  16777. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16778. }
  16779. //客户名称
  16780. if (doc.Range.Bookmarks["GName"] != null)
  16781. {
  16782. string guestName = "";
  16783. string[] clients = new string[] { };
  16784. if (hr.GuestName.Contains(","))
  16785. {
  16786. clients = hr.GuestName.Split(",");
  16787. }
  16788. else
  16789. {
  16790. clients = new string[] { hr.GuestName };
  16791. }
  16792. List<int> clientIds_int = new List<int>();
  16793. if (clients.Length > 0)
  16794. {
  16795. foreach (var item in clients)
  16796. {
  16797. if (item.IsNumeric())
  16798. {
  16799. clientIds_int.Add(int.Parse(item));
  16800. }
  16801. }
  16802. }
  16803. if (clientIds_int.Count > 0)
  16804. {
  16805. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  16806. foreach (var client in _clientDatas)
  16807. {
  16808. //男
  16809. if (client.Sex == 0) guestName += $"Mr.";
  16810. //女
  16811. else if (client.Sex == 1) guestName += $"Ms.";
  16812. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  16813. {
  16814. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  16815. }
  16816. //guestName += $"{client.Pinyin},";
  16817. }
  16818. if (guestName.Length > 0)
  16819. {
  16820. guestName = guestName.Substring(0, guestName.Length - 1);
  16821. }
  16822. }
  16823. else
  16824. {
  16825. guestName = hr.GuestName;
  16826. }
  16827. Bookmark mark = doc.Range.Bookmarks["GName"];
  16828. mark.Text = guestName;
  16829. }
  16830. //房间介绍
  16831. if (doc.Range.Bookmarks["ROOM"] != null)
  16832. {
  16833. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  16834. mark.Text = hr.RoomExplanation;
  16835. }
  16836. //报价描述
  16837. if (doc.Range.Bookmarks["NOTE"] != null)
  16838. {
  16839. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  16840. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  16841. if (ss != null)
  16842. mark.Text = ss.Name;
  16843. }
  16844. //入住时间
  16845. if (doc.Range.Bookmarks["CheckIn"] != null)
  16846. {
  16847. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16848. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  16849. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16850. }
  16851. //退房时间
  16852. if (doc.Range.Bookmarks["CheckOut"] != null)
  16853. {
  16854. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16855. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  16856. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16857. }
  16858. //日期
  16859. if (doc.Range.Bookmarks["DT"] != null)
  16860. {
  16861. Bookmark mark = doc.Range.Bookmarks["DT"];
  16862. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16863. }
  16864. //名称
  16865. if (doc.Range.Bookmarks["VName"] != null)
  16866. {
  16867. Bookmark mark = doc.Range.Bookmarks["VName"];
  16868. mark.Text = hr.HotelName;
  16869. }
  16870. //号码
  16871. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  16872. {
  16873. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  16874. mark.Text = hr.CheckNumber;
  16875. }
  16876. #endregion
  16877. strFileName += "VOUCHER.doc";
  16878. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16879. doc.Save(fileDir);
  16880. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16881. return Ok(JsonView(true, "操作成功!", Url));
  16882. }
  16883. else
  16884. {
  16885. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  16886. }
  16887. }
  16888. else
  16889. {
  16890. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  16891. }
  16892. }
  16893. catch (Exception ex)
  16894. {
  16895. return Ok(JsonView(false, ex.Message));
  16896. }
  16897. }
  16898. /// <summary>
  16899. /// 酒店预订
  16900. /// 生成VOUCHER
  16901. /// 2024.05.06 之后版本
  16902. /// </summary>
  16903. /// <param name="_dto"></param>
  16904. /// <returns></returns>
  16905. [HttpPost]
  16906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16907. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  16908. {
  16909. #region 参数验证
  16910. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16911. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16912. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16913. #region 团组操作权限验证 76 酒店预定模块
  16914. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16915. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16916. #endregion
  16917. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16918. #region 页面操作权限验证
  16919. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16920. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16921. #endregion
  16922. #endregion
  16923. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  16924. //判断数据是否完整
  16925. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  16926. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16927. string strFileName = "HotelStatement/";
  16928. string guestNames = ""; //格式Mr.xxx Ms.xxx
  16929. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  16930. #region 数据处理
  16931. List<int> guestIds = new List<int>();
  16932. //int index = 0;
  16933. foreach (var item in hrDtas)
  16934. {
  16935. if (item.GuestName.Contains(","))
  16936. {
  16937. string[] guestIdArr = item.GuestName.Split(',');
  16938. foreach (var guestIdStr in guestIdArr)
  16939. {
  16940. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  16941. if (guestBool)
  16942. {
  16943. guestIds.Add(guestId);
  16944. }
  16945. }
  16946. }
  16947. else guestNames += item.GuestName;
  16948. var voucherInfo = new HotelVoucherInfoView()
  16949. {
  16950. HotelName = item.HotelName,
  16951. CheckInDate = item.CheckInDate,
  16952. CheckOutDate = item.CheckOutDate,
  16953. ConfirmationNumber = item.DetermineNo.Trim(),
  16954. RoomType = item.RoomExplanation
  16955. };
  16956. vouchers.Add(voucherInfo);
  16957. }
  16958. if (guestIds.Count > 0)
  16959. {
  16960. guestIds = guestIds.Distinct().ToList();
  16961. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  16962. if (guestDatas.Count > 0)
  16963. {
  16964. guestNames = "";
  16965. foreach (var guest in guestDatas)
  16966. {
  16967. string guestName = "";
  16968. if (guest.Sex == 0) guestName += @"MR.";
  16969. else if (guest.Sex == 1) guestName += @"MS.";
  16970. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  16971. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  16972. guestNames += @$"{guestName.Trim()}、";
  16973. }
  16974. if (guestNames.Length > 0)
  16975. {
  16976. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  16977. }
  16978. }
  16979. }
  16980. #endregion
  16981. //载入模板
  16982. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  16983. Document doc = new Document(sss);
  16984. DocumentBuilder builder = new DocumentBuilder(doc);
  16985. if (doc.Range.Bookmarks["GuestName"] != null)
  16986. {
  16987. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  16988. mark.Text = guestNames;
  16989. }
  16990. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16991. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  16992. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  16993. for (int i = 1; i <= vouchers.Count; i++)
  16994. {
  16995. HotelVoucherInfoView hviv = vouchers[i - 1];
  16996. builder.MoveToCell(0, i, 0, 0);
  16997. builder.Write(hviv.HotelName);
  16998. builder.MoveToCell(0, i, 1, 0);
  16999. builder.Write(hviv.CheckInDate);
  17000. builder.MoveToCell(0, i, 2, 0);
  17001. builder.Write(hviv.CheckOutDate);
  17002. builder.MoveToCell(0, i, 3, 0);
  17003. builder.Write(hviv.RoomType);
  17004. builder.MoveToCell(0, i, 4, 0);
  17005. builder.Write(hviv.ConfirmationNumber);
  17006. }
  17007. //删除多余行
  17008. int currRowIndex = vouchers.Count + 1;
  17009. int delRows = 21 - currRowIndex;
  17010. if (delRows > 0)
  17011. {
  17012. for (int i = 0; i < delRows; i++)
  17013. {
  17014. table.Rows.RemoveAt(currRowIndex);
  17015. //cultivateRowIndex++;
  17016. }
  17017. }
  17018. strFileName += "VOUCHER.docx";
  17019. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17020. doc.Save(fileDir);
  17021. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17022. return Ok(JsonView(true, "操作成功!", Url));
  17023. }
  17024. /// <summary>
  17025. /// 酒店预订
  17026. /// 生成VOUCHER 批量生成
  17027. /// New
  17028. /// </summary>
  17029. /// <param name="_dto"></param>
  17030. /// <returns></returns>
  17031. [HttpPost]
  17032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17033. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17034. {
  17035. #region 参数验证
  17036. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17037. if (_dto.PageId < 1) _dto.PageId = 28;
  17038. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17039. #region 团组操作权限验证 76 酒店预定模块
  17040. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17041. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17042. #endregion
  17043. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17044. #region 页面操作权限验证
  17045. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17046. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17047. #endregion
  17048. #endregion
  17049. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17050. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17051. .OrderBy(x => x.CheckInDate)
  17052. .ToListAsync();
  17053. //判断数据是否完整
  17054. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17055. string strFileName = "HotelStatement/";
  17056. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17057. if (dele != null)
  17058. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17059. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17060. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17061. .Where(it => it.IsDel == 0)
  17062. .ToListAsync();
  17063. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17064. for (int i = 0; i < hrDtas.Count; i++)
  17065. {
  17066. string guestNames = string.Empty;
  17067. List<int> guestIds = new List<int>();
  17068. var item = hrDtas[i];
  17069. //处理客户姓名
  17070. if (item.GuestName.Contains(","))
  17071. {
  17072. string[] guestIdArr = item.GuestName.Split(',');
  17073. foreach (var guestIdStr in guestIdArr)
  17074. if (int.TryParse(guestIdStr, out int guestId))
  17075. guestIds.Add(guestId);
  17076. }
  17077. else
  17078. {
  17079. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17080. if (guestIdBool)
  17081. {
  17082. guestIds.Add(guestId);
  17083. }
  17084. //NaN
  17085. if (item.GuestName.Contains("NaN"))
  17086. {
  17087. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17088. }
  17089. }
  17090. if (guestIds.Count > 0)
  17091. {
  17092. guestIds = guestIds.Distinct().ToList();
  17093. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17094. if (guestDatas1.Count > 0)
  17095. {
  17096. guestNames = "";
  17097. foreach (var guest in guestDatas1)
  17098. {
  17099. string guestName = "";
  17100. if (guest.Sex == 0) guestName += @"MR.";
  17101. else if (guest.Sex == 1) guestName += @"MS.";
  17102. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17103. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17104. guestNames += @$"{guestName.Trim()}、";
  17105. }
  17106. if (guestNames.Length > 0)
  17107. {
  17108. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17109. }
  17110. }
  17111. }
  17112. //if (!string.IsNullOrEmpty(guestNames))
  17113. //{
  17114. hrDtas[i].GuestName = guestNames;
  17115. //}
  17116. }
  17117. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17118. Document doc = new Document();
  17119. DocumentBuilder builder = new DocumentBuilder(doc);
  17120. try
  17121. {
  17122. builder.MoveToDocumentStart();
  17123. foreach (var item in hrDtas)
  17124. {
  17125. //标题
  17126. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17127. builder.ParagraphFormat.LineSpacing = 1;
  17128. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17129. builder.ParagraphFormat.Style.Font.Size = 9;
  17130. builder.ParagraphFormat.Style.Font.Bold = true;
  17131. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17132. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17133. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17134. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17135. builder.ParagraphFormat.LineSpacing = 1;
  17136. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17137. builder.ParagraphFormat.Style.Font.Size = 9;
  17138. builder.ParagraphFormat.Style.Font.Bold = true;
  17139. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17140. builder.StartTable();
  17141. // 设置边框颜色
  17142. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17143. //设置边框样式
  17144. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17145. //表格
  17146. #region 第一行
  17147. builder.InsertCell();
  17148. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17149. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17150. //builder.CellFormat.AllowAutoFit = false;
  17151. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17152. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17153. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17154. builder.CellFormat.WrapText = true; //自动换行
  17155. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17156. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17157. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17158. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17159. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17160. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17161. builder.Write("TOUR NO:");
  17162. builder.InsertCell();
  17163. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17164. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17165. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17166. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17167. builder.ParagraphFormat.Style.Font.Bold = false;
  17168. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17169. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17170. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17171. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17172. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17173. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17174. builder.Write($"{dele?.TourCode ?? "-"}");
  17175. builder.InsertCell();
  17176. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17177. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17178. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17179. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17180. builder.ParagraphFormat.Style.Font.Bold = false;
  17181. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17182. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17183. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17184. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17185. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17186. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17187. builder.Write($"CITY:");
  17188. builder.InsertCell();
  17189. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17190. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17191. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17192. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17193. builder.ParagraphFormat.Style.Font.Bold = false;
  17194. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17195. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17196. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17197. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17198. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17199. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17200. builder.Write($"{item.City}");
  17201. builder.EndRow();
  17202. #endregion
  17203. #region 第二行
  17204. builder.InsertCell();
  17205. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17206. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17207. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17208. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17209. builder.ParagraphFormat.Style.Font.Bold = false;
  17210. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17211. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17212. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17213. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17214. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17215. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17216. builder.Write("CONFIRMATION NO:");
  17217. builder.InsertCell();
  17218. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17219. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17220. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17221. builder.ParagraphFormat.Style.Font.Bold = false;
  17222. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17223. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17224. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17225. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17226. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17227. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17228. builder.CellFormat.VerticalMerge = CellMerge.None;
  17229. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17230. builder.Write($"{item.DetermineNo}");
  17231. builder.InsertCell();
  17232. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17233. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17234. builder.InsertCell();
  17235. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17236. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17237. builder.EndRow();
  17238. #endregion
  17239. #region 第三行
  17240. builder.InsertCell();
  17241. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17242. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17243. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17244. builder.ParagraphFormat.Style.Font.Bold = false;
  17245. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17246. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17247. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17248. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17249. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17250. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17251. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17252. builder.Write($"HOTEL NAME:");
  17253. builder.InsertCell();
  17254. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17255. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17256. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17257. builder.ParagraphFormat.Style.Font.Bold = false;
  17258. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17259. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17260. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17261. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17262. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17263. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17264. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17265. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17266. builder.Write($"{item.HotelName}");
  17267. builder.InsertCell();
  17268. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17269. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17270. builder.InsertCell();
  17271. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17272. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17273. builder.EndRow();
  17274. #endregion
  17275. #region 第四行
  17276. builder.InsertCell();
  17277. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17278. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17279. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17280. builder.ParagraphFormat.Style.Font.Bold = false;
  17281. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17282. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17283. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17284. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17285. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17286. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17287. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17288. builder.Write($"HOTEL ADDRESS:");
  17289. builder.InsertCell();
  17290. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17291. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17292. builder.ParagraphFormat.Style.Font.Size = 8;
  17293. builder.ParagraphFormat.Style.Font.Bold = false;
  17294. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17295. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17296. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17297. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17298. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17299. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17300. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17301. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17302. builder.Write($"{item.HotelAddress}");
  17303. builder.InsertCell();
  17304. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17305. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17306. builder.InsertCell();
  17307. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17308. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17309. builder.EndRow();
  17310. #endregion
  17311. #region 第五行
  17312. builder.InsertCell();
  17313. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17314. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17315. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17316. builder.ParagraphFormat.Style.Font.Bold = false;
  17317. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17318. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17319. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17320. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17321. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17322. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17323. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17324. builder.Write("TEL:");
  17325. builder.InsertCell();
  17326. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17327. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17328. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17329. builder.ParagraphFormat.Style.Font.Bold = false;
  17330. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17331. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17332. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17333. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17334. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17335. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17336. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17337. builder.Write($"{item.HotelTel}");
  17338. builder.InsertCell();
  17339. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17340. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17341. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17342. builder.ParagraphFormat.Style.Font.Bold = false;
  17343. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17344. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17345. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17346. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17347. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17348. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17349. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17350. builder.Write($"FAX:");
  17351. builder.InsertCell();
  17352. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17353. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17354. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17355. builder.ParagraphFormat.Style.Font.Bold = false;
  17356. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17357. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17358. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17359. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17360. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17361. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17362. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17363. builder.Write($"{item.HotelFax}");
  17364. builder.EndRow();
  17365. #endregion
  17366. #region 第六行
  17367. builder.InsertCell();
  17368. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17369. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17370. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17371. builder.ParagraphFormat.Style.Font.Bold = false;
  17372. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17373. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17374. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17375. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17376. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17377. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17378. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17379. builder.Write("CHECK IN:");
  17380. builder.InsertCell();
  17381. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17382. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17383. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17384. builder.ParagraphFormat.Style.Font.Bold = false;
  17385. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17386. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17387. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17388. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17389. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17390. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17391. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17392. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17393. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17394. builder.Write($"{checkInStr}");
  17395. builder.InsertCell();
  17396. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17397. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17398. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17399. builder.ParagraphFormat.Style.Font.Bold = false;
  17400. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17401. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17402. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17403. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17404. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17405. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17406. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17407. builder.Write($"CHECK OUT:");
  17408. builder.InsertCell();
  17409. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17410. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17411. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17412. builder.ParagraphFormat.Style.Font.Bold = false;
  17413. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17414. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17415. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17416. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17417. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17418. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17419. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17420. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17421. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17422. builder.Write($"{checkOutStr}");
  17423. builder.EndRow();
  17424. #endregion
  17425. #region 第七行
  17426. builder.InsertCell();
  17427. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17428. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17429. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17430. builder.ParagraphFormat.Style.Font.Bold = false;
  17431. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17432. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17433. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17434. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17435. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17436. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17437. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17438. builder.Write($"GUEST NAME:");
  17439. builder.InsertCell();
  17440. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17441. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17442. builder.ParagraphFormat.Style.Font.Size = 8;
  17443. builder.ParagraphFormat.Style.Font.Bold = false;
  17444. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17445. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17446. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17447. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17448. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17449. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17450. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17451. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17452. builder.Write($"{item.GuestName}");
  17453. builder.InsertCell();
  17454. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17455. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17456. builder.InsertCell();
  17457. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17458. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17459. builder.EndRow();
  17460. #endregion
  17461. #region 第八行
  17462. builder.InsertCell();
  17463. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17464. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17465. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17466. builder.ParagraphFormat.Style.Font.Bold = false;
  17467. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17468. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17469. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17470. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17471. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17472. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17473. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17474. builder.Write($"ROOM TYPE:");
  17475. builder.InsertCell();
  17476. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17477. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17478. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17479. builder.ParagraphFormat.Style.Font.Bold = false;
  17480. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17481. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17482. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17483. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17484. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17485. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17486. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17487. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17488. builder.Write($"{item.RoomExplanation}");
  17489. builder.InsertCell();
  17490. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17491. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17492. builder.InsertCell();
  17493. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17494. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17495. builder.EndRow();
  17496. #endregion
  17497. #region 第九行
  17498. builder.InsertCell();
  17499. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17500. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17501. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17502. builder.ParagraphFormat.Style.Font.Bold = false;
  17503. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17504. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17505. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17506. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17507. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17508. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17509. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17510. builder.Write($"NOTE:");
  17511. builder.InsertCell();
  17512. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17513. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17514. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17515. builder.ParagraphFormat.Style.Font.Bold = false;
  17516. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17517. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17518. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17519. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17520. 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.");
  17521. builder.InsertCell();
  17522. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17523. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17524. builder.InsertCell();
  17525. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17526. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17527. builder.EndRow();
  17528. #endregion
  17529. builder.EndTable();
  17530. //换行
  17531. builder.Writeln("");
  17532. builder.Writeln("");
  17533. }
  17534. #region 获取文档中的所有表格 设置文字自适应
  17535. // 获取文档中的所有表格。
  17536. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17537. {
  17538. // 遍历表格中的所有行。
  17539. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17540. {
  17541. foreach (Cell cell in row.Cells)
  17542. {
  17543. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17544. cellFormat.Width = 0;
  17545. }
  17546. }
  17547. }
  17548. #endregion
  17549. #region 设置页眉
  17550. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  17551. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  17552. if (System.IO.File.Exists(voucherHeaderPath))
  17553. {
  17554. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  17555. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  17556. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  17557. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  17558. // 调整图片位置
  17559. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  17560. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  17561. shape.Top = 50; // 将图片距离页眉上边缘的距离
  17562. shape.Left = 0; // 将图片距离页面左边缘的距离
  17563. shape.Width = 81; // 设置图片宽度
  17564. shape.Height = 36; // 设置图片高度
  17565. }
  17566. //靠右
  17567. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17568. //// 设置页脚上下边距
  17569. //builder.PageSetup.HeaderDistance = 42;
  17570. // 添加页眉线
  17571. Aspose.Words.Border borderHeader = null;
  17572. try
  17573. {
  17574. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  17575. }
  17576. catch (Exception e)
  17577. {
  17578. // TODO Auto-generated catch block
  17579. //e.printStackTrace();
  17580. }
  17581. borderHeader.Shadow = true;
  17582. borderHeader.DistanceFromText = 2;
  17583. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  17584. #endregion
  17585. }
  17586. catch (Exception ex)
  17587. {
  17588. }
  17589. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17590. doc.Save(fileDir);
  17591. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17592. return Ok(JsonView(true, "操作成功!", Url));
  17593. }
  17594. /// <summary>
  17595. /// 酒店预订
  17596. /// 生成 预定成本 Excel
  17597. /// </summary>
  17598. /// <param name="_dto"></param>
  17599. /// <returns></returns>
  17600. [HttpPost]
  17601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17602. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  17603. {
  17604. #region 参数验证
  17605. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  17606. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  17607. if (!vadalitorRes.IsValid)
  17608. {
  17609. var errors = new StringBuilder();
  17610. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  17611. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  17612. }
  17613. #region 团组操作权限验证 76 酒店预定模块
  17614. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17615. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17616. #endregion
  17617. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17618. #region 页面操作权限验证
  17619. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17620. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17621. #endregion
  17622. #endregion
  17623. decimal _rate = 1.00M;
  17624. string _currency = string.Empty;
  17625. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  17626. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17627. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  17628. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17629. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  17630. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  17631. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  17632. if (_GroupCostParameter == null)
  17633. {
  17634. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  17635. bool isIntType = int.TryParse(_currency, out int currId);
  17636. if (isIntType)
  17637. {
  17638. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17639. }
  17640. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17641. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17642. if (currInfo == null)
  17643. {
  17644. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17645. }
  17646. else _rate = currInfo.Rate;
  17647. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  17648. {
  17649. _rate = _GroupCostParameter.Rate;
  17650. }
  17651. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17652. //string strFileName = "HotelStatement/";
  17653. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17654. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17655. var rateDatas = new List<dynamic>();
  17656. #region 数据处理
  17657. foreach (var item in hrDtas)
  17658. {
  17659. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17660. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17661. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17662. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17663. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17664. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  17665. {
  17666. continue;
  17667. }
  17668. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17669. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  17670. string singleRoomFeeStr = string.Empty,
  17671. doubleRoomFeeStr = string.Empty,
  17672. suiteRoomFeeStr = string.Empty,
  17673. otherRoomFeeStr = string.Empty,
  17674. payMoneyStr = string.Empty,
  17675. cardPriceStr = string.Empty;
  17676. if (roomCurr.Equals("CNY"))
  17677. {
  17678. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  17679. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17680. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17681. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17682. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17683. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  17684. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  17685. }
  17686. else
  17687. {
  17688. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17689. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17690. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17691. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17692. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17693. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17694. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17695. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17696. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17697. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17698. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  17699. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  17700. if (ccpPaymentCurrency.Equals("CNY"))
  17701. {
  17702. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  17703. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17704. }
  17705. else
  17706. {
  17707. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17708. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17709. }
  17710. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17711. if (hotelcardPriceCurrency.Equals("CNY"))
  17712. {
  17713. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17714. }
  17715. else
  17716. {
  17717. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  17718. }
  17719. }
  17720. string breakfastPriceStr = string.Empty,
  17721. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17722. governmentRentStr = string.Empty,
  17723. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17724. cityTaxStr = string.Empty,
  17725. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17726. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  17727. if (!string.IsNullOrEmpty(breakfastCurrency1))
  17728. {
  17729. if (breakfastCurrency1.Equals("CNY"))
  17730. {
  17731. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17732. }
  17733. else
  17734. {
  17735. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  17736. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  17737. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  17738. }
  17739. }
  17740. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17741. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  17742. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  17743. {
  17744. if (governmentRentCurrency.Equals("CNY"))
  17745. {
  17746. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17747. }
  17748. else
  17749. {
  17750. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  17751. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  17752. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  17753. }
  17754. }
  17755. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17756. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  17757. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  17758. {
  17759. if (cityTaxStrCurrency1.Equals("CNY"))
  17760. {
  17761. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17762. }
  17763. else
  17764. {
  17765. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  17766. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  17767. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  17768. }
  17769. }
  17770. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17771. int payDId = roomInfo?.PayDId ?? 0;
  17772. pcfds.Add(new HotelReservations_PCFD_View()
  17773. {
  17774. City = item.City,
  17775. HotelName = item.HotelName,
  17776. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17777. // SingleRoomCount = item.SingleRoomCount,
  17778. SingleRoomPrice = singleRoomFeeStr,
  17779. // DoubleRoomCount = item.DoubleRoomCount,
  17780. DoubleRoomPrice = doubleRoomFeeStr,
  17781. //SuiteRoomCount = item.SuiteRoomCount,
  17782. SuiteRoomPrice = suiteRoomFeeStr,
  17783. OtherRoomPrice = otherRoomFeeStr,
  17784. //OtherRoomCount = item.OtherRoomCount,
  17785. BreakfastPrice = breakfastPriceStr,
  17786. GovernmentRent = governmentRentStr,
  17787. CityTax = cityTaxStr,
  17788. RoomExplanation = item.RoomExplanation,
  17789. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17790. PayTime = roomInfo?.ConsumptionDate,
  17791. BankNo = roomInfo?.BankNo,
  17792. PayMoney = payMoneyStr,
  17793. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17794. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17795. CardPrice = cardPriceStr,
  17796. Remark = ccpInfo.Remark
  17797. });
  17798. }
  17799. #endregion
  17800. //载入模板
  17801. WorkbookDesigner designer = new WorkbookDesigner();
  17802. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17803. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17804. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17805. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17806. var rateDatas1 = rateDatas.Distinct();
  17807. var rateStr = string.Empty;
  17808. foreach (var item in rateDatas1)
  17809. {
  17810. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  17811. }
  17812. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  17813. designer.SetDataSource("Opertor", userInfo.CnName);
  17814. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17815. dt.TableName = "ViewMyHotelReservations";
  17816. designer.SetDataSource(dt);
  17817. designer.Process();
  17818. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17819. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17820. designer.Workbook.Save(serverPath);
  17821. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17822. #region 删除指定行
  17823. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17824. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17825. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17826. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17827. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17828. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17829. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17830. cssIndex = dt.Columns["CityTax"].Ordinal,
  17831. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17832. remarkIndex = dt.Columns["Remark"].Ordinal;
  17833. //删除指定列
  17834. foreach (DataRow item in dt.Rows)
  17835. {
  17836. string singleStr = item["SingleRoomPrice"].ToString();
  17837. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17838. if (containsDigitButNotZero1) singleDel = false;
  17839. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17840. string doubleStr = item["DoubleRoomPrice"].ToString();
  17841. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17842. if (containsDigitButNotZero2) doubleDel = false;
  17843. string suiteStr = item["SuiteRoomPrice"].ToString();
  17844. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17845. if (containsDigitButNotZero3) suiteDel = false;
  17846. string otherStr = item["OtherRoomPrice"].ToString();
  17847. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17848. if (containsDigitButNotZero4) otherDel = false;
  17849. string zcStr = item["BreakfastPrice"].ToString();
  17850. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17851. if (containsDigitButNotZero5) zcDel = false;
  17852. string dsStr = item["GovernmentRent"].ToString();
  17853. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17854. if (containsDigitButNotZero6) dsDel = false;
  17855. string cssStr = item["CityTax"].ToString();
  17856. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17857. if (containsDigitButNotZero7) cssDel = false;
  17858. string cpStr = item["ConsumptionPatterns"].ToString();
  17859. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  17860. string remarkStr = item["Remark"].ToString();
  17861. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  17862. }
  17863. DeleteColumn(serverPath, remarkIndex, remarkDel);
  17864. DeleteColumn(serverPath, cpIndex, cpDel);
  17865. DeleteColumn(serverPath, dsIndex, dsDel);
  17866. DeleteColumn(serverPath, cssIndex, cssDel);
  17867. DeleteColumn(serverPath, zcIndex, zcDel);
  17868. DeleteColumn(serverPath, otherIndex, otherDel);
  17869. DeleteColumn(serverPath, suiteIndex, suiteDel);
  17870. DeleteColumn(serverPath, doubleIndex, doubleDel);
  17871. DeleteColumn(serverPath, singleIndex, singleDel);
  17872. #endregion
  17873. //只保留第一个表格
  17874. DeleteSheet(serverPath);
  17875. return Ok(JsonView(true, "操作成功", url = rst));
  17876. }
  17877. else
  17878. {
  17879. _currency = _GroupCostParameter.Currency;
  17880. bool isIntType = int.TryParse(_currency, out int currId);
  17881. if (isIntType)
  17882. {
  17883. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17884. }
  17885. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17886. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17887. if (currInfo == null)
  17888. {
  17889. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17890. }
  17891. if (!_currency.ToUpper().Equals("CNY"))
  17892. {
  17893. _rate = _GroupCostParameter.Rate;
  17894. }
  17895. _rate = currInfo.Rate;
  17896. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17897. //string strFileName = "HotelStatement/";
  17898. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17899. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17900. #region 数据处理
  17901. foreach (var item in hrDtas)
  17902. {
  17903. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17904. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17905. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17906. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17907. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17908. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17909. string singleRoomFeeStr = string.Empty,
  17910. doubleRoomFeeStr = string.Empty,
  17911. suiteRoomFeeStr = string.Empty,
  17912. otherRoomFeeStr = string.Empty,
  17913. payMoneyStr = string.Empty,
  17914. cardPriceStr = string.Empty;
  17915. if (roomCurr.Equals(_currency))
  17916. {
  17917. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  17918. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  17919. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  17920. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  17921. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  17922. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  17923. }
  17924. else
  17925. {
  17926. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17927. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17928. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17929. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17930. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17931. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17932. }
  17933. string breakfastPriceStr = string.Empty,
  17934. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17935. governmentRentStr = string.Empty,
  17936. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17937. cityTaxStrStr = string.Empty,
  17938. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17939. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  17940. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  17941. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  17942. int payDId = roomInfo?.PayDId ?? 0;
  17943. pcfds.Add(new HotelReservations_PCFD_View()
  17944. {
  17945. City = item.City,
  17946. HotelName = item.HotelName,
  17947. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17948. // SingleRoomCount = item.SingleRoomCount,
  17949. SingleRoomPrice = singleRoomFeeStr,
  17950. // DoubleRoomCount = item.DoubleRoomCount,
  17951. DoubleRoomPrice = doubleRoomFeeStr,
  17952. //SuiteRoomCount = item.SuiteRoomCount,
  17953. SuiteRoomPrice = suiteRoomFeeStr,
  17954. OtherRoomPrice = otherRoomFeeStr,
  17955. //OtherRoomCount = item.OtherRoomCount,
  17956. BreakfastPrice = breakfastPriceStr,
  17957. GovernmentRent = governmentRentStr,
  17958. CityTax = cityTaxStrStr,
  17959. RoomExplanation = item.RoomExplanation,
  17960. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17961. PayTime = roomInfo?.ConsumptionDate,
  17962. BankNo = roomInfo?.BankNo,
  17963. PayMoney = payMoneyStr,
  17964. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17965. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17966. CardPrice = cardPriceStr,
  17967. Remark = ccpInfo.Remark
  17968. });
  17969. }
  17970. #endregion
  17971. //载入模板
  17972. WorkbookDesigner designer = new WorkbookDesigner();
  17973. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17974. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17975. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17976. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17977. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  17978. designer.SetDataSource("Opertor", userInfo.CnName);
  17979. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17980. dt.TableName = "ViewMyHotelReservations";
  17981. designer.SetDataSource(dt);
  17982. designer.Process();
  17983. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17984. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17985. designer.Workbook.Save(serverPath);
  17986. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17987. #region 删除指定行
  17988. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17989. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17990. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17991. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17992. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17993. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17994. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17995. cssIndex = dt.Columns["CityTax"].Ordinal,
  17996. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17997. remarkIndex = dt.Columns["Remark"].Ordinal;
  17998. //删除指定列
  17999. foreach (DataRow item in dt.Rows)
  18000. {
  18001. string singleStr = item["SingleRoomPrice"].ToString();
  18002. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18003. if (containsDigitButNotZero1) singleDel = false;
  18004. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18005. string doubleStr = item["DoubleRoomPrice"].ToString();
  18006. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18007. if (containsDigitButNotZero2) doubleDel = false;
  18008. string suiteStr = item["SuiteRoomPrice"].ToString();
  18009. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18010. if (containsDigitButNotZero3) suiteDel = false;
  18011. string otherStr = item["OtherRoomPrice"].ToString();
  18012. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18013. if (containsDigitButNotZero4) otherDel = false;
  18014. string zcStr = item["BreakfastPrice"].ToString();
  18015. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18016. if (containsDigitButNotZero5) zcDel = false;
  18017. string dsStr = item["GovernmentRent"].ToString();
  18018. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18019. if (containsDigitButNotZero6) dsDel = false;
  18020. string cssStr = item["CityTax"].ToString();
  18021. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18022. if (containsDigitButNotZero7) cssDel = false;
  18023. string cpStr = item["ConsumptionPatterns"].ToString();
  18024. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18025. string remarkStr = item["Remark"].ToString();
  18026. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18027. }
  18028. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18029. DeleteColumn(serverPath, cpIndex, cpDel);
  18030. DeleteColumn(serverPath, dsIndex, dsDel);
  18031. DeleteColumn(serverPath, cssIndex, cssDel);
  18032. DeleteColumn(serverPath, zcIndex, zcDel);
  18033. DeleteColumn(serverPath, otherIndex, otherDel);
  18034. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18035. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18036. DeleteColumn(serverPath, singleIndex, singleDel);
  18037. #endregion
  18038. //只保留第一个表格
  18039. DeleteSheet(serverPath);
  18040. return Ok(JsonView(true, "操作成功", url = rst));
  18041. }
  18042. //return Ok(JsonView(false));
  18043. }
  18044. /// <summary>
  18045. /// 删除指定列
  18046. /// </summary>
  18047. /// <param name="file"></param>
  18048. /// <param name="columnIndex"></param>
  18049. /// <param name="isDel"></param>
  18050. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18051. {
  18052. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18053. //wb.Save(file);
  18054. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18055. if (sheet1 != null)
  18056. {
  18057. if (isDel)
  18058. {
  18059. Cells cells = sheet1.Cells;
  18060. cells.DeleteColumn(columnIndex);
  18061. }
  18062. }
  18063. wb.Save(file);
  18064. }
  18065. /// <summary>
  18066. /// 删除sheet
  18067. /// </summary>
  18068. /// <param name="file"></param>
  18069. /// <param name="sheetName"></param>
  18070. private void DeleteSheet(string file, string sheetName = "")
  18071. {
  18072. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18073. //wb.Save(file);
  18074. List<string> sheets = new List<string>();
  18075. foreach (var item in wb.Worksheets)
  18076. {
  18077. sheets.Add(item.Name);
  18078. }
  18079. if (sheets.Count > 0)
  18080. {
  18081. sheets.RemoveAt(0);//不删除第一个sheet
  18082. foreach (var item in sheets)
  18083. {
  18084. wb.Worksheets.RemoveAt(item);
  18085. }
  18086. }
  18087. wb.Save(file);
  18088. }
  18089. /// <summary>
  18090. /// 酒店预订
  18091. /// 确认单
  18092. /// </summary>
  18093. /// <param name="_dto"></param>
  18094. /// <returns></returns>
  18095. [HttpPost]
  18096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18097. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18098. {
  18099. try
  18100. {
  18101. #region 参数验证
  18102. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18103. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18104. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18105. #region 团组操作权限验证 76 酒店预定模块
  18106. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18107. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18108. #endregion
  18109. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18110. #region 页面操作权限验证
  18111. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18112. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18113. #endregion
  18114. #endregion
  18115. //团组信息
  18116. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18117. //酒店数据
  18118. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18119. if (listhoteldata.Count < 0)
  18120. {
  18121. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18122. }
  18123. //利datatable存储
  18124. DataTable dt = new DataTable();
  18125. dt.Columns.Add("CheckInDate", typeof(string));
  18126. dt.Columns.Add("City", typeof(string));
  18127. dt.Columns.Add("Hotel", typeof(string));
  18128. dt.Columns.Add("Room", typeof(string));
  18129. for (int i = 0; i < listhoteldata.Count; i++)
  18130. {
  18131. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18132. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18133. while (dayStart < dayEnd)
  18134. {
  18135. string temp = "";
  18136. DataRow row = dt.NewRow();
  18137. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18138. row["City"] = listhoteldata[i].City;
  18139. row["Hotel"] = listhoteldata[i].HotelName;
  18140. if (listhoteldata[i].SingleRoomCount > 0)
  18141. {
  18142. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18143. }
  18144. if (listhoteldata[i].DoubleRoomCount > 0)
  18145. {
  18146. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18147. }
  18148. if (listhoteldata[i].SuiteRoomCount > 0)
  18149. {
  18150. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18151. }
  18152. if (listhoteldata[i].OtherRoomCount > 0)
  18153. {
  18154. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18155. }
  18156. row["Room"] = temp;
  18157. dt.Rows.Add(row);
  18158. dayStart = dayStart.AddDays(1);
  18159. }
  18160. }
  18161. Dictionary<string, string> dic = new Dictionary<string, string>();
  18162. dic.Add("Dele", di.TeamName);
  18163. dic.Add("City", di.VisitCountry);
  18164. //模板路径
  18165. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18166. //载入模板
  18167. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18168. DocumentBuilder builder = new DocumentBuilder(doc);
  18169. foreach (var key in dic.Keys)
  18170. {
  18171. builder.MoveToBookmark(key);
  18172. builder.Write(dic[key]);
  18173. }
  18174. //获取word里所有表格
  18175. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18176. //获取所填表格的序数
  18177. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18178. var rowStart = tableOne.Rows[0]; //获取第1行
  18179. //循环赋值
  18180. for (int i = 0; i < dt.Rows.Count; i++)
  18181. {
  18182. builder.MoveToCell(0, i + 1, 0, 0);
  18183. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18184. builder.MoveToCell(0, i + 1, 1, 0);
  18185. builder.Write(dt.Rows[i]["City"].ToString());
  18186. builder.MoveToCell(0, i + 1, 2, 0);
  18187. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18188. builder.MoveToCell(0, i + 1, 3, 0);
  18189. builder.Write(dt.Rows[i]["Room"].ToString());
  18190. }
  18191. //删除多余行
  18192. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18193. {
  18194. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18195. }
  18196. string strFileName = di.TeamName + "酒店确认单.doc";
  18197. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18198. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18199. return Ok(JsonView(true, "成功", url));
  18200. }
  18201. catch (Exception ex)
  18202. {
  18203. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18204. }
  18205. }
  18206. #endregion
  18207. #region 团组状态
  18208. /// <summary>
  18209. /// 团组状态列表 Page
  18210. /// </summary>
  18211. /// <param name="dto">团组列表请求dto</param>
  18212. /// <returns></returns>
  18213. [HttpPost]
  18214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18215. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18216. {
  18217. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18218. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18219. {
  18220. string sqlWhere = string.Empty;
  18221. if (dto.IsSure == 0) //未完成
  18222. {
  18223. sqlWhere += string.Format(@" And IsSure = 0");
  18224. }
  18225. else if (dto.IsSure == 1) //已完成
  18226. {
  18227. sqlWhere += string.Format(@" And IsSure = 1");
  18228. }
  18229. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18230. {
  18231. string tj = dto.SearchCriteria;
  18232. 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}%')",
  18233. tj, tj, tj, tj, tj);
  18234. }
  18235. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18236. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18237. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18238. From (
  18239. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18240. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18241. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18242. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18243. From Grp_DelegationInfo gdi
  18244. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18245. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18246. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18247. Where gdi.IsDel = 0 {0}
  18248. ) temp ", sqlWhere);
  18249. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18250. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18251. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18252. }
  18253. else
  18254. {
  18255. return Ok(JsonView(false, "查询失败"));
  18256. }
  18257. }
  18258. /// <summary>
  18259. /// 团组状态
  18260. /// 设置操作完成
  18261. /// </summary>
  18262. /// <param name="dto">团组列表请求dto</param>
  18263. /// <returns></returns>
  18264. [HttpPost]
  18265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18266. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18267. {
  18268. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18269. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18270. {
  18271. Id = dto.Id,
  18272. IsSure = 1
  18273. };
  18274. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18275. .UpdateColumns(it => new { it.IsSure })
  18276. .WhereColumns(it => new { it.Id })
  18277. .ExecuteCommandAsync();
  18278. if (result > 0)
  18279. {
  18280. return Ok(JsonView(true, "操作完成!"));
  18281. }
  18282. return Ok(JsonView(false, "操作失败!"));
  18283. }
  18284. #endregion
  18285. #region 保险费用录入
  18286. /// <summary>
  18287. /// 根据团组Id查询保险费用列表
  18288. /// </summary>
  18289. /// <param name="dto"></param>
  18290. /// <returns></returns>
  18291. [HttpPost]
  18292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18293. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18294. {
  18295. Result groupData = await _customersRep.CustomersByDiId(dto);
  18296. if (groupData.Code != 0)
  18297. {
  18298. return Ok(JsonView(false, groupData.Msg));
  18299. }
  18300. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18301. }
  18302. /// <summary>
  18303. /// 根据保险费用Id查询保险费用详细
  18304. /// </summary>
  18305. /// <param name="dto"></param>
  18306. /// <returns></returns>
  18307. [HttpPost]
  18308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18309. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18310. {
  18311. try
  18312. {
  18313. Result groupData = await _customersRep.CustomersById(dto);
  18314. if (groupData.Code != 0)
  18315. {
  18316. return Ok(JsonView(false, groupData.Msg));
  18317. }
  18318. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18319. }
  18320. catch (Exception ex)
  18321. {
  18322. return Ok(JsonView(false, ex.Message));
  18323. }
  18324. }
  18325. /// <summary>
  18326. /// 保险费用录入页面初始化绑定
  18327. /// </summary>
  18328. /// <param name="dto"></param>
  18329. /// <returns></returns>
  18330. [HttpPost]
  18331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18332. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18333. {
  18334. try
  18335. {
  18336. Result groupData = await _customersRep.CustomersInitialize(dto);
  18337. if (groupData.Code != 0)
  18338. {
  18339. return Ok(JsonView(false, groupData.Msg));
  18340. }
  18341. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18342. }
  18343. catch (Exception ex)
  18344. {
  18345. return Ok(JsonView(false, ex.Message));
  18346. }
  18347. }
  18348. /// <summary>
  18349. /// 保险费用操作(Status:1.新增,2.修改)
  18350. /// </summary>
  18351. /// <param name="dto"></param>
  18352. /// <returns></returns>
  18353. [HttpPost]
  18354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18355. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18356. {
  18357. Result groupData = await _customersRep.OpCustomers(dto);
  18358. if (groupData.Code != 0)
  18359. {
  18360. return Ok(JsonView(false, groupData.Msg));
  18361. }
  18362. #region 应用推送
  18363. try
  18364. {
  18365. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18366. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18367. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18368. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18369. //自动审核
  18370. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18371. //2024-10-21 新增LZ UID
  18372. var userIds = new List<int>() { 21 };
  18373. string title = $"系统通知";
  18374. var diId = dto.DiId;
  18375. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18376. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18377. string content = "";
  18378. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18379. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18380. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18381. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18382. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18383. }
  18384. catch (Exception ex)
  18385. {
  18386. }
  18387. #endregion
  18388. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18389. }
  18390. /// <summary>
  18391. /// 保险文件上传
  18392. /// </summary>
  18393. /// <param name="file"></param>
  18394. /// <returns></returns>
  18395. [HttpPost]
  18396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18397. public async Task<IActionResult> UploadCus(IFormFile file)
  18398. {
  18399. try
  18400. {
  18401. if (file != null)
  18402. {
  18403. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18404. //文件名称
  18405. string projectFileName = file.FileName;
  18406. //上传的文件的路径
  18407. string filePath = "";
  18408. if (!Directory.Exists(fileDir))
  18409. {
  18410. Directory.CreateDirectory(fileDir);
  18411. }
  18412. //上传的文件的路径
  18413. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18414. using (FileStream fs = System.IO.File.Create(filePath))
  18415. {
  18416. file.CopyTo(fs);
  18417. fs.Flush();
  18418. }
  18419. return Ok(JsonView(true, "上传成功!", projectFileName));
  18420. }
  18421. else
  18422. {
  18423. return Ok(JsonView(false, "上传失败!"));
  18424. }
  18425. }
  18426. catch (Exception ex)
  18427. {
  18428. return Ok(JsonView(false, "程序错误!"));
  18429. throw;
  18430. }
  18431. }
  18432. /// <summary>
  18433. /// 保险删除指定文件
  18434. /// </summary>
  18435. /// <param name="dto"></param>
  18436. /// <returns></returns>
  18437. [HttpPost]
  18438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18439. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18440. {
  18441. try
  18442. {
  18443. string filePath = "";
  18444. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18445. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18446. //int id = 0;
  18447. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18448. // 删除该文件
  18449. try
  18450. {
  18451. System.IO.File.Delete(filePath);
  18452. 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()
  18453. {
  18454. Attachment = "",
  18455. }).ExecuteCommandAsync();
  18456. if (result != 0)
  18457. {
  18458. return Ok(JsonView(true, "成功!"));
  18459. }
  18460. else
  18461. {
  18462. return Ok(JsonView(false, "失败!"));
  18463. }
  18464. }
  18465. catch (Exception)
  18466. {
  18467. 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()
  18468. {
  18469. Attachment = "",
  18470. }).ExecuteCommandAsync();
  18471. if (result != 0)
  18472. {
  18473. return Ok(JsonView(true, "成功!"));
  18474. }
  18475. else
  18476. {
  18477. return Ok(JsonView(false, "失败!"));
  18478. }
  18479. }
  18480. }
  18481. catch (Exception ex)
  18482. {
  18483. return Ok(JsonView(false, "程序错误!"));
  18484. throw;
  18485. }
  18486. }
  18487. /// <summary>
  18488. /// 保险费用操作(删除)
  18489. /// </summary>
  18490. /// <param name="dto"></param>
  18491. /// <returns></returns>
  18492. [HttpPost]
  18493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18494. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18495. {
  18496. try
  18497. {
  18498. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18499. if (!res)
  18500. {
  18501. return Ok(JsonView(false, "删除失败"));
  18502. }
  18503. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18504. {
  18505. IsDel = 1,
  18506. DeleteUserId = dto.DeleteUserId,
  18507. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18508. }).ExecuteCommandAsync();
  18509. return Ok(JsonView(true, "删除成功!"));
  18510. }
  18511. catch (Exception ex)
  18512. {
  18513. return Ok(JsonView(false, "程序错误!"));
  18514. throw;
  18515. }
  18516. }
  18517. #endregion
  18518. #region 接团客户名单 PageId 104
  18519. /// <summary>
  18520. /// 接团客户名单
  18521. /// 迁移数据(慎用!)
  18522. /// </summary>
  18523. /// <returns></returns>
  18524. [HttpPost]
  18525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18526. public async Task<IActionResult> PostTourClientListChange()
  18527. {
  18528. try
  18529. {
  18530. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18531. //var groupClinetData1
  18532. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18533. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18534. int updateCount = 0;
  18535. if (oldOAClientList.Count > 0)
  18536. {
  18537. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18538. _sqlSugar.BeginTran();
  18539. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18540. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18541. foreach (var item in oldOAClientList)
  18542. {
  18543. int comId = 0;
  18544. string format = "yyyy-MM-dd HH:mm:ss";
  18545. string data11 = "1990-01-01 00:00";
  18546. var data1 = IsValidDate(item.OPdate, format);
  18547. if (data1) data11 = item.OPdate;
  18548. //客户公司验证
  18549. if (!string.IsNullOrEmpty(item.Company))
  18550. {
  18551. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  18552. if (clientComInfo == null) // add
  18553. {
  18554. var addInfo = new Crm_CustomerCompany()
  18555. {
  18556. CompanyAbbreviation = "",
  18557. CompanyFullName = item.Company,
  18558. Address = "",
  18559. PostCodes = "",
  18560. LastedOpUserId = item.OPer,
  18561. LastedOpDt = Convert.ToDateTime(data11),
  18562. CreateUserId = item.OPer,
  18563. CreateTime = Convert.ToDateTime(data11),
  18564. IsDel = 0
  18565. };
  18566. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  18567. if (comId1 > 0) comId = comId1;
  18568. }
  18569. else comId = clientComInfo.Id;
  18570. }
  18571. //客户人员验证
  18572. int clientId = 0;
  18573. string name = item.LastName + item.Name;
  18574. if (!string.IsNullOrEmpty(name))
  18575. {
  18576. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  18577. if (clientInfo == null)
  18578. {
  18579. DateTime? dateTime = null;
  18580. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  18581. if (isDt) dateTime = birthDayDt;
  18582. var addInfo1 = new Crm_DeleClient()
  18583. {
  18584. CrmCompanyId = comId,
  18585. DiId = -1,
  18586. LastName = item.LastName,
  18587. FirstName = item.Name,
  18588. OldName = "",
  18589. Pinyin = item.Pinyin,
  18590. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  18591. Marriage = 0,
  18592. Phone = item.Phone,
  18593. Job = item.Job,
  18594. BirthDay = dateTime
  18595. };
  18596. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  18597. if (clientId1 > 0) clientId = clientId1;
  18598. }
  18599. else clientId = clientInfo.Id;
  18600. }
  18601. if (clientId < 1)
  18602. {
  18603. continue;
  18604. }
  18605. int airType = 0;
  18606. if (item.AirType == "超经舱") airType = 459;
  18607. else if (item.AirType == "公务舱") airType = 458;
  18608. else if (item.AirType == "经济舱") airType = 460;
  18609. else if (item.AirType == "其他") airType = 565;
  18610. else if (item.AirType == "头等舱") airType = 457;
  18611. var _TourClientListEntity = new Grp_TourClientList()
  18612. {
  18613. DiId = item.Diid,
  18614. ClientId = clientId,
  18615. CreateUserId = item.OPer,
  18616. CreateTime = Convert.ToDateTime(data11),
  18617. Remark = item.Remark,
  18618. IsDel = item.Isdel,
  18619. ShippingSpaceTypeId = airType,
  18620. ShippingSpaceSpecialNeeds = item.AirRemark,
  18621. HotelSpecialNeeds = item.RoomType
  18622. };
  18623. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  18624. if (_TourClientList > 0)
  18625. {
  18626. updateCount++;
  18627. }
  18628. }
  18629. _sqlSugar.CommitTran();
  18630. }
  18631. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  18632. }
  18633. catch (Exception ex)
  18634. {
  18635. _sqlSugar.RollbackTran();
  18636. return Ok(JsonView(false, ex.Message));
  18637. }
  18638. //return Ok(JsonView(true));
  18639. }
  18640. private bool IsValidDate(string dateString, string format)
  18641. {
  18642. DateTime dateValue;
  18643. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  18644. return valid;
  18645. }
  18646. /// <summary>
  18647. /// 接团客户名单
  18648. /// 根据团组Id查询List
  18649. /// </summary>
  18650. /// <param name="_dto"></param>
  18651. /// <returns></returns>
  18652. [HttpPost]
  18653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18654. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  18655. {
  18656. #region 参数验证
  18657. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  18658. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  18659. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  18660. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18661. #region 页面操作权限验证
  18662. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18663. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18664. #endregion
  18665. #endregion
  18666. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  18667. if (viewData.Code != 0)
  18668. {
  18669. return Ok(JsonView(false, viewData.Msg));
  18670. }
  18671. return Ok(JsonView(viewData.Data));
  18672. }
  18673. /// <summary>
  18674. /// 接团客户名单
  18675. /// 基础数据 Init
  18676. /// </summary>
  18677. /// <param name="_dto"></param>
  18678. /// <returns></returns>
  18679. [HttpPost]
  18680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18681. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  18682. {
  18683. #region 参数验证
  18684. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18685. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18687. #region 页面操作权限验证
  18688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18689. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18690. #endregion
  18691. #endregion
  18692. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  18693. }
  18694. /// <summary>
  18695. /// 接团客户名单
  18696. /// 根据 Id查询 Details
  18697. /// </summary>
  18698. /// <param name="_dto"></param>
  18699. /// <returns></returns>
  18700. [HttpPost]
  18701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18702. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  18703. {
  18704. #region 参数验证
  18705. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18706. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18707. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18708. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18709. #region 页面操作权限验证
  18710. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18711. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18712. #endregion
  18713. #endregion
  18714. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18715. if (viewData.Code != 0)
  18716. {
  18717. return Ok(JsonView(false, viewData.Msg));
  18718. }
  18719. return Ok(JsonView(viewData.Data));
  18720. }
  18721. /// <summary>
  18722. /// 接团客户名单
  18723. /// Add Or Edit
  18724. /// </summary>
  18725. /// <param name="_dto"></param>
  18726. /// <returns></returns>
  18727. [HttpPost]
  18728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18729. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  18730. {
  18731. #region 参数验证
  18732. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18733. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18734. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18735. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18736. #region 页面操作权限验证
  18737. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18738. if (_dto.Id == 0) //添加
  18739. {
  18740. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18741. }
  18742. else if (_dto.Id >= 0) //修改
  18743. {
  18744. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18745. }
  18746. #endregion
  18747. #endregion
  18748. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  18749. if (viewData.Code != 0)
  18750. {
  18751. return Ok(JsonView(false, viewData.Msg));
  18752. }
  18753. return Ok(JsonView(true));
  18754. }
  18755. /// <summary>
  18756. /// 接团客户名单
  18757. /// json字符串 AddMultiple(添加多个)
  18758. /// </summary>
  18759. /// <param name="_dto"></param>
  18760. /// <returns></returns>
  18761. [HttpPost]
  18762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18763. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  18764. {
  18765. #region 参数验证
  18766. string jsonLabel = _dto.JsonLabel;
  18767. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18768. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18769. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18770. #region 页面操作权限验证
  18771. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18772. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18773. #endregion
  18774. #endregion
  18775. var request = new TourClientListAddMultipleDto();
  18776. request.DiId = _dto.DiId;
  18777. request.UserId = _dto.UserId;
  18778. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  18779. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  18780. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  18781. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  18782. var infos = new List<TourClientListInfo>();
  18783. foreach (var data in datas)
  18784. {
  18785. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  18786. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  18787. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  18788. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  18789. {
  18790. continue;
  18791. }
  18792. infos.Add(new TourClientListInfo()
  18793. {
  18794. IsAccompany = 1,
  18795. LastName = lastName,
  18796. FirstName = firstName,
  18797. Pinyin = lastNameEn + @"/" + firstNameEn,
  18798. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  18799. CompanyFullName = data.CompanyFullName,
  18800. Job = data.Job
  18801. });
  18802. }
  18803. if (infos.Any())
  18804. {
  18805. var viewData = await _tourClientListRep._AddMultiple(request);
  18806. if (viewData.Code != 0)
  18807. {
  18808. return Ok(JsonView(false, viewData.Msg));
  18809. }
  18810. return Ok(JsonView(true));
  18811. }
  18812. return Ok(JsonView(false));
  18813. }
  18814. /// <summary>
  18815. /// 接团客户名单
  18816. /// AddMultiple(添加多个)
  18817. /// </summary>
  18818. /// <param name="_dto"></param>
  18819. /// <returns></returns>
  18820. [HttpPost]
  18821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18822. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  18823. {
  18824. #region 参数验证
  18825. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18826. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18827. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18828. #region 页面操作权限验证
  18829. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18830. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18831. #endregion
  18832. #endregion
  18833. var viewData = await _tourClientListRep._AddMultiple(_dto);
  18834. if (viewData.Code != 0)
  18835. {
  18836. return Ok(JsonView(false, viewData.Msg));
  18837. }
  18838. return Ok(JsonView(true));
  18839. }
  18840. /// <summary>
  18841. /// 接团客户名单
  18842. /// Del
  18843. /// </summary>
  18844. /// <param name="_dto"></param>
  18845. /// <returns></returns>
  18846. [HttpPost]
  18847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18848. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  18849. {
  18850. #region 参数验证
  18851. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18852. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18853. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18854. #region 页面操作权限验证
  18855. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18856. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18857. #endregion
  18858. #endregion
  18859. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  18860. if (viewData.Code != 0)
  18861. {
  18862. return Ok(JsonView(false, viewData.Msg));
  18863. }
  18864. return Ok(JsonView(true));
  18865. }
  18866. /// <summary>
  18867. /// 接团客户名单
  18868. /// 文件下载 客户名单
  18869. /// </summary>
  18870. /// <param name="_dto"></param>
  18871. /// <returns></returns>
  18872. [HttpPost]
  18873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18874. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  18875. {
  18876. #region 参数验证
  18877. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18878. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18879. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  18880. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18881. #region 页面操作权限验证
  18882. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18883. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18884. #endregion
  18885. #endregion
  18886. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  18887. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  18888. From Grp_TourClientList tcl
  18889. Left Join
  18890. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  18891. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  18892. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  18893. From Crm_DeleClient dc
  18894. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  18895. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  18896. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  18897. Where dc.IsDel = 0) temp
  18898. On temp.DcId =tcl.ClientId
  18899. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  18900. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  18901. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  18902. //载入模板
  18903. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  18904. if (_dto.Language == 1)
  18905. {
  18906. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  18907. }
  18908. //载入模板
  18909. var doc = new Document(tempPath);
  18910. DocumentBuilder builder = new DocumentBuilder(doc);
  18911. //获取word里所有表格
  18912. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18913. //获取所填表格的序数
  18914. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18915. var rowStart = tableOne.Rows[0]; //获取第1行
  18916. if (_dto.Language == 0)
  18917. {
  18918. //循环赋值
  18919. for (int i = 0; i < DcList.Count; i++)
  18920. {
  18921. EncryptionProcessor.DecryptProperties(DcList[i]);
  18922. builder.MoveToCell(0, i + 1, 0, 0);
  18923. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  18924. builder.MoveToCell(0, i + 1, 1, 0);
  18925. int sex = DcList[i].Sex;
  18926. string sexStr = string.Empty;
  18927. if (sex == 0) sexStr = "男";
  18928. else if (sex == 1) sexStr = "女";
  18929. else sexStr = "未设置";
  18930. builder.Write(sexStr);
  18931. builder.MoveToCell(0, i + 1, 2, 0);
  18932. string birthDay = DcList[i].BirthDay;
  18933. string birthDayStr = string.Empty;
  18934. if (!string.IsNullOrEmpty(birthDay))
  18935. {
  18936. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  18937. }
  18938. builder.Write(birthDayStr);
  18939. builder.MoveToCell(0, i + 1, 3, 0);
  18940. string company = "";
  18941. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  18942. {
  18943. company = DcList[i].CompanyFullName.ToString();
  18944. }
  18945. builder.Write(company);
  18946. builder.MoveToCell(0, i + 1, 4, 0);
  18947. builder.Write(DcList[i].Job);
  18948. }
  18949. }
  18950. else if (_dto.Language == 1)
  18951. {
  18952. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  18953. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  18954. List<string> transArrayStr = new List<string>();
  18955. string transStrRes1 = "";
  18956. for (int i = 0; i < DcList.Count; i++)
  18957. {
  18958. var dc = DcList[i];
  18959. EncryptionProcessor.DecryptProperties(dc);
  18960. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  18961. if (dc.Job.Equals("暂无")) dc.Job = "-";
  18962. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  18963. if (DcList.Count - 1 == i) transStrRes1 += str1;
  18964. else transStrRes1 += $"{str1}|";
  18965. }
  18966. //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";
  18967. string transStrRes = "";
  18968. if (transStrRes1.Length > 0)
  18969. {
  18970. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  18971. }
  18972. //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
  18973. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  18974. //List<string> transArray = new List<string> { };
  18975. List<TranslateInfo> transArray = new List<TranslateInfo>();
  18976. if (transStrRes.Contains("|"))
  18977. {
  18978. string[] transArray1 = transStrRes.Split('|');
  18979. if (transArray1.Length > 0)
  18980. {
  18981. foreach (var item in transArray1)
  18982. {
  18983. if (item.Contains("&"))
  18984. {
  18985. string[] transArray2 = item.Split('&');
  18986. int index = 0;
  18987. string companyName = "", job = "";
  18988. if (transArray2.Length > 0)
  18989. {
  18990. bool success = int.TryParse(transArray2[0].Trim(), out index);
  18991. if (1 < transArray2.Length) companyName = transArray2[1];
  18992. if (2 < transArray2.Length) job = transArray2[2];
  18993. }
  18994. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  18995. }
  18996. }
  18997. }
  18998. }
  18999. //循环赋值
  19000. for (int i = 0; i < DcList.Count; i++)
  19001. {
  19002. string PYName = "";
  19003. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19004. {
  19005. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19006. string PY_First = DcList[i].Pinyin.Split('/')[1];
  19007. PYName = PY_First + " " + PY_Last;
  19008. }
  19009. else
  19010. {
  19011. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19012. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19013. PYName = PY_First + " " + PY_Last;
  19014. }
  19015. builder.MoveToCell(0, i + 1, 0, 0);
  19016. builder.Write(PYName);
  19017. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19018. builder.MoveToCell(0, i + 1, 1, 0);
  19019. builder.Write(sex);
  19020. DateTime birthDt;
  19021. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19022. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19023. builder.MoveToCell(0, i + 1, 2, 0);
  19024. builder.Write(birthday);
  19025. string company = string.Empty, job = string.Empty;
  19026. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19027. if (dcTransInfo != null)
  19028. {
  19029. company = dcTransInfo.CompanyName;
  19030. job = dcTransInfo.Job;
  19031. }
  19032. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19033. {
  19034. //查询对照表
  19035. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19036. if (tempCec != null)
  19037. {
  19038. company = tempCec.enName;
  19039. }
  19040. //翻译
  19041. else
  19042. {
  19043. }
  19044. }
  19045. builder.MoveToCell(0, i + 1, 3, 0);
  19046. builder.Write(company);
  19047. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19048. {
  19049. //查询对照表
  19050. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19051. if (tempPec != null)
  19052. {
  19053. job = tempPec.enName;
  19054. }
  19055. //翻译
  19056. else
  19057. {
  19058. }
  19059. }
  19060. builder.MoveToCell(0, i + 1, 4, 0);
  19061. builder.Write(job);
  19062. }
  19063. }
  19064. //删除多余行
  19065. while (tableOne.Rows.Count > DcList.Count + 1)
  19066. {
  19067. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19068. }
  19069. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19070. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19071. doc.Save(fileDir);
  19072. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19073. return Ok(JsonView(true, "操作成功!", Url));
  19074. }
  19075. private class TranslateInfo
  19076. {
  19077. public int Index { get; set; }
  19078. public string CompanyName { get; set; }
  19079. public string Job { get; set; }
  19080. }
  19081. [HttpPost]
  19082. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19083. {
  19084. if (files.Count == 0)
  19085. {
  19086. return Ok(JsonView(false, "文件为空"));
  19087. }
  19088. KiMiApiClient KiMiApi = new KiMiApiClient();
  19089. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19090. if (seedConter.Count == 0)
  19091. {
  19092. return Ok(JsonView(false, "上传结果为空!"));
  19093. }
  19094. var messages = new List<SeedMessages>
  19095. {
  19096. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19097. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19098. };
  19099. messages.InsertRange(1, seedConter);
  19100. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19101. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19102. string clients = kimiApiResult_JObject["content"].ToString();
  19103. string startStr = "```json", endStr = "```";
  19104. // 判断并清除开头部分
  19105. if (clients.StartsWith(startStr))
  19106. {
  19107. clients = clients.Remove(0, startStr.Length);
  19108. }
  19109. // 判断并清除结尾部分
  19110. if (clients.EndsWith(endStr))
  19111. {
  19112. clients = clients.Remove(clients.Length - endStr.Length);
  19113. }
  19114. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19115. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19116. {
  19117. {"姓", "LastName" },
  19118. {"名", "FirstName" },
  19119. {"姓名拼音", "Pinyin" },
  19120. {"性别", "Sex" },
  19121. {"单位", "CompanyFullName" },
  19122. {"职务", "Job" },
  19123. {"出生日期", "Birthday" },
  19124. };
  19125. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19126. foreach (var item in clients_JObject)
  19127. {
  19128. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19129. foreach (var field in clientFieldMap.Keys)
  19130. {
  19131. if (item.TryGetValue(field, out JToken value))
  19132. {
  19133. var getValue = value.ToString();
  19134. System.Type type = cdc.GetType();
  19135. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19136. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19137. propertyInfo.SetValue(cdc, propertyValue);
  19138. }
  19139. }
  19140. crmClients.Add(cdc);
  19141. }
  19142. return Ok(JsonView(new
  19143. {
  19144. fileCount = files.Count,
  19145. UploadCount = seedConter.Count,
  19146. ApiResult = clients,
  19147. CrmClients = crmClients
  19148. }));
  19149. }
  19150. #endregion
  19151. #region 团组倒推表
  19152. /// <summary>
  19153. /// 倒推表基础数据
  19154. /// Init
  19155. /// </summary>
  19156. /// <returns></returns>
  19157. [HttpPost]
  19158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19159. public async Task<IActionResult> PostInvertedListInit()
  19160. {
  19161. var viewData = await _invertedListRep._Init();
  19162. if (viewData.Code != 0)
  19163. {
  19164. return Ok(JsonView(false, viewData.Msg));
  19165. }
  19166. return Ok(JsonView(viewData.Data));
  19167. }
  19168. /// <summary>
  19169. /// 倒推表
  19170. /// Info
  19171. /// </summary>
  19172. /// <param name="dto"></param>
  19173. /// <returns></returns>
  19174. [HttpPost]
  19175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19176. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19177. {
  19178. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19179. if (viewData.Code != 0)
  19180. {
  19181. return Ok(JsonView(false, viewData.Msg));
  19182. }
  19183. return Ok(JsonView(viewData.Data));
  19184. }
  19185. /// <summary>
  19186. /// 倒推表
  19187. /// Create
  19188. /// </summary>
  19189. /// <param name="dto"></param>
  19190. /// <returns></returns>
  19191. [HttpPost]
  19192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19193. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19194. {
  19195. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19196. if (viewData.Code != 0)
  19197. {
  19198. return Ok(JsonView(false, viewData.Msg));
  19199. }
  19200. return Ok(JsonView(viewData.Data));
  19201. }
  19202. /// <summary>
  19203. /// 倒推表
  19204. /// Update
  19205. /// </summary>
  19206. /// <param name="dto"></param>
  19207. /// <returns></returns>
  19208. [HttpPost]
  19209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19210. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19211. {
  19212. var viewData = await _invertedListRep._Update(dto);
  19213. if (viewData.Code != 0)
  19214. {
  19215. return Ok(JsonView(false, viewData.Msg));
  19216. }
  19217. return Ok(JsonView(viewData.Data));
  19218. }
  19219. /// <summary>
  19220. /// 倒推表
  19221. /// File Download
  19222. /// </summary>
  19223. /// <param name="dto"></param>
  19224. /// <returns></returns>
  19225. [HttpPost]
  19226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19227. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19228. {
  19229. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19230. if (info2.Code != 0)
  19231. {
  19232. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19233. }
  19234. var info1 = info2.Data as InvertedListInfoView;
  19235. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19236. string teamName = "";
  19237. if (info != null) teamName = info.TeamName;
  19238. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19239. var doc = new Document();
  19240. var builder = new DocumentBuilder(doc);
  19241. #region old insert
  19242. ////载入模板
  19243. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19244. //Document doc = new Document(tempPath);
  19245. //DocumentBuilder builder = new DocumentBuilder(doc);
  19246. //利用键值对存放数据
  19247. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19248. //dic.Add("TeamName", teamName);
  19249. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19250. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19251. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19252. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19253. //dic.Add("SQRemark", info1.ApprovalRemark);
  19254. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19255. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19256. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19257. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19258. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19259. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19260. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19261. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19262. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19263. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19264. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19265. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19266. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19267. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19268. //#region 填充word模板书签内容
  19269. //foreach (var key in dic.Keys)
  19270. //{
  19271. // builder.MoveToBookmark(key);
  19272. // builder.Write(dic[key]);
  19273. //}
  19274. //#endregion
  19275. #endregion
  19276. #region New Insert
  19277. string titleFont = $"仿宋",
  19278. contentFont = $"仿宋";
  19279. var fontColor = Color.FromArgb(64, 64, 64);
  19280. //设置标题 团组名称
  19281. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19282. builder.Font.Name = titleFont;
  19283. builder.Font.Color = fontColor;
  19284. builder.Font.Size = 12;
  19285. builder.Font.Bold = true;
  19286. builder.Writeln(teamName);
  19287. //设置副标题 团组出访时间
  19288. builder.Font.Size = 12;
  19289. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19290. builder.Writeln();
  19291. var backgroundColor = Color.FromArgb(199, 199, 199);
  19292. var table = builder.StartTable();
  19293. builder.InsertCell();
  19294. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19295. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19296. builder.CellFormat.Borders.LineWidth = 1;
  19297. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19298. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19299. builder.RowFormat.Height = 40;
  19300. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19301. builder.Font.Name = contentFont;
  19302. builder.Font.Size = 12;
  19303. builder.Font.Bold = true;
  19304. builder.Font.Color = fontColor;
  19305. builder.Write("时间");
  19306. builder.InsertCell();
  19307. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19308. builder.Write("流程");
  19309. builder.InsertCell();
  19310. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19311. builder.Write("说明");
  19312. builder.EndRow();
  19313. //报批资料准备
  19314. if (info1.IsSelectedAirportd)
  19315. {
  19316. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19317. }
  19318. //报批/提供送签资料
  19319. if (info1.IsSelectedApprovalData)
  19320. {
  19321. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19322. }
  19323. //出批件护照办理
  19324. if (info1.IsSelectedIssueApproval)
  19325. {
  19326. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19327. }
  19328. //签证资料准备
  19329. if (info1.IsSelectedVisaInfo)
  19330. {
  19331. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19332. }
  19333. //送签
  19334. if (info1.IsSelectedSendVisa)
  19335. {
  19336. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19337. }
  19338. //出签
  19339. if (info1.IsSelectedIssueVisa)
  19340. {
  19341. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19342. }
  19343. //机票
  19344. if (info1.IsSelectedAirTicket)
  19345. {
  19346. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19347. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19348. }
  19349. //酒店
  19350. if (info1.IsSelectedHotel)
  19351. {
  19352. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19353. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19354. }
  19355. //开行前会
  19356. if (info1.IsSelectedPreTripMeeting)
  19357. {
  19358. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19359. }
  19360. //送机
  19361. if (info1.IsSelectedAirportdDropOff)
  19362. {
  19363. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19364. }
  19365. builder.EndTable();
  19366. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19367. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19368. for (int i = 0; i < table.Rows.Count; i++)
  19369. {
  19370. var row = table.Rows[i];
  19371. //设置宽度
  19372. row.Cells[0].CellFormat.Width = 20.00;
  19373. row.Cells[1].CellFormat.Width = 30.00;
  19374. row.Cells[2].CellFormat.Width = 50.00;
  19375. if (i != 0)
  19376. {
  19377. //边框设置
  19378. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19379. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19380. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19381. }
  19382. }
  19383. #region 页脚插入图片
  19384. // 创建页脚
  19385. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19386. doc.FirstSection.HeadersFooters.Add(footer);
  19387. Paragraph para = new Paragraph(doc);
  19388. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19389. footer.AppendChild(para);
  19390. builder.MoveTo(para);
  19391. string imagePath = "./Images/FMGJ_Log.png";
  19392. builder.InsertImage(imagePath);
  19393. #endregion
  19394. #endregion
  19395. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19396. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19397. string filePath = fileDir + $@"InvertedList/{fileName}";
  19398. doc.Save(filePath);
  19399. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19400. return Ok(JsonView(true, "操作成功!", Url));
  19401. }
  19402. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19403. {
  19404. var fontColor = Color.FromArgb(64, 64, 64);
  19405. builder.InsertCell();
  19406. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19407. builder.RowFormat.Height = 40;
  19408. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19409. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19410. builder.Font.Name = fontName;
  19411. builder.Font.Size = 8;
  19412. builder.Font.Bold = true;
  19413. builder.Font.Color = fontColor;
  19414. builder.Write(dateTime);
  19415. builder.InsertCell();
  19416. builder.Font.Size = 9;
  19417. builder.Font.Bold = true;
  19418. builder.Font.Color = fontColor;
  19419. builder.Write(content);
  19420. builder.InsertCell();
  19421. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19422. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19423. builder.Font.Size = 9;
  19424. builder.Font.Bold = false;
  19425. builder.Font.Color = fontColor;
  19426. builder.Write(reamrk);
  19427. builder.EndRow();
  19428. }
  19429. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19430. {
  19431. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19432. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19433. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19434. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19435. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19436. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19437. }
  19438. #endregion
  19439. #region 会务倒推表
  19440. /// <summary>
  19441. /// 会务倒推表
  19442. /// Init
  19443. /// </summary>
  19444. /// <returns></returns>
  19445. [HttpPost]
  19446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19447. public async Task<IActionResult> InforRetrogressTableInit()
  19448. {
  19449. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19450. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19451. return Ok(JsonView(false, groupData.Msg));
  19452. }
  19453. /// <summary>
  19454. /// 会务倒推表
  19455. /// ExcelDownload
  19456. /// </summary>
  19457. /// <param name="dto"></param>
  19458. /// <returns></returns>
  19459. [HttpPost]
  19460. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19462. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19463. {
  19464. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19465. var validatorRes = await validator.ValidateAsync(dto);
  19466. if (!validatorRes.IsValid)
  19467. {
  19468. StringBuilder sb = new StringBuilder();
  19469. foreach (var item in validatorRes.Errors)
  19470. {
  19471. sb.AppendLine(item.ErrorMessage);
  19472. }
  19473. return Ok(JsonView(false, sb.ToString()));
  19474. }
  19475. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  19476. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  19477. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  19478. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  19479. #region Excel
  19480. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  19481. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  19482. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  19483. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  19484. var fileNamePrefix = string.Empty;
  19485. if (days >= 30)
  19486. {
  19487. tempPath += $"会务工作倒推进度表(30天).xlsx";
  19488. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  19489. }
  19490. else if (days < 30 && days > 7)
  19491. {
  19492. tempPath += $"会务工作倒推进度表(15天).xlsx";
  19493. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  19494. }
  19495. else if (days <= 7)
  19496. {
  19497. tempPath += $"会务工作倒推进度表(7天).xlsx";
  19498. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  19499. }
  19500. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  19501. fileName = CommonFun.ValidFileName(fileName);
  19502. //载入模板
  19503. WorkbookDesigner designer = new WorkbookDesigner();
  19504. designer.Workbook = new Workbook(tempPath);
  19505. designer.Process();
  19506. if (!Directory.Exists(savePath))
  19507. {
  19508. Directory.CreateDirectory(savePath);
  19509. }
  19510. string serverPath = $"{savePath}{fileName}";
  19511. designer.Workbook.Save(serverPath);
  19512. string rst = $"{servicePath}{ftpPath}{fileName}";
  19513. #endregion
  19514. return Ok(JsonView(new { url = rst }));
  19515. }
  19516. #endregion
  19517. #region 三公签证费用(签证费、代办费)
  19518. /// <summary>
  19519. /// 三公签证费用(签证费、代办费)
  19520. /// List
  19521. /// </summary>
  19522. /// <returns></returns>
  19523. [HttpPost]
  19524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19525. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  19526. {
  19527. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  19528. if (_view.Code != 0)
  19529. {
  19530. return Ok(JsonView(false, _view.Msg));
  19531. }
  19532. return Ok(JsonView(true, "操作成功!", _view.Data));
  19533. }
  19534. /// <summary>
  19535. /// 三公签证费用(签证费、代办费)
  19536. /// Add Or Update
  19537. /// </summary>
  19538. /// <returns></returns>
  19539. [HttpPost]
  19540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19541. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  19542. {
  19543. var _view = await _visaFeeInfoRep._Update(_dto);
  19544. if (_view.Code != 0)
  19545. {
  19546. return Ok(JsonView(false, _view.Msg));
  19547. }
  19548. return Ok(JsonView(true, _view.Msg));
  19549. }
  19550. #endregion
  19551. #region 酒店询价
  19552. /// <summary>
  19553. /// 酒店询价
  19554. /// Init
  19555. /// </summary>
  19556. /// <returns></returns>
  19557. [HttpPost]
  19558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19559. public async Task<IActionResult> PostHotelInquiryInit()
  19560. {
  19561. var res = await _hotelInquiryRep._Init();
  19562. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19563. return Ok(JsonView(true, res.Msg, res.Data));
  19564. }
  19565. /// <summary>
  19566. /// 酒店询价
  19567. /// page Item
  19568. /// </summary>
  19569. /// <param name="_dto"></param>
  19570. /// <returns></returns>
  19571. [HttpPost]
  19572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19573. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  19574. {
  19575. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  19576. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19577. var view = res.Data as PageDataViewBase;
  19578. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  19579. }
  19580. /// <summary>
  19581. /// 酒店询价
  19582. /// info
  19583. /// </summary>
  19584. /// <param name="_dto"></param>
  19585. /// <returns></returns>
  19586. [HttpPost]
  19587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19588. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  19589. {
  19590. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  19591. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19592. return Ok(JsonView(true, res.Msg, res.Data));
  19593. }
  19594. /// <summary>
  19595. /// 酒店询价
  19596. /// Add Or Edit
  19597. /// </summary>
  19598. /// <param name="_dto"></param>
  19599. /// <returns></returns>
  19600. [HttpPost]
  19601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19602. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  19603. {
  19604. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  19605. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19606. return Ok(JsonView(true, res.Msg, res.Data));
  19607. }
  19608. /// <summary>
  19609. /// 酒店询价
  19610. /// Del
  19611. /// </summary>
  19612. /// <param name="_dto"></param>
  19613. /// <returns></returns>
  19614. [HttpPost]
  19615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19616. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  19617. {
  19618. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  19619. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19620. return Ok(JsonView(true, res.Msg, res.Data));
  19621. }
  19622. #endregion
  19623. #region 下载匹配op行程单
  19624. /// <summary>
  19625. /// 匹配op行程单
  19626. /// Init
  19627. /// </summary>
  19628. /// <param name="dto">团组列表请求dto</param>
  19629. /// <returns></returns>
  19630. [HttpPost]
  19631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19632. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  19633. {
  19634. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19635. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19636. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  19637. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  19638. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  19639. .Where(it => it.IsDel == 0)
  19640. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  19641. .OrderByDescending(it => it.VisitStartDate)
  19642. .ToList();
  19643. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  19644. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  19645. var diids = groupInfos.Select(it => it.Id).ToList();
  19646. List<string> countrys = new List<string>();
  19647. foreach (var item in country)
  19648. {
  19649. var data = _groupRepository.FormartTeamName(item);
  19650. var dataArray = _groupRepository.GroupSplitCountry(data);
  19651. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  19652. }
  19653. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  19654. List<string> areaArray = new List<string>(); //GetGroupCityLine
  19655. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  19656. foreach (var item in areaItem)
  19657. {
  19658. string areaStr = item.Value;
  19659. if (!string.IsNullOrEmpty(areaStr))
  19660. {
  19661. string[] str1 = areaStr.Split("-");
  19662. if (str1.Length > 0)
  19663. {
  19664. areaArray.AddRange(str1);
  19665. }
  19666. }
  19667. }
  19668. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  19669. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  19670. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  19671. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  19672. .ToList();
  19673. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  19674. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  19675. .Where(it => countriesIds.Contains(it.Id))
  19676. .Select(it => new { it.Id, Name = it.Name_CN })
  19677. .ToList();
  19678. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  19679. .Select(it => it.TeamName).ToList();
  19680. stopwatch.Stop();
  19681. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  19682. }
  19683. ///// <summary>
  19684. ///// 匹配op行程单
  19685. ///// Init 查询区域数据
  19686. ///// </summary>
  19687. ///// <param name="dto">团组列表请求dto</param>
  19688. ///// <returns></returns>
  19689. //[HttpPost]
  19690. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19691. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  19692. //{
  19693. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19694. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  19695. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  19696. // if (string.IsNullOrEmpty(countriesDataStr))
  19697. // {
  19698. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  19699. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  19700. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  19701. // }
  19702. // else
  19703. // {
  19704. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  19705. // }
  19706. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  19707. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  19708. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  19709. // List<dynamic> childList = new List<dynamic>();
  19710. // int parentId = dto.CountriesId;
  19711. // if (provinceData.Count > 1)
  19712. // {
  19713. // foreach (var item1 in provinceData)
  19714. // {
  19715. // List<dynamic> childList1 = new List<dynamic>();
  19716. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  19717. // foreach (var item2 in citiesData1)
  19718. // {
  19719. // List<dynamic> childList2 = new List<dynamic>();
  19720. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19721. // foreach (var item3 in countiesData1)
  19722. // {
  19723. // childList2.Add(new
  19724. // {
  19725. // id = item3.Id,
  19726. // parentId = item2.Id,
  19727. // level = "district",
  19728. // name = item3.Name_CN,
  19729. // });
  19730. // }
  19731. // childList1.Add(new
  19732. // {
  19733. // id = item2.Id,
  19734. // parentId = item1.Id,
  19735. // level = "city",
  19736. // name = item2.Name_CN,
  19737. // childList = childList2
  19738. // });
  19739. // }
  19740. // childList.Add(new
  19741. // {
  19742. // id = item1.Id,
  19743. // parentId = parentId,
  19744. // level = "province",
  19745. // name = item1.Name_CN,
  19746. // childList = childList1
  19747. // });
  19748. // }
  19749. // //城市
  19750. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  19751. // foreach (var item2 in citiesData2)
  19752. // {
  19753. // List<dynamic> childList22 = new List<dynamic>();
  19754. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19755. // foreach (var item3 in countiesData1)
  19756. // {
  19757. // childList22.Add(new
  19758. // {
  19759. // id = item3.Id,
  19760. // parentId = item2.Id,
  19761. // level = "district",
  19762. // name = item3.Name_CN,
  19763. // });
  19764. // }
  19765. // childList.Add(new
  19766. // {
  19767. // id = item2.Id,
  19768. // parentId = parentId,
  19769. // level = "city",
  19770. // name = item2.Name_CN,
  19771. // childList = childList22
  19772. // });
  19773. // }
  19774. // }
  19775. // else
  19776. // {
  19777. // foreach (var item2 in citiesData)
  19778. // {
  19779. // string cname = item2.Name_CN;
  19780. // List<dynamic> childList1 = new List<dynamic>();
  19781. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19782. // foreach (var item3 in countiesData1)
  19783. // {
  19784. // childList1.Add(new
  19785. // {
  19786. // Id = item3.Id,
  19787. // parentId = item2.Id,
  19788. // level = "district",
  19789. // name = item3.Name_CN
  19790. // });
  19791. // }
  19792. // childList.Add(new
  19793. // {
  19794. // id = item2.Id,
  19795. // parentId = parentId,
  19796. // level = "city",
  19797. // name = item2.Name_CN,
  19798. // childList = childList1
  19799. // });
  19800. // }
  19801. // }
  19802. // stopwatch.Stop();
  19803. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  19804. //}
  19805. /// <summary>
  19806. /// 匹配op行程单
  19807. /// 接团信息列表 Page
  19808. /// </summary>
  19809. /// <param name="dto">团组列表请求dto</param>
  19810. /// <returns></returns>
  19811. [HttpPost]
  19812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19813. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  19814. {
  19815. var swatch = new Stopwatch();
  19816. swatch.Start();
  19817. #region 参数验证
  19818. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19819. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19820. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19821. #region 页面操作权限验证
  19822. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19823. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  19824. #endregion
  19825. #endregion
  19826. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19827. {
  19828. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  19829. //string sqlWhere = "";
  19830. if (!string.IsNullOrEmpty(dto.Country))
  19831. {
  19832. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  19833. }
  19834. if (!string.IsNullOrEmpty(dto.Area))
  19835. {
  19836. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  19837. }
  19838. if (!string.IsNullOrEmpty(dto.TeamName))
  19839. {
  19840. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  19841. }
  19842. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  19843. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  19844. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  19845. swatch.Stop();
  19846. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  19847. }
  19848. else
  19849. {
  19850. return Ok(JsonView(false, "查询失败"));
  19851. }
  19852. }
  19853. /// <summary>
  19854. /// 匹配op行程单
  19855. /// 行程单下载
  19856. /// </summary>
  19857. /// <param name="dto">团组列表请求dto</param>
  19858. /// <returns></returns>
  19859. [HttpPost]
  19860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19861. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  19862. {
  19863. #region 参数验证
  19864. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19865. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19866. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19867. #region 页面操作权限验证
  19868. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19869. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  19870. #endregion
  19871. #endregion
  19872. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19873. {
  19874. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  19875. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  19876. }
  19877. else
  19878. {
  19879. return Ok(JsonView(false, "下载失败!"));
  19880. }
  19881. }
  19882. #endregion
  19883. #region 国家信息 数据 注释
  19884. //[HttpPost]
  19885. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  19886. //{
  19887. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  19888. // foreach (var item in dto)
  19889. // {
  19890. // infos.Add(new Grp_GroupsTaskAssignment()
  19891. // {
  19892. // DIId = item,
  19893. // CTId = 82,
  19894. // UId = 248,
  19895. // IsEnable = 1,
  19896. // CreateUserId = 233,
  19897. // CreateTime = DateTime.Now,
  19898. // IsDel = 0
  19899. // });
  19900. // infos.Add(new Grp_GroupsTaskAssignment()
  19901. // {
  19902. // DIId = item,
  19903. // CTId = 82,
  19904. // UId = 286,
  19905. // IsEnable = 1,
  19906. // CreateUserId = 233,
  19907. // CreateTime = DateTime.Now,
  19908. // IsDel = 0
  19909. // });
  19910. // }
  19911. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  19912. // return Ok("操作成功");
  19913. //}
  19914. //public class paramJsonDto
  19915. //{
  19916. // public List<CountriesInfo> str { get; set; }
  19917. //}
  19918. //[HttpPost]
  19919. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  19920. //{
  19921. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  19922. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  19923. // List<Sys_Cities> cities = new List<Sys_Cities>();
  19924. // List<Sys_Cities> districts = new List<Sys_Cities>();
  19925. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  19926. // _sqlSugar.BeginTran();
  19927. // int countitiesIndex = 0;
  19928. // foreach (var item in dto.str)
  19929. // {
  19930. // dynamic data = item.c;
  19931. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  19932. // if (data != null)
  19933. // {
  19934. // countitiesIndex++;
  19935. // foreach (var item1 in data)
  19936. // {
  19937. // string cnname = item1.cn;
  19938. // string enname = item1.en;
  19939. // Sys_Cities provinceInfo = new Sys_Cities()
  19940. // {
  19941. // CountriesId = countriesId,
  19942. // Name_CN = cnname,
  19943. // Name_EN = enname,
  19944. // ParentId = 0,
  19945. // IsCapital = 1,
  19946. // CreateUserId = 208,
  19947. // CreateTime = DateTime.Now,
  19948. // IsDel = 0
  19949. // };
  19950. // if (item1.lv == "province") //省份
  19951. // {
  19952. // provinceInfo.Level = 1;
  19953. // int provinceId = 0;
  19954. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  19955. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  19956. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  19957. // var data1 = item1.c;
  19958. // foreach (var item2 in data1)
  19959. // {
  19960. // if (item2.lv == "city")
  19961. // {
  19962. // string citycnname = item2.cn;
  19963. // string cityenname = item2.en;
  19964. // Sys_Cities cityInfo = new Sys_Cities()
  19965. // {
  19966. // CountriesId = countriesId,
  19967. // ParentId = provinceId,
  19968. // Level = 2,
  19969. // Name_CN = citycnname,
  19970. // Name_EN = cityenname,
  19971. // IsCapital = 1,
  19972. // CreateUserId = 208,
  19973. // CreateTime = DateTime.Now,
  19974. // IsDel = 0
  19975. // };
  19976. // if (item2.c != null)
  19977. // {
  19978. // int cityId = 0;
  19979. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  19980. // if (citiesInfo != null) cityId = citiesInfo.Id;
  19981. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  19982. // foreach (var item3 in item2.c)
  19983. // {
  19984. // if (item3.lv == "district")
  19985. // {
  19986. // var districtInfo = new Sys_Cities()
  19987. // {
  19988. // CountriesId = countriesId,
  19989. // Name_CN = item3.cn,
  19990. // Name_EN = item3.en,
  19991. // Level = 3,
  19992. // ParentId = cityId,
  19993. // IsCapital = 1,
  19994. // CreateUserId = 208,
  19995. // CreateTime = DateTime.Now,
  19996. // IsDel = 0
  19997. // };
  19998. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  19999. // //{
  20000. // districts.Add(districtInfo);
  20001. // //}
  20002. // }
  20003. // }
  20004. // }
  20005. // else
  20006. // {
  20007. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20008. // //{
  20009. // cities.Add(cityInfo);
  20010. // //}
  20011. // }
  20012. // }
  20013. // }
  20014. // }
  20015. // else if (item1.lv == "city")//城市
  20016. // {
  20017. // provinceInfo.Level = 2;
  20018. // if (item1.c != null)
  20019. // {
  20020. // int cityId = 0;
  20021. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20022. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20023. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20024. // foreach (var item3 in item1.c)
  20025. // {
  20026. // if (item3.lv == "district")
  20027. // {
  20028. // var districtInfo = new Sys_Cities()
  20029. // {
  20030. // CountriesId = countriesId,
  20031. // Name_CN = item3.cn,
  20032. // Name_EN = item3.en,
  20033. // Level = 3,
  20034. // ParentId = cityId,
  20035. // IsCapital = 1,
  20036. // CreateUserId = 208,
  20037. // CreateTime = DateTime.Now,
  20038. // IsDel = 0
  20039. // };
  20040. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20041. // //{
  20042. // districts.Add(districtInfo);
  20043. // //}
  20044. // }
  20045. // }
  20046. // }
  20047. // else
  20048. // {
  20049. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20050. // //{
  20051. // cities.Add(provinceInfo);
  20052. // //}
  20053. // }
  20054. // }
  20055. // }
  20056. // }
  20057. // }
  20058. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20059. // cities = cities.Distinct().ToList();
  20060. // districts = districts.Distinct().ToList();
  20061. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20062. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20063. // cities.AddRange(districts);
  20064. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20065. // //_sqlSugar.RollbackTran();
  20066. // _sqlSugar.CommitTran();
  20067. // return Ok(JsonView(false, "操作成功!"));
  20068. //}
  20069. //[HttpPost]
  20070. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20071. //{
  20072. // List<CountitiesInfo> infos = dto.MyProperty;
  20073. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20074. // _sqlSugar.BeginTran();
  20075. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20076. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20077. // foreach (var item in infos)
  20078. // {
  20079. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20080. // if (countryInfo != null)
  20081. // {
  20082. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20083. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20084. // if (cityInfo1 != null)
  20085. // {
  20086. // cityInfo1.IsCapital = 0;
  20087. // cityInfos.Add(cityInfo1);
  20088. // }
  20089. // }
  20090. // }
  20091. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20092. // .UpdateColumns(it => it.IsCapital)
  20093. // .WhereColumns(it => it.Id)
  20094. // .ExecuteCommand();
  20095. // //_sqlSugar.RollbackTran();
  20096. // _sqlSugar.CommitTran();
  20097. // return Ok(JsonView(false, "操作成功!"));
  20098. //}
  20099. //public class CounrtiesDto
  20100. //{
  20101. // public List<CountitiesInfo> MyProperty { get; set; }
  20102. //}
  20103. //public class CountitiesInfo
  20104. //{
  20105. // /// <summary>
  20106. // /// 圣约翰
  20107. // /// </summary>
  20108. // public string capital_name_chinese { get; set; }
  20109. // /// <summary>
  20110. // ///
  20111. // /// </summary>
  20112. // public string capital_name { get; set; }
  20113. // /// <summary>
  20114. // ///
  20115. // /// </summary>
  20116. // public string country_type { get; set; }
  20117. // /// <summary>
  20118. // /// 安提瓜和巴布达
  20119. // /// </summary>
  20120. // public string country_name_chinese { get; set; }
  20121. // /// <summary>
  20122. // /// 安提瓜和巴布达
  20123. // /// </summary>
  20124. // public string country_name_chinese_short { get; set; }
  20125. // /// <summary>
  20126. // /// 安提瓜和巴布达
  20127. // /// </summary>
  20128. // public string country_name_chinese_UN { get; set; }
  20129. // /// <summary>
  20130. // ///
  20131. // /// </summary>
  20132. // public string country_name_english_abbreviation { get; set; }
  20133. // /// <summary>
  20134. // ///
  20135. // /// </summary>
  20136. // public string country_name_english_formal { get; set; }
  20137. // /// <summary>
  20138. // ///
  20139. // /// </summary>
  20140. // public string country_name_english_UN { get; set; }
  20141. // /// <summary>
  20142. // ///
  20143. // /// </summary>
  20144. // public string continent_name { get; set; }
  20145. // /// <summary>
  20146. // ///
  20147. // /// </summary>
  20148. // public string subregion_name { get; set; }
  20149. // /// <summary>
  20150. // ///
  20151. // /// </summary>
  20152. // public string country_code2 { get; set; }
  20153. // /// <summary>
  20154. // ///
  20155. // /// </summary>
  20156. // public string country_code3 { get; set; }
  20157. // /// <summary>
  20158. // ///
  20159. // /// </summary>
  20160. // public string phone_code { get; set; }
  20161. //}
  20162. //public class CountriesInfo : BasicInfo
  20163. //{
  20164. // public List<CitiesInfo> c { get; set; }
  20165. //}
  20166. //public class CitiesInfo : BasicInfo
  20167. //{
  20168. // public List<AreaInfo> c { get; set; }
  20169. //}
  20170. //public class AreaInfo : BasicInfo
  20171. //{
  20172. // public List<AreaInfo> c { get; set; }
  20173. //}
  20174. //public class BasicInfo
  20175. //{
  20176. // public string code { get; set; }
  20177. // public string cn { get; set; }
  20178. // public string lv { get; set; }
  20179. // public string en { get; set; }
  20180. //}
  20181. #endregion
  20182. #region 查看邀请方
  20183. /// <summary>
  20184. /// 查看邀请方
  20185. /// 邀请方信息 Init
  20186. /// </summary>
  20187. /// <param name="dto"></param>
  20188. /// <returns></returns>
  20189. [HttpPost]
  20190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20191. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20192. {
  20193. string sqlWhere = string.Empty;
  20194. if (!string.IsNullOrEmpty(dto.Search))
  20195. {
  20196. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20197. }
  20198. string sql = string.Format($@"Select
  20199. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20200. Id,
  20201. UnitName
  20202. From Res_InvitationOfficialActivityData
  20203. Where IsDel = 0
  20204. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20205. RefAsync<int> total = 0;
  20206. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20207. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20208. }
  20209. /// <summary>
  20210. /// 查看邀请方
  20211. /// 国家信息 Init
  20212. /// </summary>
  20213. /// <param name="dto"></param>
  20214. /// <returns></returns>
  20215. [HttpPost]
  20216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20217. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20218. {
  20219. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20220. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20221. var diids = groupInfos.Select(it => it.Id).ToList();
  20222. List<string> countrys = new List<string>();
  20223. foreach (var item in country)
  20224. {
  20225. var data = _groupRepository.FormartTeamName(item);
  20226. var dataArray = _groupRepository.GroupSplitCountry(data);
  20227. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20228. }
  20229. countrys = countrys.Distinct().ToList();
  20230. for (int i = 0; i < countrys.Count; i++)
  20231. {
  20232. string item = countrys[i];
  20233. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20234. {
  20235. countrys.Remove(item);
  20236. i--;
  20237. }
  20238. }
  20239. RefAsync<int> total = 0;
  20240. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20241. .Where(it => countrys.Contains(it.Name_CN))
  20242. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20243. .Select(it => new { id = it.Id, name = it.Name_CN })
  20244. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20245. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20246. }
  20247. /// <summary>
  20248. /// 查看邀请方
  20249. /// 城市信息 Init
  20250. /// </summary>
  20251. /// <param name="dto"></param>
  20252. /// <returns></returns>
  20253. [HttpPost]
  20254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20255. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20256. {
  20257. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20258. RefAsync<int> total = 0;
  20259. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20260. .Where(it => it.CountriesId == dto.CountiesId)
  20261. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20262. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20263. .Select(it => new { id = it.Id, name = it.Name_CN })
  20264. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20265. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20266. }
  20267. /// <summary>
  20268. /// 查看邀请方
  20269. /// 团组名称 Init
  20270. /// </summary>
  20271. /// <param name="dto"></param>
  20272. /// <returns></returns>
  20273. [HttpPost]
  20274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20275. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20276. {
  20277. var watch = new Stopwatch();
  20278. watch.Start();
  20279. RefAsync<int> total = 0;
  20280. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20281. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20282. .Where((oa, di) => oa.IsDel == 0)
  20283. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20284. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20285. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20286. .Distinct()
  20287. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20288. watch.Stop();
  20289. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20290. }
  20291. /// <summary>
  20292. /// 查看邀请方
  20293. /// 团组 & 邀请方信息
  20294. /// </summary>
  20295. /// <param name="dto"></param>
  20296. /// <returns></returns>
  20297. [HttpPost]
  20298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20299. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20300. {
  20301. var watch = new Stopwatch();
  20302. watch.Start();
  20303. RefAsync<int> total = 0;
  20304. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20305. .AS("Grp_DelegationInfo")
  20306. .Includes(x => x.InvitingInfos)
  20307. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20308. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20309. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20310. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20311. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20312. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20313. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20314. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20315. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20316. infos.ForEach(x =>
  20317. {
  20318. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20319. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20320. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20321. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20322. });
  20323. watch.Stop();
  20324. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20325. }
  20326. #endregion
  20327. #region 报批行程
  20328. /// <summary>
  20329. /// 报批行程初始化
  20330. /// </summary>
  20331. /// <param name="dto"></param>
  20332. /// <returns></returns>
  20333. [HttpPost]
  20334. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20335. {
  20336. const int chiNumber = 5;
  20337. var jw = JsonView(false);
  20338. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20339. var group = groupList.First();
  20340. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20341. group = groupList.First(x => x.Id == diid);
  20342. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20343. .Where(x => x.DiId == diid && x.IsDel == 0)
  20344. .ToArray();
  20345. var count = 1;
  20346. foreach (var item in blackCodeList)
  20347. {
  20348. if (string.IsNullOrWhiteSpace(item.Title))
  20349. {
  20350. item.Title = "未设置名称数据" + count;
  20351. }
  20352. count++;
  20353. };
  20354. if (group == null)
  20355. {
  20356. jw.Msg = "暂无团组!";
  20357. return Ok(jw);
  20358. }
  20359. var data = new
  20360. {
  20361. groupList = groupList.Select(x => new
  20362. {
  20363. x.TeamName,
  20364. x.Id
  20365. }),
  20366. content = new ArrayList(),
  20367. groupInfo = new
  20368. {
  20369. group.VisitDays,
  20370. group.TourCode,
  20371. group.VisitPNumber,
  20372. group.TeamName,
  20373. group.Id,
  20374. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20375. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  20376. },
  20377. blackCodeList = blackCodeList.Select(x => new
  20378. {
  20379. x.Title,
  20380. x.Id
  20381. }),
  20382. FileTempList = new ArrayList()
  20383. {
  20384. new { Index = 1,FileName = "旧模板" },
  20385. new { Index = 2,FileName = "省外办" },
  20386. new { Index = 3,FileName = "市外办" },
  20387. }
  20388. };
  20389. var resultArr = new ArrayList();
  20390. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20391. #region 默认不生成行程
  20392. //if (content.Count == 0)
  20393. //{
  20394. // var stay = "-";
  20395. // var cityPath = "-";
  20396. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20397. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20398. // .ToList();
  20399. // //添加城市路径以及住宿地
  20400. // //黑屏代码数据
  20401. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20402. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20403. // {
  20404. // jw = JsonView(true, "黑屏代码有误!", data);
  20405. // return Ok(jw);
  20406. // }
  20407. // data = data with
  20408. // {
  20409. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20410. // {
  20411. // x.Title,
  20412. // x.Id,
  20413. // }).ToArray())
  20414. // };
  20415. // foreach (DataRow row in dtBlack.Rows)
  20416. // {
  20417. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20418. // {
  20419. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20420. // return Ok(jw);
  20421. // }
  20422. // }
  20423. // //黑屏代码获取时间区间
  20424. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20425. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20426. // _sqlSugar.BeginTran();
  20427. // for (int i = 0; i < timeArr.Count; i++)
  20428. // {
  20429. // stay = "-";
  20430. // cityPath = "-";
  20431. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20432. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20433. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20434. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20435. // if (tbSelect.Length > 0)
  20436. // {
  20437. // List<string> threeCodeStr = new List<string>();
  20438. // foreach (var item in tbSelect)
  20439. // {
  20440. // var threeCode = item["Three"].ToString() ?? "";
  20441. // if (threeCode.Length == 6)
  20442. // {
  20443. // var start = threeCode.Substring(0, 3);
  20444. // var end = threeCode.Substring(3, 3);
  20445. // if (threeCodeStr.Count == 0)
  20446. // {
  20447. // threeCodeStr.Add(start);
  20448. // threeCodeStr.Add(end);
  20449. // }
  20450. // else
  20451. // {
  20452. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20453. // {
  20454. // threeCodeStr.Add(end);
  20455. // }
  20456. // else
  20457. // {
  20458. // threeCodeStr.Add(start);
  20459. // threeCodeStr.Add(end);
  20460. // }
  20461. // }
  20462. // }
  20463. // }
  20464. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20465. // var last = threeCodeStr.Last();
  20466. // foreach (var item in threeCodeStr)
  20467. // {
  20468. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20469. // if (item.Equals(last))
  20470. // {
  20471. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20472. // }
  20473. // }
  20474. // cityPath = cityPath.Trim('-');
  20475. // }
  20476. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  20477. // appro.Diid = diid ?? -1;
  20478. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20479. // appro.Id = thisId;
  20480. // appro.CreateUserId = dto.UserId;
  20481. // appro.CreateTime = DateTime.Now;
  20482. // content.Add(appro);
  20483. // }
  20484. // _sqlSugar.CommitTran();
  20485. //}
  20486. #endregion
  20487. foreach (var x in content)
  20488. {
  20489. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  20490. if (chiList.Count < chiNumber)
  20491. {
  20492. for (int i = chiList.Count; i < chiNumber; i++)
  20493. {
  20494. chiList.Add(new Grp_ApprovalTravelDetails());
  20495. }
  20496. }
  20497. resultArr.Add(new
  20498. {
  20499. x.Id,
  20500. x.Date,
  20501. x.Diid,
  20502. chiList = chiList.Select(x1 => new
  20503. {
  20504. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20505. x1.Details,
  20506. x1.ParentId,
  20507. x1.Id
  20508. })
  20509. });
  20510. }
  20511. data = data with
  20512. {
  20513. content = resultArr,
  20514. };
  20515. jw = JsonView(true, "获取成功!", data);
  20516. return Ok(jw);
  20517. }
  20518. /// <summary>
  20519. /// 报批行程删除
  20520. /// </summary>
  20521. /// <param name="dto"></param>
  20522. /// <returns></returns>
  20523. [HttpPost]
  20524. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  20525. {
  20526. var jw = JsonView(false);
  20527. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20528. if (group == null)
  20529. {
  20530. jw.Msg = "团组参数有误!";
  20531. return Ok(jw);
  20532. }
  20533. try
  20534. {
  20535. _sqlSugar.BeginTran();
  20536. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  20537. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  20538. {
  20539. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20540. DeleteUserId = dto.uesrId,
  20541. IsDel = 1
  20542. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  20543. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  20544. {
  20545. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20546. DeleteUserId = dto.uesrId,
  20547. IsDel = 1
  20548. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  20549. _sqlSugar.CommitTran();
  20550. jw = JsonView(true, "删除成功");
  20551. }
  20552. catch (Exception ex)
  20553. {
  20554. jw = JsonView(false, ex.Message);
  20555. }
  20556. return Ok(jw);
  20557. }
  20558. /// <summary>
  20559. /// 报批行程保存
  20560. /// </summary>
  20561. /// <param name="dto"></param>
  20562. /// <returns></returns>
  20563. [HttpPost]
  20564. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  20565. {
  20566. var jw = JsonView(false);
  20567. var Find = dto.Arr.Find(x => x.id == 0);
  20568. if (Find != null)
  20569. {
  20570. jw.Msg = "生成的ID为0!";
  20571. return Ok(jw);
  20572. }
  20573. foreach (var item in dto.Arr)
  20574. {
  20575. foreach (var chi in item.chiList)
  20576. {
  20577. if (chi.parentId == 0)
  20578. {
  20579. chi.parentId = item.id;
  20580. }
  20581. }
  20582. }
  20583. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  20584. _sqlSugar.BeginTran();
  20585. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  20586. {
  20587. var parentIds = dto.Arr.Select(x => x.id).ToList();
  20588. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  20589. {
  20590. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20591. DeleteUserId = dto.UserId,
  20592. IsDel = 1
  20593. }).ExecuteCommand();
  20594. }
  20595. try
  20596. {
  20597. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  20598. {
  20599. CreateTime = DateTime.Now,
  20600. CreateUserId = dto.UserId,
  20601. Details = x.details,
  20602. ParentId = x.parentId,
  20603. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20604. Remark = "",
  20605. IsDel = 0
  20606. }).ToList()).ExecuteCommand();
  20607. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  20608. {
  20609. Id = x.id,
  20610. Details = x.details,
  20611. ParentId = x.parentId,
  20612. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20613. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  20614. {
  20615. Details = x.Details,
  20616. ParentId = x.ParentId,
  20617. Time = x.Time
  20618. }).ExecuteCommand();
  20619. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  20620. {
  20621. Id = x.id,
  20622. Date = x.date,
  20623. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  20624. {
  20625. Date = x.Date
  20626. }).ExecuteCommand();
  20627. _sqlSugar.CommitTran();
  20628. jw = JsonView(true, "保存成功!");
  20629. }
  20630. catch (Exception ex)
  20631. {
  20632. _sqlSugar.RollbackTran();
  20633. jw = JsonView(false, "保存失败!" + ex.Message);
  20634. }
  20635. return Ok(jw);
  20636. }
  20637. /// <summary>
  20638. /// 报批行程生成
  20639. /// </summary>
  20640. /// <param name="dto"></param>
  20641. /// <returns></returns>
  20642. [HttpPost]
  20643. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  20644. {
  20645. var jw = JsonView(false);
  20646. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20647. if (group == null)
  20648. {
  20649. jw.Msg = "暂无该团组!";
  20650. return Ok(jw);
  20651. }
  20652. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  20653. //黑屏代码数据
  20654. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  20655. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20656. {
  20657. jw.Msg = "黑屏代码有误!";
  20658. return Ok(jw);
  20659. }
  20660. foreach (DataRow row in dtBlack.Rows)
  20661. {
  20662. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20663. {
  20664. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  20665. return Ok(jw);
  20666. }
  20667. }
  20668. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  20669. var resultArr = new ArrayList();
  20670. //if (officialActivitiesArr.Count == 0)
  20671. //{
  20672. // jw.Msg = "暂无公务出访信息!";
  20673. // return Ok(jw);
  20674. //}
  20675. try
  20676. {
  20677. _sqlSugar.BeginTran();
  20678. DeleteApprovalJourney(new
  20679. Domain.Dtos.Groups.DeleteApprovalJourney
  20680. {
  20681. Diid = dto.Diid,
  20682. uesrId = dto.Userid
  20683. });
  20684. var stay = "-";
  20685. var cityPath = "-";
  20686. var arriveCountry = string.Empty;
  20687. //添加城市路径以及住宿地
  20688. //黑屏代码获取时间区间
  20689. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20690. var empty = "【未收入该三字码!请机票同事录入】";
  20691. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20692. #region 配置公务活动时间
  20693. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  20694. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  20695. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  20696. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  20697. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  20698. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20699. {
  20700. 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" }),
  20701. 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"}),
  20702. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20703. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  20704. };
  20705. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20706. {
  20707. 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" }),
  20708. 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"}),
  20709. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20710. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  20711. };
  20712. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  20713. {
  20714. 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" }),
  20715. 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"}),
  20716. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  20717. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  20718. };
  20719. #endregion
  20720. var nextDayNum = 0;
  20721. for (int i = 0; i < timeArr.Count; i++)
  20722. {
  20723. stay = "-";
  20724. cityPath = "-";
  20725. var chiarr = new List<Grp_ApprovalTravelDetails>();
  20726. DateTime NewData = DateTime.Parse(timeArr[i]);
  20727. //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();
  20728. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20729. if (nextDayNum > 0)
  20730. {
  20731. nextDayNum--;
  20732. }
  20733. if (tbSelect.Length > 0)
  20734. {
  20735. List<string> threeCodeStr = new List<string>();
  20736. bool isTrade = false;
  20737. string trip = string.Empty;
  20738. foreach (var item in tbSelect)
  20739. {
  20740. if (nextDayNum == 0)
  20741. {
  20742. nextDayNum = Convert.ToInt32(item["Sign"]);
  20743. }
  20744. var airStartTime = item["StartTime"].ToString() ?? "0000";
  20745. var airEndTime = item["EndTime"].ToString() ?? "0000";
  20746. var takeOffTime = DateTime.Parse(timeArr[i]);
  20747. var fallToTime = DateTime.Parse(timeArr[i]);
  20748. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  20749. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  20750. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  20751. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  20752. if (nextDayNum > 0)
  20753. {
  20754. fallToTime = fallToTime.AddDays(nextDayNum);
  20755. }
  20756. trip = string.Empty;
  20757. var start = string.Empty;
  20758. var end = string.Empty;
  20759. var threeCode = item["Three"].ToString() ?? "";
  20760. if (threeCode.Length == 6)
  20761. {
  20762. start = threeCode.Substring(0, 3);
  20763. end = threeCode.Substring(3, 3);
  20764. if (threeCodeStr.Count == 0)
  20765. {
  20766. threeCodeStr.Add(start);
  20767. threeCodeStr.Add(end);
  20768. }
  20769. else
  20770. {
  20771. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20772. {
  20773. threeCodeStr.Add(end);
  20774. }
  20775. else
  20776. {
  20777. threeCodeStr.Add(start);
  20778. threeCodeStr.Add(end);
  20779. }
  20780. }
  20781. }
  20782. //处理机票信息
  20783. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  20784. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  20785. if (start_Object == null)
  20786. {
  20787. start_Object = new Res_ThreeCode()
  20788. {
  20789. AirPort = empty,
  20790. AirPort_En = empty,
  20791. City = empty,
  20792. Country = empty,
  20793. Four = empty,
  20794. Three = empty,
  20795. };
  20796. }
  20797. if (end_Object == null)
  20798. {
  20799. end_Object = new Res_ThreeCode()
  20800. {
  20801. AirPort = empty,
  20802. AirPort_En = empty,
  20803. City = empty,
  20804. Country = empty,
  20805. Four = empty,
  20806. Three = empty,
  20807. };
  20808. }
  20809. //机型判断
  20810. string airModel = item["AirModel"].ToString();
  20811. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  20812. string flightTime = item["FlightTime"].ToString();
  20813. flightTime = ParseBlackTime(flightTime);
  20814. //航班号
  20815. string flightcode = item["Fliagtcode"].ToString();
  20816. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  20817. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  20818. if (aircompany == null)
  20819. {
  20820. aircompany = new Res_AirCompany
  20821. {
  20822. CnName = hsEmpty,
  20823. EnName = hsEmpty,
  20824. ShortCode = hsEmpty,
  20825. };
  20826. }
  20827. //航班前公务安排
  20828. if (tbSelect.First().Equals(item) && i != 0)
  20829. {
  20830. foreach (var takeoff in takeoffTimes)
  20831. {
  20832. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  20833. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  20834. {
  20835. foreach (var addTime in takeoff.Item2)
  20836. {
  20837. chiarr.Add(new Grp_ApprovalTravelDetails
  20838. {
  20839. Time = addTime,
  20840. CreateTime = DateTime.Now,
  20841. CreateUserId = dto.Userid,
  20842. ParentId = 0,
  20843. Details = "公务活动"
  20844. });
  20845. }
  20846. break;
  20847. }
  20848. }
  20849. }
  20850. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  20851. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  20852. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  20853. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  20854. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  20855. if (isTrade)
  20856. {
  20857. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  20858. trip += "(转机不出机场)。";
  20859. }
  20860. //else
  20861. //{
  20862. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  20863. //}
  20864. chiarr.Add(new Grp_ApprovalTravelDetails
  20865. {
  20866. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  20867. CreateTime = DateTime.Now,
  20868. CreateUserId = dto.Userid,
  20869. ParentId = 0,
  20870. Details = trip
  20871. });
  20872. //最后一条到达的时间安排公务
  20873. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  20874. {
  20875. bool isCheckCountry = false;
  20876. if (end_Object.Country != arriveCountry)
  20877. {
  20878. arriveCountry = end_Object.Country;
  20879. isCheckCountry = true;
  20880. }
  20881. if (nextDayNum == 0)
  20882. {
  20883. //需要入境的情况
  20884. if (isCheckCountry)
  20885. {
  20886. foreach (var fallTime in fallTimesCheckCountry)
  20887. {
  20888. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20889. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20890. {
  20891. foreach (var addTime in fallTime.Item2)
  20892. {
  20893. chiarr.Add(new Grp_ApprovalTravelDetails
  20894. {
  20895. Time = addTime,
  20896. CreateTime = DateTime.Now,
  20897. CreateUserId = dto.Userid,
  20898. ParentId = 0,
  20899. Details = "公务活动"
  20900. });
  20901. }
  20902. break;
  20903. }
  20904. }
  20905. }
  20906. else
  20907. {
  20908. foreach (var fallTime in fallTimesNotCheckCountry)
  20909. {
  20910. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20911. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20912. {
  20913. foreach (var addTime in fallTime.Item2)
  20914. {
  20915. chiarr.Add(new Grp_ApprovalTravelDetails
  20916. {
  20917. Time = addTime,
  20918. CreateTime = DateTime.Now,
  20919. CreateUserId = dto.Userid,
  20920. ParentId = 0,
  20921. Details = "公务活动"
  20922. });
  20923. }
  20924. break;
  20925. }
  20926. }
  20927. }
  20928. }
  20929. }
  20930. }
  20931. //添加乘车语句
  20932. //chiarr.Add(new Grp_ApprovalTravelDetails
  20933. //{
  20934. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  20935. // CreateTime = DateTime.Now,
  20936. // CreateUserId = dto.Userid,
  20937. // ParentId = 0,
  20938. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  20939. //});
  20940. //if (i != timeArr.Count - 1)
  20941. //{
  20942. // fallToTime = fallToTime.AddHours(2.5);
  20943. // foreach (var item in Times)
  20944. // {
  20945. // //排列公务时间
  20946. // if (fallToTime.Hour < item.Item1)
  20947. // {
  20948. // chiarr.Add(new Grp_ApprovalTravelDetails
  20949. // {
  20950. // Time = $"{item.Item2} - {item.Item3}",
  20951. // CreateTime = DateTime.Now,
  20952. // CreateUserId = dto.Userid,
  20953. // ParentId = 0,
  20954. // Details = "公务活动"
  20955. // });
  20956. // }
  20957. // }
  20958. //}
  20959. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20960. var last = threeCodeStr.Last();
  20961. foreach (var item in threeCodeStr)
  20962. {
  20963. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20964. if (item.Equals(last))
  20965. {
  20966. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20967. }
  20968. }
  20969. cityPath = cityPath.Trim('-');
  20970. }
  20971. else
  20972. {
  20973. foreach (var item in Times)
  20974. {
  20975. chiarr.Add(new Grp_ApprovalTravelDetails
  20976. {
  20977. Time = $"{item.Item2} - {item.Item3}",
  20978. CreateTime = DateTime.Now,
  20979. CreateUserId = dto.Userid,
  20980. ParentId = 0,
  20981. Details = "公务活动"
  20982. });
  20983. }
  20984. }
  20985. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20986. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20987. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  20988. appro.Diid = dto.Diid;
  20989. appro.CreateUserId = dto.Userid;
  20990. appro.CreateTime = DateTime.Now;
  20991. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20992. appro.Id = thisId;
  20993. //foreach (var item in gwinfo)
  20994. //{
  20995. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  20996. // chi.Details = "拜访" + item.Client;
  20997. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  20998. // {
  20999. // chi.Details += "," + item.ReqSample;
  21000. // }
  21001. // chi.ParentId = thisId;
  21002. // chi.Time = item.Time;
  21003. // chiarr.Add(chi);
  21004. //}
  21005. if (chiarr.Count < 6)
  21006. {
  21007. for (int j = chiarr.Count; j < 6; j++)
  21008. {
  21009. chiarr.Add(new
  21010. Grp_ApprovalTravelDetails());
  21011. }
  21012. }
  21013. resultArr.Add(new
  21014. {
  21015. appro.Id,
  21016. appro.Date,
  21017. appro.Diid,
  21018. chiList = chiarr.Select(x1 => new
  21019. {
  21020. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21021. x1.Details,
  21022. x1.ParentId,
  21023. x1.Id
  21024. })
  21025. });
  21026. }
  21027. _sqlSugar.CommitTran();
  21028. jw = JsonView(true, "生成成功!", resultArr);
  21029. }
  21030. catch (Exception ex)
  21031. {
  21032. jw.Code = 400;
  21033. jw.Msg = "生成失败!" + ex.Message;
  21034. }
  21035. return Ok(jw);
  21036. }
  21037. /// <summary>
  21038. /// 报批行程word导出
  21039. /// </summary>
  21040. /// <param name="dto"></param>
  21041. /// <returns></returns>
  21042. [HttpPost]
  21043. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21044. {
  21045. var jw = JsonView(false);
  21046. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21047. if (group == null)
  21048. {
  21049. jw.Msg = "暂无该团组!";
  21050. return Ok(jw);
  21051. }
  21052. //模板路径
  21053. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21054. var fileName = string.Empty;
  21055. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21056. bool bold = false;
  21057. if (dto.FileIndex == 1)
  21058. {
  21059. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21060. }
  21061. else if (dto.FileIndex == 2)
  21062. {
  21063. fileName = "省外办-报批.docx";
  21064. bold = false;
  21065. titleFont = "方正黑体简体";
  21066. timeFont = "Times New Roman";
  21067. contentFont = "方正仿宋_GBK";
  21068. }
  21069. else if (dto.FileIndex == 3)
  21070. {
  21071. fileName = "市外办-报批.docx";
  21072. titleFont = "方正黑体简体";
  21073. timeFont = "Times New Roman";
  21074. contentFont = "方正仿宋简体";
  21075. }
  21076. tempPath = tempPath + fileName;
  21077. //载入模板
  21078. Document doc = new Document(tempPath);
  21079. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21080. //获取所填表格的序数
  21081. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21082. Aspose.Words.Tables.Row titleRowClone = null;
  21083. Aspose.Words.Tables.Row CenterRowClone = null;
  21084. int index = 0;
  21085. int indexChi = 0;
  21086. int SetIndex = 0;
  21087. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21088. //获取数据,放到datatable
  21089. foreach (var item in ApprovalTravelArr)
  21090. {
  21091. if (index > 0)
  21092. {
  21093. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21094. tableOne.AppendChild(titleRowClone);
  21095. }
  21096. var textTime = item.Date;
  21097. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21098. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21099. SetIndex++;
  21100. if (ChiRep.Count > 0)
  21101. {
  21102. foreach (var itemChi in ChiRep)
  21103. {
  21104. var txtTime = itemChi.Time;
  21105. var txtDetail = itemChi.Details;
  21106. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21107. {
  21108. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21109. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21110. //indexChi++;
  21111. //SetIndex++;
  21112. break;
  21113. }
  21114. if (indexChi > 0)
  21115. {
  21116. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21117. tableOne.AppendChild(CenterRowClone);
  21118. }
  21119. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21120. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21121. indexChi++;
  21122. SetIndex++;
  21123. }
  21124. }
  21125. //else
  21126. //{
  21127. // if (indexChi > 0)
  21128. // {
  21129. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21130. // tableOne.AppendChild(CenterRowClone);
  21131. // }
  21132. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21133. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21134. // indexChi++;
  21135. // SetIndex++;
  21136. //}
  21137. index++;
  21138. }
  21139. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21140. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21141. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21142. jw.Code = 200;
  21143. jw.Msg = "";
  21144. return Ok(jw);
  21145. }
  21146. private string ParseBlackTime(string time)
  21147. {
  21148. // 匹配可能只有分钟的情况
  21149. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21150. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21151. if (match.Success)
  21152. {
  21153. string hours = match.Groups[1].Value;
  21154. string minutes = match.Groups[2].Value;
  21155. // 如果小时部分为空,则只显示分钟
  21156. if (string.IsNullOrEmpty(hours))
  21157. {
  21158. return $"{minutes}分钟";
  21159. }
  21160. // 如果分钟部分为空,则只显示小时
  21161. else if (string.IsNullOrEmpty(minutes))
  21162. {
  21163. return $"{hours}小时";
  21164. }
  21165. // 否则显示完整格式
  21166. else
  21167. {
  21168. return $"{hours}小时{minutes}分钟";
  21169. }
  21170. }
  21171. else
  21172. {
  21173. return "未知时长";
  21174. }
  21175. }
  21176. private string intToString(int numberVal)
  21177. {
  21178. string numberval = numberVal.ToString();
  21179. Dictionary<char, string> Number = new Dictionary<char, string>();
  21180. Number.Add('1', "一");
  21181. Number.Add('2', "二");
  21182. Number.Add('3', "三");
  21183. Number.Add('4', "四");
  21184. Number.Add('5', "五");
  21185. Number.Add('6', "六");
  21186. Number.Add('7', "七");
  21187. Number.Add('8', "八");
  21188. Number.Add('9', "九");
  21189. string stringNumberVal = string.Empty;
  21190. for (int i = 0; i < numberval.Length; i++)
  21191. {
  21192. if (i == 0)
  21193. {
  21194. stringNumberVal += Number[numberval[i]];
  21195. }
  21196. else if (i >= 1)
  21197. {
  21198. if (numberval[i] == '0')
  21199. {
  21200. stringNumberVal = "十";
  21201. }
  21202. else
  21203. {
  21204. stringNumberVal += "十" + Number[numberval[i]];
  21205. }
  21206. }
  21207. }
  21208. return stringNumberVal;
  21209. }
  21210. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21211. {
  21212. //获取table中的某个单元格,从0开始
  21213. Cell lshCell = table.Rows[rows].Cells[cells];
  21214. //将单元格中段落移除
  21215. foreach (Paragraph item in lshCell.Paragraphs)
  21216. {
  21217. lshCell.Paragraphs.Remove(item);
  21218. }
  21219. if (val.Contains("\r\n"))
  21220. {
  21221. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21222. foreach (var item in spArr)
  21223. {
  21224. //新建一个段落
  21225. Paragraph p = new Paragraph(doc);
  21226. var r = new Run(doc, item);
  21227. //设置字体
  21228. if (!string.IsNullOrEmpty(font))
  21229. {
  21230. r.Font.Name = font;
  21231. }
  21232. r.Font.Bold = bold;
  21233. //把设置的值赋给之前新建的段落
  21234. p.AppendChild(r);
  21235. //将此段落加到单元格内
  21236. lshCell.AppendChild(p);
  21237. }
  21238. }
  21239. else
  21240. {
  21241. //新建一个段落
  21242. Paragraph p = new Paragraph(doc);
  21243. var r = new Run(doc, val);
  21244. //设置字体
  21245. if (!string.IsNullOrEmpty(font))
  21246. {
  21247. r.Font.Name = font;
  21248. }
  21249. r.Font.Bold = bold;
  21250. //把设置的值赋给之前新建的段落
  21251. p.AppendChild(r);
  21252. //将此段落加到单元格内
  21253. lshCell.AppendChild(p);
  21254. }
  21255. }
  21256. //[HttpPost]
  21257. //public async Task<IActionResult> ServerHttp(string paramStr)
  21258. //{
  21259. // paramStr = paramStr.TrimEnd('\'');
  21260. // paramStr = paramStr.TrimStart('\'');
  21261. // JsonView jw = JsonView(false);
  21262. // JObject param = JObject.Parse(paramStr);
  21263. // if (!param.ContainsKey("url"))
  21264. // {
  21265. // jw.Msg = "url null";
  21266. // return Ok(jw);
  21267. // }
  21268. // string url = param["url"]!.ToString();
  21269. // var methon = "get";
  21270. // Dictionary<string, string> headValues = null;
  21271. // string bodyStr = string.Empty;
  21272. // if (param.ContainsKey("methon"))
  21273. // {
  21274. // methon = param["methon"]!.ToString().ToLower();
  21275. // }
  21276. // if (param.ContainsKey("header"))
  21277. // {
  21278. // var header = param["header"]!.ToString();
  21279. // JObject headerJobject = JObject.Parse(header);
  21280. // headValues = new Dictionary<string, string>();
  21281. // foreach (JProperty item in headerJobject.Properties())
  21282. // {
  21283. // var value = item.Value.ToString();
  21284. // var head = item.Path;
  21285. // headValues.Add(head, value);
  21286. // }
  21287. // }
  21288. // HttpClient client = new HttpClient();
  21289. // string responseString = string.Empty;
  21290. // StringContent content = null;
  21291. // if (headValues != null)
  21292. // {
  21293. // foreach (var item in headValues.Keys)
  21294. // {
  21295. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  21296. // {
  21297. // if (param.ContainsKey("body"))
  21298. // {
  21299. // bodyStr = param["body"]!.ToString();
  21300. // }
  21301. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  21302. // }
  21303. // else
  21304. // {
  21305. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  21306. // }
  21307. // }
  21308. // }
  21309. // try
  21310. // {
  21311. // if (methon == "get")
  21312. // {
  21313. // responseString = await client.GetStringAsync(url);
  21314. // }
  21315. // else if (methon == "post")
  21316. // {
  21317. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  21318. // {
  21319. // Content = content
  21320. // };
  21321. // var response = await client.SendAsync(request);
  21322. // try
  21323. // {
  21324. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  21325. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  21326. // {
  21327. // using (StreamReader reader = new StreamReader(gzipStream))
  21328. // {
  21329. // responseString = await reader.ReadToEndAsync();
  21330. // }
  21331. // }
  21332. // }
  21333. // catch (Exception)
  21334. // {
  21335. // responseString = await response.Content.ReadAsStringAsync();
  21336. // }
  21337. // }
  21338. // else
  21339. // {
  21340. // responseString = "methon error";
  21341. // }
  21342. // jw = JsonView(true, "success", responseString);
  21343. // }
  21344. // catch (Exception ex)
  21345. // {
  21346. // jw.Msg = "error " + ex.Message;
  21347. // jw.Data = ex.StackTrace;
  21348. // }
  21349. // finally
  21350. // {
  21351. // client.Dispose();
  21352. // }
  21353. // return Ok(jw);
  21354. //}
  21355. #endregion
  21356. #region 团组接待意见调查
  21357. /// <summary>
  21358. /// 团组接待意见调查 - 信息管理
  21359. /// 基础数据(团组)
  21360. /// </summary>
  21361. /// <returns></returns>
  21362. [HttpGet]
  21363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21364. public async Task<IActionResult> OpinionaireInit()
  21365. {
  21366. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21367. .Select(x => new
  21368. {
  21369. x.Id,
  21370. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21371. })
  21372. .OrderByDescending(x => x.Id)
  21373. .ToListAsync();
  21374. return Ok(JsonView(groupData, groupData.Count));
  21375. }
  21376. /// <summary>
  21377. /// 团组接待意见调查 - 信息管理
  21378. /// 列表
  21379. /// </summary>
  21380. /// <param name="groupId"></param>
  21381. /// <returns></returns>
  21382. [HttpGet("{groupId}")]
  21383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21384. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21385. {
  21386. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21387. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21388. .Select(x => new
  21389. {
  21390. x.Id,
  21391. x.TourGuideName,
  21392. x.CityName,
  21393. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21394. x.CreateTime
  21395. })
  21396. .OrderBy(x => x.Id)
  21397. .ToListAsync();
  21398. return Ok(JsonView(data));
  21399. }
  21400. /// <summary>
  21401. /// 团组接待意见调查 - 信息管理
  21402. /// 保存
  21403. /// </summary>
  21404. /// <param name="dto"></param>
  21405. /// <returns></returns>
  21406. [HttpPost]
  21407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21408. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21409. {
  21410. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21411. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21412. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21413. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21414. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21415. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21416. _opinionaireRep.BeginTran();
  21417. if (addData != null && addData.Count > 0)
  21418. {
  21419. foreach (var item in addData)
  21420. {
  21421. item.CreateUserId = currUserInfo.UserId;
  21422. item.DiId = dto.DiId;
  21423. }
  21424. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21425. }
  21426. if (updData != null && updData.Count > 0)
  21427. {
  21428. var upd = await _opinionaireRep._sqlSugar
  21429. .Updateable(updData)
  21430. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21431. .WhereColumns(x => new { x.Id })
  21432. .ExecuteCommandAsync();
  21433. }
  21434. _opinionaireRep.CommitTran();
  21435. return Ok(JsonView("操作成功!"));
  21436. }
  21437. /// <summary>
  21438. /// 团组接待意见调查 - 信息管理
  21439. /// 删除
  21440. /// </summary>
  21441. /// <param name="id"></param>
  21442. /// <returns></returns>
  21443. [HttpDelete("{id}")]
  21444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21445. public async Task<IActionResult> OpinionaireManageDel(int id)
  21446. {
  21447. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21448. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21449. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21450. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21451. if (!del) return Ok(JsonView("操作失败!"));
  21452. return Ok(JsonView("操作成功!"));
  21453. }
  21454. /// <summary>
  21455. /// 团组接待意见调查 - 用户
  21456. /// 列表
  21457. /// </summary>
  21458. /// <param name="diId"></param>
  21459. /// <returns></returns>
  21460. [HttpGet("{diId}")]
  21461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21462. public async Task<IActionResult> OpinionaireUserList(int diId)
  21463. {
  21464. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21465. var sql = string.Format(@"
  21466. SELECT
  21467. o.Id,
  21468. o.DiId,
  21469. di.TeamName AS 'GroupName',
  21470. di.VisitPNumber AS 'PeopleNumber',
  21471. di.ClientName AS 'LeadGroup',
  21472. di.VisitCountry AS 'Travel',
  21473. di.VisitDays AS 'Days',
  21474. o.CityName,
  21475. o.TourGuideName,
  21476. o.Catering,
  21477. o.CateringReason,
  21478. o.Stay,
  21479. o.StayReason,
  21480. o.[Route],
  21481. o.RouteReason,
  21482. o.OfficialActivity,
  21483. o.OfficialActivityReason,
  21484. o.TourGuide,
  21485. o.TourGuideReason,
  21486. o.[Translate],
  21487. o.TranslateReason,
  21488. o.Trip,
  21489. o.TripReason,
  21490. o.ESFileName,
  21491. o.SignatureDate,
  21492. o.Remark
  21493. FROM
  21494. Grp_Opinionaire o
  21495. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21496. WHERE
  21497. o.IsDel = 0
  21498. AND o.DiId = {0}
  21499. ORDER BY
  21500. o.Id ASC", diId);
  21501. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21502. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21503. return Ok(JsonView(data));
  21504. }
  21505. /// <summary>
  21506. /// 团组接待意见调查 - 用户
  21507. /// 保存
  21508. /// </summary>
  21509. /// <param name="dto"></param>
  21510. /// <returns></returns>
  21511. [HttpPost]
  21512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21513. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21514. {
  21515. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21516. foreach (var item in dto)
  21517. {
  21518. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21519. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21520. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21521. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21522. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21523. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21524. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21525. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21526. }
  21527. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21528. if (!Directory.Exists(filePathBase))
  21529. {
  21530. Directory.CreateDirectory(filePathBase);
  21531. }
  21532. #region 上传文件
  21533. var filePaths = new List<string>();
  21534. foreach (var item in dto)
  21535. {
  21536. var file = item.File;
  21537. // 将文件保存到指定位置
  21538. var filePath = Path.Combine(filePathBase, file.FileName);
  21539. using (var stream = new FileStream(filePath, FileMode.Create))
  21540. {
  21541. await file.CopyToAsync(stream);
  21542. }
  21543. //验证文件是否上传成功
  21544. if (!System.IO.File.Exists(filePath))
  21545. {
  21546. foreach (var filePathStr in filePaths)
  21547. {
  21548. System.IO.File.Delete(filePathStr);
  21549. }
  21550. return Ok(JsonView(false, "文件上传失败!"));
  21551. }
  21552. item.ESFileName = file.FileName;
  21553. }
  21554. #endregion
  21555. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  21556. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  21557. .UpdateColumns(x => new
  21558. {
  21559. x.Catering,
  21560. x.CateringReason,
  21561. x.Stay,
  21562. x.StayReason,
  21563. x.Route,
  21564. x.RouteReason,
  21565. x.OfficialActivity,
  21566. x.OfficialActivityReason,
  21567. x.TourGuide,
  21568. x.TourGuideReason,
  21569. x.Translate,
  21570. x.TranslateReason,
  21571. x.Trip,
  21572. x.TripReason,
  21573. x.ESFileName,
  21574. x.SignatureDate,
  21575. x.Remark
  21576. })
  21577. .WhereColumns(x => new { x.Id })
  21578. .ExecuteCommandAsync();
  21579. if (upd < 1)
  21580. {
  21581. foreach (var filePathStr in filePaths)
  21582. {
  21583. System.IO.File.Delete(filePathStr);
  21584. }
  21585. return Ok(JsonView(false));
  21586. }
  21587. return Ok(JsonView(true));
  21588. }
  21589. #endregion
  21590. #region 团组餐厅相关信息
  21591. /// <summary>
  21592. /// 团组相关餐厅信息
  21593. /// 基础数据(团组)
  21594. /// </summary>
  21595. /// <returns></returns>
  21596. [HttpGet]
  21597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21598. public async Task<IActionResult> RestaurantInit()
  21599. {
  21600. return Ok(await _restaurantRep.InitAsync());
  21601. }
  21602. /// <summary>
  21603. /// 团组相关餐厅信息
  21604. /// Item
  21605. /// </summary>
  21606. /// <param name="dto"></param>
  21607. /// <returns></returns>
  21608. [HttpPost]
  21609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21610. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  21611. {
  21612. int portType = dto.PortType,
  21613. groupId = dto.GroupId;
  21614. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21615. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21616. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  21617. }
  21618. /// <summary>
  21619. /// 团组相关餐厅信息
  21620. /// List
  21621. /// </summary>
  21622. /// <param name="dto"></param>
  21623. /// <returns></returns>
  21624. [HttpPost]
  21625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21626. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  21627. {
  21628. int portType = dto.PortType,
  21629. groupId = dto.GroupId;
  21630. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21631. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21632. var sql = string.Format(@" SELECT
  21633. ri.Id,
  21634. ri.GroupId,
  21635. ri.Date,
  21636. ri.StartTime,
  21637. ri.EndTime,
  21638. CASE WHEN ri.Type = 1 THEN '早餐'
  21639. WHEN ri.Type = 2 THEN '午餐'
  21640. WHEN ri.Type = 3 THEN '晚餐'
  21641. ELSE '其他'
  21642. END AS 'Type',
  21643. ri.Name,
  21644. ri.Address,
  21645. ri.Tel,
  21646. ri.Remark,
  21647. ri.CreateTime,
  21648. u.CnName AS CreateUserName
  21649. FROM
  21650. Grp_RestaurantInfo ri
  21651. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  21652. WHERE
  21653. ri.IsDel = 0
  21654. AND ri.GroupId = {0}
  21655. ORDER BY
  21656. ri.Date ASC
  21657. ", groupId);
  21658. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  21659. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  21660. return Ok(JsonView(infos));
  21661. }
  21662. /// <summary>
  21663. /// 团组相关餐厅信息
  21664. /// Info
  21665. /// </summary>
  21666. /// <param name="dto"></param>
  21667. /// <returns></returns>
  21668. [HttpPost]
  21669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21670. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  21671. {
  21672. int portType = dto.PortType,
  21673. id = dto.Id;
  21674. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21675. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21676. return Ok(await _restaurantRep.InfoAsync(portType, id));
  21677. }
  21678. /// <summary>
  21679. /// 团组相关餐厅信息
  21680. /// Op
  21681. /// </summary>
  21682. /// <param name="dto"></param>
  21683. /// <returns></returns>
  21684. [HttpPost]
  21685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21686. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  21687. {
  21688. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21689. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21690. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  21691. return Ok(await _restaurantRep.OpAsync(dto));
  21692. }
  21693. /// <summary>
  21694. /// 团组相关餐厅信息
  21695. /// Del
  21696. /// </summary>
  21697. /// <param name="dto"></param>
  21698. /// <returns></returns>
  21699. [HttpPost]
  21700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21701. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  21702. {
  21703. int userId = dto.DeleteUserId;
  21704. var id = dto.Id;
  21705. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21706. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21707. return Ok(await _restaurantRep.DelAsync(dto));
  21708. }
  21709. #endregion
  21710. // /// <summary>
  21711. // ///
  21712. // /// </summary>
  21713. // /// <param name="_dto"></param>
  21714. // /// <returns></returns>
  21715. // [HttpPost]
  21716. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21717. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21718. // {
  21719. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21720. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  21721. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  21722. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21723. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  21724. // dic_psg.Add("客人", 974);
  21725. // dic_psg.Add("司机", 975);
  21726. // dic_psg.Add("导游", 976);
  21727. // dic_psg.Add("公司内部人员", 977);
  21728. // dic_psg.Add("司机/导游/公司内部人员", 978);
  21729. // foreach (var item in list_visa)
  21730. // {
  21731. // Grp_VisaInfo temp = new Grp_VisaInfo();
  21732. // temp.Id = item.Id;
  21733. // temp.DIId = item.DIId;
  21734. // temp.VisaClient = item.VisaClient;
  21735. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  21736. // temp.VisaCurrency = item.VisaCurrency;
  21737. // temp.IsThird = item.IsThird;
  21738. // if (dic_psg.ContainsKey(item.PassengerType))
  21739. // {
  21740. // temp.PassengerType = dic_psg[item.PassengerType];
  21741. // }
  21742. // else {
  21743. // temp.PassengerType = -1;
  21744. // }
  21745. // temp.VisaNumber = item.VisaNumber;
  21746. // temp.VisaFreeNumber = item.VisaFreeNumber;
  21747. // temp.CreateUserId = item.Operators;
  21748. // DateTime dt_ct;
  21749. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  21750. // if (b_ct)
  21751. // {
  21752. // temp.CreateTime = dt_ct;
  21753. // }
  21754. // else
  21755. // {
  21756. // temp.CreateTime = DateTime.Now;
  21757. // }
  21758. // temp.DeleteTime = "";
  21759. // temp.DeleteUserId = 0;
  21760. // temp.Remark = item.Remark;
  21761. // if (string.IsNullOrEmpty(temp.Remark)) {
  21762. // temp.Remark = "";
  21763. // }
  21764. // temp.IsDel = item.IsDel;
  21765. // temp.VisaDescription = item.VisaAttachment;
  21766. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  21767. //([Id]
  21768. // ,[DIId]
  21769. // ,[VisaClient]
  21770. // ,[VisaPrice]
  21771. // ,[VisaCurrency]
  21772. // ,[IsThird]
  21773. // ,[PassengerType]
  21774. // ,[VisaNumber]
  21775. // ,[VisaFreeNumber]
  21776. // ,[CreateUserId]
  21777. // ,[CreateTime]
  21778. // ,[DeleteTime]
  21779. // ,[DeleteUserId]
  21780. // ,[Remark]
  21781. // ,[IsDel]
  21782. // ,[visaDescription])
  21783. // VALUES
  21784. // ({0},{1},'{2}',{3},{4}
  21785. //,{5},{6},{7},{8},{9}
  21786. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  21787. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  21788. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  21789. //);
  21790. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  21791. // }
  21792. // return Ok(JsonView(true, "操作成功!"));
  21793. // }
  21794. /// <summary>
  21795. /// 123132123
  21796. /// </summary>
  21797. /// <param name="_dto"></param>
  21798. /// <returns></returns>
  21799. [HttpPost]
  21800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21801. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21802. {
  21803. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21804. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  21805. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  21806. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21807. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  21808. dicDetail.Add(789, 1034);
  21809. dicDetail.Add(790, 1035);
  21810. dicDetail.Add(791, 1036);
  21811. dicDetail.Add(792, 1037);
  21812. dicDetail.Add(793, 1038);
  21813. dicDetail.Add(794, 1039);
  21814. dicDetail.Add(795, 1040);
  21815. dicDetail.Add(796, 1041);
  21816. dicDetail.Add(797, 1042);
  21817. dicDetail.Add(798, 1043);
  21818. dicDetail.Add(801, 1044);
  21819. dicDetail.Add(802, 1045);
  21820. dicDetail.Add(803, 1046);
  21821. Dictionary<int, int> dic = new Dictionary<int, int>();
  21822. dic.Add(806, 1027);
  21823. dic.Add(807, 1028);
  21824. dic.Add(808, 1029);
  21825. dic.Add(809, 1030);
  21826. dic.Add(810, 1031);
  21827. dic.Add(811, 1032);
  21828. dic.Add(812, 1033);
  21829. foreach (var item in list_visa)
  21830. {
  21831. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  21832. temp.Coefficient = item.coefficient;
  21833. DateTime dtCrt;
  21834. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  21835. if (b1)
  21836. {
  21837. temp.CreateTime = dtCrt;
  21838. }
  21839. else
  21840. {
  21841. temp.CreateTime = DateTime.Now;
  21842. }
  21843. temp.CreateUserId = item.Operators;
  21844. temp.DeleteTime = "";
  21845. temp.DeleteUserId = 0;
  21846. temp.DiId = int.Parse(item.DIID);
  21847. temp.FilePath = item.FilePath;
  21848. temp.IsDel = item.IsDel;
  21849. temp.Price = item.Price;
  21850. temp.PriceCount = 1;
  21851. temp.PriceCurrency = item.Currency;
  21852. int detailId = 0;
  21853. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  21854. {
  21855. detailId = dicDetail[item.PriceTypeDetail];
  21856. }
  21857. temp.PriceDetailType = detailId;
  21858. temp.PriceDt = DateTime.Now;
  21859. temp.PriceName = item.PriceName;
  21860. temp.PriceSum = item.Price;
  21861. int tid = 0;
  21862. if (dic.ContainsKey(item.PriceType))
  21863. {
  21864. tid = dic[item.PriceType];
  21865. }
  21866. temp.PriceType = tid;
  21867. temp.Remark = item.Remark;
  21868. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  21869. }
  21870. return Ok(JsonView(true, "操作成功!"));
  21871. }
  21872. [HttpPost]
  21873. public IActionResult TimeTest()
  21874. {
  21875. var jw = JsonView(false, "error");
  21876. _sqlSugar.BeginTran();
  21877. try
  21878. {
  21879. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  21880. .Select(x => new Crm_NewClientData
  21881. {
  21882. Id = x.Id,
  21883. Client = x.Client,
  21884. Contact = x.Contact,
  21885. Location = x.Location,
  21886. })
  21887. .ToList();
  21888. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  21889. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  21890. Stopwatch stopwatch = new Stopwatch();
  21891. // 开始计时
  21892. stopwatch.Start();
  21893. foreach (var item in clientList)
  21894. {
  21895. EncryptionProcessor.DecryptProperties(item);
  21896. }
  21897. stopwatch.Stop();
  21898. jw.Code = 200;
  21899. jw.Data = stopwatch.ElapsedMilliseconds;
  21900. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  21901. }
  21902. catch (Exception ex)
  21903. {
  21904. jw.Code = 400;
  21905. jw.Msg = ex.Message;
  21906. }
  21907. return Ok(jw);
  21908. }
  21909. }
  21910. }