GroupsController.cs 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451
  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. /// <param name="pageIndex">当前页码</param>
  463. /// <param name="pageSize">每页条数</param>
  464. /// <param name="search">查询条件</param>
  465. /// <returns></returns>
  466. [HttpGet]
  467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  468. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  469. {
  470. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  471. if (pageIndex == 0 && pageSize == 0)
  472. {
  473. //所有数据
  474. return Ok(JsonView(countrys, countrys.Count));
  475. }
  476. //分页
  477. int skip = (pageIndex - 1) * pageSize;
  478. int take = pageSize;
  479. if (!string.IsNullOrEmpty(search))
  480. {
  481. IEnumerable<char> charSequence = search.Select(c => c);
  482. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  483. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  484. return Ok(JsonView(pageData, pageResult1.Count));
  485. }
  486. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  487. return Ok(JsonView(pageResult2, countrys.Count));
  488. }
  489. /// <summary>
  490. /// 城市数据源
  491. /// </summary>
  492. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  493. /// <param name="pageIndex">当前页码</param>
  494. /// <param name="pageSize">每页条数</param>
  495. /// <param name="search">查询条件</param>
  496. /// <returns></returns>
  497. [HttpGet("{countryLabel}")]
  498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  499. public async Task<IActionResult> CityByCountry(
  500. string countryLabel,
  501. [FromQuery] int pageIndex,
  502. [FromQuery] int pageSize,
  503. [FromQuery] string search)
  504. {
  505. countryLabel = HttpUtility.UrlDecode(countryLabel);
  506. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  507. var citys = Array.Empty<string?>();
  508. if (countryList.Any())
  509. {
  510. var cityDatas = await _sqlSugar
  511. .Queryable<Grp_NationalTravelFee>()
  512. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  513. .ToArrayAsync();
  514. foreach (var item in cityDatas)
  515. {
  516. if (item.City.Contains("城市"))
  517. {
  518. item.City = item.Country + "-所有城市";
  519. }
  520. }
  521. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  522. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  523. }
  524. if (pageIndex == 0 && pageSize == 0)
  525. {
  526. //所有数据
  527. return Ok(JsonView(citys, citys?.Length ?? 0));
  528. }
  529. //分页
  530. int skip = (pageIndex - 1) * pageSize;
  531. int take = pageSize;
  532. if (!string.IsNullOrEmpty(search))
  533. {
  534. IEnumerable<char> charSequence = search.Select(c => c);
  535. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  536. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  537. return Ok(JsonView(pageData, pageResult1.Count()));
  538. }
  539. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  540. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  541. }
  542. /// <summary>
  543. /// 团组前期信息 Info
  544. /// </summary>
  545. /// <param name="dto">Id</param>
  546. /// <param name="portType">Id</param>
  547. /// <returns></returns>
  548. [HttpGet("{Id}/{TempId}")]
  549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  550. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto,int portType=1)
  551. {
  552. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  553. }
  554. /// <summary>
  555. /// 团组前期信息 移动端 Info
  556. /// </summary>
  557. /// <param name="dto">Id</param>
  558. /// <returns></returns>
  559. [HttpGet("{Id}/{TempId}")]
  560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  561. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  562. {
  563. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  564. }
  565. /// <summary>
  566. /// 团组前期信息 Save
  567. /// </summary>
  568. /// <param name="dto">Id</param>
  569. /// <returns></returns>
  570. [HttpPost]
  571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  572. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  573. {
  574. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  575. }
  576. /// <summary>
  577. /// 团组前期信息 Del
  578. /// </summary>
  579. /// <param name="dto">Id</param>
  580. /// <returns></returns>
  581. [HttpPost]
  582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  583. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  584. {
  585. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  586. }
  587. /// <summary>
  588. /// 团组前期信息 文件下载
  589. /// </summary>
  590. /// <param name="dto">Id</param>
  591. /// <returns></returns>
  592. [HttpGet("{Id}/{TempId}")]
  593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  594. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  595. {
  596. int id = dto.Id, tempId = dto.TempId;
  597. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  598. var data = view.Data as GrpOrderPreInfoView;
  599. #region Excel
  600. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  601. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  602. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  603. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  604. var fileNamePrefix = string.Empty;
  605. if (tempId == 1405)
  606. {
  607. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  608. fileNamePrefix = $"{data.Name}_无商邀版";
  609. }
  610. else if (tempId == 1406)
  611. {
  612. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  613. fileNamePrefix = $"{data.Name}_有商邀版";
  614. }
  615. else
  616. {
  617. //tempId == 1404 默认下载
  618. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  619. fileNamePrefix = $"{data.Name}_单接送机";
  620. }
  621. foreach (var item in data.Items)
  622. {
  623. var obj = item.NewValue;
  624. if (obj == null) item.OriginVal = "";
  625. else if (obj.Equals("有") || obj.Equals("无"))
  626. {
  627. item.OriginVal = obj.ToString();
  628. }
  629. else if (obj is object[] objArray)
  630. {
  631. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  632. item.OriginVal = string.Join("、", stringArray);
  633. }
  634. else if (obj is string[] stringArray)
  635. {
  636. item.OriginVal = string.Join("、", stringArray);
  637. }
  638. else if (obj.Equals("-"))
  639. {
  640. item.OriginVal = "";
  641. }
  642. }
  643. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  644. fileName = CommonFun.ValidFileName(fileName);
  645. //载入模板
  646. WorkbookDesigner designer = new WorkbookDesigner();
  647. designer.Workbook = new Workbook(tempPath);
  648. if (tempId == 1406)
  649. {
  650. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  651. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  652. for (int i = 1; i <= view2.Length; i++)
  653. {
  654. view2[i - 1].Index = i;
  655. }
  656. designer.SetDataSource("View1", view1);
  657. designer.SetDataSource("View2", view2);
  658. }
  659. else
  660. {
  661. designer.SetDataSource("View", data.Items);
  662. }
  663. designer.Process();
  664. if (!Directory.Exists(savePath))
  665. {
  666. Directory.CreateDirectory(savePath);
  667. }
  668. string serverPath = $"{savePath}{fileName}";
  669. designer.Workbook.Save(serverPath);
  670. string rst = $"{servicePath}{ftpPath}{fileName}";
  671. #endregion
  672. return Ok(JsonView(new { url = rst }));
  673. }
  674. #endregion
  675. #region 团组基本信息
  676. /// <summary>
  677. /// 接团信息列表
  678. /// </summary>
  679. /// <param name="dto">团组列表请求dto</param>
  680. /// <returns></returns>
  681. [HttpPost]
  682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  683. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  684. {
  685. var groupData = await _groupRepository.GetGroupList(dto);
  686. if (groupData.Code != 0)
  687. {
  688. return Ok(JsonView(false, groupData.Msg));
  689. }
  690. return Ok(JsonView(groupData.Data));
  691. }
  692. /// <summary>
  693. /// 分页查询团组列表
  694. /// </summary>
  695. /// <param name="dto"></param>
  696. /// <returns></returns>
  697. [HttpPost]
  698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  699. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  700. {
  701. var watch = new Stopwatch();
  702. watch.Start();
  703. RefAsync<int> total = 0;
  704. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  705. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  706. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  707. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  708. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  709. .Distinct()
  710. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  711. watch.Stop();
  712. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  713. }
  714. /// <summary>
  715. /// 接团信息列表 Page Init
  716. /// </summary>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> PostGroupPageListInit()
  721. {
  722. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  723. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  724. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  725. var _view = new
  726. {
  727. depData = depDatas,
  728. rankData = rankDatas
  729. };
  730. return Ok(JsonView(true, "查询成功!", _view));
  731. }
  732. /// <summary>
  733. /// 接团信息列表 Page
  734. /// </summary>
  735. /// <param name="dto">团组列表请求dto</param>
  736. /// <returns></returns>
  737. [HttpPost]
  738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  739. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  740. {
  741. #region 参数验证
  742. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  743. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  744. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  745. #region 页面操作权限验证
  746. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  747. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  748. #endregion
  749. #endregion
  750. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  751. {
  752. string sqlWhere = string.Empty;
  753. if (dto.IsSure == 0) //未完成
  754. {
  755. sqlWhere += string.Format(@" And IsSure = 0");
  756. }
  757. else if (dto.IsSure == 1) //已完成
  758. {
  759. sqlWhere += string.Format(@" And IsSure = 1");
  760. }
  761. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  762. {
  763. string tj = dto.SearchCriteria;
  764. 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}%')",
  765. tj, tj, tj, tj, tj);
  766. }
  767. if (int.TryParse(dto.Rank, out int rankId))
  768. {
  769. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  770. }
  771. string sqlWhere1 = string.Empty;
  772. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  773. {
  774. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  775. }
  776. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  777. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  778. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  779. JietuanOperator,IsSure,CreateTime,IsBid
  780. From (
  781. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  782. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  783. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  784. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  785. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  786. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  787. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  788. From Grp_DelegationInfo gdi
  789. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  790. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  791. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  792. Where gdi.IsDel = 0 {0}
  793. ) temp {1}", sqlWhere, sqlWhere1);
  794. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  795. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  796. var _view = new
  797. {
  798. PageFuncAuth = pageFunAuthView,
  799. Data = _DelegationList
  800. };
  801. return Ok(JsonView(true, "查询成功!", _view, total));
  802. }
  803. else
  804. {
  805. return Ok(JsonView(false, "查询失败"));
  806. }
  807. }
  808. /// <summary>
  809. /// 团组列表
  810. /// </summary>
  811. /// <returns></returns>
  812. [HttpPost]
  813. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  814. {
  815. #region 参数验证
  816. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  817. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  818. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  819. #region 页面操作权限验证
  820. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  821. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  822. #endregion
  823. #endregion
  824. if (dto.PortType != 1 && dto.PortType != 2)
  825. {
  826. return Ok(JsonView(false, "查询失败!"));
  827. }
  828. string orderbyStr = "order by gdi.CreateTime Desc";
  829. string sqlWhere = string.Empty;
  830. if (dto.IsSure == 0) //未完成
  831. {
  832. sqlWhere += string.Format(@" And IsSure = 0");
  833. }
  834. else if (dto.IsSure == 1) //已完成
  835. {
  836. sqlWhere += string.Format(@" And IsSure = 1");
  837. }
  838. //团组类型
  839. if (dto.TeamDid > 0)
  840. {
  841. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  842. }
  843. //团组名称
  844. if (!string.IsNullOrEmpty(dto.TeamName))
  845. {
  846. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  847. }
  848. //客户名称
  849. if (!string.IsNullOrEmpty(dto.ClientName))
  850. {
  851. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  852. }
  853. //客户单位
  854. if (!string.IsNullOrEmpty(dto.ClientUnit))
  855. {
  856. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  857. }
  858. //出访时间
  859. if (!string.IsNullOrEmpty(dto.visitDataTime))
  860. {
  861. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  862. orderbyStr = "order by gdi.VisitDate";
  863. }
  864. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  865. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  866. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  867. JietuanOperator,IsSure,CreateTime
  868. From (
  869. Select row_number() over({0}) as Row_Number,
  870. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  871. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  872. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  873. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  874. From Grp_DelegationInfo gdi
  875. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  876. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  877. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  878. Where gdi.IsDel = 0 {1}
  879. ) temp ", orderbyStr, sqlWhere);
  880. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  881. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  882. #region 处理所属部门
  883. /*
  884. * 1.sq 和 gyy 等显示 市场部
  885. * 2.王鸽和主管及张总还有管理员号统一国交部
  886. * 2-1. 4 管理员 ,21 张海麟
  887. */
  888. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  889. List<int> userIds1 = new List<int>() { 4, 21 };
  890. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  891. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  892. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  893. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  894. .ToList();
  895. foreach (var item in _DelegationList)
  896. {
  897. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  898. }
  899. #endregion
  900. var _view = new
  901. {
  902. PageFuncAuth = pageFunAuthView,
  903. Data = _DelegationList
  904. };
  905. return Ok(JsonView(true, "查询成功!", _view, total));
  906. }
  907. /// <summary>
  908. /// 接团信息详情
  909. /// </summary>
  910. /// <param name="dto">团组info请求dto</param>
  911. /// <returns></returns>
  912. [HttpPost]
  913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  914. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  915. {
  916. var groupData = await _groupRepository.GetGroupInfo(dto);
  917. if (groupData.Code != 0)
  918. {
  919. return Ok(JsonView(false, groupData.Msg));
  920. }
  921. return Ok(JsonView(groupData.Data));
  922. }
  923. /// <summary>
  924. /// 接团信息 编辑添加
  925. /// 基础信息数据源
  926. /// </summary>
  927. /// <param name="dto"></param>
  928. /// <returns></returns>
  929. [HttpPost]
  930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  931. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  932. {
  933. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  934. if (groupData.Code != 0)
  935. {
  936. return Ok(JsonView(false, groupData.Msg));
  937. }
  938. return Ok(JsonView(groupData.Data));
  939. }
  940. /// <summary>
  941. /// 接团信息 编辑添加
  942. /// 省份-城市 基础信息数据源
  943. /// </summary>
  944. /// <param name="dto"></param>
  945. /// <returns></returns>
  946. [HttpPost]
  947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  948. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  949. {
  950. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  951. string search = dto.Search;
  952. var data = await _groupRepository.CityBasicSource();
  953. int total = data.Length;
  954. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  955. .Skip((pageIndex - 1) * pageSize)
  956. .Take(pageSize)
  957. .ToArray();
  958. return Ok(JsonView(data, total));
  959. }
  960. /// <summary>
  961. /// 接团信息 操作(增改)
  962. /// </summary>
  963. /// <param name="dto"></param>
  964. /// <returns></returns>
  965. [HttpPost]
  966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  967. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  968. {
  969. // 创建 Stopwatch 实例
  970. Stopwatch stopwatch = Stopwatch.StartNew();
  971. decimal ffrPrice = 0.00M;
  972. DateTime? visitDt = null;
  973. if (dto.Status == 2)
  974. {
  975. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  976. if (groupInfo != null)
  977. {
  978. ffrPrice = groupInfo.PaymentMoney;
  979. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  980. }
  981. }
  982. var groupData = await _groupRepository.GroupOperation(dto);
  983. if (groupData.Code != 0)
  984. {
  985. return Ok(JsonView(false, groupData.Msg));
  986. }
  987. int diId = 0;
  988. try
  989. {
  990. //添加时 默认加入团组汇率
  991. if (dto.Status == 1) //添加
  992. {
  993. diId = groupData.Data;
  994. //添加默认币种
  995. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  996. //默认分配权限
  997. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  998. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  999. var _managerIds = new List<int>() { 22, 32, 21 };
  1000. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1001. if (userIds.Count > 0)
  1002. {
  1003. userIds.Add(208);
  1004. //创建团组管控
  1005. GroupStepForDelegation.CreateWorkStep(diId);
  1006. //发送消息
  1007. string groupName = dto.TeamName;
  1008. string createGroupUser = string.Empty;
  1009. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1010. if (userInfo != null) createGroupUser = userInfo.CnName;
  1011. string title = $"系统通知";
  1012. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1013. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1014. }
  1015. //默认创建倒推表
  1016. await _invertedListRep._Create(dto.UserId, diId);
  1017. }
  1018. else if (dto.Status == 2)
  1019. {
  1020. diId = dto.Id;
  1021. }
  1022. #region 签证人员团组时间通知
  1023. #region 计算出访起止时间
  1024. var startTime = new DateTime();
  1025. var endTime = new DateTime();
  1026. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1027. {
  1028. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1029. }
  1030. #endregion
  1031. #endregion
  1032. #region 团组操作默认添加/修改收款账单
  1033. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1034. {
  1035. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1036. .Where(x => x.IsDel == 0 &&
  1037. x.Diid == diId &&
  1038. x.Remark.Equals("预付款")
  1039. )
  1040. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1041. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1042. .FirstAsync();
  1043. ffrInfo = new Fin_ForeignReceivables()
  1044. {
  1045. Diid = diId,
  1046. PriceName = dto.ClientUnit,
  1047. Price = dto.PaymentMoney,
  1048. Count = 1,
  1049. Unit = $"元",
  1050. ItemSumPrice = dto.PaymentMoney,
  1051. Rate = 1.0000M,
  1052. Currency = 836,
  1053. AddingWay = 0,
  1054. CreateUserId = dto.UserId,
  1055. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1056. Remark = $"预付款"
  1057. };
  1058. if (ffrInfo == null) //Add
  1059. {
  1060. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1061. }
  1062. else //修改
  1063. {
  1064. await _sqlSugar.Updateable(ffrInfo)
  1065. .UpdateColumns(x => new
  1066. {
  1067. x.PriceName,
  1068. x.Price,
  1069. x.ItemSumPrice,
  1070. x.CreateTime,
  1071. x.CreateUserId
  1072. })
  1073. .WhereColumns(x => x.Id)
  1074. .ExecuteCommandAsync();
  1075. }
  1076. }
  1077. #endregion
  1078. if (diId > 0)
  1079. {
  1080. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1081. }
  1082. // 停止计时
  1083. stopwatch.Stop();
  1084. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1085. }
  1086. catch (Exception ex)
  1087. {
  1088. // 停止计时
  1089. stopwatch.Stop();
  1090. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1091. Logs(ex.Message);
  1092. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1093. }
  1094. // 停止计时
  1095. stopwatch.Stop();
  1096. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1097. }
  1098. /// <summary>
  1099. /// 接团流程操作(增改)
  1100. /// 安卓端使用 建团时添加客户名单
  1101. /// </summary>
  1102. /// <param name="dto"></param>
  1103. /// <returns></returns>
  1104. [HttpPost]
  1105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1106. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1107. {
  1108. #region 参数验证
  1109. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1110. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1111. #region 页面操作权限验证
  1112. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1113. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1114. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1115. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1116. #endregion
  1117. #endregion
  1118. try
  1119. {
  1120. //_sqlSugar.BeginTran();
  1121. decimal ffrPrice = 0.00M;
  1122. DateTime? visitDt = null;
  1123. if (dto.Status == 2)
  1124. {
  1125. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1126. if (groupInfo != null)
  1127. {
  1128. ffrPrice = groupInfo.PaymentMoney;
  1129. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1130. }
  1131. }
  1132. var _dto = new GroupOperationDto();
  1133. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1134. var groupData = await _groupRepository.GroupOperation(_dto);
  1135. if (groupData.Code != 0)
  1136. {
  1137. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1138. }
  1139. int diId = 0;
  1140. //添加时 默认加入团组汇率
  1141. if (dto.Status == 1) //添加
  1142. {
  1143. diId = groupData.Data;
  1144. //添加默认币种
  1145. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1146. //默认分配权限
  1147. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1148. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1149. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1150. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1151. if (userIds.Count > 0)
  1152. {
  1153. userIds.Add(208);
  1154. //创建团组管控
  1155. GroupStepForDelegation.CreateWorkStep(diId);
  1156. //发送消息
  1157. string groupName = dto.TeamName;
  1158. string createGroupUser = string.Empty;
  1159. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1160. if (userInfo != null) createGroupUser = userInfo.CnName;
  1161. string title = $"系统通知";
  1162. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1163. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1164. }
  1165. #region 应用推送
  1166. try
  1167. {
  1168. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1169. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1170. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1171. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1172. {
  1173. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1174. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1175. }
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. }
  1180. #endregion
  1181. //默认创建倒推表
  1182. await _invertedListRep._Create(dto.UserId, diId);
  1183. }
  1184. if (dto.Status == 2)
  1185. {
  1186. diId = dto.Id;
  1187. if (diId == 0)
  1188. {
  1189. //_sqlSugar.RollbackTran();
  1190. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1191. }
  1192. }
  1193. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1194. if (viewData.Code != 0)
  1195. {
  1196. //_sqlSugar.RollbackTran();
  1197. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1198. }
  1199. #region 团组操作默认添加/修改收款账单
  1200. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1201. {
  1202. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1203. .Where(x => x.IsDel == 0 &&
  1204. x.Diid == diId &&
  1205. x.Remark.Equals("预付款")
  1206. )
  1207. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1208. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1209. .FirstAsync();
  1210. ffrInfo = new Fin_ForeignReceivables()
  1211. {
  1212. Diid = diId,
  1213. PriceName = dto.ClientUnit,
  1214. Price = dto.PaymentMoney,
  1215. Count = 1,
  1216. Unit = $"元",
  1217. ItemSumPrice = dto.PaymentMoney,
  1218. Rate = 1.0000M,
  1219. Currency = 836,
  1220. AddingWay = 0,
  1221. CreateUserId = dto.UserId,
  1222. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1223. Remark = $"预付款"
  1224. };
  1225. if (ffrInfo == null) //Add
  1226. {
  1227. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1228. }
  1229. else //修改
  1230. {
  1231. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1232. .UpdateColumns(x => new
  1233. {
  1234. x.PriceName,
  1235. x.Price,
  1236. x.ItemSumPrice,
  1237. x.CreateTime,
  1238. x.CreateUserId
  1239. })
  1240. .WhereColumns(x => x.Id)
  1241. .ExecuteCommandAsync();
  1242. }
  1243. }
  1244. #endregion
  1245. #region 签证人员团组时间通知
  1246. #region 计算出访起止时间
  1247. var startTime = new DateTime();
  1248. var endTime = new DateTime();
  1249. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1250. {
  1251. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1252. }
  1253. #endregion
  1254. if (diId > 0)
  1255. {
  1256. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1257. }
  1258. #endregion
  1259. //_sqlSugar.CommitTran();
  1260. return Ok(JsonView(true, "添加成功"));
  1261. }
  1262. catch (Exception ex)
  1263. {
  1264. _sqlSugar.RollbackTran();
  1265. return Ok(JsonView(false, ex.Message));
  1266. }
  1267. }
  1268. /// <summary>
  1269. /// 接团流程操作(增改)
  1270. /// 安卓端使用 建团时添加客户名单
  1271. /// </summary>
  1272. /// <param name="dto"></param>
  1273. /// <returns></returns>
  1274. [HttpPost]
  1275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1276. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1277. {
  1278. #region 参数验证
  1279. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1280. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1281. #region 页面操作权限验证
  1282. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1283. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1284. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1285. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1286. #endregion
  1287. #endregion
  1288. _sqlSugar.BeginTran();
  1289. decimal ffrPrice = 0.00M;
  1290. DateTime? visitDt = null;
  1291. if (dto.Status == 2)
  1292. {
  1293. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1294. if (groupInfo != null)
  1295. {
  1296. ffrPrice = groupInfo.PaymentMoney;
  1297. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1298. }
  1299. }
  1300. var _dto = new GroupOperationDto();
  1301. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1302. var groupData = await _groupRepository.GroupOperation(_dto);
  1303. if (groupData.Code != 0)
  1304. {
  1305. _sqlSugar.RollbackTran();
  1306. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1307. }
  1308. try
  1309. {
  1310. int diId = 0;
  1311. //添加时 默认加入团组汇率
  1312. if (dto.Status == 1) //添加
  1313. {
  1314. diId = groupData.Data;
  1315. //添加默认币种
  1316. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1317. //默认分配权限
  1318. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1319. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1320. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1321. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1322. if (userIds.Count > 0)
  1323. {
  1324. userIds.Add(208);
  1325. //创建团组管控
  1326. GroupStepForDelegation.CreateWorkStep(diId);
  1327. //发送消息
  1328. string groupName = dto.TeamName;
  1329. string createGroupUser = string.Empty;
  1330. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1331. if (userInfo != null) createGroupUser = userInfo.CnName;
  1332. string title = $"系统通知";
  1333. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1334. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1335. }
  1336. #region 应用推送
  1337. try
  1338. {
  1339. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1340. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1341. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1342. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1343. {
  1344. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1345. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1346. }
  1347. }
  1348. catch (Exception ex)
  1349. {
  1350. _sqlSugar.CommitTran();
  1351. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1352. }
  1353. #endregion
  1354. //默认创建倒推表
  1355. await _invertedListRep._Create(dto.UserId, diId);
  1356. }
  1357. else if (dto.Status == 2)
  1358. {
  1359. diId = dto.Id;
  1360. if (diId == 0)
  1361. {
  1362. _sqlSugar.RollbackTran();
  1363. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1364. }
  1365. }
  1366. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1367. if (viewData.Code != 0)
  1368. {
  1369. _sqlSugar.RollbackTran();
  1370. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1371. }
  1372. #region 团组操作默认添加/修改收款账单
  1373. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1374. {
  1375. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1376. .Where(x => x.IsDel == 0 &&
  1377. x.Diid == diId &&
  1378. x.Remark.Equals("预付款")
  1379. )
  1380. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1381. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1382. .FirstAsync();
  1383. ffrInfo = new Fin_ForeignReceivables()
  1384. {
  1385. Diid = diId,
  1386. PriceName = dto.ClientUnit,
  1387. Price = dto.PaymentMoney,
  1388. Count = 1,
  1389. Unit = $"元",
  1390. ItemSumPrice = dto.PaymentMoney,
  1391. Rate = 1.0000M,
  1392. Currency = 836,
  1393. AddingWay = 0,
  1394. CreateUserId = dto.UserId,
  1395. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1396. Remark = $"预付款"
  1397. };
  1398. if (ffrInfo == null) //Add
  1399. {
  1400. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1401. }
  1402. else //修改
  1403. {
  1404. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1405. .UpdateColumns(x => new
  1406. {
  1407. x.PriceName,
  1408. x.Price,
  1409. x.ItemSumPrice,
  1410. x.CreateTime,
  1411. x.CreateUserId
  1412. })
  1413. .WhereColumns(x => x.Id)
  1414. .ExecuteCommandAsync();
  1415. }
  1416. }
  1417. #endregion
  1418. #region 签证人员团组时间通知
  1419. #region 计算出访起止时间
  1420. var startTime = new DateTime();
  1421. var endTime = new DateTime();
  1422. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1423. {
  1424. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1425. }
  1426. #endregion
  1427. if (diId > 0)
  1428. {
  1429. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1430. }
  1431. #endregion
  1432. _sqlSugar.CommitTran();
  1433. return Ok(JsonView(true));
  1434. }
  1435. catch (Exception ex)
  1436. {
  1437. _sqlSugar.RollbackTran();
  1438. return Ok(JsonView(false, ex.Message));
  1439. }
  1440. }
  1441. /// <summary>
  1442. /// 接团信息 操作(删除)
  1443. /// </summary>
  1444. /// <param name="dto"></param>
  1445. /// <returns></returns>
  1446. [HttpPost]
  1447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1448. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1449. {
  1450. var diId = dto.Id;
  1451. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1452. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1453. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1454. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1455. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1456. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1457. #endregion
  1458. var groupData = await _groupRepository.GroupDel(dto);
  1459. if (groupData.Code != 0)
  1460. {
  1461. return Ok(JsonView(false, groupData.Msg));
  1462. }
  1463. return Ok(JsonView(true));
  1464. }
  1465. /// <summary>
  1466. /// 获取团组销售报价号
  1467. /// 团组添加时 使用
  1468. /// </summary>
  1469. /// <returns></returns>
  1470. [HttpPost]
  1471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1472. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1473. {
  1474. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1475. if (groupData.Code != 0)
  1476. {
  1477. return Ok(JsonView(false, groupData.Msg));
  1478. }
  1479. object salesQuoteNo = new
  1480. {
  1481. SalesQuoteNo = groupData.Data
  1482. };
  1483. return Ok(JsonView(salesQuoteNo));
  1484. }
  1485. /// <summary>
  1486. /// 设置确认出团
  1487. /// </summary>
  1488. /// <param name="dto"></param>
  1489. /// <returns></returns>
  1490. [HttpPost]
  1491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1492. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1493. {
  1494. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1495. if (groupData.Code != 0)
  1496. {
  1497. return Ok(JsonView(false, groupData.Msg));
  1498. }
  1499. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1500. #region OA消息推送
  1501. try
  1502. {
  1503. string groupName = groupInfo.TeamName;
  1504. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1505. string title = $"系统通知";
  1506. string content = $"团组[{groupName}]已确认出团!";
  1507. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1508. }
  1509. catch (Exception ex)
  1510. {
  1511. }
  1512. #endregion
  1513. #region 应用推送
  1514. try
  1515. {
  1516. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1517. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1518. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1519. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1520. {
  1521. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1522. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1523. }
  1524. }
  1525. catch (Exception ex)
  1526. {
  1527. }
  1528. #endregion
  1529. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1530. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1531. }
  1532. /// <summary>
  1533. /// 获取团组名称data And 签证国别Data
  1534. /// </summary>
  1535. /// <param name="dto"></param>
  1536. /// <returns></returns>
  1537. [HttpPost]
  1538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1539. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1540. {
  1541. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1542. if (groupData.Code != 0)
  1543. {
  1544. return Ok(JsonView(false, groupData.Msg));
  1545. }
  1546. return Ok(JsonView(groupData.Data));
  1547. }
  1548. /// <summary>
  1549. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1550. /// </summary>
  1551. /// <returns></returns>
  1552. [HttpPost]
  1553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1554. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1555. {
  1556. try
  1557. {
  1558. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1559. if (groupData.Code != 0)
  1560. {
  1561. return Ok(JsonView(false, groupData.Msg));
  1562. }
  1563. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1564. }
  1565. catch (Exception ex)
  1566. {
  1567. return Ok(JsonView(false, "程序错误!"));
  1568. throw;
  1569. }
  1570. }
  1571. /// <summary>
  1572. /// 团组清单 Excel
  1573. /// </summary>
  1574. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1575. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1576. /// <returns></returns>
  1577. [HttpGet]
  1578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1579. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1580. {
  1581. DateTime _beginDt, _endDt;
  1582. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1583. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1584. if (!beginBool && !endBool)
  1585. {
  1586. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1587. }
  1588. string sql = string.Format(@"
  1589. SELECT
  1590. ROW_NUMBER,
  1591. Id,
  1592. SalesQuoteNo,
  1593. TourCode,
  1594. TeamTypeId,
  1595. TeamType,
  1596. TeamLevId,
  1597. TeamLev,
  1598. TeamName,
  1599. ClientName,
  1600. ClientUnit,
  1601. VisitDate,
  1602. VisitDays,
  1603. VisitPNumber,
  1604. JietuanOperatorId,
  1605. JietuanOperator,
  1606. IsSure,
  1607. CreateUserName,
  1608. IsBid
  1609. FROM
  1610. (
  1611. SELECT
  1612. ROW_NUMBER() OVER(
  1613. ORDER BY
  1614. gdi.VisitDate Desc
  1615. ) AS ROW_NUMBER,
  1616. gdi.Id,
  1617. SalesQuoteNo,
  1618. TourCode,
  1619. ssd.Id TeamTypeId,
  1620. ssd.Name TeamType,
  1621. ssd1.Id TeamLevId,
  1622. ssd1.Name TeamLev,
  1623. TeamName,
  1624. ClientName,
  1625. ClientUnit,
  1626. VisitDate,
  1627. VisitDays,
  1628. VisitPNumber,
  1629. JietuanOperator JietuanOperatorId,
  1630. su.CnName JietuanOperator,
  1631. IsSure,
  1632. gdi.CreateTime,
  1633. su1.CnName As CreateUserName,
  1634. gdi.IsBid
  1635. FROM
  1636. Grp_DelegationInfo gdi
  1637. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1638. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1639. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1640. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1641. WHERE
  1642. gdi.IsDel = 0
  1643. AND gdi.IsBid = 0
  1644. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1645. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1646. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1647. #region 处理所属部门
  1648. /*
  1649. * 1.sq 和 gyy 等显示 市场部
  1650. * 2.王鸽和主管及张总还有管理员号统一国交部
  1651. * 2-1. 4 管理员 ,21 张海麟
  1652. */
  1653. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1654. List<int> userIds1 = new List<int>() { 4, 21 };
  1655. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1656. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1657. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1658. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1659. .ToListAsync();
  1660. var droupIds = groupList.Select(it => it.Id).ToList();
  1661. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1662. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1663. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1664. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1665. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1666. {
  1667. DiId = tcl.DiId,
  1668. LastName = dc.LastName,
  1669. FirstName = dc.FirstName,
  1670. Sex = dc.Sex,
  1671. Birthday = dc.BirthDay,
  1672. Company = cc.CompanyFullName,
  1673. Job = dc.Job,
  1674. CreateTime = tcl.CreateTime,
  1675. })
  1676. .ToList();
  1677. foreach (var item in groupList)
  1678. {
  1679. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1680. string groupFirstName = "";
  1681. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1682. if (currDatas.Any())
  1683. {
  1684. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1685. }
  1686. item.GroupFirst = groupFirstName;
  1687. }
  1688. #endregion
  1689. #region Excel
  1690. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1691. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1692. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1693. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1694. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1695. //载入模板
  1696. WorkbookDesigner designer = new WorkbookDesigner();
  1697. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1698. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1699. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1700. dt.TableName = "GroupList";
  1701. designer.SetDataSource(dt);
  1702. designer.Process();
  1703. if (!Directory.Exists(savePath))
  1704. {
  1705. Directory.CreateDirectory(savePath);
  1706. }
  1707. string serverPath = $"{savePath}{fileName}";
  1708. designer.Workbook.Save(serverPath);
  1709. string rst = $"{servicePath}{ftpPath}{fileName}";
  1710. #endregion
  1711. return Ok(JsonView(true, "操作成功!", rst));
  1712. }
  1713. /// <summary>
  1714. /// 团组合同下载(1.付款80% 2.付全款)
  1715. /// </summary>
  1716. /// <param name="dto"></param>
  1717. /// <returns></returns>
  1718. /// <exception cref="Exception"></exception>
  1719. [HttpPost]
  1720. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1721. {
  1722. var jw = JsonView(false);
  1723. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1724. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1725. if (di == null)
  1726. {
  1727. jw.Msg = "团组Id有误!";
  1728. return Ok(jw);
  1729. }
  1730. #region 权限校验
  1731. var allDownFile = new List<int>() { 21 };
  1732. try
  1733. {
  1734. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1735. .First(x => x.Id == 1418 && x.IsDel == 0);
  1736. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1737. }
  1738. catch (Exception)
  1739. { }
  1740. var guojiaoDownFile = new List<int>() { 330 };
  1741. var shichangDownFile = new List<int>() { 95 };
  1742. if (allDownFile.Contains(dto.UserId))
  1743. {
  1744. }
  1745. else if (guojiaoDownFile.Contains(dto.UserId))
  1746. {
  1747. var guojiaobuDi = new List<int>() { 4, 21 };
  1748. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1749. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1750. .Where((d, u) => u.Id == di.JietuanOperator)
  1751. .Select((d, u) => d.DepName)
  1752. .First();
  1753. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1754. {
  1755. jw.Msg = "暂无下载权限!";
  1756. return Ok(jw);
  1757. }
  1758. }
  1759. else if (shichangDownFile.Contains(dto.UserId))
  1760. {
  1761. var dic = new Dictionary<int, int[]>()
  1762. {
  1763. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1764. };
  1765. try
  1766. {
  1767. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1768. if (sqSetting != null)
  1769. {
  1770. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1771. foreach (var item in result.Keys)
  1772. {
  1773. if (dic.Keys.Contains(item))
  1774. {
  1775. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1776. Array.Copy(dic[item], dilatation, dic[item].Length);
  1777. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1778. dic[item] = dilatation;
  1779. }
  1780. else
  1781. {
  1782. dic.Add(item, result[item]);
  1783. }
  1784. }
  1785. }
  1786. if (!dic[95].Contains(di.CreateUserId))
  1787. {
  1788. jw.Msg = "暂无下载权限!";
  1789. return Ok(jw);
  1790. }
  1791. }
  1792. catch (Exception)
  1793. { }
  1794. }
  1795. else if (dto.UserId == di.CreateUserId)
  1796. {
  1797. }
  1798. else
  1799. {
  1800. jw.Msg = "暂无下载权限!";
  1801. return Ok(jw);
  1802. }
  1803. #endregion
  1804. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1805. .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
  1806. .ToListAsync();
  1807. if (!blackCodeList.Any())
  1808. {
  1809. jw.Msg = "该团无机票行程代码!";
  1810. return Ok(jw);
  1811. }
  1812. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1813. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1814. if (groupEnterExitCost == null)
  1815. {
  1816. jw.Msg = "暂无三公费用信息!";
  1817. return Ok(jw);
  1818. }
  1819. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1820. rateList ??= new List<CurrencyInfo>();
  1821. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1822. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1823. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1824. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1825. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1826. .Select((x, a, b) => new
  1827. {
  1828. x.Index,
  1829. itemName = a.Name,
  1830. CurrencyStr = b.Name,
  1831. x.Cost,
  1832. x.SubTotal,
  1833. x.Remark
  1834. })
  1835. .OrderBy((x) => x.Index)
  1836. .ToList();
  1837. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1838. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1839. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1840. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1841. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1842. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1843. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1844. decimal subJJC = 0.00M,
  1845. subGWC = 0.00M,
  1846. subTDC = 0.00M;
  1847. //经济舱
  1848. if (groupEnterExitCost.SumJJC == 1)
  1849. {
  1850. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1851. }
  1852. //公务舱
  1853. if (groupEnterExitCost.SumGWC == 1)
  1854. {
  1855. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1856. }
  1857. //头等舱
  1858. if (groupEnterExitCost.SumTDC == 1)
  1859. {
  1860. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1861. }
  1862. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1863. .LeftJoin<Sys_SetData>((x,s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0 )
  1864. .Where((x, s) => x.DiId == dto.GroupId && x.IsDel == 0)
  1865. .Select((x, s) => new
  1866. {
  1867. x.Id,
  1868. s.Name,
  1869. })
  1870. .ToListAsync();
  1871. //获取舱位人数
  1872. var cabinCount = groupClints.GroupBy(x => x.Name)
  1873. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1874. .ToList();
  1875. string cityPath = string.Empty;
  1876. string startCity = string.Empty;
  1877. string endCity = string.Empty;
  1878. foreach (var item in blackCodeList)
  1879. {
  1880. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1881. cityPath += city + "\r\n";
  1882. if (item.Equals(blackCodeList.First()))
  1883. {
  1884. var sp = city.Split('-');
  1885. startCity = sp[0];
  1886. endCity = sp[sp.Length - 1];
  1887. }
  1888. }
  1889. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1890. bookMarkDic.Add("ClientUnit",di.ClientUnit);
  1891. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1892. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1893. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1894. bookMarkDic.Add("CityPath", cityPath);
  1895. bookMarkDic.Add("StartCity", startCity);
  1896. bookMarkDic.Add("EndCity", endCity);
  1897. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
  1898. Document doc = null;
  1899. var percentage = 0.8M;
  1900. var fileNameadd = "预付";
  1901. if (dto.FileType == 1)
  1902. {
  1903. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1904. }
  1905. else if (dto.FileType == 2)
  1906. {
  1907. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1908. percentage = 1;
  1909. fileNameadd = "全款";
  1910. }
  1911. else
  1912. {
  1913. throw new Exception("FileType有误!");
  1914. }
  1915. DocumentBuilder builder = new DocumentBuilder(doc);
  1916. decimal totalPrice = 0.00M;
  1917. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1918. if (firstTable != null)
  1919. {
  1920. // 遍历表格的行和单元格
  1921. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1922. {
  1923. for (int i = 0; i < row.Cells.Count; i++)
  1924. {
  1925. var cell = row.Cells[i];
  1926. // 读取单元格内容
  1927. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  1928. if (cellTextFirst.Contains("舱位"))
  1929. {
  1930. break;
  1931. }
  1932. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  1933. {
  1934. if (i == 2)
  1935. {
  1936. if (cellTextFirst == "经济舱")
  1937. {
  1938. // 设置单元格内容
  1939. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1940. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  1941. }
  1942. else
  1943. {
  1944. // 设置单元格内容
  1945. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1946. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  1947. }
  1948. }
  1949. if (i == 3)
  1950. {
  1951. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1952. if (count != null)
  1953. {
  1954. // 设置单元格内容
  1955. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1956. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  1957. }
  1958. }
  1959. if (i == 4)
  1960. {
  1961. var rowPrice = 0.00M;
  1962. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1963. count ??= 0;
  1964. if (cellTextFirst == "经济舱")
  1965. {
  1966. rowPrice = subJJC * (int)count;
  1967. }
  1968. else
  1969. {
  1970. rowPrice = subGWC * (int)count;
  1971. }
  1972. totalPrice += rowPrice;
  1973. // 设置单元格内容
  1974. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1975. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  1976. }
  1977. }
  1978. }
  1979. }
  1980. }
  1981. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  1982. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  1983. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  1984. //--合同表格部分
  1985. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  1986. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  1987. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  1988. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  1989. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日")+"-"+di.VisitEndDate.ToString("yyyy年MM月dd日"));
  1990. bookMarkDic.Add("CityPath1", cityPath);
  1991. bookMarkDic.Add("CityPath2", cityPath);
  1992. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  1993. if (contractTable != null)
  1994. {
  1995. //数据源
  1996. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  1997. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  1998. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  1999. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2000. .Select((it, y, s) => new
  2001. {
  2002. it.Cost,
  2003. it.SubTotal,
  2004. it.Type,
  2005. y.Id,
  2006. y.City,
  2007. s.Name,
  2008. CurrencyCodeCn = s.Remark
  2009. })
  2010. .ToList()
  2011. .Select(x => new
  2012. {
  2013. CurrencyCode = x.Name,
  2014. CityId = x.Id,
  2015. x.City,
  2016. VisitPNumber = di.VisitPNumber,
  2017. x.Type,
  2018. x.Cost,
  2019. x.SubTotal,
  2020. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2021. x.CurrencyCodeCn,
  2022. });
  2023. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2024. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2025. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2026. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2027. List<tableSetting> tableSettings = new List<tableSetting>()
  2028. {
  2029. new tableSetting{ Index = 1 , Property = "City"},
  2030. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  2031. new tableSetting{ Index = 3 , Property = "Cost"},
  2032. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  2033. //new tableSetting{ Index = 5 , Property = ""},
  2034. //new tableSetting{ Index = 6 , Property = ""},
  2035. new tableSetting{ Index = 7 , Property = "Rate"},
  2036. //new tableSetting{ Index = 8 , Property = ""},
  2037. };
  2038. //1.住宿费
  2039. int cloneRow = 8;
  2040. int startDayPrice = 8; //写入index
  2041. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2042. foreach (var dac in dac1)
  2043. {
  2044. var first = dac.First();
  2045. var dayCount = dac.Count();
  2046. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2047. for (int i = 1; i < row.Cells.Count; i++)
  2048. {
  2049. var cell = row.Cells[i];
  2050. var findProperty = tableSettings.Find(x => x.Index == i);
  2051. if (findProperty != null)
  2052. {
  2053. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2054. // 设置单元格内容
  2055. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2056. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2057. }
  2058. else
  2059. {
  2060. switch (i)
  2061. {
  2062. case 5:
  2063. cell.FirstParagraph.Runs.Clear();
  2064. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2065. break;
  2066. case 6:
  2067. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2068. cell.FirstParagraph.Runs.Clear();
  2069. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2070. break;
  2071. case 8:
  2072. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2073. cell.FirstParagraph.Runs.Clear();
  2074. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2075. ZSPriceSum += xiaojiRMB;
  2076. break;
  2077. default:
  2078. break;
  2079. }
  2080. }
  2081. }
  2082. startDayPrice++;
  2083. if (!dac1.Last().Equals(dac))
  2084. {
  2085. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2086. // 将克隆的行追加到原行后面
  2087. contractTable.Rows.Insert(startDayPrice, newRow);
  2088. }
  2089. else
  2090. {
  2091. cloneRow += dac1.Count() + 1;
  2092. startDayPrice = cloneRow;
  2093. }
  2094. }
  2095. //2.伙食费
  2096. foreach (var dac in dac2)
  2097. {
  2098. var first = dac.First();
  2099. var dayCount = dac.Count();
  2100. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2101. for (int i = 1; i < row.Cells.Count; i++)
  2102. {
  2103. var cell = row.Cells[i];
  2104. var findProperty = tableSettings.Find(x => x.Index == i);
  2105. if (findProperty != null)
  2106. {
  2107. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2108. // 设置单元格内容
  2109. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2110. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2111. }
  2112. else
  2113. {
  2114. switch (i)
  2115. {
  2116. case 5:
  2117. cell.FirstParagraph.Runs.Clear();
  2118. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2119. break;
  2120. case 6:
  2121. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2122. cell.FirstParagraph.Runs.Clear();
  2123. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2124. break;
  2125. case 8:
  2126. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2127. cell.FirstParagraph.Runs.Clear();
  2128. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2129. HSPriceSum += xiaojiRMB;
  2130. break;
  2131. default:
  2132. break;
  2133. }
  2134. }
  2135. }
  2136. startDayPrice++;
  2137. if (!dac2.Last().Equals(dac))
  2138. {
  2139. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2140. // 将克隆的行追加到原行后面
  2141. contractTable.Rows.Insert(startDayPrice, newRow);
  2142. }
  2143. else
  2144. {
  2145. cloneRow += dac2.Count() + 1;
  2146. startDayPrice = cloneRow;
  2147. }
  2148. }
  2149. //3.公杂费
  2150. foreach (var dac in dac3)
  2151. {
  2152. var first = dac.First();
  2153. var dayCount = dac.Count();
  2154. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2155. for (int i = 1; i < row.Cells.Count; i++)
  2156. {
  2157. var cell = row.Cells[i];
  2158. var findProperty = tableSettings.Find(x => x.Index == i);
  2159. if (findProperty != null)
  2160. {
  2161. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2162. // 设置单元格内容
  2163. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2164. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2165. }
  2166. else
  2167. {
  2168. switch (i)
  2169. {
  2170. case 5:
  2171. cell.FirstParagraph.Runs.Clear();
  2172. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2173. break;
  2174. case 6:
  2175. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2176. cell.FirstParagraph.Runs.Clear();
  2177. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2178. break;
  2179. case 8:
  2180. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2181. cell.FirstParagraph.Runs.Clear();
  2182. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2183. GZPriceSum += xiaojiRMB;
  2184. break;
  2185. default:
  2186. break;
  2187. }
  2188. }
  2189. }
  2190. startDayPrice++;
  2191. if (!dac3.Last().Equals(dac))
  2192. {
  2193. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2194. // 将克隆的行追加到原行后面
  2195. contractTable.Rows.Insert(startDayPrice, newRow);
  2196. }
  2197. else
  2198. {
  2199. cloneRow += dac3.Count() + 1;
  2200. startDayPrice = cloneRow;
  2201. }
  2202. }
  2203. //合并单元格
  2204. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2205. {
  2206. var currentRow = contractTable.Rows[i];
  2207. var nextRow = contractTable.Rows[i + 1];
  2208. // 获取当前行和下一行的第一个单元格
  2209. Cell currentCell = currentRow.Cells[0];
  2210. Cell nextCell = nextRow.Cells[0];
  2211. // 检查单元格内容是否一致(去除尾部的换行符)
  2212. string currentText = currentCell.GetText().Trim();
  2213. string nextText = nextCell.GetText().Trim();
  2214. if (currentText == nextText)
  2215. {
  2216. // 如果当前单元格已经被合并,找到合并的起始单元格
  2217. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2218. {
  2219. // 找到合并的起始单元格
  2220. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2221. // 将下一行的单元格设置为合并的后续单元格
  2222. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2223. }
  2224. else
  2225. {
  2226. // 如果当前单元格是合并的起始单元格
  2227. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2228. // 将下一行的单元格设置为合并的后续单元格
  2229. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2230. }
  2231. }
  2232. else
  2233. {
  2234. // 如果内容不一致,重置当前单元格的合并属性
  2235. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2236. {
  2237. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2238. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2239. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2240. }
  2241. else
  2242. {
  2243. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2244. }
  2245. }
  2246. }
  2247. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2248. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2249. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2250. }
  2251. foreach (var bookmarkName in bookMarkDic.Keys)
  2252. {
  2253. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2254. if (bookmark != null)
  2255. {
  2256. if (bookmarkName == "ClientUnit")
  2257. {
  2258. // 移动到书签位置
  2259. builder.MoveTo(bookmark.BookmarkStart);
  2260. // 设置字体样式为下划线
  2261. builder.Font.Underline = Aspose.Words.Underline.Single;
  2262. // 插入书签值
  2263. builder.Write(bookMarkDic[bookmarkName]);
  2264. // 清除字体格式,避免影响后续文本
  2265. builder.Font.ClearFormatting();
  2266. }
  2267. else
  2268. {
  2269. builder.MoveToBookmark(bookmarkName);
  2270. builder.Write(bookMarkDic[bookmarkName]);
  2271. }
  2272. }
  2273. }
  2274. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2275. doc.Save(savePaht);
  2276. jw.Msg = "生成成功!";
  2277. jw.Code = 200;
  2278. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
  2279. return Ok(jw);
  2280. }
  2281. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2282. {
  2283. int index = rowIndex;
  2284. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2285. {
  2286. index--;
  2287. }
  2288. return index;
  2289. }
  2290. #endregion
  2291. #region 团组&签证
  2292. /// <summary>
  2293. /// 根据团组Id获取签证客户信息List
  2294. /// </summary>
  2295. /// <param name="dto">请求dto</param>
  2296. /// <returns></returns>
  2297. [HttpPost]
  2298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2299. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2300. {
  2301. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2302. if (groupData.Code != 0)
  2303. {
  2304. return Ok(JsonView(false, groupData.Msg));
  2305. }
  2306. return Ok(JsonView(groupData.Data));
  2307. }
  2308. /// <summary>
  2309. /// IOS获取团组签证拍照上传进度01(团组列表)
  2310. /// </summary>
  2311. /// <param name="dto">请求dto</param>
  2312. /// <returns></returns>
  2313. [HttpPost]
  2314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2315. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2316. {
  2317. if (dto == null)
  2318. {
  2319. return Ok(JsonView(false, "参数为空"));
  2320. }
  2321. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2322. return Ok(JsonView(visaList));
  2323. }
  2324. /// <summary>
  2325. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2326. /// </summary>
  2327. /// <returns></returns>
  2328. [HttpPost]
  2329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2330. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2331. {
  2332. if (dto == null)
  2333. {
  2334. return Ok(JsonView(false, "请求错误:"));
  2335. }
  2336. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2337. return Ok(JsonView(list));
  2338. }
  2339. /// <summary>
  2340. /// IOS获取团组签证拍照上传进度03(相册)
  2341. /// </summary>
  2342. /// <returns></returns>
  2343. [HttpPost]
  2344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2345. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2346. {
  2347. if (dto == null)
  2348. {
  2349. return Ok(JsonView(false, "请求错误:"));
  2350. }
  2351. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2352. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2353. list.ForEach(s => s.url = url);
  2354. return Ok(JsonView(list));
  2355. }
  2356. /// <summary>
  2357. /// IOS获取团组签证拍照上传进度04(图片上传)
  2358. /// </summary>
  2359. /// <param name="dto"></param>
  2360. /// <returns></returns>
  2361. [HttpPost]
  2362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2363. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2364. {
  2365. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2366. //if (!string.IsNullOrEmpty(result))
  2367. //{
  2368. //}
  2369. //else {
  2370. // return Ok(JsonView(false, "上传失败"));
  2371. //}
  2372. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2373. int sucNum = 0;
  2374. try
  2375. {
  2376. foreach (var item in dto.base64DataList)
  2377. {
  2378. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2379. string result = DecodeBase64ToImage(item, imageName);
  2380. if (!string.IsNullOrEmpty(result))
  2381. {
  2382. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2383. pic.CreateUserId = dto.CreateUserId;
  2384. pic.PicName = imageName;
  2385. pic.PicPath = result;
  2386. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2387. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2388. if (insertResult > 0)
  2389. {
  2390. sucNum++;
  2391. }
  2392. }
  2393. }
  2394. }
  2395. catch (Exception ex)
  2396. {
  2397. return Ok(JsonView(false, ex.Message));
  2398. }
  2399. string msg = string.Format(@"成功上传{0}张", sucNum);
  2400. return Ok(JsonView(true, msg));
  2401. }
  2402. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2403. {
  2404. string filename = "";//声明一个string类型的相对路径
  2405. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2406. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2407. try//会有异常抛出,try,catch一下
  2408. {
  2409. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2410. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2411. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2412. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2413. //文件名称
  2414. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2415. //上传的文件的路径
  2416. string filePath = "";
  2417. if (!Directory.Exists(fileDir))
  2418. {
  2419. Directory.CreateDirectory(fileDir);
  2420. }
  2421. //上传的文件的路径
  2422. filePath = fileDir + filename;
  2423. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2424. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2425. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2426. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2427. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2428. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2429. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2430. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2431. bitmap.Dispose();
  2432. }
  2433. catch (Exception e)
  2434. {
  2435. string massage = e.Message;
  2436. Logs("IOS图片上传Error:" + massage);
  2437. //filename = e.Message;
  2438. }
  2439. return filename;//返回相对路径
  2440. }
  2441. /// <summary>
  2442. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2443. /// </summary>
  2444. /// <param name="dto"></param>
  2445. /// <returns></returns>
  2446. [HttpPost]
  2447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2448. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2449. {
  2450. if (dto == null)
  2451. {
  2452. return Ok(JsonView(false, "请求错误:"));
  2453. }
  2454. string msg = "参数错误";
  2455. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2456. {
  2457. try
  2458. {
  2459. //_delegationVisaRep.BeginTran();
  2460. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2461. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2462. .Where(s => s.Id == dto.visaProgressCustomerId)
  2463. .ExecuteCommandAsync();
  2464. if (updCount > 0 && dto.publishCode == 1)
  2465. {
  2466. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2467. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2468. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2469. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2470. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2471. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2472. if (groupData == null)
  2473. {
  2474. _delegationVisaRep.RollbackTran();
  2475. }
  2476. string title = string.Format(@"[签证进度更新]");
  2477. string content = string.Format(@"测试文本");
  2478. bool rst = await _message.AddMsg(new MessageDto()
  2479. {
  2480. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2481. IssuerId = dto.publisher,
  2482. Title = title,
  2483. Content = content,
  2484. ReleaseTime = DateTime.Now,
  2485. UIdList = new List<int> {
  2486. 234
  2487. }
  2488. });
  2489. if (rst)
  2490. {
  2491. return Ok(JsonView(true, "发送通知成功"));
  2492. }
  2493. }
  2494. //_delegationVisaRep.CommitTran();
  2495. }
  2496. catch (Exception)
  2497. {
  2498. //_delegationVisaRep.RollbackTran();
  2499. }
  2500. }
  2501. return Ok(JsonView(true, msg));
  2502. }
  2503. #endregion
  2504. #region 团组任务分配
  2505. /// <summary>
  2506. /// 团组任务分配初始化
  2507. /// </summary>
  2508. /// <returns></returns>
  2509. [HttpPost]
  2510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2511. public async Task<IActionResult> GetTaskAssignmen()
  2512. {
  2513. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2514. if (groupData.Code != 0)
  2515. {
  2516. return Ok(JsonView(false, groupData.Msg));
  2517. }
  2518. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2519. }
  2520. /// <summary>
  2521. /// 团组任务分配查询
  2522. /// </summary>
  2523. /// <param name="dto"></param>
  2524. /// <returns></returns>
  2525. [HttpPost]
  2526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2527. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2528. {
  2529. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2530. if (groupData.Code != 0)
  2531. {
  2532. return Ok(JsonView(false, groupData.Msg));
  2533. }
  2534. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2535. }
  2536. /// <summary>
  2537. /// 团组任务分配操作
  2538. /// </summary>
  2539. /// <param name="dto"></param>
  2540. /// <returns></returns>
  2541. [HttpPost]
  2542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2543. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2544. {
  2545. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2546. if (groupData.Code != 0)
  2547. {
  2548. return Ok(JsonView(false, groupData.Msg));
  2549. }
  2550. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2551. }
  2552. /// <summary>
  2553. /// 团组任务分配
  2554. /// 批量分配
  2555. /// 查询团组
  2556. /// </summary>
  2557. /// <param name="dto"></param>
  2558. /// <returns></returns>
  2559. [HttpPost]
  2560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2561. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2562. {
  2563. //参数验证
  2564. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2565. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2566. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2567. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2568. }
  2569. /// <summary>
  2570. /// 团组任务分配
  2571. /// 批量分配
  2572. /// </summary>
  2573. /// <param name="dto"></param>
  2574. /// <returns></returns>
  2575. [HttpPost]
  2576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2577. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2578. {
  2579. //参数验证
  2580. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2581. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2582. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2583. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2584. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2585. }
  2586. #endregion
  2587. #region 团组费用审核
  2588. /// <summary>
  2589. /// 费用审核
  2590. /// 团组列表 Page
  2591. /// </summary>
  2592. /// <param name="_dto">团组列表请求dto</param>
  2593. /// <returns></returns>
  2594. [HttpPost]
  2595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2596. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2597. {
  2598. #region 参数验证
  2599. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2600. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2601. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2602. #region 页面操作权限验证
  2603. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2604. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2605. #endregion
  2606. #endregion
  2607. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2608. {
  2609. string sqlWhere = string.Empty;
  2610. if (_dto.IsSure == 0) //未完成
  2611. {
  2612. sqlWhere += string.Format(@" And IsSure = 0");
  2613. }
  2614. else if (_dto.IsSure == 1) //已完成
  2615. {
  2616. sqlWhere += string.Format(@" And IsSure = 1");
  2617. }
  2618. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2619. {
  2620. string tj = _dto.SearchCriteria;
  2621. 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}%')",
  2622. tj, tj, tj, tj, tj);
  2623. }
  2624. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2625. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2626. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2627. From (
  2628. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2629. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2630. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2631. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2632. From Grp_DelegationInfo gdi
  2633. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2634. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2635. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2636. Where gdi.IsDel = 0 {0}
  2637. ) temp ", sqlWhere);
  2638. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2639. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2640. var _view = new
  2641. {
  2642. PageFuncAuth = pageFunAuthView,
  2643. Data = _DelegationList
  2644. };
  2645. return Ok(JsonView(true, "查询成功!", _view, total));
  2646. }
  2647. else
  2648. {
  2649. return Ok(JsonView(false, "查询失败"));
  2650. }
  2651. }
  2652. /// <summary>
  2653. /// 获取团组费用审核
  2654. /// </summary>
  2655. /// <param name="_dto"></param>
  2656. /// <returns></returns>
  2657. [HttpPost]
  2658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2659. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2660. {
  2661. try
  2662. {
  2663. #region 参数验证
  2664. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2665. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2666. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2667. #region 页面操作权限验证
  2668. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2669. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2670. #endregion
  2671. #endregion
  2672. var _view = new Grp_CreditCardPaymentView();
  2673. var clientNameList = getSimplClientList(_dto.DiId);
  2674. #region 费用清单
  2675. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2676. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2677. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2678. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2679. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2680. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2681. /*
  2682. * 76://酒店预订
  2683. */
  2684. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2685. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2686. /*
  2687. * 79://车/导游地接
  2688. */
  2689. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2690. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2691. /*
  2692. * 80: //签证
  2693. */
  2694. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2695. /*
  2696. *81: //邀请/公务活动
  2697. */
  2698. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2699. /*
  2700. * 82: //团组客户保险
  2701. */
  2702. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2703. /*
  2704. * Lable = 85 机票预订
  2705. */
  2706. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2707. /*
  2708. * 85 机票预定
  2709. */
  2710. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2711. /*
  2712. * 98 其他款项
  2713. */
  2714. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2715. /*
  2716. * 285:收款退还
  2717. */
  2718. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2719. /*
  2720. * 1015: //超支费用
  2721. */
  2722. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2723. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2724. /*
  2725. * 币种信息
  2726. */
  2727. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2728. /*
  2729. * 车/导游地接 费用类型
  2730. */
  2731. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2732. /*
  2733. * 车/导游地接 费用类型
  2734. */
  2735. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2736. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2737. /*
  2738. * 用户信息
  2739. */
  2740. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2741. /*
  2742. * 费用模块
  2743. */
  2744. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2745. string priceModule = string.Empty;
  2746. if (sdPriceName != null)
  2747. {
  2748. priceModule = sdPriceName.Name;
  2749. }
  2750. /*
  2751. * 成本信息
  2752. */
  2753. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2754. decimal _groupRate = 0.0000M;
  2755. string _groupCurrencyCode = "-";
  2756. if (groupCost != null)
  2757. {
  2758. _groupRate = groupCost.Rate;
  2759. if (int.TryParse(groupCost.Currency, out int _currency))
  2760. {
  2761. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2762. }
  2763. else _groupCurrencyCode = groupCost.Currency;
  2764. }
  2765. string costContentSql = $"Select * From Grp_GroupCost";
  2766. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2767. //处理日期为空的天数
  2768. for (int i = 0; i < groupCostDetails.Count; i++)
  2769. if (i != 0)
  2770. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2771. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2772. /*
  2773. * 处理详情数据
  2774. */
  2775. foreach (var entity in entityList)
  2776. {
  2777. var _detail = new Grp_CreditCardPaymentDetailView();
  2778. _detail.Id = entity.Id;
  2779. _detail.PriceName = priceModule;
  2780. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2781. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2782. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2783. //处理金额
  2784. if (entity.CTable == 1015)
  2785. {
  2786. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2787. if (czInfo != null)
  2788. {
  2789. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2790. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2791. }
  2792. }
  2793. /*
  2794. * 应付款金额
  2795. */
  2796. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2797. string PaymentCurrency_WaitPay = "Unknown";
  2798. string hotelCurrncyCode = "Unknown";
  2799. string hotelCurrncyName = "Unknown";
  2800. if (sdPaymentCurrency_WaitPay != null)
  2801. {
  2802. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2803. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2804. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2805. if (hotelCurrncyCode.Equals("CNY"))
  2806. {
  2807. entity.DayRate = 1.0000M;
  2808. }
  2809. }
  2810. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2811. /*
  2812. * 此次付款金额
  2813. */
  2814. decimal CurrPayStr = 0.00M,
  2815. OriginalCurrPay = 0.00M;
  2816. if (entity.PayPercentage == 0)
  2817. {
  2818. if (entity.PayThenMoney != 0)
  2819. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2820. }
  2821. else
  2822. {
  2823. if (entity.PayMoney != 0)
  2824. {
  2825. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2826. }
  2827. }
  2828. //if (_dto.Label == 79)
  2829. //{
  2830. // string original = string.Empty;
  2831. // if (hotelCurrncyCode.Equals("CNY"))
  2832. // {
  2833. // OriginalCurrPay = CurrPayStr;
  2834. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2835. // }
  2836. // else
  2837. // {
  2838. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2839. // //760 EUR(7600.00 CNY)
  2840. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2841. // }
  2842. //}
  2843. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2844. string original = string.Empty;
  2845. if (hotelCurrncyCode.Equals("CNY"))
  2846. {
  2847. OriginalCurrPay = CurrPayStr;
  2848. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2849. }
  2850. else
  2851. {
  2852. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2853. //760 EUR(7600.00 CNY)
  2854. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2855. }
  2856. /*
  2857. * 剩余尾款
  2858. */
  2859. decimal BalanceStr = 0;
  2860. if (CurrPayStr != 0)
  2861. {
  2862. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2863. BalanceStr = 0;
  2864. else
  2865. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2866. }
  2867. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2868. /*
  2869. * Bus名称
  2870. */
  2871. _detail.BusName = "待增加";
  2872. /*
  2873. *费用所属
  2874. */
  2875. switch (entity.CTable)
  2876. {
  2877. case 76://酒店预订
  2878. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2879. if (hotelReservations != null)
  2880. {
  2881. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2882. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2883. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2884. string roomFeeStr = "", roomFeestr1 = "";
  2885. //是否比较房型价格
  2886. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2887. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2888. roomFeeStr += $"<br/>";
  2889. var roomTotal = 0.00M;
  2890. if (hotelReservations.SingleRoomPrice > 0)
  2891. {
  2892. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2893. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2894. //__isSingle = true;
  2895. roomTotal += fee;
  2896. }
  2897. if (hotelReservations.DoubleRoomPrice > 0)
  2898. {
  2899. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2900. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2901. // __isDouble = true;
  2902. roomTotal += fee;
  2903. }
  2904. if (hotelReservations.SuiteRoomPrice > 0)
  2905. {
  2906. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2907. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2908. //__isSuite = true;
  2909. roomTotal += fee;
  2910. }
  2911. if (hotelReservations.OtherRoomPrice > 0)
  2912. {
  2913. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2914. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2915. //__isOther = true;
  2916. roomTotal += fee;
  2917. }
  2918. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2919. else roomFeeStr += " 0.00 * 0";
  2920. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2921. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2922. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2923. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2924. /*
  2925. * 费用类型
  2926. * 1:房费
  2927. * 2:早餐
  2928. * 3:地税
  2929. * 4:城市税
  2930. * </summary>
  2931. */
  2932. //地税
  2933. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2934. if (governmentRentData != null)
  2935. {
  2936. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2937. governmentRentFee = governmentRentData.Price;
  2938. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2939. if (governmentRentCurrData != null)
  2940. {
  2941. governmentRentCode = governmentRentCurrData.Name;
  2942. governmentRentName = $"({governmentRentCurrData.Remark})";
  2943. }
  2944. }
  2945. //城市税
  2946. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2947. if (cityTaxData != null)
  2948. {
  2949. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2950. cityTaxFee = cityTaxData.Price;
  2951. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2952. if (cityTaxCurrData != null)
  2953. {
  2954. cityTaxCode = cityTaxCurrData.Name;
  2955. cityTaxName = $"({cityTaxCurrData.Remark})";
  2956. }
  2957. }
  2958. //酒店早餐
  2959. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2960. if (breakfastData != null)
  2961. {
  2962. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2963. breakfastFee = breakfastData.Price;
  2964. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2965. if (breakfastCurrData != null)
  2966. {
  2967. breakfastCode = breakfastCurrData.Name;
  2968. breakfastName = $"({breakfastCurrData.Remark})";
  2969. }
  2970. }
  2971. //房间费用
  2972. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2973. if (roomData != null)
  2974. {
  2975. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2976. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2977. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2978. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2979. roomFee = roomData.Price;
  2980. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2981. if (roomCurrData != null)
  2982. {
  2983. roomCode = roomCurrData.Name;
  2984. roomName = $"({roomCurrData.Remark})";
  2985. }
  2986. }
  2987. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2988. string hotelCostStr = "";
  2989. decimal hotelCsotTotal = 0.00M;
  2990. if (groupCost != null)
  2991. {
  2992. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2993. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2994. }
  2995. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2996. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2997. string hotelCost_day = "";
  2998. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2999. foreach (var item in hotelCostDetails1)
  3000. {
  3001. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3002. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3003. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  3004. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3005. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  3006. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3007. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  3008. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3009. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  3010. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3011. hotelCost_day += @$"<br/>";
  3012. }
  3013. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3014. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3015. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3016. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3017. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3018. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3019. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3020. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3021. $"房间说明: {hotelReservations.Remark} <br/>" +
  3022. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3023. $"{hotelBreakfastStr}" +
  3024. $"{hotelGovernmentRentStr}" +
  3025. $"{hotelCityTaxStr}";
  3026. _detail.PriceNameContent = hotelReservations.HotelName;
  3027. }
  3028. break;
  3029. case 79://车/导游地接
  3030. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3031. if (touristGuideGroundReservations != null)
  3032. {
  3033. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3034. {
  3035. _detail.BusName = touristGuideGroundReservations.BusName;
  3036. }
  3037. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3038. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3039. //if (isInt)
  3040. //{
  3041. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3042. // if (cityInfo != null)
  3043. // {
  3044. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3045. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3046. // if (carFeeItem != null)
  3047. // {
  3048. // nameContent += $@"({carFeeItem.Name})";
  3049. // }
  3050. // _detail.PriceNameContent = nameContent;
  3051. // }
  3052. //}
  3053. //else
  3054. //{
  3055. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3056. //}
  3057. var touristGuideGroundReservationsContents =
  3058. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3059. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3060. foreach (var item in touristGuideGroundReservationsContents)
  3061. {
  3062. string typeName = "Unknown";
  3063. string carCurrencyCode = "Unknown";
  3064. string carCurrencyName = "Unknown";
  3065. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3066. if (carTypeData != null) typeName = carTypeData.Name;
  3067. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3068. if (currencyData != null)
  3069. {
  3070. carCurrencyCode = currencyData.Name;
  3071. carCurrencyName = currencyData.Remark;
  3072. }
  3073. //op、成本 币种是否一致
  3074. bool IsCurrencyAgreement = false;
  3075. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3076. string opCostStr = string.Empty;
  3077. decimal opCostTypePrice = 0.00M;
  3078. #region 处理成本各项费用
  3079. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3080. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3081. if (opCost.Count > 0)
  3082. {
  3083. switch (item.SId)
  3084. {
  3085. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3086. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3087. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3088. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3089. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3090. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3091. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3092. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3093. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3094. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3095. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3096. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3097. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3098. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3099. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3100. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3101. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3102. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3103. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3104. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3105. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3106. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3107. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3108. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3109. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3110. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3111. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3112. }
  3113. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  3114. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  3115. }
  3116. #endregion
  3117. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  3118. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  3119. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3120. $"{opTypeStr} {opCostStr}<br/>" +
  3121. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3122. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3123. }
  3124. _detail.PriceMsgContent = priceMsg;
  3125. }
  3126. break;
  3127. case 80: //签证
  3128. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3129. if (visaInfo != null)
  3130. {
  3131. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3132. _detail.PriceNameContent = visaInfo.VisaDescription;
  3133. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3134. }
  3135. break;
  3136. case 81: //邀请/公务活动
  3137. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3138. if (_ioa != null)
  3139. {
  3140. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3141. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3142. sendCurrName = "Unknown", //快递费用币种 Name
  3143. sendCurrCode = "Unknown", //快递费用币种 Code
  3144. eventsCurrName = "Unknown", //公务活动费币种 Name
  3145. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3146. translateCurrName = "Unknown", //公务翻译费 Name
  3147. translateCurrCode = "Unknown"; //公务翻译费 Code
  3148. #region 处理费用币种
  3149. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3150. if (inviteCurrData != null)
  3151. {
  3152. inviteCurrName = inviteCurrData.Remark;
  3153. inviteCurrCode = inviteCurrData.Name;
  3154. }
  3155. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3156. if (sendCurrData != null)
  3157. {
  3158. sendCurrName = sendCurrData.Remark;
  3159. sendCurrCode = sendCurrData.Name;
  3160. }
  3161. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3162. if (eventsCurrData != null)
  3163. {
  3164. eventsCurrName = eventsCurrData.Remark;
  3165. eventsCurrCode = eventsCurrData.Name;
  3166. }
  3167. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3168. if (translateCurrData != null)
  3169. {
  3170. translateCurrName = translateCurrData.Remark;
  3171. translateCurrCode = translateCurrData.Name;
  3172. }
  3173. #endregion
  3174. _detail.PriceNameContent = _ioa.InviterArea;
  3175. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3176. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3177. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3178. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3179. $@"备注:" + _ioa.Remark + "<br/>";
  3180. }
  3181. break;
  3182. case 82: //团组客户保险
  3183. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3184. if (customers != null)
  3185. {
  3186. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3187. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3188. }
  3189. break;
  3190. case 85: //机票预订
  3191. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3192. if (jpRes != null)
  3193. {
  3194. string FlightsDescription = jpRes.FlightsDescription;
  3195. string PriceDescription = jpRes.PriceDescription;
  3196. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3197. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3198. }
  3199. break;
  3200. case 98://其他款项
  3201. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3202. if (gdpRes != null)
  3203. {
  3204. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3205. _detail.PriceNameContent = gdpRes.PriceName;
  3206. }
  3207. break;
  3208. case 285://收款退还
  3209. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3210. if (refundAndOtherMoney != null)
  3211. {
  3212. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3213. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3214. }
  3215. break;
  3216. case 751://酒店早餐
  3217. break;
  3218. case 1015://超支费用
  3219. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3220. if (groupExtraCost != null)
  3221. {
  3222. _detail.PriceNameContent = groupExtraCost.PriceName;
  3223. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3224. }
  3225. break;
  3226. default:
  3227. break;
  3228. }
  3229. /*
  3230. * 申请人
  3231. */
  3232. string operatorName = " - ";
  3233. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3234. if (_opUser != null)
  3235. {
  3236. operatorName = _opUser.CnName;
  3237. }
  3238. _detail.OperatorName = operatorName;
  3239. /*
  3240. * 审核人
  3241. */
  3242. string auditOperatorName = "Unknown";
  3243. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3244. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3245. else
  3246. {
  3247. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3248. if (_adUser != null)
  3249. {
  3250. auditOperatorName = _adUser.CnName;
  3251. }
  3252. }
  3253. _detail.AuditOperatorName = auditOperatorName;
  3254. /*
  3255. * 超预算比例
  3256. */
  3257. string overBudgetStr = "";
  3258. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3259. else if (entity.ExceedBudget == 0)
  3260. {
  3261. if (entity.CTable == 76 || entity.CTable == 79)
  3262. {
  3263. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3264. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3265. }
  3266. else
  3267. {
  3268. overBudgetStr = "未超预算";
  3269. }
  3270. }
  3271. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3272. _detail.OverBudget = overBudgetStr;
  3273. decimal auditFee = 0.00M; //已审核金额 人名币
  3274. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3275. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3276. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3277. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3278. {
  3279. auditedFeeOriginal = entity.PayMoney;
  3280. auditFee = CurrPayStr;
  3281. }
  3282. else if (entity.IsAuditGM == 0)
  3283. {
  3284. unAuditFeeCNY = CurrPayStr;
  3285. unAuditFeeOriginal = OriginalCurrPay;
  3286. OriginalCurrPay = 0.00M;
  3287. }
  3288. /*
  3289. * 费用总计
  3290. */
  3291. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3292. {
  3293. CurrencyId = entity.PaymentCurrency,
  3294. CurrencyName = PaymentCurrency_WaitPay,
  3295. AmountPayable = entity.PayMoney,
  3296. ThisPayment = OriginalCurrPay,
  3297. BalancePayment = BalanceStr,
  3298. AuditedFunds = auditFee,
  3299. AuditedFundsOriginal = auditedFeeOriginal,
  3300. UnAuditFundsCNY = unAuditFeeCNY,
  3301. UnAuditFundsOriginal = unAuditFeeOriginal
  3302. });
  3303. _detail.IsAuditGM = entity.IsAuditGM;
  3304. detailList.Add(_detail);
  3305. }
  3306. #endregion
  3307. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3308. /*
  3309. * 下方描述处理
  3310. */
  3311. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3312. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3313. if (ccpCurrencyPrice != null)
  3314. {
  3315. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3316. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3317. }
  3318. else
  3319. {
  3320. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3321. }
  3322. string amountPayableStr = string.Format(@"应付款总金额: ");
  3323. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3324. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3325. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3326. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3327. foreach (var item in nonDuplicat)
  3328. {
  3329. var currencyName = item.CurrencyName;
  3330. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3331. if (strs.Count > 0)
  3332. {
  3333. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3334. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3335. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3336. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3337. //单独处理此次付款金额
  3338. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3339. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3340. //单独处理已审核费用
  3341. //if (item.CurrencyId == 836) //人民币
  3342. //{
  3343. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3344. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3345. //}
  3346. //else
  3347. //{
  3348. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3349. //}
  3350. if (currencyName.Equals("CNY"))
  3351. {
  3352. //已审核费用
  3353. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3354. //未审核费用
  3355. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3356. }
  3357. else
  3358. {
  3359. //已审核费用
  3360. 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"));
  3361. //未审核费用
  3362. 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"));
  3363. }
  3364. }
  3365. }
  3366. _view.TotalStr1 = amountPayableStr[..^1];
  3367. _view.TotalStr2 = thisPaymentStr[..^1];
  3368. _view.TotalStr3 = balancePaymentStr[..^1];
  3369. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3370. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3371. var _view1 = new
  3372. {
  3373. PageFuncAuth = pageFunAuthView,
  3374. Data = _view
  3375. };
  3376. return Ok(JsonView(_view1));
  3377. }
  3378. catch (Exception ex)
  3379. {
  3380. return Ok(JsonView(false, ex.Message));
  3381. }
  3382. }
  3383. /// <summary>
  3384. /// 费用审核
  3385. /// 修改团组费用审核状态
  3386. /// </summary>
  3387. /// <param name="_dto">参数Json字符串</param>
  3388. /// <returns></returns>
  3389. [HttpPost]
  3390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3391. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3392. {
  3393. #region 参数验证
  3394. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3395. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3396. #endregion
  3397. #region 页面操作权限验证
  3398. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3399. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3400. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3401. #endregion
  3402. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3403. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3404. DateTime dtNow = DateTime.Now;
  3405. _groupRepository.BeginTran();
  3406. int rst = 0;
  3407. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3408. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3409. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3410. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3411. List<dynamic> msgDatas = new List<dynamic>();
  3412. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3413. foreach (var item in idList)
  3414. {
  3415. int CreditId = int.Parse(item);
  3416. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3417. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3418. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3419. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3420. .Where(s => s.Id == CreditId)
  3421. .ExecuteCommandAsync();
  3422. if (result < 1)
  3423. {
  3424. rst = -1;
  3425. _groupRepository.RollbackTran();
  3426. return Ok(JsonView(false, "操作失败并回滚!"));
  3427. }
  3428. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3429. if (creditData != null)
  3430. {
  3431. #region 应用通知配置
  3432. try
  3433. {
  3434. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3435. }
  3436. catch (Exception ex)
  3437. {
  3438. }
  3439. #endregion
  3440. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3441. string groupNameStr = string.Empty;
  3442. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3443. if (groupData != null) groupNameStr = groupData.TeamName;
  3444. string creditTypeStr = string.Empty;
  3445. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3446. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3447. string creditCurrency = string.Empty;
  3448. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3449. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3450. if (creditCurrency.Equals("CNY"))
  3451. {
  3452. creditData.DayRate = 1.0000M;
  3453. }
  3454. if (creditData.PayPercentage == 0.00M)
  3455. {
  3456. creditData.PayPercentage = 100M;
  3457. }
  3458. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3459. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3460. string msgContent = "";
  3461. if (creditCurrency.Equals("CNY"))
  3462. {
  3463. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3464. }
  3465. else
  3466. {
  3467. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3468. }
  3469. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3470. }
  3471. }
  3472. if (rst == 0)
  3473. {
  3474. _groupRepository.CommitTran();
  3475. foreach (var item in msgDatas)
  3476. {
  3477. //发送消息
  3478. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3479. }
  3480. #region 应用推送
  3481. try
  3482. {
  3483. foreach (var ccpId in dic_ccp_user.Keys)
  3484. {
  3485. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3486. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3487. }
  3488. }
  3489. catch (Exception)
  3490. {
  3491. }
  3492. #endregion
  3493. return Ok(JsonView(true, "操作成功!"));
  3494. }
  3495. return Ok(JsonView(false, "操作失败!"));
  3496. }
  3497. #endregion
  3498. #region 机票费用录入
  3499. /// <summary>
  3500. /// 机票录入当前登录人可操作团组
  3501. /// </summary>
  3502. /// <param name="dto"></param>
  3503. /// <returns></returns>
  3504. [HttpPost]
  3505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3506. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3507. {
  3508. try
  3509. {
  3510. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3511. if (groupData.Code != 0)
  3512. {
  3513. return Ok(JsonView(false, groupData.Msg));
  3514. }
  3515. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3516. }
  3517. catch (Exception ex)
  3518. {
  3519. return Ok(JsonView(false, "程序错误!"));
  3520. throw;
  3521. }
  3522. }
  3523. /// <summary>
  3524. /// 机票费用录入列表
  3525. /// </summary>
  3526. /// <param name="dto"></param>
  3527. /// <returns></returns>
  3528. [HttpPost]
  3529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3530. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3531. {
  3532. try
  3533. {
  3534. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3535. if (groupData.Code != 0)
  3536. {
  3537. return Ok(JsonView(false, groupData.Msg));
  3538. }
  3539. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3540. }
  3541. catch (Exception ex)
  3542. {
  3543. return Ok(JsonView(false, ex.Message));
  3544. throw;
  3545. }
  3546. }
  3547. /// <summary>
  3548. /// 根据id查询费用录入信息
  3549. /// </summary>
  3550. /// <param name="dto"></param>
  3551. /// <returns></returns>
  3552. [HttpPost]
  3553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3554. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3555. {
  3556. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3557. if (groupData.Code != 0)
  3558. {
  3559. return Ok(JsonView(false, groupData.Msg));
  3560. }
  3561. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3562. }
  3563. /// <summary>
  3564. /// 机票费用录入操作(Status:1.新增,2.修改)
  3565. /// </summary>
  3566. /// <param name="dto"></param>
  3567. /// <returns></returns>
  3568. [HttpPost]
  3569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3570. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3571. {
  3572. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3573. if (groupData.Code != 0)
  3574. {
  3575. return Ok(JsonView(false, groupData.Msg));
  3576. }
  3577. #region 应用推送
  3578. try
  3579. {
  3580. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3581. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3582. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3583. //2024-10-21 新增LZ UID
  3584. var userIds = new List<int>() { 21 };
  3585. string title = $"系统通知";
  3586. string content = "";
  3587. var diId = dto.AirTicketResOpData.DiId;
  3588. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3589. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3590. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3591. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3592. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3593. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3594. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3595. }
  3596. catch (Exception ex)
  3597. {
  3598. }
  3599. #endregion
  3600. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3601. }
  3602. /// <summary>
  3603. /// 根据舱位类型查询接团客户名单信息
  3604. /// </summary>
  3605. /// <param name="dto"></param>
  3606. /// <returns></returns>
  3607. [HttpPost]
  3608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3609. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3610. {
  3611. try
  3612. {
  3613. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3614. if (crm_Groups.Count != 0)
  3615. {
  3616. List<dynamic> Customer = new List<dynamic>();
  3617. foreach (var item in crm_Groups)
  3618. {
  3619. var data = new
  3620. {
  3621. Id = item.Id,
  3622. Pinyin = item.Pinyin,
  3623. Name = item.LastName + item.FirstName
  3624. };
  3625. Customer.Add(data);
  3626. }
  3627. return Ok(JsonView(true, "查询成功!", Customer));
  3628. }
  3629. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3630. }
  3631. catch (Exception ex)
  3632. {
  3633. return Ok(JsonView(false, "程序错误!"));
  3634. throw;
  3635. }
  3636. }
  3637. /// <summary>
  3638. /// 根据团号获取客户信息
  3639. /// </summary>
  3640. /// <param name="dto"></param>
  3641. /// <returns></returns>
  3642. [HttpPost]
  3643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3644. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3645. {
  3646. var jw = JsonView(false);
  3647. if (dto.DIID < 1)
  3648. {
  3649. jw.Msg += "请输入正确的diid";
  3650. return Ok(jw);
  3651. }
  3652. var arr = getSimplClientList(dto.DIID);
  3653. jw = JsonView(true, "获取成功!", arr);
  3654. return Ok(jw);
  3655. }
  3656. private List<SimplClientInfo> getSimplClientList(int diId)
  3657. {
  3658. 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);
  3659. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3660. foreach (var item in arr)
  3661. {
  3662. EncryptionProcessor.DecryptProperties(item);
  3663. }
  3664. return arr;
  3665. }
  3666. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3667. {
  3668. string result = origin;
  3669. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3670. {
  3671. string[] temparr = origin.Split(',');
  3672. string fistrStr = temparr[0];
  3673. int count = temparr.Count();
  3674. int tempId;
  3675. bool success = int.TryParse(fistrStr, out tempId);
  3676. if (success)
  3677. {
  3678. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3679. if (tempInfo != null)
  3680. {
  3681. if (count > 1)
  3682. {
  3683. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3684. }
  3685. else
  3686. {
  3687. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3688. }
  3689. }
  3690. }
  3691. }
  3692. return result;
  3693. }
  3694. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3695. {
  3696. string result = origin;
  3697. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3698. {
  3699. string[] temparr = origin.Split(',');
  3700. result = "";
  3701. foreach (var item in temparr)
  3702. {
  3703. int tempId;
  3704. bool success = int.TryParse(item, out tempId);
  3705. if (success)
  3706. {
  3707. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3708. if (tempInfo != null)
  3709. {
  3710. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3711. }
  3712. }
  3713. }
  3714. }
  3715. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3716. return result;
  3717. }
  3718. /// <summary>
  3719. /// 机票费用录入,删除
  3720. /// </summary>
  3721. /// <param name="dto"></param>
  3722. /// <returns></returns>
  3723. [HttpPost]
  3724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3725. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3726. {
  3727. try
  3728. {
  3729. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3730. if (res)
  3731. {
  3732. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3733. {
  3734. IsDel = 1,
  3735. DeleteUserId = dto.DeleteUserId,
  3736. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3737. }).ExecuteCommandAsync();
  3738. return Ok(JsonView(true, "删除成功!"));
  3739. }
  3740. return Ok(JsonView(false, "删除失败!"));
  3741. }
  3742. catch (Exception ex)
  3743. {
  3744. return Ok(JsonView(false, "程序错误!"));
  3745. throw;
  3746. }
  3747. }
  3748. /// <summary>
  3749. /// 导出机票录入报表
  3750. /// </summary>
  3751. /// <param name="dto"></param>
  3752. /// <returns></returns>
  3753. [HttpPost]
  3754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3755. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3756. {
  3757. try
  3758. {
  3759. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3760. if (groupData.Code != 0)
  3761. {
  3762. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3763. }
  3764. else
  3765. {
  3766. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3767. if (AirTicketReservations.Count != 0)
  3768. {
  3769. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3770. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3771. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3772. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3773. WorkbookDesigner designer = new WorkbookDesigner();
  3774. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3775. decimal countCost = 0;
  3776. foreach (var item in AirTicketReservations)
  3777. {
  3778. #region 处理客人姓名
  3779. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3780. item.ClientName = clientNames;
  3781. #endregion
  3782. if (item.BankType == "其他")
  3783. {
  3784. item.BankNo = "--";
  3785. }
  3786. else
  3787. {
  3788. if (!string.IsNullOrEmpty(item.BankType))
  3789. {
  3790. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3791. }
  3792. }
  3793. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3794. item.Price = System.Decimal.Round(item.Price, 2);
  3795. countCost += Convert.ToDecimal(item.Price);
  3796. }
  3797. designer.SetDataSource("Export", AirTicketReservations);
  3798. designer.SetDataSource("ExportDiCode", diCode);
  3799. designer.SetDataSource("ExportDiName", diName);
  3800. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3801. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3802. designer.Process();
  3803. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3804. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3805. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3806. return Ok(JsonView(true, "成功", url = rst));
  3807. }
  3808. else
  3809. {
  3810. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3811. }
  3812. }
  3813. }
  3814. catch (Exception ex)
  3815. {
  3816. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3817. throw;
  3818. }
  3819. }
  3820. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3821. /// <summary>
  3822. /// 行程单导出
  3823. /// </summary>
  3824. /// <param name="dto"></param>
  3825. /// <returns></returns>
  3826. [HttpPost]
  3827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3828. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3829. {
  3830. try
  3831. {
  3832. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3833. if (groupData.Code != 0)
  3834. {
  3835. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3836. }
  3837. else
  3838. {
  3839. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3840. if (dto.Language == "CN")
  3841. {
  3842. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3843. DocumentBuilder builder = new DocumentBuilder(doc);
  3844. int tableIndex = 0;//表格索引
  3845. //得到文档中的第一个表格
  3846. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3847. foreach (var item in _AirTicketReservations)
  3848. {
  3849. #region 处理固定数据
  3850. string[] FlightsCode = item.FlightsCode.Split('/');
  3851. if (FlightsCode.Length != 0)
  3852. {
  3853. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3854. if (_AirCompany != null)
  3855. {
  3856. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3857. }
  3858. else
  3859. {
  3860. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3861. }
  3862. }
  3863. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3864. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3865. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3866. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3867. string name = "";
  3868. foreach (string clientName in nameArray)
  3869. {
  3870. if (!name.Contains(clientName))
  3871. {
  3872. name += clientName + ",";
  3873. }
  3874. }
  3875. if (!string.IsNullOrWhiteSpace(name))
  3876. {
  3877. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3878. }
  3879. else
  3880. {
  3881. table.Range.Bookmarks["ClientName"].Text = "--";
  3882. }
  3883. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3884. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3885. table.Range.Bookmarks["JointTicket"].Text = "--";
  3886. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3887. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3888. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3889. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3890. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3891. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3892. #endregion
  3893. #region 循环数据处理
  3894. List<AirInfo> airs = new List<AirInfo>();
  3895. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3896. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3897. for (int i = 0; i < FlightsCode.Length; i++)
  3898. {
  3899. AirInfo air = new AirInfo();
  3900. string[] tempstr = DayArray[i]
  3901. .Replace("\r\n", string.Empty)
  3902. .Replace("\\r\\n", string.Empty)
  3903. .TrimStart().TrimEnd()
  3904. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3905. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3906. string starCity = "";
  3907. if (star_Three != null)
  3908. {
  3909. starCity = star_Three.AirPort;
  3910. }
  3911. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3912. string EndCity = "";
  3913. if (End_Three != null)
  3914. {
  3915. EndCity = End_Three.AirPort;
  3916. }
  3917. air.Destination = starCity + "/" + EndCity;
  3918. air.Flight = FlightsCode[i];
  3919. air.SeatingClass = item.CTypeName;
  3920. string dateTime = tempstr[2];
  3921. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3922. air.FlightDate = DateTemp;
  3923. air.DepartureTime = tempstr[5];
  3924. air.LandingTime = tempstr[6];
  3925. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3926. air.TicketStatus = "--";
  3927. air.Luggage = "--";
  3928. air.DepartureTerminal = "--";
  3929. air.LandingTerminal = "--";
  3930. airs.Add(air);
  3931. }
  3932. int row = 13;
  3933. for (int i = 0; i < airs.Count; i++)
  3934. {
  3935. if (airs.Count > 2)
  3936. {
  3937. for (int j = 0; j < airs.Count - 2; j++)
  3938. {
  3939. var CopyRow = table.Rows[12].Clone(true);
  3940. table.Rows.Add(CopyRow);
  3941. }
  3942. }
  3943. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3944. int index = 0;
  3945. foreach (PropertyInfo property in properties)
  3946. {
  3947. string value = property.GetValue(airs[i]).ToString();
  3948. Cell ishcel0 = table.Rows[row].Cells[index];
  3949. Paragraph p = new Paragraph(doc);
  3950. string s = value;
  3951. p.AppendChild(new Run(doc, s));
  3952. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3953. ishcel0.AppendChild(p);
  3954. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3955. index++;
  3956. }
  3957. row++;
  3958. }
  3959. #endregion
  3960. Paragraph lastParagraph = new Paragraph(doc);
  3961. //第一个表格末尾加段落
  3962. table.ParentNode.InsertAfter(lastParagraph, table);
  3963. //复制第一个表格
  3964. Table cloneTable = (Table)table.Clone(true);
  3965. //在文档末尾段落后面加入复制的表格
  3966. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3967. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3968. {
  3969. int rownewsIndex = 13;
  3970. for (int i = 0; i < 2; i++)
  3971. {
  3972. var CopyRow = table.Rows[12].Clone(true);
  3973. table.Rows.RemoveAt(13);
  3974. table.Rows.Add(CopyRow);
  3975. rownewsIndex++;
  3976. }
  3977. }
  3978. else
  3979. {
  3980. table.Rows.RemoveAt(12);
  3981. }
  3982. cloneTable.Rows.RemoveAt(12);
  3983. }
  3984. if (_AirTicketReservations.Count != 0)
  3985. {
  3986. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3987. if (FlightsCode.Length != 0)
  3988. {
  3989. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3990. if (_AirCompany != null)
  3991. {
  3992. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3993. }
  3994. else
  3995. {
  3996. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3997. }
  3998. }
  3999. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4000. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4001. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4002. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4003. string name = "";
  4004. foreach (string clientName in nameArray)
  4005. {
  4006. if (!name.Contains(clientName))
  4007. {
  4008. name += clientName + ",";
  4009. }
  4010. }
  4011. if (!string.IsNullOrWhiteSpace(name))
  4012. {
  4013. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4014. }
  4015. else
  4016. {
  4017. table.Range.Bookmarks["ClientName"].Text = "--";
  4018. }
  4019. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4020. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4021. table.Range.Bookmarks["JointTicket"].Text = "--";
  4022. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4023. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4024. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4025. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4026. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4027. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4028. }
  4029. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4030. //保存合并后的文档
  4031. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4032. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4033. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4034. return Ok(JsonView(true, "成功!", rst));
  4035. }
  4036. else
  4037. {
  4038. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4039. DocumentBuilder builder = new DocumentBuilder(doc);
  4040. int tableIndex = 0;//表格索引
  4041. //得到文档中的第一个表格
  4042. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4043. List<string> texts = new List<string>();
  4044. foreach (var item in _AirTicketReservations)
  4045. {
  4046. string[] FlightsCode = item.FlightsCode.Split('/');
  4047. if (FlightsCode.Length != 0)
  4048. {
  4049. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4050. if (_AirCompany != null)
  4051. {
  4052. if (!transDic.ContainsKey(_AirCompany.CnName))
  4053. {
  4054. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4055. }
  4056. }
  4057. else
  4058. {
  4059. if (!transDic.ContainsKey("--"))
  4060. {
  4061. transDic.Add("--", "--");
  4062. }
  4063. }
  4064. }
  4065. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4066. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4067. string name = "";
  4068. foreach (string clientName in nameArray)
  4069. {
  4070. name += clientName + ",";
  4071. }
  4072. if (!texts.Contains(name))
  4073. {
  4074. texts.Add(name);
  4075. }
  4076. List<AirInfo> airs = new List<AirInfo>();
  4077. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4078. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4079. for (int i = 0; i < FlightsCode.Length; i++)
  4080. {
  4081. AirInfo air = new AirInfo();
  4082. string[] tempstr = DayArray[i]
  4083. .Replace("\r\n", string.Empty)
  4084. .Replace("\\r\\n", string.Empty)
  4085. .TrimStart().TrimEnd()
  4086. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4087. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4088. if (star_Three != null)
  4089. {
  4090. if (!transDic.ContainsKey(star_Three.AirPort))
  4091. {
  4092. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4093. }
  4094. }
  4095. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4096. if (End_Three != null)
  4097. {
  4098. if (!transDic.ContainsKey(End_Three.AirPort))
  4099. {
  4100. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4101. }
  4102. }
  4103. if (!texts.Contains(item.CTypeName))
  4104. {
  4105. texts.Add(item.CTypeName);
  4106. }
  4107. }
  4108. }
  4109. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4110. if (transData.Count > 0)
  4111. {
  4112. foreach (TranslateResult item in transData)
  4113. {
  4114. if (!transDic.ContainsKey(item.Query))
  4115. {
  4116. transDic.Add(item.Query, item.Translation);
  4117. }
  4118. }
  4119. }
  4120. foreach (var item in _AirTicketReservations)
  4121. {
  4122. #region 处理固定数据
  4123. string[] FlightsCode = item.FlightsCode.Split('/');
  4124. if (FlightsCode.Length != 0)
  4125. {
  4126. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4127. if (_AirCompany != null)
  4128. {
  4129. string str = "--";
  4130. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4131. if (!string.IsNullOrEmpty(translateResult))
  4132. {
  4133. str = translateResult;
  4134. str = _airTicketResRep.Processing(str);
  4135. }
  4136. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4137. }
  4138. else
  4139. {
  4140. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4141. }
  4142. }
  4143. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4144. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4145. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4146. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4147. string names = "";
  4148. foreach (string clientName in nameArray)
  4149. {
  4150. names += clientName + ",";
  4151. }
  4152. if (!string.IsNullOrWhiteSpace(names))
  4153. {
  4154. string str = "--";
  4155. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4156. if (!string.IsNullOrEmpty(translateResult))
  4157. {
  4158. str = translateResult;
  4159. str = _airTicketResRep.Processing(str);
  4160. }
  4161. table.Range.Bookmarks["ClientName"].Text = str;
  4162. }
  4163. else
  4164. {
  4165. table.Range.Bookmarks["ClientName"].Text = "--";
  4166. }
  4167. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4168. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4169. table.Range.Bookmarks["JointTicket"].Text = "--";
  4170. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4171. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4172. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4173. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4174. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4175. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4176. #endregion
  4177. #region 循环数据处理
  4178. List<AirInfo> airs = new List<AirInfo>();
  4179. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4180. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4181. for (int i = 0; i < FlightsCode.Length; i++)
  4182. {
  4183. AirInfo air = new AirInfo();
  4184. string[] tempstr = DayArray[i]
  4185. .Replace("\r\n", string.Empty)
  4186. .Replace("\\r\\n", string.Empty)
  4187. .TrimStart().TrimEnd()
  4188. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4189. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4190. string starCity = "";
  4191. if (star_Three != null)
  4192. {
  4193. string str2 = "--";
  4194. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4195. if (!string.IsNullOrEmpty(translateResult2))
  4196. {
  4197. str2 = translateResult2;
  4198. str2 = _airTicketResRep.Processing(str2);
  4199. }
  4200. starCity = str2;
  4201. }
  4202. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4203. string EndCity = "";
  4204. if (End_Three != null)
  4205. {
  4206. string str1 = "--";
  4207. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4208. if (!string.IsNullOrEmpty(translateResult1))
  4209. {
  4210. str1 = translateResult1;
  4211. str1 = _airTicketResRep.Processing(str1);
  4212. }
  4213. EndCity = str1;
  4214. }
  4215. air.Destination = starCity + "/" + EndCity;
  4216. air.Flight = FlightsCode[i];
  4217. string str = "--";
  4218. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4219. if (!string.IsNullOrEmpty(translateResult))
  4220. {
  4221. str = translateResult;
  4222. str = _airTicketResRep.Processing(str);
  4223. }
  4224. air.SeatingClass = str;
  4225. string dateTime = tempstr[2];
  4226. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4227. air.FlightDate = DateTemp;
  4228. air.DepartureTime = tempstr[5];
  4229. air.LandingTime = tempstr[6];
  4230. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4231. air.TicketStatus = "--";
  4232. air.Luggage = "--";
  4233. air.DepartureTerminal = "--";
  4234. air.LandingTerminal = "--";
  4235. airs.Add(air);
  4236. }
  4237. int row = 13;
  4238. for (int i = 0; i < airs.Count; i++)
  4239. {
  4240. if (airs.Count > 2)
  4241. {
  4242. for (int j = 0; j < airs.Count - 2; j++)
  4243. {
  4244. var CopyRow = table.Rows[12].Clone(true);
  4245. table.Rows.Add(CopyRow);
  4246. }
  4247. }
  4248. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4249. int index = 0;
  4250. foreach (PropertyInfo property in properties)
  4251. {
  4252. string value = property.GetValue(airs[i]).ToString();
  4253. Cell ishcel0 = table.Rows[row].Cells[index];
  4254. Paragraph p = new Paragraph(doc);
  4255. string s = value;
  4256. p.AppendChild(new Run(doc, s));
  4257. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4258. ishcel0.AppendChild(p);
  4259. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4260. //ishcel0.CellFormat.VerticalAlignment=
  4261. index++;
  4262. }
  4263. row++;
  4264. }
  4265. #endregion
  4266. Paragraph lastParagraph = new Paragraph(doc);
  4267. //第一个表格末尾加段落
  4268. table.ParentNode.InsertAfter(lastParagraph, table);
  4269. //复制第一个表格
  4270. Table cloneTable = (Table)table.Clone(true);
  4271. //在文档末尾段落后面加入复制的表格
  4272. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4273. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4274. {
  4275. int rownewsIndex = 13;
  4276. for (int i = 0; i < 2; i++)
  4277. {
  4278. var CopyRow = table.Rows[12].Clone(true);
  4279. table.Rows.RemoveAt(13);
  4280. table.Rows.Add(CopyRow);
  4281. rownewsIndex++;
  4282. }
  4283. }
  4284. else
  4285. {
  4286. table.Rows.RemoveAt(12);
  4287. }
  4288. cloneTable.Rows.RemoveAt(12);
  4289. }
  4290. if (_AirTicketReservations.Count != 0)
  4291. {
  4292. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4293. if (FlightsCode.Length != 0)
  4294. {
  4295. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4296. if (_AirCompany != null)
  4297. {
  4298. string str = "--";
  4299. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4300. if (!string.IsNullOrEmpty(translateResult))
  4301. {
  4302. str = translateResult;
  4303. str = _airTicketResRep.Processing(str);
  4304. }
  4305. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4306. }
  4307. else
  4308. {
  4309. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4310. }
  4311. }
  4312. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4313. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4314. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4315. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4316. string names = "";
  4317. foreach (string clientName in nameArray)
  4318. {
  4319. names += clientName + ",";
  4320. }
  4321. if (!string.IsNullOrWhiteSpace(names))
  4322. {
  4323. string str = "--";
  4324. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4325. if (!string.IsNullOrEmpty(translateResult))
  4326. {
  4327. str = translateResult;
  4328. str = _airTicketResRep.Processing(str);
  4329. }
  4330. table.Range.Bookmarks["ClientName"].Text = str;
  4331. }
  4332. else
  4333. {
  4334. table.Range.Bookmarks["ClientName"].Text = "--";
  4335. }
  4336. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4337. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4338. table.Range.Bookmarks["JointTicket"].Text = "--";
  4339. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4340. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4341. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4342. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4343. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4344. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4345. }
  4346. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4347. //保存合并后的文档
  4348. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4349. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4350. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4351. return Ok(JsonView(true, "成功!", rst));
  4352. }
  4353. }
  4354. }
  4355. catch (Exception ex)
  4356. {
  4357. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4358. throw;
  4359. }
  4360. }
  4361. #endregion
  4362. #region 团组增减款项 --> 其他款项
  4363. /// <summary>
  4364. /// 团组增减款项下拉框绑定
  4365. /// </summary>
  4366. /// <param name="dto"></param>
  4367. /// <returns></returns>
  4368. [HttpPost]
  4369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4370. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4371. {
  4372. #region 参数验证
  4373. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4374. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4375. #endregion
  4376. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4377. }
  4378. /// <summary>
  4379. /// 根据团组Id查询团组增减款项
  4380. /// </summary>
  4381. /// <param name="dto"></param>
  4382. /// <returns></returns>
  4383. [HttpPost]
  4384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4385. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4386. {
  4387. #region 参数验证
  4388. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4389. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4390. #endregion
  4391. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4392. }
  4393. /// <summary>
  4394. /// 团组增减款项操作(Status:1.新增,2.修改)
  4395. /// </summary>
  4396. /// <param name="dto"></param>
  4397. /// <returns></returns>
  4398. [HttpPost]
  4399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4400. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4401. {
  4402. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4403. if (groupData.Code != 200)
  4404. {
  4405. return Ok(JsonView(false, groupData.Msg));
  4406. }
  4407. #region 应用推送
  4408. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4409. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4410. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4411. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4412. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4413. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4414. //自动审核
  4415. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4416. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4417. //2024-10-21 新增LZ UID
  4418. var userIds = new List<int>() { 21 };
  4419. string title = $"系统通知";
  4420. string content = "";
  4421. var diId = dto.DiId;
  4422. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4423. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4424. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4425. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4426. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4427. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4428. #endregion
  4429. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4430. }
  4431. /// <summary>
  4432. /// 团组增减款项操作 删除
  4433. /// </summary>
  4434. /// <param name="dto"></param>
  4435. /// <returns></returns>
  4436. [HttpPost]
  4437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4438. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4439. {
  4440. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4441. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4442. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4443. if (res.Code == 0)
  4444. {
  4445. return Ok(JsonView(true, "删除成功!"));
  4446. }
  4447. return Ok(JsonView(false, "删除失败!"));
  4448. }
  4449. /// <summary>
  4450. /// 根据团组增减款项Id查询
  4451. /// </summary>
  4452. /// <param name="dto"></param>
  4453. /// <returns></returns>
  4454. [HttpPost]
  4455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4456. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4457. {
  4458. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4459. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4460. }
  4461. /// <summary>
  4462. /// 查询供应商名称
  4463. /// </summary>
  4464. /// <param name="dto"></param>
  4465. /// <returns></returns>
  4466. [HttpPost]
  4467. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4468. {
  4469. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4470. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4471. ?? new List<Grp_DecreasePayments>();
  4472. dbResult = dbResult.Distinct(new
  4473. ProductComparer()).ToList();
  4474. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4475. {
  4476. x.Id,
  4477. x.SupplierAddress,
  4478. x.SupplierArea,
  4479. x.SupplierContact,
  4480. x.SupplierContactNumber,
  4481. x.SupplierEmail,
  4482. x.SupplierName,
  4483. x.SupplierSocialAccount,
  4484. x.SupplierTypeId,
  4485. }).ToList());
  4486. return Ok(jw);
  4487. }
  4488. /// <summary>
  4489. /// 团组增减款项 OTA匹配
  4490. /// </summary>
  4491. /// <param name="file"></param>
  4492. /// <returns></returns>
  4493. [HttpPost]
  4494. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4495. {
  4496. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4497. string fileName = file.FileName;
  4498. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4499. {
  4500. return Ok(JsonView(false, "请上传Excel文件!"));
  4501. }
  4502. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4503. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4504. if (!Directory.Exists(path))
  4505. {
  4506. Directory.CreateDirectory(path);
  4507. }
  4508. var filePath = @$"{path}/{fileName}";
  4509. //保存文件
  4510. using (FileStream fs = System.IO.File.Create(filePath))
  4511. {
  4512. file.CopyTo(fs);
  4513. fs.Flush();
  4514. }
  4515. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4516. //读取ExcelFile
  4517. DataTable dt = ConvertExcelToDataTable(filePath);
  4518. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4519. dt.TableName = "TB";
  4520. //修改table列名
  4521. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4522. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4523. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4524. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4525. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4526. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4527. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4528. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4529. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4530. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4531. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4532. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4533. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4534. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4535. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4536. var otaOrderNos = new List<string>();
  4537. foreach (DataRow item in dt.Rows)
  4538. {
  4539. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4540. }
  4541. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4542. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4543. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4544. .Select((dp, di) => new
  4545. {
  4546. dp.PriceName,
  4547. dp.OTAOrderNo,
  4548. dp.FeeTotal,
  4549. di.TeamName,
  4550. })
  4551. .ToListAsync();
  4552. foreach (DataRow item in dt.Rows)
  4553. {
  4554. var otaOrderNo = item["OTAOrderNo"].ToString();
  4555. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4556. if (oaData == null) continue;
  4557. item["GroupName"] = oaData.TeamName;
  4558. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4559. }
  4560. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4561. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4562. List<DataTable> datas = new List<DataTable>();
  4563. datas.Add(dt);
  4564. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4565. return Ok(JsonView(true, "操作成功", new { url = url }));
  4566. }
  4567. #region
  4568. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4569. {
  4570. // 创建Workbook对象
  4571. Workbook workbook = new Workbook(excelFilePath);
  4572. // 获取第一个工作表
  4573. Worksheet worksheet = workbook.Worksheets[0];
  4574. // 将工作表转换为DataTable
  4575. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4576. return dataTable;
  4577. }
  4578. #endregion
  4579. #endregion
  4580. #region 文件上传、删除
  4581. /// <summary>
  4582. /// region 文件上传 可以带参数
  4583. /// </summary>
  4584. /// <param name="file"></param>
  4585. /// <returns></returns>
  4586. [HttpPost]
  4587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4588. public async Task<IActionResult> UploadProject(IFormFile file)
  4589. {
  4590. //var TypeName = Request.Headers["TypeName"].ToString();
  4591. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4592. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4593. ////文件名称
  4594. //string projectFileName = file.FileName;
  4595. ////上传的文件的路径
  4596. //string filePath = $"{fileDir}/{projectFileName}";
  4597. //if (TypeName == "A")//A代表团组增减款项
  4598. //{
  4599. // filePath = fileDir + $@"\团组增减款项相关文件";
  4600. // if (!Directory.Exists(filePath))
  4601. // {
  4602. // Directory.CreateDirectory(filePath);
  4603. // }
  4604. // //上传的文件的路径
  4605. // filePath += $@"\{projectFileName}";
  4606. //}
  4607. //else if (TypeName == "B")//B代表商邀相关文件
  4608. //{
  4609. // //上传的文件的路径
  4610. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4611. // if (!Directory.Exists(filePath))
  4612. // {
  4613. // Directory.CreateDirectory(filePath);
  4614. // }
  4615. // //上传的文件的路径
  4616. // filePath = $@"\{projectFileName}";
  4617. //}
  4618. //try
  4619. //{
  4620. // using (FileStream fs = System.IO.File.Create(filePath))
  4621. // {
  4622. // file.CopyTo(fs);
  4623. // fs.Flush();
  4624. // }
  4625. //}
  4626. //catch (Exception ex)
  4627. //{
  4628. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4629. //}
  4630. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4631. try
  4632. {
  4633. var TypeName = Request.Headers["TypeName"].ToString();
  4634. if (file != null)
  4635. {
  4636. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4637. //文件名称
  4638. string projectFileName = file.FileName;
  4639. //上传的文件的路径
  4640. string filePath = $"{fileDir}/{projectFileName}";
  4641. if (TypeName == "A")//A代表团组增减款项
  4642. {
  4643. if (!Directory.Exists(fileDir))
  4644. {
  4645. Directory.CreateDirectory(fileDir);
  4646. }
  4647. //上传的文件的路径
  4648. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4649. }
  4650. else if (TypeName == "B")//B代表商邀相关文件
  4651. {
  4652. if (!Directory.Exists(fileDir))
  4653. {
  4654. Directory.CreateDirectory(fileDir);
  4655. }
  4656. //上传的文件的路径
  4657. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4658. }
  4659. using (FileStream fs = System.IO.File.Create(filePath))
  4660. {
  4661. file.CopyTo(fs);
  4662. fs.Flush();
  4663. }
  4664. return Ok(JsonView(true, "上传成功!", projectFileName));
  4665. }
  4666. else
  4667. {
  4668. return Ok(JsonView(false, "上传失败!"));
  4669. }
  4670. }
  4671. catch (Exception ex)
  4672. {
  4673. return Ok(JsonView(false, "程序错误!"));
  4674. }
  4675. }
  4676. /// <summary>
  4677. /// 删除指定文件
  4678. /// </summary>
  4679. /// <param name="dto"></param>
  4680. /// <returns></returns>
  4681. [HttpPost]
  4682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4683. public async Task<IActionResult> DelFile(DelFileDto dto)
  4684. {
  4685. try
  4686. {
  4687. var TypeName = Request.Headers["TypeName"].ToString();
  4688. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4689. string filePath = "";
  4690. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4691. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4692. int id = 0;
  4693. if (TypeName == "A")
  4694. {
  4695. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4696. // 删除该文件
  4697. System.IO.File.Delete(filePath);
  4698. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4699. .Where(a => a.Id == dto.Id)
  4700. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4701. .ExecuteCommandAsync();
  4702. }
  4703. else if (TypeName == "B")
  4704. {
  4705. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4706. // 删除该文件
  4707. System.IO.File.Delete(filePath);
  4708. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4709. if (info != null)
  4710. {
  4711. string[] files = new string[] { };
  4712. if (!string.IsNullOrEmpty(info.Attachment))
  4713. {
  4714. try
  4715. {
  4716. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4717. }
  4718. catch (Exception)
  4719. {
  4720. files = new List<string>() { info.Attachment }.ToArray();
  4721. }
  4722. }
  4723. if (files.Length > 0)
  4724. {
  4725. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4726. string filePath2 = string.Empty;
  4727. if (files1.Length > 0)
  4728. {
  4729. filePath2 = JsonConvert.SerializeObject(files1);
  4730. }
  4731. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4732. .Where(a => a.Id == dto.Id)
  4733. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4734. .ExecuteCommandAsync();
  4735. }
  4736. }
  4737. }
  4738. if (id != 0)
  4739. {
  4740. return Ok(JsonView(true, "成功!"));
  4741. }
  4742. else
  4743. {
  4744. return Ok(JsonView(false, "失败!"));
  4745. }
  4746. }
  4747. catch (Exception ex)
  4748. {
  4749. return Ok(JsonView(false, "程序错误!"));
  4750. throw;
  4751. }
  4752. }
  4753. /// <summary>
  4754. /// 文件上传多个文件 可以带参数
  4755. /// </summary>
  4756. /// <param name="files"></param>
  4757. /// <returns></returns>
  4758. [HttpPost]
  4759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4760. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4761. {
  4762. try
  4763. {
  4764. var TypeName = Request.Headers["TypeName"].ToString();
  4765. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4766. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4767. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4768. var filePahts = new List<string>();
  4769. foreach (var file in files)
  4770. {
  4771. //文件名称
  4772. string projectFileName = file.FileName;
  4773. //上传的文件的路径
  4774. string filePath = $"{fileDir}/{projectFileName}";
  4775. if (TypeName == "A")//A代表团组增减款项
  4776. {
  4777. if (!Directory.Exists(fileDir))
  4778. {
  4779. Directory.CreateDirectory(fileDir);
  4780. }
  4781. //上传的文件的路径
  4782. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4783. }
  4784. else if (TypeName == "B")//B代表商邀相关文件
  4785. {
  4786. if (!Directory.Exists(fileDir))
  4787. {
  4788. Directory.CreateDirectory(fileDir);
  4789. }
  4790. //上传的文件的路径
  4791. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4792. }
  4793. using (FileStream fs = System.IO.File.Create(filePath))
  4794. {
  4795. file.CopyTo(fs);
  4796. fs.Flush();
  4797. }
  4798. filePahts.Add(projectFileName);
  4799. }
  4800. return Ok(JsonView(true, "上传成功!", filePahts));
  4801. }
  4802. catch (Exception ex)
  4803. {
  4804. return Ok(JsonView(false, "程序错误!"));
  4805. }
  4806. }
  4807. #endregion
  4808. #region 商邀费用录入
  4809. /// <summary>
  4810. /// 根据团组Id查询商邀费用列表
  4811. /// </summary>
  4812. /// <param name="dto"></param>
  4813. /// <returns></returns>
  4814. [HttpPost]
  4815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4816. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4817. {
  4818. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4819. if (groupData.Code != 0)
  4820. {
  4821. return Ok(JsonView(false, groupData.Msg));
  4822. }
  4823. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4824. }
  4825. /// <summary>
  4826. /// 商邀费用列表
  4827. /// 下载文件
  4828. /// </summary>
  4829. /// <param name="id"></param>
  4830. /// <returns></returns>
  4831. [HttpGet("{id}")]
  4832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4833. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4834. {
  4835. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4836. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4837. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4838. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4839. var filePaths = new List<string>();
  4840. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4841. try
  4842. {
  4843. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4844. }
  4845. catch (Exception ex)
  4846. {
  4847. filePaths.Add(info.Attachment);
  4848. }
  4849. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4850. for (int i = 0; i < filePaths.Count; i++)
  4851. {
  4852. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4853. }
  4854. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4855. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4856. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4857. {
  4858. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4859. {
  4860. foreach (string filePath in filePaths)
  4861. {
  4862. if (System.IO.File.Exists(filePath))
  4863. {
  4864. // 获取文件名
  4865. string fileName = Path.GetFileName(filePath);
  4866. // 将文件添加到ZIP归档中
  4867. zipArchive.CreateEntryFromFile(filePath, fileName);
  4868. }
  4869. }
  4870. }
  4871. }
  4872. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4873. }
  4874. /// <summary>
  4875. /// 商邀费用 Info Page 基础数据源
  4876. /// </summary>
  4877. /// <returns></returns>
  4878. [HttpPost]
  4879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4880. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4881. {
  4882. try
  4883. {
  4884. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4885. if (groupData.Code != 0)
  4886. {
  4887. return Ok(JsonView(false, groupData.Msg));
  4888. }
  4889. return Ok(JsonView(true, "操作成功", groupData.Data));
  4890. }
  4891. catch (Exception ex)
  4892. {
  4893. return Ok(JsonView(false, ex.Message));
  4894. throw;
  4895. }
  4896. }
  4897. /// <summary>
  4898. /// 根据商邀费用ID查询C表和商邀费用数据
  4899. /// </summary>
  4900. /// <param name="dto"></param>
  4901. /// <returns></returns>
  4902. [HttpPost]
  4903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4904. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4905. {
  4906. try
  4907. {
  4908. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4909. if (groupData.Code != 0)
  4910. {
  4911. return Ok(JsonView(false, groupData.Msg));
  4912. }
  4913. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4914. }
  4915. catch (Exception ex)
  4916. {
  4917. return Ok(JsonView(false, ex.Message));
  4918. throw;
  4919. }
  4920. }
  4921. /// <summary>
  4922. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4923. /// </summary>
  4924. /// <param name="dto"></param>
  4925. /// <returns></returns>
  4926. [HttpPost]
  4927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4928. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4929. {
  4930. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4931. if (groupData.Code != 0)
  4932. {
  4933. return Ok(JsonView(false, groupData.Msg));
  4934. }
  4935. #region 应用推送
  4936. try
  4937. {
  4938. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4939. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4940. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4941. //2024-10-21 新增LZ UID
  4942. var userIds = new List<int>() { 21 };
  4943. string title = $"系统通知";
  4944. string content = "";
  4945. var diId = dto.DiId;
  4946. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4947. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4948. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4949. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4950. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4951. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  4952. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4953. }
  4954. catch (Exception ex)
  4955. {
  4956. }
  4957. #endregion
  4958. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4959. }
  4960. /// <summary>
  4961. /// 商邀删除
  4962. /// </summary>
  4963. /// <param name="dto"></param>
  4964. /// <returns></returns>
  4965. [HttpPost]
  4966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4967. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4968. {
  4969. try
  4970. {
  4971. _sqlSugar.BeginTran();
  4972. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4973. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4974. {
  4975. IsDel = 1,
  4976. DeleteUserId = dto.DeleteUserId,
  4977. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4978. })
  4979. .Where(it => it.Id == dto.Id)
  4980. .ExecuteCommand();
  4981. if (res1 > 0)
  4982. {
  4983. int _diId = 0;
  4984. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4985. if (_ioaInfo != null)
  4986. {
  4987. _diId = _ioaInfo.DiId;
  4988. }
  4989. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4990. .SetColumns(a => new Grp_CreditCardPayment()
  4991. {
  4992. IsDel = 1,
  4993. DeleteUserId = dto.DeleteUserId,
  4994. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4995. })
  4996. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4997. .ExecuteCommand();
  4998. if (res2 > 0)
  4999. {
  5000. _sqlSugar.CommitTran();
  5001. return Ok(JsonView(true, "删除成功!"));
  5002. }
  5003. }
  5004. _sqlSugar.RollbackTran();
  5005. return Ok(JsonView(false, "删除失败"));
  5006. }
  5007. catch (Exception ex)
  5008. {
  5009. _sqlSugar.RollbackTran();
  5010. return Ok(JsonView(false, ex.Message));
  5011. }
  5012. }
  5013. #endregion
  5014. #region 票据上传
  5015. /// <summary>
  5016. /// 团组模块文件上传
  5017. /// </summary>
  5018. /// <param name="dto"></param>
  5019. /// <returns></returns>
  5020. [HttpPost]
  5021. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5022. {
  5023. var jw = JsonView(false);
  5024. long M = 1024 * 1024;
  5025. if (dto.Files == null || dto.Files.Count == 0)
  5026. {
  5027. jw.Msg = "无文件信息!";
  5028. return Ok(jw);
  5029. }
  5030. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5031. {
  5032. jw.Msg = "文件大小超过20M!";
  5033. return Ok(jw);
  5034. }
  5035. //var nameSp = dto.File.FileName.Split(".");
  5036. //if (nameSp.Length < 2)
  5037. //{
  5038. // jw.Msg = "拓展名称有误!";
  5039. // return Ok(jw);
  5040. //}
  5041. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5042. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5043. //{
  5044. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5045. // return Ok(jw);
  5046. //}
  5047. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5048. if (Ctable == null)
  5049. {
  5050. jw.Msg = "Ctable指向有误!";
  5051. return Ok(jw);
  5052. }
  5053. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5054. if (groupInfo == null)
  5055. {
  5056. jw.Msg = "团组信息不存在!";
  5057. return Ok(jw);
  5058. }
  5059. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5060. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5061. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5062. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5063. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5064. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5065. try
  5066. {
  5067. if (!Directory.Exists(fileBase))
  5068. {
  5069. Directory.CreateDirectory(fileBase);
  5070. }
  5071. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5072. foreach (var fileStream in dto.Files)
  5073. {
  5074. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5075. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5076. {
  5077. Cid = dto.Cid,
  5078. CreateTime = DateTime.Now,
  5079. CreateUserId = dto.Userid,
  5080. Ctable = dto.Ctable,
  5081. Diid = dto.Diid,
  5082. IsDel = 0,
  5083. FilePath = saveFilePath,
  5084. FileName = fileStream.FileName
  5085. };
  5086. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5087. {
  5088. fileStream.CopyTo(fs);
  5089. fs.Flush();
  5090. }
  5091. saveArr.Add(file);
  5092. }
  5093. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5094. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5095. jw = JsonView(true, "保存成功!", new
  5096. {
  5097. count = addResult,
  5098. filesName = saveArr.Select(x => x.FileName)
  5099. });
  5100. }
  5101. catch (Exception ex)
  5102. {
  5103. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5104. {
  5105. count = 0,
  5106. filesName = new string[0],
  5107. });
  5108. }
  5109. return Ok(jw);
  5110. }
  5111. /// <summary>
  5112. /// 查询各模块已保存文件
  5113. /// </summary>
  5114. /// <param name="dto"></param>
  5115. /// <returns></returns>
  5116. [HttpPost]
  5117. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5118. {
  5119. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5120. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5121. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5122. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5123. {
  5124. expression = Expressionable.Create<Grp_GroupModelFile>()
  5125. .And(x => visaIds.Contains(x.CreateUserId));
  5126. }
  5127. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5128. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5129. .Where(expression.ToExpression())
  5130. .ToList();
  5131. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5132. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5133. {
  5134. x.FileName,
  5135. x.Id,
  5136. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5137. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5138. })));
  5139. }
  5140. /// <summary>
  5141. /// 下载该团组下的所有文件
  5142. /// </summary>
  5143. /// <param name="dto"></param>
  5144. /// <returns></returns>
  5145. [HttpPost]
  5146. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5147. {
  5148. var jw = JsonView(false);
  5149. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5150. if (groupInfo == null)
  5151. {
  5152. jw.Msg = "团组信息不存在!";
  5153. return Ok(jw);
  5154. }
  5155. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5156. var isModule = Convert.ToBoolean(dto.isModule);
  5157. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5158. IOOperatorHelper io = new IOOperatorHelper();
  5159. if (isModule)
  5160. {
  5161. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5162. foreach (var moduleArr in moduleGroup)
  5163. {
  5164. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5165. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5166. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5167. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5168. foreach (var item in moduleArr)
  5169. {
  5170. if (System.IO.File.Exists(item.FilePath))
  5171. {
  5172. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5173. {
  5174. byte[] bytes = new byte[fileStream.Length];
  5175. fileStream.Read(bytes, 0, bytes.Length);
  5176. fileStream.Close();
  5177. Stream stream = new MemoryStream(bytes);
  5178. chiZips.Add(item.FileName, stream);
  5179. }
  5180. }
  5181. }
  5182. if (chiZips.Count > 0)
  5183. {
  5184. var byts = io.ConvertZipStream(chiZips);
  5185. Stream stream = new MemoryStream(byts);
  5186. Zips.Add(key.Name + "_.zip", stream);
  5187. }
  5188. }
  5189. }
  5190. else
  5191. {
  5192. foreach (var item in dbQuery)
  5193. {
  5194. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5195. {
  5196. byte[] bytes = new byte[fileStream.Length];
  5197. fileStream.Read(bytes, 0, bytes.Length);
  5198. fileStream.Close();
  5199. Stream stream = new MemoryStream(bytes);
  5200. while (Zips.Keys.Contains(item.FileName))
  5201. {
  5202. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5203. }
  5204. Zips.Add(item.FileName, stream);
  5205. }
  5206. }
  5207. }
  5208. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5209. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5210. if (Zips.Count > 0)
  5211. {
  5212. var byts = io.ConvertZipStream(Zips);
  5213. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5214. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5215. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5216. }
  5217. else
  5218. {
  5219. jw.Msg = "暂无生成文件!";
  5220. }
  5221. return Ok(jw);
  5222. }
  5223. /// <summary>
  5224. /// 下载该团组下此模块的所有文件
  5225. /// </summary>
  5226. /// <param name="dto"></param>
  5227. /// <returns></returns>
  5228. [HttpPost]
  5229. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5230. {
  5231. var jw = JsonView(false);
  5232. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5233. if (groupInfo == null)
  5234. {
  5235. jw.Msg = "团组信息不存在!";
  5236. return Ok(jw);
  5237. }
  5238. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5239. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5240. && x.IsDel == 0);
  5241. if (key == null)
  5242. {
  5243. jw.Msg = "Ctable指向错误!";
  5244. return Ok(jw);
  5245. }
  5246. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5247. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5248. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5249. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5250. IOOperatorHelper io = new IOOperatorHelper();
  5251. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5252. foreach (var item in dbQuery)
  5253. {
  5254. if (System.IO.File.Exists(item.FilePath))
  5255. {
  5256. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5257. {
  5258. byte[] bytes = new byte[fileStream.Length];
  5259. fileStream.Read(bytes, 0, bytes.Length);
  5260. fileStream.Close();
  5261. Stream stream = new MemoryStream(bytes);
  5262. while (Zips.Keys.Contains(item.FileName))
  5263. {
  5264. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5265. }
  5266. Zips.Add(item.FileName, stream);
  5267. }
  5268. }
  5269. }
  5270. if (Zips.Count > 0)
  5271. {
  5272. var byts = io.ConvertZipStream(Zips);
  5273. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5274. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5275. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5276. }
  5277. else
  5278. {
  5279. jw.Msg = "暂无生成文件!";
  5280. }
  5281. return Ok(jw);
  5282. }
  5283. /// <summary>
  5284. /// 删除该团组下的指定文件
  5285. /// </summary>
  5286. /// <param name="dto"></param>
  5287. /// <returns></returns>
  5288. [HttpPost]
  5289. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5290. {
  5291. var jw = JsonView(false);
  5292. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5293. if (sing == null)
  5294. {
  5295. jw.Msg = "暂无";
  5296. return Ok(jw);
  5297. }
  5298. if (System.IO.File.Exists(sing.FilePath))
  5299. {
  5300. try
  5301. {
  5302. System.IO.File.Delete(sing.FilePath);
  5303. }
  5304. catch (Exception ex)
  5305. {
  5306. jw.Msg = "删除失败!" + ex.Message;
  5307. return Ok(jw);
  5308. }
  5309. }
  5310. sing.IsDel = 1;
  5311. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5312. sing.DeleteUserId = dto.UserId;
  5313. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5314. jw = JsonView(true, "删除成功!");
  5315. return Ok(jw);
  5316. }
  5317. #endregion
  5318. #region 共享文件上传
  5319. /// <summary>
  5320. /// 共享文件数据初始化
  5321. /// </summary>
  5322. /// <returns></returns>
  5323. [HttpGet]
  5324. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  5325. {
  5326. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  5327. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5328. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5329. .Select(x => x.Id)
  5330. .ToList()
  5331. .Contains(userid);
  5332. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5333. .Where(x => x.STid == 111 && x.IsDel == 0)
  5334. .Select(x => new
  5335. {
  5336. x.Name,
  5337. x.Id,
  5338. }).ToList();
  5339. if (isMarketingDepartment)
  5340. {
  5341. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5342. }
  5343. if (portType == 1)
  5344. {
  5345. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5346. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5347. .Where(x => x.IsDel == 0)
  5348. .OrderByDescending(x=> x.VisitDate )
  5349. .Select(x => new
  5350. {
  5351. x.TeamName,
  5352. x.Id,
  5353. x.CityId,
  5354. })
  5355. .ToList()
  5356. .Select(x=>
  5357. {
  5358. var provinceId = x.CityId;
  5359. var isDefualtVal = true;
  5360. if (provinceId > 0)
  5361. {
  5362. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5363. if (parentId != null)
  5364. {
  5365. isDefualtVal = false;
  5366. provinceId = (int)parentId;
  5367. }
  5368. }
  5369. if (isDefualtVal)
  5370. {
  5371. provinceId = 122; //默认四川
  5372. }
  5373. return new
  5374. {
  5375. x.TeamName,
  5376. x.Id,
  5377. provinceId,
  5378. };
  5379. })
  5380. .ToList();
  5381. return Ok(JsonView(true, "SUCCESS!", new
  5382. {
  5383. dropDownType,
  5384. dropDownGroupList,
  5385. isMarketingDepartment
  5386. }));
  5387. }
  5388. else if (portType == 2 || portType == 3)
  5389. {
  5390. return Ok(JsonView(true, "SUCCESS!", new
  5391. {
  5392. dropDownType,
  5393. isMarketingDepartment
  5394. }));
  5395. }
  5396. else
  5397. {
  5398. return Ok(JsonView(false, "portType有误!"));
  5399. }
  5400. }
  5401. /// <summary>
  5402. /// 共享文件上传
  5403. /// </summary>
  5404. /// <param name="dto"></param>
  5405. /// <returns></returns>
  5406. [HttpPost]
  5407. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5408. {
  5409. var isGroup = new List<int> { 1412 };
  5410. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5411. {
  5412. return Ok(JsonView(false, "该文件需要关联团组!"));
  5413. }
  5414. if (dto.Files == null || dto.Files.Count == 0)
  5415. {
  5416. return Ok(JsonView(false, "无文件信息!"));
  5417. }
  5418. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5419. {
  5420. return Ok(JsonView(false, "文件大小超过20M!"));
  5421. }
  5422. if (dto.Userid < 1)
  5423. {
  5424. return Ok(JsonView(false, "请传入有效的Userid!"));
  5425. }
  5426. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5427. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5428. .Select((u, j) => new
  5429. {
  5430. u.CnName,
  5431. UserId = u.Id,
  5432. j.JobName,
  5433. })
  5434. .First();
  5435. if (jobInfo == null)
  5436. {
  5437. return Ok(JsonView(false, "请传入有效的Userid!"));
  5438. }
  5439. List<string> commonFileExtensions = new List<string>
  5440. {
  5441. // 文本文件
  5442. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5443. // 图片文件
  5444. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5445. // 视频文件
  5446. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5447. // 音频文件
  5448. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5449. // 压缩文件
  5450. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5451. // 数据文件
  5452. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5453. };
  5454. try
  5455. {
  5456. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5457. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5458. commonFileExtensions.AddRange(settingExtend);
  5459. }
  5460. catch (Exception)
  5461. { }
  5462. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5463. if (setdata == null)
  5464. {
  5465. return Ok(JsonView(false, "请传入有效的FileType!"));
  5466. }
  5467. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5468. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5469. if (!Directory.Exists(winPath))
  5470. {
  5471. Directory.CreateDirectory(winPath);
  5472. }
  5473. foreach (var item in dto.Files)
  5474. {
  5475. var houzui = Path.GetExtension(item.FileName);
  5476. if (!commonFileExtensions.Contains(houzui))
  5477. {
  5478. return Ok(JsonView(false, "未知后缀名称!"));
  5479. }
  5480. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5481. var saveFilePath = winPath + fileName;
  5482. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5483. {
  5484. item.CopyTo(fs);
  5485. fs.Flush();
  5486. }
  5487. var fileDetail = new Grp_GroupShareFile()
  5488. {
  5489. CreateUserId = dto.Userid,
  5490. CreateTime = DateTime.Now,
  5491. UploadJob = jobInfo.JobName,
  5492. FileName = fileName,
  5493. FileType = dto.FileType,
  5494. Diid = dto.Diid,
  5495. FilePath = winPath + fileName,
  5496. };
  5497. insertList.Add(fileDetail);
  5498. }
  5499. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5500. return Ok(JsonView(true, "保存成功!"));
  5501. }
  5502. /// <summary>
  5503. /// 查询共享文件列表
  5504. /// </summary>
  5505. /// <param name="dto"></param>
  5506. /// <returns></returns>
  5507. [HttpPost]
  5508. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5509. {
  5510. var isGroup = new List<int> { 1412 };
  5511. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5512. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5513. .And(x => x.Diid == dto.Diid)
  5514. .And(x => x.FileType == dto.FileType)
  5515. .And(x => x.IsDel == 0)
  5516. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5517. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5518. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5519. int totalCount = 0;
  5520. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5521. .Where(queryExpression.ToExpression())
  5522. .OrderBy(x => x.UploadJob)
  5523. .Select(x => new
  5524. {
  5525. x.Id,
  5526. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5527. x.FileName,
  5528. x.FileType,
  5529. x.CreateTime,
  5530. })
  5531. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5532. return Ok(JsonView(true, "SUCCESS!", new
  5533. {
  5534. FileList = dbQuery,
  5535. dto.PageSize,
  5536. dto.PageIndex,
  5537. totalCount
  5538. }));
  5539. }
  5540. /// <summary>
  5541. /// 删除共享文件模块下的指定文件
  5542. /// </summary>
  5543. /// <param name="dto"></param>
  5544. /// <returns></returns>
  5545. [HttpPost]
  5546. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5547. {
  5548. var jw = JsonView(false);
  5549. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5550. if (sing == null)
  5551. {
  5552. jw.Msg = "暂无文件信息!";
  5553. return Ok(jw);
  5554. }
  5555. if (sing.CreateUserId != dto.UserId)
  5556. {
  5557. jw.Msg = "只能删除自己上传的文件!";
  5558. return Ok(jw);
  5559. }
  5560. if (System.IO.File.Exists(sing.FilePath))
  5561. {
  5562. try
  5563. {
  5564. System.IO.File.Delete(sing.FilePath);
  5565. }
  5566. catch (Exception ex)
  5567. {
  5568. jw.Msg = "删除失败!" + ex.Message;
  5569. return Ok(jw);
  5570. }
  5571. }
  5572. sing.IsDel = 1;
  5573. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5574. sing.DeleteUserId = dto.UserId;
  5575. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5576. jw = JsonView(true, "删除成功!");
  5577. return Ok(jw);
  5578. }
  5579. #endregion
  5580. #region 团组英文资料
  5581. /// <summary>
  5582. /// 查询团组英文所有资料
  5583. /// </summary>
  5584. /// <param name="dto"></param>
  5585. /// <returns></returns>
  5586. [HttpPost]
  5587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5588. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5589. {
  5590. try
  5591. {
  5592. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5593. if (groupData.Code != 0)
  5594. {
  5595. return Ok(JsonView(false, groupData.Msg));
  5596. }
  5597. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5598. }
  5599. catch (Exception ex)
  5600. {
  5601. return Ok(JsonView(false, "程序错误!"));
  5602. throw;
  5603. }
  5604. }
  5605. /// <summary>
  5606. /// 团组英文资料操作(Status:1.新增,2.修改)
  5607. /// </summary>
  5608. /// <param name="dto"></param>
  5609. /// <returns></returns>
  5610. [HttpPost]
  5611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5612. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5613. {
  5614. try
  5615. {
  5616. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5617. if (groupData.Code != 0)
  5618. {
  5619. return Ok(JsonView(false, groupData.Msg));
  5620. }
  5621. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5622. }
  5623. catch (Exception ex)
  5624. {
  5625. return Ok(JsonView(false, "程序错误!"));
  5626. throw;
  5627. }
  5628. }
  5629. /// <summary>
  5630. /// 团组英文资料Id查询数据
  5631. /// </summary>
  5632. /// <param name="dto"></param>
  5633. /// <returns></returns>
  5634. [HttpPost]
  5635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5636. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5637. {
  5638. try
  5639. {
  5640. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5641. if (_DelegationEnData != null)
  5642. {
  5643. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5644. }
  5645. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5646. }
  5647. catch (Exception ex)
  5648. {
  5649. return Ok(JsonView(false, "程序错误!"));
  5650. throw;
  5651. }
  5652. }
  5653. /// <summary>
  5654. /// 团组英文资料删除
  5655. /// </summary>
  5656. /// <param name="dto"></param>
  5657. /// <returns></returns>
  5658. [HttpPost]
  5659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5660. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5661. {
  5662. try
  5663. {
  5664. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5665. if (!res)
  5666. {
  5667. return Ok(JsonView(false, "删除失败"));
  5668. }
  5669. return Ok(JsonView(true, "删除成功!"));
  5670. }
  5671. catch (Exception ex)
  5672. {
  5673. return Ok(JsonView(false, "程序错误!"));
  5674. throw;
  5675. }
  5676. }
  5677. #endregion
  5678. #region 导出邀请函
  5679. /// <summary>
  5680. /// 导出邀请函页面初始化
  5681. /// </summary>
  5682. /// <param name="dto"></param>
  5683. /// <returns></returns>
  5684. [HttpPost]
  5685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5686. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5687. {
  5688. try
  5689. {
  5690. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5691. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5692. if (dto.DiId == 0)
  5693. {
  5694. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5695. }
  5696. else
  5697. {
  5698. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5699. }
  5700. return Ok(JsonView(true, "查询成功!", new
  5701. {
  5702. deleClient = crm_Deles,
  5703. delegations = grp_Delegations
  5704. }));
  5705. }
  5706. catch (Exception ex)
  5707. {
  5708. return Ok(JsonView(false, "程序错误!"));
  5709. throw;
  5710. }
  5711. }
  5712. /// <summary>
  5713. /// 导出邀请函
  5714. /// </summary>
  5715. /// <param name="dto"></param>
  5716. /// <returns></returns>
  5717. [HttpPost]
  5718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5719. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5720. {
  5721. #region 参数验证
  5722. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5723. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5724. #endregion
  5725. try
  5726. {
  5727. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5728. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5729. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5730. From Grp_TourClientList tcl
  5731. Left Join
  5732. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5733. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5734. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5735. From Crm_DeleClient dc
  5736. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5737. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5738. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5739. Where dc.IsDel = 0) temp
  5740. On temp.DcId =tcl.ClientId
  5741. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5742. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5743. List<string> texts = new List<string>();
  5744. if (datas.Count != 0)
  5745. {
  5746. foreach (TourClientListDetailsView item in datas)
  5747. {
  5748. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5749. {
  5750. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5751. }
  5752. else
  5753. {
  5754. string name = item.LastName + item.FirstName;
  5755. texts.Add(name);
  5756. }
  5757. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5758. {
  5759. if (!transDic.ContainsKey(item.Job))
  5760. {
  5761. texts.Add(item.Job);
  5762. }
  5763. }
  5764. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5765. {
  5766. texts.Add(item.CompanyFullName);
  5767. }
  5768. }
  5769. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5770. if (transData.Count > 0)
  5771. {
  5772. foreach (TranslateResult item in transData)
  5773. {
  5774. if (!transDic.ContainsKey(item.Query))
  5775. {
  5776. transDic.Add(item.Query, item.Translation);
  5777. }
  5778. }
  5779. }
  5780. List<GuestList> list = new List<GuestList>();
  5781. foreach (TourClientListDetailsView dele in datas)
  5782. {
  5783. GuestList guestList = new GuestList();
  5784. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5785. {
  5786. guestList.Name = dele.Pinyin;
  5787. }
  5788. else
  5789. {
  5790. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5791. guestList.Name = Name;
  5792. }
  5793. if (dele.Sex == 0)
  5794. {
  5795. guestList.Sex = "Male";
  5796. }
  5797. else if (dele.Sex == 1)
  5798. {
  5799. guestList.Sex = "Female";
  5800. }
  5801. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5802. if (!string.IsNullOrEmpty(dele.Job))
  5803. {
  5804. guestList.Job = dele.Job;
  5805. }
  5806. list.Add(guestList);
  5807. }
  5808. //载入模板
  5809. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5810. DocumentBuilder builder = new DocumentBuilder(doc);
  5811. //获取word里所有表格
  5812. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5813. //获取所填表格的序数
  5814. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5815. var rowStart = tableOne.Rows[0]; //获取第1行
  5816. //循环赋值
  5817. for (int i = 0; i < list.Count; i++)
  5818. {
  5819. builder.MoveToCell(0, i + 1, 0, 0);
  5820. builder.Write(list[i].Name.ToString());
  5821. builder.MoveToCell(0, i + 1, 1, 0);
  5822. builder.Write(list[i].Sex.ToString());
  5823. builder.MoveToCell(0, i + 1, 2, 0);
  5824. builder.Write(list[i].DOB.ToString());
  5825. builder.MoveToCell(0, i + 1, 3, 0);
  5826. builder.Write(list[i].Job.ToString());
  5827. }
  5828. //删除多余行
  5829. while (tableOne.Rows.Count > list.Count + 1)
  5830. {
  5831. tableOne.Rows.RemoveAt(list.Count + 1);
  5832. }
  5833. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5834. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5835. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5836. doc.Save(filePath);
  5837. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5838. return Ok(JsonView(true, "操作成功!", Url));
  5839. }
  5840. else
  5841. {
  5842. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5843. }
  5844. }
  5845. catch (Exception ex)
  5846. {
  5847. return Ok(JsonView(false, ex.Message));
  5848. throw;
  5849. }
  5850. }
  5851. #endregion
  5852. #region 团组经理模块 出入境费用
  5853. /// <summary>
  5854. /// 团组模块 - 出入境费用 - 省份基础数据源
  5855. /// </summary>
  5856. /// <returns></returns>
  5857. [HttpGet]
  5858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5859. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5860. {
  5861. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5862. }
  5863. /// <summary>
  5864. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5865. /// </summary>
  5866. /// <returns></returns>
  5867. [HttpPost]
  5868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5869. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5870. {
  5871. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5872. var groupNamFirst = groupNameData.FirstOrDefault();
  5873. //SetDataInfoView
  5874. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5875. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5876. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5877. //验证城市归属并给默认值
  5878. int provinceId = 122;
  5879. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5880. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5881. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5882. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5883. return Ok(JsonView(true, "查询成功!", new
  5884. {
  5885. GroupNameData = groupNameData,
  5886. CurrencyData = _CurrencyData,
  5887. WordTypeData = wordTypeData,
  5888. ExcelTypeData = excelTypeData,
  5889. CurrencyInit = _currencyInfos,
  5890. ViewPermissionData = viewPermissionData
  5891. }));
  5892. }
  5893. /// <summary>
  5894. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5895. /// </summary>
  5896. /// <returns></returns>
  5897. [HttpGet("{provinceId}")]
  5898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5899. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5900. {
  5901. //验证城市归属并给默认值
  5902. if (provinceId < 1) provinceId = 122;
  5903. /*
  5904. * 122 四川
  5905. * 108 贵州
  5906. * 103 重庆
  5907. * 132 云南
  5908. */
  5909. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5910. return Ok(JsonView(true, "查询成功!", new
  5911. {
  5912. WordTypeData = wordTypeData,
  5913. ExcelTypeData = excelTypeData,
  5914. }));
  5915. }
  5916. /// <summary>
  5917. /// 团组模块 - 出入境费用
  5918. /// 实时汇率 tips
  5919. /// 签证费用 tips
  5920. /// 机票费用 tips
  5921. /// </summary>
  5922. /// <returns></returns>
  5923. [HttpPost]
  5924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5925. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5926. {
  5927. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5928. //默认币种显示
  5929. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5930. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5931. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  5932. return Ok(JsonView(true, "查询成功!", new
  5933. {
  5934. //GroupNameData = groupNameData.Data,
  5935. visaData = visaData.Data,
  5936. airData = airData,
  5937. reteInfos = reteInfos
  5938. }));
  5939. }
  5940. /// <summary>
  5941. /// 团组模块 - 出入境费用 - Info
  5942. /// </summary>
  5943. /// <returns></returns>
  5944. [HttpPost]
  5945. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5947. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5948. {
  5949. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5950. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5951. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5952. }
  5953. /// <summary>
  5954. /// 团组模块 - 出入境费用 - 设置view权限
  5955. /// </summary>
  5956. /// <returns></returns>
  5957. [HttpPost]
  5958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5959. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5960. {
  5961. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5962. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5963. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5964. var permissions = new List<Grp_EnterExitCostPermission>();
  5965. foreach (var userId in dto.UserIds)
  5966. {
  5967. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5968. }
  5969. if (permissions.Any())
  5970. {
  5971. _sqlSugar.BeginTran();
  5972. try
  5973. {
  5974. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5975. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5976. if (result < 1)
  5977. {
  5978. _sqlSugar.RollbackTran();
  5979. return Ok(JsonView(false));
  5980. }
  5981. }
  5982. catch (Exception ex)
  5983. {
  5984. _sqlSugar.RollbackTran();
  5985. return Ok(JsonView(false, ex.Message));
  5986. }
  5987. _sqlSugar.CommitTran();
  5988. return Ok(JsonView(true));
  5989. }
  5990. return Ok(JsonView(false));
  5991. }
  5992. /// <summary>
  5993. /// 团组模块 - 出入境费用 - Add And Update
  5994. /// </summary>
  5995. /// <returns></returns>
  5996. [HttpPost]
  5997. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5999. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6000. {
  6001. try
  6002. {
  6003. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6004. if (dto.DayOtherPriceData.Any())
  6005. {
  6006. var inserList = dto.DayOtherPriceData
  6007. .Where(x => x.Id == 0)
  6008. .Select(x => new Grp_DayOtherPrice
  6009. {
  6010. Cost = x.Cost,
  6011. Id = x.Id,
  6012. CreateTime = DateTime.Now,
  6013. CreateUserId = dto.UserId,
  6014. Currency = x.Currency,
  6015. Diid = x.DiId,
  6016. Index = x.Index,
  6017. IsDel = 0,
  6018. SetDataId = x.SetDataId,
  6019. SubTotal = x.SubTotal,
  6020. Remark = x.Remark
  6021. })
  6022. .ToList();
  6023. var updateList = dto.DayOtherPriceData
  6024. .Where(x => x.Id != 0)
  6025. .Select(x => new Grp_DayOtherPrice
  6026. {
  6027. Cost = x.Cost,
  6028. Id = x.Id,
  6029. CreateTime = DateTime.Now,
  6030. CreateUserId = dto.UserId,
  6031. Currency = x.Currency,
  6032. Diid = x.DiId,
  6033. Index = x.Index,
  6034. IsDel = 0,
  6035. SetDataId = x.SetDataId,
  6036. SubTotal = x.SubTotal,
  6037. Remark = x.Remark
  6038. })
  6039. .ToList();
  6040. //添加
  6041. _sqlSugar.BeginTran();
  6042. if (inserList.Any())
  6043. {
  6044. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6045. }
  6046. if (updateList.Any())
  6047. {
  6048. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6049. }
  6050. _sqlSugar.CommitTran();
  6051. }
  6052. if (data.Code != 0)
  6053. {
  6054. return Ok(JsonView(false, data.Msg));
  6055. }
  6056. //生成默认文件pdf并且通知人员
  6057. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6058. {
  6059. DiId = dto.DiId,
  6060. ExportType = 1,
  6061. SubTypeId = 1005
  6062. }, "pdf");
  6063. //发送通知
  6064. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6065. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6066. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6067. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6068. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6069. //汇率信息记录
  6070. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6071. return Ok(JsonView(true, data.Msg, data.Data));
  6072. }
  6073. catch (Exception ex)
  6074. {
  6075. return Ok(JsonView(false, ex.Message));
  6076. }
  6077. }
  6078. /// <summary>
  6079. /// 团组模块 - 出入境费用 - Confirm 费用
  6080. /// </summary>
  6081. /// <returns></returns>
  6082. [HttpPost]
  6083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6084. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6085. {
  6086. //TODO:测试完毕需把对应的用户ID更改
  6087. //1、数据表添加字段
  6088. //2、更改字段接口()
  6089. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6090. //3、确认成功 给财务发送消息
  6091. if (_view.Code == 200)
  6092. {
  6093. if (dto.Type == 1)
  6094. {
  6095. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6096. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6097. }
  6098. }
  6099. return Ok(_view);
  6100. }
  6101. /// <summary>
  6102. /// 团组模块 - 出入境费用 - File download
  6103. /// </summary>
  6104. /// <param name="dto"></param>
  6105. /// <returns></returns>
  6106. [HttpPost]
  6107. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6109. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6110. {
  6111. try
  6112. {
  6113. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6114. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6115. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6116. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6117. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6118. 3 团组成员名单 1 团组成员名单", ""));
  6119. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6120. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6121. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6122. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6123. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6124. //数据源
  6125. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6126. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6127. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6128. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6129. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6130. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6131. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6132. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6133. .Select((x, a, b) => new
  6134. {
  6135. x.Index,
  6136. itemName = a.Name,
  6137. CurrencyStr = b.Name,
  6138. x.Cost,
  6139. x.SubTotal,
  6140. x.Remark
  6141. })
  6142. .OrderBy((x) => x.Index)
  6143. .ToList(); //其他款项费用
  6144. var peiceItemCurrencys = new List<string>();
  6145. if (_DayAndCosts.Any())
  6146. {
  6147. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6148. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6149. }
  6150. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6151. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6152. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6153. {
  6154. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6155. }
  6156. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6157. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6158. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6159. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6160. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6161. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6162. .Select((tcl, dc, cc) => new ClientInfo
  6163. {
  6164. LastName = dc.LastName,
  6165. FirstName = dc.FirstName,
  6166. Sex = dc.Sex,
  6167. Birthday = dc.BirthDay,
  6168. Company = cc.CompanyFullName,
  6169. Job = dc.Job
  6170. })
  6171. .ToList();
  6172. foreach (var item in DeleClientList)
  6173. {
  6174. EncryptionProcessor.DecryptProperties(item);
  6175. }
  6176. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6177. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6178. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6179. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6180. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6181. if (dto.ExportType == 1) //明细表
  6182. {
  6183. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6184. {
  6185. //获取模板
  6186. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6187. //载入模板
  6188. Document doc = new Document(tempPath);
  6189. DocumentBuilder builder = new DocumentBuilder(doc);
  6190. //利用键值对存放数据
  6191. Dictionary<string, string> dic = new Dictionary<string, string>();
  6192. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6193. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6194. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6195. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6196. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6197. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6198. //境内费用(其他费用)
  6199. if (_EnterExitCosts.ChoiceOne == 1)
  6200. {
  6201. string row1_1 = "";
  6202. if (_EnterExitCosts.Visa > 0)
  6203. {
  6204. //insidePayTotal += _EnterExitCosts.Visa;
  6205. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6206. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6207. //{
  6208. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6209. //}
  6210. }
  6211. string row1_2 = "";
  6212. if (_EnterExitCosts.YiMiao > 0)
  6213. {
  6214. //insidePayTotal += _EnterExitCosts.YiMiao;
  6215. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6216. }
  6217. if (_EnterExitCosts.HeSuan > 0)
  6218. {
  6219. //insidePayTotal += _EnterExitCosts.HeSuan;
  6220. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6221. }
  6222. if (_EnterExitCosts.Service > 0)
  6223. {
  6224. //insidePayTotal += _EnterExitCosts.Service;
  6225. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6226. }
  6227. string row1_3 = "";
  6228. if (_EnterExitCosts.Safe > 0)
  6229. {
  6230. //insidePayTotal += _EnterExitCosts.Safe;
  6231. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6232. }
  6233. if (_EnterExitCosts.Ticket > 0)
  6234. {
  6235. //insidePayTotal += _EnterExitCosts.Ticket;
  6236. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6237. }
  6238. string row1 = "";
  6239. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6240. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6241. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6242. row1 += $"备注:{_EnterExitCosts.Remark}";
  6243. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6244. dic.Add("Row1Str", row1);
  6245. }
  6246. string airTotalStr = string.Empty,
  6247. airPriceStr = string.Empty;
  6248. //经济舱
  6249. if (_EnterExitCosts.SumJJC == 1)
  6250. {
  6251. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6252. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6253. }
  6254. //公务舱
  6255. if (_EnterExitCosts.SumGWC == 1)
  6256. {
  6257. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6258. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6259. }
  6260. //头等舱
  6261. if (_EnterExitCosts.SumTDC == 1)
  6262. {
  6263. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6264. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6265. }
  6266. //汇率描述
  6267. string rateStr = "";
  6268. if (peiceItemCurrencyInfos.Any())
  6269. {
  6270. rateStr = "\r\n汇率描述:";
  6271. foreach (var item in peiceItemCurrencyInfos)
  6272. {
  6273. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6274. }
  6275. }
  6276. string twoItemRemark = "备注:";
  6277. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6278. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6279. dic.Add("AirTotalStr", airTotalStr);
  6280. dic.Add("AirPriceStr", airPriceStr);
  6281. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6282. dic.Add("TwoItemRemark", twoItemRemark);
  6283. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6284. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6285. int table1Row = 0,
  6286. table2Row = 0,
  6287. table3Row = 0,
  6288. table4Row = 0,
  6289. table5Row = 0;
  6290. //住宿费
  6291. if (_EnterExitCosts.ChoiceThree == 1)
  6292. {
  6293. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6294. table1Row = dac1.Count;
  6295. #region 填充word表格内容
  6296. for (int i = 0; i < dac1.Count; i++)
  6297. {
  6298. Grp_DayAndCost dac = dac1[i];
  6299. if (dac == null) continue;
  6300. builder.MoveToCell(0, i, 0, 0);
  6301. builder.Write("第" + dac.Days.ToString() + "晚:");
  6302. builder.MoveToCell(0, i, 1, 0);
  6303. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6304. //builder.Write(dac.Place == null ? "" : dac.Place);
  6305. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6306. builder.MoveToCell(0, i, 2, 0);
  6307. builder.Write("费用标准:");
  6308. string curr = "";
  6309. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6310. if (currData != null)
  6311. {
  6312. curr = currData.Name;
  6313. }
  6314. builder.MoveToCell(0, i, 3, 0);
  6315. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6316. builder.MoveToCell(0, i, 4, 0);
  6317. builder.Write("费用小计:");
  6318. builder.MoveToCell(0, i, 5, 0);
  6319. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6320. }
  6321. #endregion
  6322. }
  6323. else dic.Add("SubZS", "0.00");
  6324. //删除多余行
  6325. while (table1.Rows.Count > table1Row)
  6326. {
  6327. table1.Rows.RemoveAt(table1Row);
  6328. }
  6329. //伙食费
  6330. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6331. if (_EnterExitCosts.ChoiceFour == 1)
  6332. {
  6333. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6334. table2Row = dac2.Count;
  6335. #region 填充word表格内容
  6336. for (int i = 0; i < dac2.Count; i++)
  6337. {
  6338. Grp_DayAndCost dac = dac2[i];
  6339. if (dac == null) continue;
  6340. builder.MoveToCell(1, i, 0, 0);
  6341. builder.Write("第" + dac.Days.ToString() + "天:");
  6342. builder.MoveToCell(1, i, 1, 0);
  6343. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6344. builder.MoveToCell(1, i, 2, 0);
  6345. builder.Write("费用标准:");
  6346. string curr = "";
  6347. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6348. if (currData != null)
  6349. {
  6350. curr = currData.Name;
  6351. }
  6352. builder.MoveToCell(1, i, 3, 0);
  6353. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6354. builder.MoveToCell(1, i, 4, 0);
  6355. builder.Write("费用小计:");
  6356. builder.MoveToCell(1, i, 5, 0);
  6357. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6358. }
  6359. #endregion
  6360. }
  6361. else dic.Add("SubHS", "0.00");
  6362. //删除多余行
  6363. while (table2.Rows.Count > table2Row)
  6364. {
  6365. table2.Rows.RemoveAt(table2Row);
  6366. }
  6367. //公杂费
  6368. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6369. if (_EnterExitCosts.ChoiceFive == 1)
  6370. {
  6371. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6372. table3Row = dac3.Count;
  6373. #region 填充word表格内容
  6374. for (int i = 0; i < dac3.Count; i++)
  6375. {
  6376. Grp_DayAndCost dac = dac3[i];
  6377. if (dac == null) continue;
  6378. builder.MoveToCell(2, i, 0, 0);
  6379. builder.Write("第" + dac.Days.ToString() + "天:");
  6380. builder.MoveToCell(2, i, 1, 0);
  6381. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6382. builder.MoveToCell(2, i, 2, 0);
  6383. builder.Write("费用标准:");
  6384. string curr = "";
  6385. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6386. if (currData != null)
  6387. {
  6388. curr = currData.Name;
  6389. }
  6390. builder.MoveToCell(2, i, 3, 0);
  6391. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6392. builder.MoveToCell(2, i, 4, 0);
  6393. builder.Write("费用小计:");
  6394. builder.MoveToCell(2, i, 5, 0);
  6395. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6396. }
  6397. //删除多余行
  6398. while (table3.Rows.Count > table3Row)
  6399. {
  6400. table3.Rows.RemoveAt(table3Row);
  6401. }
  6402. #endregion
  6403. }
  6404. else dic.Add("SubGZF", "0.00");
  6405. //删除多余行
  6406. while (table3.Rows.Count > table3Row)
  6407. {
  6408. table3.Rows.RemoveAt(table3Row);
  6409. }
  6410. //培训费
  6411. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6412. if (_EnterExitCosts.ChoiceSix == 1)
  6413. {
  6414. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6415. dic.Add("SubPX", pxStr);
  6416. table4Row = dac4.Count;
  6417. #region 填充word表格内容
  6418. for (int i = 0; i < dac4.Count; i++)
  6419. {
  6420. Grp_DayAndCost dac = dac4[i];
  6421. if (dac == null) continue;
  6422. builder.MoveToCell(3, i, 0, 0);
  6423. builder.Write("第" + dac.Days.ToString() + "天:");
  6424. builder.MoveToCell(3, i, 1, 0);
  6425. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6426. builder.MoveToCell(3, i, 2, 0);
  6427. builder.Write("费用标准:");
  6428. string curr = "";
  6429. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6430. if (currData != null)
  6431. {
  6432. curr = currData.Name;
  6433. }
  6434. builder.MoveToCell(3, i, 3, 0);
  6435. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6436. builder.MoveToCell(3, i, 4, 0);
  6437. builder.Write("费用小计:");
  6438. builder.MoveToCell(3, i, 5, 0);
  6439. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6440. }
  6441. #endregion
  6442. }
  6443. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6444. //删除多余行
  6445. while (table4.Rows.Count > table4Row)
  6446. {
  6447. table4.Rows.RemoveAt(table4Row);
  6448. }
  6449. //其他费用
  6450. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6451. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6452. {
  6453. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6454. dic.Add("titleQi", qtStr);
  6455. table5Row = dac5.Count;
  6456. #region 填充word表格内容
  6457. for (int i = 0; i < dac5.Count; i++)
  6458. {
  6459. var dac = dac5[i];
  6460. if (dac == null) continue;
  6461. builder.MoveToCell(4, i, 0, 0);
  6462. builder.Write("第" + dac.Index.ToString() + "项:");
  6463. builder.MoveToCell(4, i, 1, 0);
  6464. builder.Write(dac.itemName);
  6465. builder.MoveToCell(4, i, 2, 0);
  6466. builder.Write("费用标准:");
  6467. builder.MoveToCell(4, i, 3, 0);
  6468. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6469. builder.MoveToCell(4, i, 4, 0);
  6470. builder.Write("费用小计:");
  6471. builder.MoveToCell(4, i, 5, 0);
  6472. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6473. builder.MoveToCell(4, i, 6, 0);
  6474. builder.Write("备注:");
  6475. builder.MoveToCell(4, i, 7, 0);
  6476. builder.Write(dac.Remark);
  6477. }
  6478. #endregion
  6479. }
  6480. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6481. //删除多余行
  6482. while (table5.Rows.Count > table5Row)
  6483. {
  6484. table5.Rows.RemoveAt(table5Row);
  6485. }
  6486. //加上其他费用
  6487. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6488. decimal subJJC = 0.00M,
  6489. subGWC = 0.00M,
  6490. subTDC = 0.00M;
  6491. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6492. string totalLabel = string.Format("全部费用总计:");
  6493. //经济舱
  6494. if (_EnterExitCosts.SumJJC == 1)
  6495. {
  6496. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6497. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6498. }
  6499. //公务舱
  6500. if (_EnterExitCosts.SumGWC == 1)
  6501. {
  6502. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6503. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6504. }
  6505. //头等舱
  6506. if (_EnterExitCosts.SumTDC == 1)
  6507. {
  6508. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6509. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6510. }
  6511. //TotalLabel
  6512. dic.Add("TotalLabel", totalLabel);
  6513. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6514. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6515. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6516. #region 填充word模板书签内容
  6517. foreach (var key in dic.Keys)
  6518. {
  6519. Bookmark bookmark = doc.Range.Bookmarks[key];
  6520. if (bookmark != null)
  6521. {
  6522. builder.MoveToBookmark(key);
  6523. builder.Write(dic[key]);
  6524. }
  6525. }
  6526. #endregion
  6527. #region 设置页眉
  6528. string userLabel = string.Empty;
  6529. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6530. if (currUserInfo != null)
  6531. {
  6532. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6533. if (userInfo != null)
  6534. {
  6535. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6536. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6537. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6538. }
  6539. }
  6540. //设置页脚
  6541. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6542. #endregion
  6543. //文件名
  6544. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6545. AsposeHelper.removewatermark_v2180();
  6546. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6547. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6548. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6549. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6550. }
  6551. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6552. {
  6553. //获取模板
  6554. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6555. //载入模板
  6556. Document doc = new Document(tempPath);
  6557. DocumentBuilder builder = new DocumentBuilder(doc);
  6558. Dictionary<string, string> dic = new Dictionary<string, string>();
  6559. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6560. {
  6561. List<string> list = new List<string>();
  6562. try
  6563. {
  6564. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6565. foreach (var item in spilitArr)
  6566. {
  6567. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6568. var depCode = spDotandEmpty[2].Substring(0, 3);
  6569. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6570. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6571. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6572. list.Add(depName);
  6573. list.Add(arrName);
  6574. }
  6575. list = list.Distinct().ToList();
  6576. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6577. }
  6578. catch (Exception)
  6579. {
  6580. dic.Add("ReturnCode", "行程录入不正确!");
  6581. }
  6582. }
  6583. else
  6584. {
  6585. dic.Add("ReturnCode", "未录入行程!");
  6586. }
  6587. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6588. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6589. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6590. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6591. {
  6592. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6593. dic.Add("Day", sp.Days.ToString());
  6594. }
  6595. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6596. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6597. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6598. //dic.Add("Names", Names);
  6599. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6600. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6601. decimal dac1totalPrice = 0.00M;
  6602. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6603. foreach (var dac in dac1)
  6604. {
  6605. if (dac.SubTotal == 0.00M)
  6606. {
  6607. continue;
  6608. }
  6609. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6610. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6611. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6612. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6613. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6614. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6615. builder.Write(currency);//币种
  6616. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6617. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6618. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6619. builder.Write("");//人数
  6620. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6621. builder.Write("");//天数
  6622. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6623. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6624. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6625. decimal rate = 0.00M;
  6626. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6627. builder.Write(rate.ToString("#0.0000"));//汇率
  6628. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6629. decimal rbmPrice = dac.SubTotal;
  6630. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6631. accommodationStartIndex++;
  6632. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6633. }
  6634. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6635. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6636. {
  6637. table1.Rows.RemoveAt(i - 1);
  6638. foodandotherStartIndex--;
  6639. }
  6640. if (dac2.Count == dac3.Count)//国家 币种 金额
  6641. {
  6642. for (int i = 0; i < dac2.Count; i++)
  6643. {
  6644. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6645. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6646. }
  6647. }
  6648. decimal dac2totalPrice = 0.00M;
  6649. foreach (var dac in dac2)
  6650. {
  6651. if (dac.SubTotal == 0)
  6652. {
  6653. continue;
  6654. }
  6655. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6656. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6657. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6658. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6659. builder.Write(currency);//币种
  6660. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6661. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6662. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6663. builder.Write("");//人数
  6664. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6665. builder.Write("");//天数
  6666. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6667. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6668. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6669. decimal rate = 0.00M;
  6670. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6671. builder.Write(rate.ToString("#0.0000"));//汇率
  6672. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6673. decimal rbmPrice = dac.SubTotal;
  6674. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6675. foodandotherStartIndex++;
  6676. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6677. }
  6678. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6679. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6680. {
  6681. table1.Rows.RemoveAt(i - 1);
  6682. }
  6683. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6684. string otherFeeStr = "";
  6685. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6686. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6687. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6688. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6689. foreach (var otherInfo in dac5)
  6690. {
  6691. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6692. }
  6693. #endregion
  6694. if (otherFeeStr.Length > 0)
  6695. {
  6696. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6697. otherFeeStr = $"({otherFeeStr})";
  6698. dic.Add("OtherFeeStr", otherFeeStr);
  6699. }
  6700. //总计
  6701. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6702. //国际旅费
  6703. string outsideAir = string.Empty;
  6704. string allPriceAir = string.Empty;
  6705. if (_EnterExitCosts.SumJJC == 1)
  6706. {
  6707. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6708. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6709. }
  6710. if (_EnterExitCosts.SumGWC == 1)
  6711. {
  6712. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6713. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6714. }
  6715. if (_EnterExitCosts.SumTDC == 1)
  6716. {
  6717. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6718. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6719. }
  6720. dic.Add("InTravelPrice", $"({outsideAir})");
  6721. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6722. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6723. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6724. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6725. foreach (var key in dic.Keys)
  6726. {
  6727. builder.MoveToBookmark(key);
  6728. builder.Write(dic[key]);
  6729. }
  6730. //模板文件名
  6731. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6732. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6733. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6734. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6735. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6736. }
  6737. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6738. {
  6739. //获取模板
  6740. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6741. //载入模板
  6742. WorkbookDesigner designer = new WorkbookDesigner();
  6743. designer.Workbook = new Workbook(tempPath);
  6744. Dictionary<string, string> dic = new Dictionary<string, string>();
  6745. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6746. {
  6747. List<string> list = new List<string>();
  6748. try
  6749. {
  6750. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6751. foreach (var item in spilitArr)
  6752. {
  6753. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6754. var depCode = spDotandEmpty[2].Substring(0, 3);
  6755. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6756. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6757. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6758. list.Add(depName);
  6759. list.Add(arrName);
  6760. }
  6761. list = list.Distinct().ToList();
  6762. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6763. }
  6764. catch (Exception)
  6765. {
  6766. dic.Add("ReturnCode", "行程录入不正确!");
  6767. }
  6768. }
  6769. else
  6770. {
  6771. dic.Add("ReturnCode", "未录入行程!");
  6772. }
  6773. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6774. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6775. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6776. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6777. {
  6778. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6779. dic.Add("Day", sp.Days.ToString());
  6780. }
  6781. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6782. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6783. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6784. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6785. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6786. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6787. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6788. designer.SetDataSource("Name", Names);
  6789. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6790. designer.SetDataSource("Day", dic["Day"] + "天");
  6791. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6792. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6793. int startIndex = 10;
  6794. const int startIndexcopy = 10;
  6795. if (dac2.Count == dac3.Count)//国家 币种 金额
  6796. {
  6797. for (int i = 0; i < dac2.Count; i++)
  6798. {
  6799. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6800. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6801. }
  6802. }
  6803. DataTable dtdac1 = new DataTable();
  6804. List<string> place = new List<string>();
  6805. dtdac1.Columns.AddRange(new DataColumn[] {
  6806. new DataColumn(){ ColumnName = "city"},
  6807. new DataColumn(){ ColumnName = "curr"},
  6808. new DataColumn(){ ColumnName = "criterion"},
  6809. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6810. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6811. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6812. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6813. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6814. });
  6815. DataTable dtdac2 = new DataTable();
  6816. dtdac2.Columns.AddRange(new DataColumn[] {
  6817. new DataColumn(){ ColumnName = "city"},
  6818. new DataColumn(){ ColumnName = "curr"},
  6819. new DataColumn(){ ColumnName = "criterion"},
  6820. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6821. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6822. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6823. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6824. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6825. });
  6826. dtdac1.TableName = "tb1";
  6827. dtdac2.TableName = "tb2";
  6828. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6829. foreach (var item in dac1)
  6830. {
  6831. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6832. if (place.Contains(item.Place))
  6833. {
  6834. continue;
  6835. }
  6836. DataRow row = dtdac1.NewRow();
  6837. row["city"] = item.Place;
  6838. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6839. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6840. row["curr"] = currency;
  6841. row["rate"] = rate.ToString("#0.0000");
  6842. row["criterion"] = item.Cost.ToString("#0.00");
  6843. row["number"] = 1;
  6844. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6845. //row["costRMB"] = rbmPrice;
  6846. dtdac1.Rows.Add(row);
  6847. place.Add(item.Place);
  6848. }
  6849. place = new List<string>();
  6850. foreach (var item in dac2)
  6851. {
  6852. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6853. if (place.Contains(item.Place))
  6854. {
  6855. continue;
  6856. }
  6857. DataRow row = dtdac2.NewRow();
  6858. row["city"] = item.Place;
  6859. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6860. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6861. row["curr"] = currency;
  6862. row["rate"] = rate.ToString("#0.0000");
  6863. row["criterion"] = item.Cost.ToString("#0.00");
  6864. row["number"] = 1;
  6865. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6866. //row["cost"] = item.SubTotal;
  6867. //row["costRMB"] = rbmPrice;
  6868. dtdac2.Rows.Add(row);
  6869. place.Add(item.Place);
  6870. //dac2totalPrice += rbmPrice;
  6871. }
  6872. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6873. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6874. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6875. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6876. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6877. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6878. string cell4Str1 = string.Empty;
  6879. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6880. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6881. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6882. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6883. string cellStr = $" 5.其他费用(";
  6884. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6885. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6886. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6887. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6888. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6889. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6890. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6891. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6892. foreach (var otherInfo in dac5)
  6893. {
  6894. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6895. }
  6896. #endregion
  6897. if (cellStr.Length > 8)
  6898. {
  6899. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6900. }
  6901. cellStr += ")";
  6902. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6903. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6904. decimal pxFee = dac4.Sum(it => it.Cost);
  6905. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6906. string celllastStr1 = "";
  6907. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6908. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6909. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6910. celllastStr1 += $",国际旅费 元";
  6911. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6912. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6913. designer.SetDataSource("cell4Str", cell4Str);
  6914. designer.SetDataSource("cellStr", cellStr);
  6915. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6916. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6917. designer.SetDataSource("celllastStr", celllastStr);
  6918. Workbook wb = designer.Workbook;
  6919. var sheet = wb.Worksheets[0];
  6920. //绑定datatable数据集
  6921. designer.SetDataSource(dtdac1);
  6922. designer.SetDataSource(dtdac2);
  6923. designer.Process();
  6924. var rowStart = dtdac1.Rows.Count;
  6925. while (rowStart > 0)
  6926. {
  6927. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6928. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6929. startIndex++;
  6930. rowStart--;
  6931. }
  6932. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6933. startIndex += 1; //总计行
  6934. rowStart = dtdac2.Rows.Count;
  6935. while (rowStart > 0)
  6936. {
  6937. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6938. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6939. startIndex++;
  6940. rowStart--;
  6941. }
  6942. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6943. wb.CalculateFormula(true);
  6944. //模板文件名
  6945. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6946. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6947. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6948. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6949. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6950. }
  6951. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6952. {
  6953. //获取模板
  6954. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6955. //载入模板
  6956. Document doc = new Document(tempPath);
  6957. DocumentBuilder builder = new DocumentBuilder(doc);
  6958. Dictionary<string, string> dic = new Dictionary<string, string>();
  6959. dic.Add("GroupName", _DelegationInfo.TeamName);
  6960. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6961. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6962. string missionLeaderJob = "";//负责人job
  6963. //int groupNumber = 0; //团人数
  6964. if (DeleClientList.Count > 0)
  6965. {
  6966. missionLeader = DeleClientList[0]?.Name ?? "";
  6967. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6968. }
  6969. dic.Add("MissionLeader", missionLeader); //团负责人
  6970. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6971. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6972. #region MyRegion
  6973. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6974. //{
  6975. // List<string> list = new List<string>();
  6976. // try
  6977. // {
  6978. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6979. // foreach (var item in spilitArr)
  6980. // {
  6981. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6982. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6983. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6984. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6985. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6986. // list.Add(depName);
  6987. // list.Add(arrName);
  6988. // }
  6989. // list = list.Distinct().ToList();
  6990. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6991. // }
  6992. // catch (Exception)
  6993. // {
  6994. // dic.Add("ReturnCode", "行程录入不正确!");
  6995. // }
  6996. //}
  6997. //else
  6998. //{
  6999. // dic.Add("ReturnCode", "未录入行程!");
  7000. //}
  7001. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7002. dic.Add("ReturnCode", string.Join("、", countrys));
  7003. #endregion
  7004. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7005. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7006. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7007. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7008. //{
  7009. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7010. // dic.Add("Day", sp.Days.ToString());
  7011. //}
  7012. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7013. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7014. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7015. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7016. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7017. //培训人员名单
  7018. int cultivateRowIndex = 7;
  7019. foreach (var item in DeleClientList)
  7020. {
  7021. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7022. builder.Write(item.Name);
  7023. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7024. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7025. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7026. string birthDay = "";
  7027. if (item.Birthday != null)
  7028. {
  7029. DateTime dt = Convert.ToDateTime(item.Birthday);
  7030. birthDay = $"{dt.Year}.{dt.Month}";
  7031. }
  7032. builder.Write(birthDay);
  7033. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7034. builder.Write(item.Company);
  7035. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7036. builder.Write(item.Job);
  7037. cultivateRowIndex++;
  7038. }
  7039. //删除多余行
  7040. //cultivateRowIndex -= 2;
  7041. int delRows = 10 + 7 - cultivateRowIndex;
  7042. if (delRows > 0)
  7043. {
  7044. for (int i = 0; i < delRows; i++)
  7045. {
  7046. table1.Rows.RemoveAt(cultivateRowIndex);
  7047. //cultivateRowIndex++;
  7048. }
  7049. }
  7050. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7051. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7052. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7053. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7054. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7055. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7056. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7057. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7058. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7059. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7060. //其他费用
  7061. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7062. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7063. //其他费用合计
  7064. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7065. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7066. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7067. //公务舱合计
  7068. //国际旅费
  7069. //string outsideJJ = "";
  7070. //string allPriceJJ = "";
  7071. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7072. {
  7073. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7074. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7075. }
  7076. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7077. {
  7078. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7079. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7080. }
  7081. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7082. {
  7083. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7084. dic.Add("AirFeeTotal", airFeeTotalStr);
  7085. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7086. dic.Add("FeeTotal", feeTotalStr);
  7087. }
  7088. foreach (var key in dic.Keys)
  7089. {
  7090. builder.MoveToBookmark(key);
  7091. builder.Write(dic[key]);
  7092. }
  7093. //模板文件名
  7094. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7095. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7096. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7097. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7098. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7099. }
  7100. }
  7101. else if (dto.ExportType == 2) //表格
  7102. {
  7103. //利用键值对存放数据
  7104. Dictionary<string, string> dic = new Dictionary<string, string>();
  7105. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7106. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7107. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7108. dic.Add("Day", sp.Days.ToString());
  7109. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7110. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7111. {
  7112. //获取模板
  7113. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7114. //载入模板
  7115. Document doc = new Document(tempPath);
  7116. DocumentBuilder builder = new DocumentBuilder(doc);
  7117. dic.Add("TeamName", _DelegationInfo.TeamName);
  7118. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7119. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7120. string missionLeaderName = "",
  7121. missionLeaderJob = "";
  7122. if (DeleClientList.Count > 0)
  7123. {
  7124. missionLeaderName = DeleClientList[0].Name;
  7125. missionLeaderJob = DeleClientList[0].Job;
  7126. }
  7127. dic.Add("MissionLeaderName", missionLeaderName);
  7128. dic.Add("MissionLeaderJob", missionLeaderJob);
  7129. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7130. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7131. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7132. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7133. int rowCount = 10;//总人数行
  7134. int startRowIndex = 7; //起始行
  7135. for (int i = 0; i < DeleClientList.Count; i++)
  7136. {
  7137. builder.MoveToCell(0, startRowIndex, 0, 0);
  7138. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7139. builder.MoveToCell(0, startRowIndex, 1, 0);
  7140. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7141. builder.Write(sex);//性别
  7142. builder.MoveToCell(0, startRowIndex, 2, 0);
  7143. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7144. builder.MoveToCell(0, startRowIndex, 3, 0);
  7145. builder.Write(DeleClientList[i].Company);//工作单位
  7146. builder.MoveToCell(0, startRowIndex, 4, 0);
  7147. builder.Write(DeleClientList[i].Job);//职务及级别
  7148. builder.MoveToCell(0, startRowIndex, 5, 0);
  7149. builder.Write("");//人员属性
  7150. builder.MoveToCell(0, startRowIndex, 6, 0);
  7151. builder.Write("");//上次出国时间
  7152. startRowIndex++;
  7153. }
  7154. int nullRow = rowCount - DeleClientList.Count;//空行
  7155. for (int i = 0; i < nullRow; i++)
  7156. {
  7157. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7158. }
  7159. foreach (var key in dic.Keys)
  7160. {
  7161. builder.MoveToBookmark(key);
  7162. builder.Write(dic[key]);
  7163. }
  7164. //模板文件名
  7165. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7166. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7167. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7168. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7169. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7170. }
  7171. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7172. {
  7173. //获取模板
  7174. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7175. //载入模板
  7176. Document doc = new Document(tempPath);
  7177. DocumentBuilder builder = new DocumentBuilder(doc);
  7178. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7179. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7180. dic.Add("Names", Names);
  7181. int accommodationRows = 12;
  7182. //int foodandotherRows = 12;
  7183. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7184. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7185. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7186. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7187. int accommodationStartIndex = 6;
  7188. decimal dac1totalPrice = 0.00M;
  7189. foreach (var dac in dac1)
  7190. {
  7191. if (dac.SubTotal == 0)
  7192. {
  7193. continue;
  7194. }
  7195. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7196. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7197. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7198. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7199. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7200. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7201. builder.Write(currency);//币种
  7202. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7203. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7204. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7205. builder.Write("");//人数
  7206. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7207. builder.Write("");//天数
  7208. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7209. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7210. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7211. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7212. builder.Write(rate.ToString("#0.0000"));//汇率
  7213. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7214. decimal rbmPrice = rate * dac.SubTotal;
  7215. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7216. accommodationStartIndex++;
  7217. dac1totalPrice += rbmPrice;
  7218. }
  7219. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7220. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7221. builder.Write("小计");
  7222. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7223. builder.Write(dac1totalPrice.ToString("#0.00"));
  7224. accommodationStartIndex++;
  7225. int nullRow = accommodationRows - dac1.Count;
  7226. //删除空行
  7227. //if (nullRow > 0)
  7228. //{
  7229. // int rowIndex = accommodationStartIndex;
  7230. // for (int i = 0; i < nullRow; i++)
  7231. // {
  7232. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7233. // row.Remove();
  7234. // rowIndex++;
  7235. // }
  7236. //}
  7237. if (dac2.Count == dac3.Count)//国家 币种 金额
  7238. {
  7239. for (int i = 0; i < dac2.Count; i++)
  7240. {
  7241. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7242. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7243. }
  7244. }
  7245. int foodandotherStartIndex = 19;//
  7246. decimal dac2totalPrice = 0.00M;
  7247. foreach (var dac in dac2)
  7248. {
  7249. if (dac.SubTotal == 0)
  7250. {
  7251. continue;
  7252. }
  7253. //foodandotherStartIndex = 12;
  7254. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7255. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7256. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7257. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7258. builder.Write(currency);//币种
  7259. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7260. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7261. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7262. builder.Write("");//人数
  7263. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7264. builder.Write("");//天数
  7265. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7266. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7267. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7268. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7269. builder.Write(rate.ToString("#0.0000"));//汇率
  7270. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7271. decimal rbmPrice = rate * dac.SubTotal;
  7272. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7273. foodandotherStartIndex++;
  7274. dac2totalPrice += rbmPrice;
  7275. }
  7276. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7277. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7278. //删除空行
  7279. //if (dac2.Count < foodandotherRows)
  7280. //{
  7281. // while (table2.Rows.Count > dac2.Count)
  7282. // {
  7283. // table2.Rows.RemoveAt(dac2.Count);
  7284. // }
  7285. //}
  7286. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7287. string otherFeeStr = "";
  7288. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7289. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7290. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7291. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7292. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7293. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7294. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7295. foreach (var otherInfo in dac5)
  7296. {
  7297. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7298. }
  7299. #endregion
  7300. if (otherFeeStr.Length > 0)
  7301. {
  7302. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7303. otherFeeStr = $"({otherFeeStr})";
  7304. dic.Add("OtherFeeStr", otherFeeStr);
  7305. }
  7306. foreach (var key in dic.Keys)
  7307. {
  7308. builder.MoveToBookmark(key);
  7309. builder.Write(dic[key]);
  7310. }
  7311. //模板文件名
  7312. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7313. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7314. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7315. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7316. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7317. }
  7318. }
  7319. else if (dto.ExportType == 3)
  7320. {
  7321. if (dto.SubTypeId == 1) //团组成员名单
  7322. {
  7323. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7324. //获取模板
  7325. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7326. //载入模板
  7327. Document doc = new Document(tempPath);
  7328. DocumentBuilder builder = new DocumentBuilder(doc);
  7329. //获取word里所有表格
  7330. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7331. //获取所填表格的序数
  7332. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7333. var rowStart = tableOne.Rows[0]; //获取第1行
  7334. //循环赋值
  7335. for (int i = 0; i < DeleClientList.Count; i++)
  7336. {
  7337. builder.MoveToCell(0, i + 1, 0, 0);
  7338. builder.Write(DeleClientList[i].Name);
  7339. builder.MoveToCell(0, i + 1, 1, 0);
  7340. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7341. builder.Write(sex);
  7342. builder.MoveToCell(0, i + 1, 2, 0);
  7343. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7344. builder.MoveToCell(0, i + 1, 3, 0);
  7345. builder.Write(DeleClientList[i].Company);
  7346. builder.MoveToCell(0, i + 1, 4, 0);
  7347. builder.Write(DeleClientList[i].Job);
  7348. }
  7349. //删除多余行
  7350. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7351. {
  7352. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7353. }
  7354. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7355. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7356. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7357. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7358. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7359. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7360. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7361. }
  7362. }
  7363. return Ok(JsonView(400, "操作失败!", ""));
  7364. }
  7365. catch (Exception ex)
  7366. {
  7367. return Ok(JsonView(400, ex.Message, ""));
  7368. }
  7369. }
  7370. /// <summary>
  7371. /// 获取三公费用标准city
  7372. /// </summary>
  7373. /// <param name="placeData"></param>
  7374. /// <param name="nationalTravelFeeId"></param>
  7375. /// <returns></returns>
  7376. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7377. {
  7378. string _city = string.Empty;
  7379. if (placeData.Count < 1) return _city;
  7380. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7381. if (data == null) return _city;
  7382. string country = data.Country;
  7383. string city = data.City;
  7384. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7385. else _city = city;
  7386. return _city;
  7387. }
  7388. ///// <summary>
  7389. ///// 团组模块 - 出入境费用 - 明细表导出
  7390. ///// </summary>
  7391. ///// <returns></returns>
  7392. //[HttpPost]
  7393. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7394. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7395. //{
  7396. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7397. // if (data.Code != 0)
  7398. // {
  7399. // return Ok(JsonView(false, data.Msg));
  7400. // }
  7401. // return Ok(JsonView(true, data.Msg, data.Data));
  7402. //}
  7403. /// <summary>
  7404. /// 团组模块 - 出入境费用 - 一键清空
  7405. /// </summary>
  7406. /// <returns></returns>
  7407. [HttpPost]
  7408. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7410. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7411. {
  7412. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7413. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7414. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7415. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7416. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7417. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7418. .SetColumns(x => new Grp_DayOtherPrice
  7419. {
  7420. IsDel = 1,
  7421. DeleteUserId = dto.UserId,
  7422. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7423. })
  7424. .ExecuteCommandAsync();
  7425. if (_view.Code == 0)
  7426. {
  7427. return Ok(JsonView(true, "操作成功"));
  7428. }
  7429. return Ok(JsonView(false, "操作失败"));
  7430. }
  7431. /// <summary>
  7432. /// 团组模块 - 出入境费用 - 子项删除
  7433. /// </summary>
  7434. /// <returns></returns>
  7435. [HttpPost]
  7436. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7438. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7439. {
  7440. try
  7441. {
  7442. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7443. if (data.Code != 0)
  7444. {
  7445. return Ok(JsonView(false, data.Msg));
  7446. }
  7447. return Ok(JsonView(true, "操作成功!", data.Data));
  7448. }
  7449. catch (Exception ex)
  7450. {
  7451. return Ok(JsonView(false, ex.Message));
  7452. }
  7453. }
  7454. /// <summary>
  7455. /// 删除三公其他费用
  7456. /// </summary>
  7457. /// <param name="dto"></param>
  7458. /// <returns></returns>
  7459. [HttpPost]
  7460. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7461. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7462. {
  7463. var jw = JsonView(false, "删除失败!");
  7464. var data = new Grp_DayOtherPrice()
  7465. {
  7466. Id = dto.Id,
  7467. IsDel = 1,
  7468. DeleteUserId = dto.DeleteUserId,
  7469. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7470. };
  7471. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7472. if (del > 0)
  7473. {
  7474. jw.Code = 200;
  7475. jw.Msg = "删除成功!";
  7476. }
  7477. return Ok(jw);
  7478. }
  7479. /// <summary>
  7480. /// 团组模块 - 出入境国家费用标准 List
  7481. /// </summary>
  7482. /// <returns></returns>
  7483. [HttpPost]
  7484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7485. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7486. {
  7487. int provinceId = dto.ProvinceId;
  7488. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7489. var nftData = await _sqlSugar
  7490. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7491. JoinType.Left, ntf.Currency == sd1.Id,
  7492. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7493. JoinType.Left, ntf.ProvinceId == c.Id
  7494. ))
  7495. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7496. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7497. {
  7498. Id = ntf.Id,
  7499. ProvinceId = ntf.ProvinceId,
  7500. ProvinceName = c.Name_CN,
  7501. Continent = ntf.Continent,
  7502. Country = ntf.Country,
  7503. City = ntf.City,
  7504. Currency = ntf.Currency,
  7505. CurrencyCode = sd1.Name,
  7506. CurrencyName = sd1.Remark,
  7507. RoomCost = ntf.RoomCost,
  7508. FoodCost = ntf.FoodCost,
  7509. PublicCost = ntf.PublicCost,
  7510. LastUpdateUserId = ntf.LastUpdateUserId,
  7511. LastUpdateUserName = u.CnName,
  7512. LastUpdateTime = ntf.LastUpdateTime
  7513. })
  7514. .ToListAsync();
  7515. return Ok(JsonView(true, "查询成功!", nftData));
  7516. }
  7517. /// <summary>
  7518. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7519. /// </summary>
  7520. /// <returns></returns>
  7521. [HttpPost]
  7522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7523. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7524. {
  7525. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7526. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7527. List<string> countryData = new List<string>();
  7528. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7529. countryData = countryData.Distinct().ToList();
  7530. List<dynamic> dataSource = new List<dynamic>();
  7531. foreach (var item in countryData)
  7532. {
  7533. var cityData1 = new List<string>();
  7534. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7535. var countryData2 = new
  7536. {
  7537. CountryName = item,
  7538. CityData = cityData1
  7539. };
  7540. if (!dataSource.Contains(countryData2))
  7541. {
  7542. dataSource.Add(countryData2);
  7543. }
  7544. }
  7545. return Ok(JsonView(true, "查询成功!", dataSource));
  7546. }
  7547. /// <summary>
  7548. /// 团组模块 - 出入境国家费用标准 Page List
  7549. /// </summary>
  7550. /// <returns></returns>
  7551. [HttpPost]
  7552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7553. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7554. {
  7555. int portId = dto.PortType,
  7556. pageIndex = dto.PageIndex,
  7557. pageSize = dto.PageSize;
  7558. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7559. if (pageIndex == 0) pageIndex = 1;
  7560. if (pageSize == 0) pageSize = 10;
  7561. RefAsync<int> total = 0;
  7562. var nationalTravelFeeData = await _sqlSugar
  7563. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7564. JoinType.Left, ntf.Currency == sd1.Id,
  7565. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7566. JoinType.Left, ntf.ProvinceId == sd2.Id
  7567. ))
  7568. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7569. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7570. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7571. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7572. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7573. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7574. {
  7575. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7576. Id = ntf.Id,
  7577. ProvinceId = ntf.ProvinceId,
  7578. ProvinceName = sd2.Name_CN,
  7579. Continent = ntf.Continent,
  7580. Country = ntf.Country,
  7581. City = ntf.City,
  7582. Currency = ntf.Currency,
  7583. CurrencyCode = sd1.Name,
  7584. CurrencyName = sd1.Remark,
  7585. RoomCost = ntf.RoomCost,
  7586. FoodCost = ntf.FoodCost,
  7587. PublicCost = ntf.PublicCost,
  7588. LastUpdateUserId = ntf.LastUpdateUserId,
  7589. LastUpdateUserName = u.CnName,
  7590. LastUpdateTime = ntf.LastUpdateTime,
  7591. Remark = ntf.Remark
  7592. })
  7593. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7594. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7595. }
  7596. /// <summary>
  7597. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7598. /// </summary>
  7599. /// <returns></returns>
  7600. [HttpPost]
  7601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7602. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7603. {
  7604. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7605. int portId = dto.PortType;
  7606. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7607. string whereSql = string.Empty;
  7608. if (!string.IsNullOrEmpty(dto.Country))
  7609. {
  7610. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7611. }
  7612. if (!string.IsNullOrEmpty(dto.City))
  7613. {
  7614. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7615. }
  7616. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7617. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7618. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7619. From Grp_NationalTravelFee gntf
  7620. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7621. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7622. Where gntf.Isdel = 0 {0} ", whereSql);
  7623. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7624. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7625. }
  7626. /// <summary>
  7627. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7628. /// </summary>
  7629. /// <returns></returns>
  7630. [HttpPost]
  7631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7632. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7633. {
  7634. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7635. }
  7636. /// <summary>
  7637. /// 团组模块 - 出入境国家费用标准 - Del
  7638. /// </summary>
  7639. /// <returns></returns>
  7640. [HttpPost]
  7641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7642. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7643. {
  7644. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7645. {
  7646. Id = dto.Id,
  7647. DeleteUserId = dto.DeleteUserId,
  7648. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7649. IsDel = 1
  7650. };
  7651. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7652. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7653. .WhereColumns(it => new { it.Id })
  7654. .ExecuteCommandAsync();
  7655. if (delStatus <= 0)
  7656. {
  7657. return Ok(JsonView(false, "删除失败!"));
  7658. }
  7659. return Ok(JsonView(true, "操作成功!"));
  7660. }
  7661. /// <summary>
  7662. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7663. /// 注:Get 请求Headers 加 Token
  7664. /// </summary>
  7665. /// <param name="groupId"></param>
  7666. /// <returns></returns>
  7667. [HttpGet("{groupId}")]
  7668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7669. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7670. {
  7671. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7672. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7673. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7674. data.ForEach(x =>
  7675. {
  7676. x.CreateUserId = _currUserInfo.UserId;
  7677. });
  7678. if (data.Any())
  7679. {
  7680. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7681. if (add > 0)
  7682. {
  7683. return Ok(JsonView(true, "操作成功!"));
  7684. }
  7685. }
  7686. return Ok(JsonView(false, "未操作!"));
  7687. }
  7688. #endregion
  7689. #region 团组经理模块 出入境费用-草稿
  7690. /// <summary>
  7691. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7692. /// </summary>
  7693. /// <returns></returns>
  7694. [HttpGet]
  7695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7696. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7697. {
  7698. var provData = await _groupRepository.ProvinceBasicSource();
  7699. return Ok(JsonView(true, "查询成功!", provData));
  7700. }
  7701. /// <summary>
  7702. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7703. /// </summary>
  7704. /// <returns></returns>
  7705. [HttpGet("{provinceId}")]
  7706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7707. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7708. {
  7709. //验证城市归属并给默认值
  7710. if (provinceId < 1) provinceId = 122;
  7711. /*
  7712. * 122 四川
  7713. * 108 贵州
  7714. * 103 重庆
  7715. * 132 云南
  7716. */
  7717. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7718. return Ok(JsonView(true, "查询成功!", new
  7719. {
  7720. WordTypeData = wordTypeData,
  7721. ExcelTypeData = excelTypeData,
  7722. }));
  7723. }
  7724. /// <summary>
  7725. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7726. /// </summary>
  7727. /// <returns></returns>
  7728. [HttpPost]
  7729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7730. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7731. {
  7732. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7733. .Where(x => x.IsDel == 0)
  7734. .OrderByDescending(x => x.CreateTime)
  7735. .Select(x => new { x.Id, x.DraftName })
  7736. .ToListAsync();
  7737. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7738. //SetDataInfoView
  7739. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7740. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7741. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7742. int provinceId = dto.ProvinceId;
  7743. if (provinceId < 1) provinceId = 122;
  7744. /*
  7745. * 122 四川
  7746. * 108 贵州
  7747. * 103 重庆
  7748. * 132 云南
  7749. */
  7750. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7751. //默认币种显示
  7752. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7753. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7754. return Ok(JsonView(true, "查询成功!", new
  7755. {
  7756. DraftNameDatas = draftNameDatas,
  7757. CurrencyData = _CurrencyData,
  7758. WordTypeData = wordTypeData,
  7759. ExcelTypeData = excelTypeData,
  7760. CurrencyInit = _currencyInfos,
  7761. ViewPermissionData = viewPermissionData
  7762. }));
  7763. }
  7764. /// <summary>
  7765. /// 团组模块 - 出入境费用-草稿
  7766. /// 实时汇率 tips
  7767. /// 机票费用 tips
  7768. /// </summary>
  7769. /// <returns></returns>
  7770. [HttpPost]
  7771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7772. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7773. {
  7774. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7775. return Ok(JsonView(true, "查询成功!", new
  7776. {
  7777. //GroupNameData = groupNameData.Data,
  7778. //visaData = visaData.Data,
  7779. //airData = airData.Data,
  7780. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7781. }));
  7782. }
  7783. /// <summary>
  7784. /// 团组模块 - 出入境费用-草稿
  7785. /// 签证费用 tips
  7786. /// </summary>
  7787. /// <returns></returns>
  7788. [HttpPost]
  7789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7790. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7791. {
  7792. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7793. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7794. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7795. .Select(x => x.NationalTravelFeeId)
  7796. .Distinct()
  7797. .ToListAsync();
  7798. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7799. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7800. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7801. .Select(x => x.Country)
  7802. .Distinct()
  7803. .ToArrayAsync();
  7804. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7805. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7806. return Ok(JsonView(true, "查询成功!", new
  7807. {
  7808. totalAmt = totalAmt,
  7809. remark = remark
  7810. }));
  7811. }
  7812. /// <summary>
  7813. /// 团组模块 - 出入境费用-草稿 - Info
  7814. /// </summary>
  7815. /// <returns></returns>
  7816. [HttpPost]
  7817. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7819. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7820. {
  7821. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7822. }
  7823. /// <summary>
  7824. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7825. /// </summary>
  7826. /// <returns></returns>
  7827. [HttpPost]
  7828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7829. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7830. {
  7831. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7832. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7833. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7834. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7835. foreach (var userId in dto.UserIds)
  7836. {
  7837. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7838. }
  7839. if (permissions.Any())
  7840. {
  7841. _sqlSugar.BeginTran();
  7842. try
  7843. {
  7844. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7845. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7846. if (result < 1)
  7847. {
  7848. _sqlSugar.RollbackTran();
  7849. return Ok(JsonView(false));
  7850. }
  7851. }
  7852. catch (Exception ex)
  7853. {
  7854. _sqlSugar.RollbackTran();
  7855. return Ok(JsonView(false, ex.Message));
  7856. }
  7857. _sqlSugar.CommitTran();
  7858. return Ok(JsonView(true));
  7859. }
  7860. return Ok(JsonView(false));
  7861. }
  7862. /// <summary>
  7863. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7864. /// </summary>
  7865. /// <returns></returns>
  7866. [HttpPost]
  7867. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7869. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7870. {
  7871. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7872. if (data.Code != 0)
  7873. {
  7874. return Ok(JsonView(false, data.Msg));
  7875. }
  7876. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7877. //汇率信息记录
  7878. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7879. return Ok(JsonView(true, data.Msg, data.Data));
  7880. }
  7881. /// <summary>
  7882. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7883. /// </summary>
  7884. /// <param name="dto"></param>
  7885. /// <returns></returns>
  7886. [HttpPost]
  7887. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7889. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7890. {
  7891. try
  7892. {
  7893. var id = dto.Id;
  7894. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7895. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7896. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7897. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7898. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7899. 3 团组成员名单 1 团组成员名单", ""));
  7900. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7901. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7902. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7903. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7904. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7905. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7906. //数据源
  7907. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7908. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7909. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7910. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7911. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7912. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7913. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7914. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7915. .Select((x, a, b) => new
  7916. {
  7917. x.Index,
  7918. itemName = a.Name,
  7919. CurrencyStr = b.Name,
  7920. x.Cost,
  7921. x.SubTotal,
  7922. x.Remark
  7923. })
  7924. .OrderBy((x) => x.Index)
  7925. .ToList(); //其他款项费用
  7926. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7927. var peiceItemCurrencys = new List<string>();
  7928. if (_DayAndCosts.Any())
  7929. {
  7930. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7931. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7932. }
  7933. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7934. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7935. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7936. {
  7937. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7938. }
  7939. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7940. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7941. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7942. if (dto.ExportType == 1) //明细表
  7943. {
  7944. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7945. {
  7946. //获取模板
  7947. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7948. //载入模板
  7949. Document doc = new Document(tempPath);
  7950. DocumentBuilder builder = new DocumentBuilder(doc);
  7951. //利用键值对存放数据
  7952. Dictionary<string, string> dic = new Dictionary<string, string>();
  7953. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7954. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7955. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7956. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7957. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7958. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7959. //境内费用(其他费用)
  7960. if (_EnterExitCosts.ChoiceOne == 1)
  7961. {
  7962. string row1_1 = "";
  7963. if (_EnterExitCosts.Visa > 0)
  7964. {
  7965. //insidePayTotal += _EnterExitCosts.Visa;
  7966. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7967. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7968. //{
  7969. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7970. //}
  7971. }
  7972. string row1_2 = "";
  7973. if (_EnterExitCosts.YiMiao > 0)
  7974. {
  7975. //insidePayTotal += _EnterExitCosts.YiMiao;
  7976. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7977. }
  7978. if (_EnterExitCosts.HeSuan > 0)
  7979. {
  7980. //insidePayTotal += _EnterExitCosts.HeSuan;
  7981. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7982. }
  7983. if (_EnterExitCosts.Service > 0)
  7984. {
  7985. //insidePayTotal += _EnterExitCosts.Service;
  7986. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7987. }
  7988. string row1_3 = "";
  7989. if (_EnterExitCosts.Safe > 0)
  7990. {
  7991. //insidePayTotal += _EnterExitCosts.Safe;
  7992. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7993. }
  7994. if (_EnterExitCosts.Ticket > 0)
  7995. {
  7996. //insidePayTotal += _EnterExitCosts.Ticket;
  7997. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7998. }
  7999. string row1 = "";
  8000. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8001. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8002. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8003. row1 += $"备注:{_EnterExitCosts.Remark}";
  8004. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8005. dic.Add("Row1Str", row1);
  8006. }
  8007. string airTotalStr = string.Empty,
  8008. airPriceStr = string.Empty;
  8009. //经济舱
  8010. if (_EnterExitCosts.SumJJC == 1)
  8011. {
  8012. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8013. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8014. }
  8015. //公务舱
  8016. if (_EnterExitCosts.SumGWC == 1)
  8017. {
  8018. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8019. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8020. }
  8021. //头等舱
  8022. if (_EnterExitCosts.SumTDC == 1)
  8023. {
  8024. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8025. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8026. }
  8027. //汇率描述
  8028. string rateStr = "";
  8029. if (peiceItemCurrencyInfos.Any())
  8030. {
  8031. rateStr = "\r\n汇率描述:";
  8032. foreach (var item in peiceItemCurrencyInfos)
  8033. {
  8034. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8035. }
  8036. }
  8037. string twoItemRemark = "备注:";
  8038. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8039. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8040. dic.Add("AirTotalStr", airTotalStr);
  8041. dic.Add("AirPriceStr", airPriceStr);
  8042. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8043. dic.Add("TwoItemRemark", twoItemRemark);
  8044. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8045. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8046. int table1Row = 0,
  8047. table2Row = 0,
  8048. table3Row = 0,
  8049. table4Row = 0,
  8050. table5Row = 0;
  8051. //住宿费
  8052. if (_EnterExitCosts.ChoiceThree == 1)
  8053. {
  8054. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8055. table1Row = dac1.Count;
  8056. #region 填充word表格内容
  8057. for (int i = 0; i < dac1.Count; i++)
  8058. {
  8059. var dac = dac1[i];
  8060. if (dac == null) continue;
  8061. builder.MoveToCell(0, i, 0, 0);
  8062. builder.Write("第" + dac.Days.ToString() + "晚:");
  8063. builder.MoveToCell(0, i, 1, 0);
  8064. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8065. //builder.Write(dac.Place == null ? "" : dac.Place);
  8066. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8067. builder.MoveToCell(0, i, 2, 0);
  8068. builder.Write("费用标准:");
  8069. string curr = "";
  8070. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8071. if (currData != null)
  8072. {
  8073. curr = currData.Name;
  8074. }
  8075. builder.MoveToCell(0, i, 3, 0);
  8076. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8077. builder.MoveToCell(0, i, 4, 0);
  8078. builder.Write("费用小计:");
  8079. builder.MoveToCell(0, i, 5, 0);
  8080. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8081. }
  8082. #endregion
  8083. }
  8084. else dic.Add("SubZS", "0.00");
  8085. //删除多余行
  8086. while (table1.Rows.Count > table1Row)
  8087. {
  8088. table1.Rows.RemoveAt(table1Row);
  8089. }
  8090. //伙食费
  8091. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8092. if (_EnterExitCosts.ChoiceFour == 1)
  8093. {
  8094. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8095. table2Row = dac2.Count;
  8096. #region 填充word表格内容
  8097. for (int i = 0; i < dac2.Count; i++)
  8098. {
  8099. var dac = dac2[i];
  8100. if (dac == null) continue;
  8101. builder.MoveToCell(1, i, 0, 0);
  8102. builder.Write("第" + dac.Days.ToString() + "天:");
  8103. builder.MoveToCell(1, i, 1, 0);
  8104. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8105. builder.MoveToCell(1, i, 2, 0);
  8106. builder.Write("费用标准:");
  8107. string curr = "";
  8108. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8109. if (currData != null)
  8110. {
  8111. curr = currData.Name;
  8112. }
  8113. builder.MoveToCell(1, i, 3, 0);
  8114. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8115. builder.MoveToCell(1, i, 4, 0);
  8116. builder.Write("费用小计:");
  8117. builder.MoveToCell(1, i, 5, 0);
  8118. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8119. }
  8120. #endregion
  8121. }
  8122. else dic.Add("SubHS", "0.00");
  8123. //删除多余行
  8124. while (table2.Rows.Count > table2Row)
  8125. {
  8126. table2.Rows.RemoveAt(table2Row);
  8127. }
  8128. //公杂费
  8129. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8130. if (_EnterExitCosts.ChoiceFive == 1)
  8131. {
  8132. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8133. table3Row = dac3.Count;
  8134. #region 填充word表格内容
  8135. for (int i = 0; i < dac3.Count; i++)
  8136. {
  8137. var dac = dac3[i];
  8138. if (dac == null) continue;
  8139. builder.MoveToCell(2, i, 0, 0);
  8140. builder.Write("第" + dac.Days.ToString() + "天:");
  8141. builder.MoveToCell(2, i, 1, 0);
  8142. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8143. builder.MoveToCell(2, i, 2, 0);
  8144. builder.Write("费用标准:");
  8145. string curr = "";
  8146. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8147. if (currData != null)
  8148. {
  8149. curr = currData.Name;
  8150. }
  8151. builder.MoveToCell(2, i, 3, 0);
  8152. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8153. builder.MoveToCell(2, i, 4, 0);
  8154. builder.Write("费用小计:");
  8155. builder.MoveToCell(2, i, 5, 0);
  8156. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8157. }
  8158. //删除多余行
  8159. while (table3.Rows.Count > table3Row)
  8160. {
  8161. table3.Rows.RemoveAt(table3Row);
  8162. }
  8163. #endregion
  8164. }
  8165. else dic.Add("SubGZF", "0.00");
  8166. //删除多余行
  8167. while (table3.Rows.Count > table3Row)
  8168. {
  8169. table3.Rows.RemoveAt(table3Row);
  8170. }
  8171. //培训费
  8172. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8173. if (_EnterExitCosts.ChoiceSix == 1)
  8174. {
  8175. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8176. dic.Add("SubPX", pxStr);
  8177. table4Row = dac4.Count;
  8178. #region 填充word表格内容
  8179. for (int i = 0; i < dac4.Count; i++)
  8180. {
  8181. var dac = dac4[i];
  8182. if (dac == null) continue;
  8183. builder.MoveToCell(3, i, 0, 0);
  8184. builder.Write("第" + dac.Days.ToString() + "天:");
  8185. builder.MoveToCell(3, i, 1, 0);
  8186. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8187. builder.MoveToCell(3, i, 2, 0);
  8188. builder.Write("费用标准:");
  8189. string curr = "";
  8190. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8191. if (currData != null)
  8192. {
  8193. curr = currData.Name;
  8194. }
  8195. builder.MoveToCell(3, i, 3, 0);
  8196. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8197. builder.MoveToCell(3, i, 4, 0);
  8198. builder.Write("费用小计:");
  8199. builder.MoveToCell(3, i, 5, 0);
  8200. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8201. }
  8202. #endregion
  8203. }
  8204. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8205. //删除多余行
  8206. while (table4.Rows.Count > table4Row)
  8207. {
  8208. table4.Rows.RemoveAt(table4Row);
  8209. }
  8210. //其他费用
  8211. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8212. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8213. {
  8214. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8215. dic.Add("titleQi", qtStr);
  8216. table5Row = dac5.Count;
  8217. #region 填充word表格内容
  8218. for (int i = 0; i < dac5.Count; i++)
  8219. {
  8220. var dac = dac5[i];
  8221. if (dac == null) continue;
  8222. builder.MoveToCell(4, i, 0, 0);
  8223. builder.Write("第" + dac.Index.ToString() + "项:");
  8224. builder.MoveToCell(4, i, 1, 0);
  8225. builder.Write(dac.itemName);
  8226. builder.MoveToCell(4, i, 2, 0);
  8227. builder.Write("费用标准:");
  8228. builder.MoveToCell(4, i, 3, 0);
  8229. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8230. builder.MoveToCell(4, i, 4, 0);
  8231. builder.Write("费用小计:");
  8232. builder.MoveToCell(4, i, 5, 0);
  8233. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8234. builder.MoveToCell(4, i, 6, 0);
  8235. builder.Write("备注:");
  8236. builder.MoveToCell(4, i, 7, 0);
  8237. builder.Write(dac.Remark);
  8238. }
  8239. #endregion
  8240. }
  8241. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8242. //删除多余行
  8243. while (table5.Rows.Count > table5Row)
  8244. {
  8245. table5.Rows.RemoveAt(table5Row);
  8246. }
  8247. //加上其他费用
  8248. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8249. decimal subJJC = 0.00M,
  8250. subGWC = 0.00M,
  8251. subTDC = 0.00M;
  8252. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8253. string totalLabel = string.Format("全部费用总计:");
  8254. //经济舱
  8255. if (_EnterExitCosts.SumJJC == 1)
  8256. {
  8257. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8258. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8259. }
  8260. //公务舱
  8261. if (_EnterExitCosts.SumGWC == 1)
  8262. {
  8263. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8264. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8265. }
  8266. //头等舱
  8267. if (_EnterExitCosts.SumTDC == 1)
  8268. {
  8269. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8270. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8271. }
  8272. //TotalLabel
  8273. dic.Add("TotalLabel", totalLabel);
  8274. #region 填充word模板书签内容
  8275. foreach (var key in dic.Keys)
  8276. {
  8277. Bookmark bookmark = doc.Range.Bookmarks[key];
  8278. if (bookmark != null)
  8279. {
  8280. builder.MoveToBookmark(key);
  8281. builder.Write(dic[key]);
  8282. }
  8283. }
  8284. #endregion
  8285. //文件名
  8286. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8287. strFileName = CommonFun.ValidFileName(strFileName);
  8288. AsposeHelper.removewatermark_v2180();
  8289. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8290. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8291. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8292. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8293. }
  8294. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8295. {
  8296. //获取模板
  8297. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8298. //载入模板
  8299. Document doc = new Document(tempPath);
  8300. DocumentBuilder builder = new DocumentBuilder(doc);
  8301. Dictionary<string, string> dic = new Dictionary<string, string>();
  8302. string returnCodeLabel = string.Empty;
  8303. if (nationalTravelFeeData.Any())
  8304. {
  8305. List<string> list = new List<string>();
  8306. foreach (var item in nationalTravelFeeData)
  8307. {
  8308. list.Add($"{item.Country}({item.City})");
  8309. }
  8310. list = list.Distinct().ToList();
  8311. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8312. }
  8313. var countryLabel = string.Empty;
  8314. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8315. if (countryData.Any())
  8316. {
  8317. countryLabel = string.Join("、", countryData);
  8318. }
  8319. dic.Add("ReturnCodeAir", returnCodeLabel);
  8320. dic.Add("VisitStartDate", "-");
  8321. dic.Add("VisitEndDate", "-");
  8322. dic.Add("Day", "-");
  8323. dic.Add("VisitCountry", countryLabel);
  8324. dic.Add("ClientUnit", "-");
  8325. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8326. //dic.Add("Names", Names);
  8327. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8328. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8329. decimal dac1totalPrice = 0.00M;
  8330. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8331. foreach (var dac in dac1)
  8332. {
  8333. if (dac.SubTotal == 0.00M)
  8334. {
  8335. continue;
  8336. }
  8337. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8338. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8339. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8340. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8341. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8342. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8343. builder.Write(currency);//币种
  8344. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8345. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8346. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8347. builder.Write("");//人数
  8348. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8349. builder.Write("");//天数
  8350. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8351. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8352. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8353. decimal rate = 0.00M;
  8354. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8355. builder.Write(rate.ToString("#0.0000"));//汇率
  8356. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8357. decimal rbmPrice = dac.SubTotal;
  8358. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8359. accommodationStartIndex++;
  8360. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8361. }
  8362. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8363. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8364. {
  8365. table1.Rows.RemoveAt(i - 1);
  8366. foodandotherStartIndex--;
  8367. }
  8368. if (dac2.Count == dac3.Count)//国家 币种 金额
  8369. {
  8370. for (int i = 0; i < dac2.Count; i++)
  8371. {
  8372. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8373. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8374. }
  8375. }
  8376. decimal dac2totalPrice = 0.00M;
  8377. foreach (var dac in dac2)
  8378. {
  8379. if (dac.SubTotal == 0)
  8380. {
  8381. continue;
  8382. }
  8383. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8384. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8385. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8386. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8387. builder.Write(currency);//币种
  8388. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8389. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8390. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8391. builder.Write("");//人数
  8392. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8393. builder.Write("");//天数
  8394. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8395. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8396. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8397. decimal rate = 0.00M;
  8398. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8399. builder.Write(rate.ToString("#0.0000"));//汇率
  8400. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8401. decimal rbmPrice = dac.SubTotal;
  8402. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8403. foodandotherStartIndex++;
  8404. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8405. }
  8406. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8407. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8408. {
  8409. table1.Rows.RemoveAt(i - 1);
  8410. }
  8411. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8412. string otherFeeStr = "";
  8413. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8414. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8415. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8416. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8417. foreach (var otherInfo in dac5)
  8418. {
  8419. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8420. }
  8421. #endregion
  8422. if (otherFeeStr.Length > 0)
  8423. {
  8424. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8425. otherFeeStr = $"({otherFeeStr})";
  8426. dic.Add("OtherFeeStr", otherFeeStr);
  8427. }
  8428. //总计
  8429. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8430. //国际旅费
  8431. string outsideAir = string.Empty;
  8432. string allPriceAir = string.Empty;
  8433. if (_EnterExitCosts.SumJJC == 1)
  8434. {
  8435. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8436. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8437. }
  8438. if (_EnterExitCosts.SumGWC == 1)
  8439. {
  8440. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8441. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8442. }
  8443. if (_EnterExitCosts.SumTDC == 1)
  8444. {
  8445. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8446. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8447. }
  8448. dic.Add("InTravelPrice", $"({outsideAir})");
  8449. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8450. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8451. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8452. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8453. foreach (var key in dic.Keys)
  8454. {
  8455. builder.MoveToBookmark(key);
  8456. builder.Write(dic[key]);
  8457. }
  8458. //模板文件名
  8459. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8460. strFileName = CommonFun.ValidFileName(strFileName);
  8461. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8462. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8463. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8464. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8465. }
  8466. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8467. {
  8468. //获取模板
  8469. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8470. //载入模板
  8471. WorkbookDesigner designer = new WorkbookDesigner();
  8472. designer.Workbook = new Workbook(tempPath);
  8473. Dictionary<string, string> dic = new Dictionary<string, string>();
  8474. string returnCodeLabel = string.Empty;
  8475. if (nationalTravelFeeData.Any())
  8476. {
  8477. List<string> list = new List<string>();
  8478. foreach (var item in nationalTravelFeeData)
  8479. {
  8480. list.Add($"{item.Country}({item.City})");
  8481. }
  8482. list = list.Distinct().ToList();
  8483. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8484. }
  8485. var countryLabel = string.Empty;
  8486. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8487. if (countryData.Any())
  8488. {
  8489. countryLabel = string.Join("、", countryData);
  8490. }
  8491. dic.Add("ReturnCodeAir", returnCodeLabel);
  8492. dic.Add("VisitStartDate", "-");
  8493. dic.Add("VisitEndDate", "-");
  8494. dic.Add("Day", "0");
  8495. dic.Add("VisitCountry", countryLabel);
  8496. dic.Add("ClientUnit", "-");
  8497. designer.SetDataSource("ClientUnit", "-");
  8498. designer.SetDataSource("VisitCountry", countryLabel);
  8499. designer.SetDataSource("Group", "-");
  8500. designer.SetDataSource("ClientUnitTitle", "-");
  8501. designer.SetDataSource("Name", "-");
  8502. designer.SetDataSource("VisitStartDate", "-");
  8503. designer.SetDataSource("Day", "0");
  8504. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8505. designer.SetDataSource("ReturnCodeAir", "-");
  8506. int startIndex = 10;
  8507. const int startIndexcopy = 10;
  8508. if (dac2.Count == dac3.Count)//国家 币种 金额
  8509. {
  8510. for (int i = 0; i < dac2.Count; i++)
  8511. {
  8512. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8513. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8514. }
  8515. }
  8516. DataTable dtdac1 = new DataTable();
  8517. List<string> place = new List<string>();
  8518. dtdac1.Columns.AddRange(new DataColumn[] {
  8519. new DataColumn(){ ColumnName = "city"},
  8520. new DataColumn(){ ColumnName = "curr"},
  8521. new DataColumn(){ ColumnName = "criterion"},
  8522. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8523. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8524. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8525. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8526. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8527. });
  8528. DataTable dtdac2 = new DataTable();
  8529. dtdac2.Columns.AddRange(new DataColumn[] {
  8530. new DataColumn(){ ColumnName = "city"},
  8531. new DataColumn(){ ColumnName = "curr"},
  8532. new DataColumn(){ ColumnName = "criterion"},
  8533. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8534. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8535. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8536. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8537. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8538. });
  8539. dtdac1.TableName = "tb1";
  8540. dtdac2.TableName = "tb2";
  8541. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8542. foreach (var item in dac1)
  8543. {
  8544. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8545. if (place.Contains(item.Place))
  8546. {
  8547. continue;
  8548. }
  8549. DataRow row = dtdac1.NewRow();
  8550. row["city"] = item.Place;
  8551. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8552. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8553. row["curr"] = currency;
  8554. row["rate"] = rate.ToString("#0.0000");
  8555. row["criterion"] = item.Cost.ToString("#0.00");
  8556. row["number"] = 1;
  8557. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8558. //row["costRMB"] = rbmPrice;
  8559. dtdac1.Rows.Add(row);
  8560. place.Add(item.Place);
  8561. }
  8562. place = new List<string>();
  8563. foreach (var item in dac2)
  8564. {
  8565. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8566. if (place.Contains(item.Place))
  8567. {
  8568. continue;
  8569. }
  8570. DataRow row = dtdac2.NewRow();
  8571. row["city"] = item.Place;
  8572. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8573. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8574. row["curr"] = currency;
  8575. row["rate"] = rate.ToString("#0.0000");
  8576. row["criterion"] = item.Cost.ToString("#0.00");
  8577. row["number"] = 1;
  8578. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8579. //row["cost"] = item.SubTotal;
  8580. //row["costRMB"] = rbmPrice;
  8581. dtdac2.Rows.Add(row);
  8582. place.Add(item.Place);
  8583. //dac2totalPrice += rbmPrice;
  8584. }
  8585. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8586. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8587. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8588. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8589. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8590. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8591. string cell4Str1 = string.Empty;
  8592. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8593. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8594. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8595. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8596. string cellStr = $" 5.其他费用(";
  8597. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8598. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8599. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8600. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8601. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8602. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8603. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8604. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8605. foreach (var otherInfo in dac5)
  8606. {
  8607. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8608. }
  8609. #endregion
  8610. if (cellStr.Length > 8)
  8611. {
  8612. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8613. }
  8614. cellStr += ")";
  8615. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8616. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8617. decimal pxFee = dac4.Sum(it => it.Cost);
  8618. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8619. string celllastStr1 = "";
  8620. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8621. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8622. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8623. celllastStr1 += $",国际旅费 元";
  8624. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8625. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8626. designer.SetDataSource("cell4Str", cell4Str);
  8627. designer.SetDataSource("cellStr", cellStr);
  8628. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8629. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8630. designer.SetDataSource("celllastStr", celllastStr);
  8631. Workbook wb = designer.Workbook;
  8632. var sheet = wb.Worksheets[0];
  8633. //绑定datatable数据集
  8634. designer.SetDataSource(dtdac1);
  8635. designer.SetDataSource(dtdac2);
  8636. designer.Process();
  8637. var rowStart = dtdac1.Rows.Count;
  8638. while (rowStart > 0)
  8639. {
  8640. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8641. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8642. startIndex++;
  8643. rowStart--;
  8644. }
  8645. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8646. startIndex += 1; //总计行
  8647. rowStart = dtdac2.Rows.Count;
  8648. while (rowStart > 0)
  8649. {
  8650. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8651. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8652. startIndex++;
  8653. rowStart--;
  8654. }
  8655. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8656. wb.CalculateFormula(true);
  8657. //模板文件名
  8658. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8659. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8660. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8661. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8662. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8663. }
  8664. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8665. {
  8666. //获取模板
  8667. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8668. //载入模板
  8669. Document doc = new Document(tempPath);
  8670. DocumentBuilder builder = new DocumentBuilder(doc);
  8671. Dictionary<string, string> dic = new Dictionary<string, string>();
  8672. dic.Add("GroupName", "-");
  8673. dic.Add("ClientUnit", "-");
  8674. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8675. //string missionLeaderJob = "";//负责人job
  8676. //int groupNumber = 0; //团人数
  8677. dic.Add("MissionLeader", "-"); //团负责人
  8678. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8679. dic.Add("GroupNumber", "0"); //团人数
  8680. dic.Add("Day", "0");
  8681. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8682. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8683. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8684. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8685. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8686. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8687. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8688. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8689. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8690. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8691. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8692. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8693. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8694. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8695. //其他费用
  8696. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8697. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8698. //其他费用合计
  8699. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8700. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8701. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8702. //公务舱合计
  8703. //国际旅费
  8704. //string outsideJJ = "";
  8705. //string allPriceJJ = "";
  8706. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8707. {
  8708. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8709. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8710. }
  8711. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8712. {
  8713. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8714. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8715. }
  8716. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8717. {
  8718. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8719. dic.Add("AirFeeTotal", airFeeTotalStr);
  8720. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8721. dic.Add("FeeTotal", feeTotalStr);
  8722. }
  8723. foreach (var key in dic.Keys)
  8724. {
  8725. builder.MoveToBookmark(key);
  8726. builder.Write(dic[key]);
  8727. }
  8728. //模板文件名
  8729. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8730. strFileName = CommonFun.ValidFileName(strFileName);
  8731. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8732. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8733. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8734. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8735. }
  8736. }
  8737. else if (dto.ExportType == 2) //表格
  8738. {
  8739. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8740. }
  8741. else if (dto.ExportType == 3)
  8742. {
  8743. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8744. }
  8745. return Ok(JsonView(400, "只可导出明细表!", ""));
  8746. }
  8747. catch (Exception ex)
  8748. {
  8749. return Ok(JsonView(400, ex.Message, ""));
  8750. }
  8751. }
  8752. /// <summary>
  8753. /// 获取三公费用标准city
  8754. /// </summary>
  8755. /// <param name="placeData"></param>
  8756. /// <param name="nationalTravelFeeId"></param>
  8757. /// <returns></returns>
  8758. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8759. {
  8760. string _city = string.Empty;
  8761. if (!placeData.Any()) return _city;
  8762. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8763. if (data == null) return _city;
  8764. string country = data.Country;
  8765. string city = data.City;
  8766. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8767. else _city = city;
  8768. return _city;
  8769. }
  8770. /// <summary>
  8771. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8772. /// </summary>
  8773. /// <returns></returns>
  8774. [HttpPost]
  8775. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8777. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8778. {
  8779. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8780. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8781. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8782. if (_view.Code == 0)
  8783. {
  8784. return Ok(JsonView(true, "操作成功"));
  8785. }
  8786. return Ok(JsonView(false, "操作失败"));
  8787. }
  8788. /// <summary>
  8789. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8790. /// </summary>
  8791. /// <returns></returns>
  8792. [HttpPost]
  8793. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8795. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8796. {
  8797. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8798. if (data.Code != 0)
  8799. {
  8800. return Ok(JsonView(false, data.Msg));
  8801. }
  8802. return Ok(JsonView(true, "操作成功!", data.Data));
  8803. }
  8804. /// <summary>
  8805. /// 三公其他费用草稿 删除
  8806. /// </summary>
  8807. /// <param name="dto"></param>
  8808. /// <returns></returns>
  8809. [HttpPost]
  8810. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8811. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8812. {
  8813. var jw = JsonView(false, "删除失败!");
  8814. var data = new Grp_DayOtherPriceDraft()
  8815. {
  8816. Id = dto.Id,
  8817. IsDel = 1,
  8818. DeleteUserId = dto.DeleteUserId,
  8819. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8820. };
  8821. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8822. if (del > 0)
  8823. {
  8824. jw.Code = 200;
  8825. jw.Msg = "删除成功!";
  8826. }
  8827. return Ok(jw);
  8828. }
  8829. /// <summary>
  8830. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8831. /// </summary>
  8832. /// <returns></returns>
  8833. [HttpPost]
  8834. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8835. {
  8836. var jw = JsonView(false);
  8837. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8838. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8839. jw.Code = StatusCodes.Status200OK;
  8840. jw.Msg = "操作成功!";
  8841. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8842. return Ok(jw);
  8843. }
  8844. /// <summary>
  8845. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8846. /// </summary>
  8847. /// <param name="dto"></param>
  8848. /// <returns></returns>
  8849. [HttpPost]
  8850. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8851. {
  8852. int userId = dto.UserId,
  8853. portId = dto.PortType,
  8854. groupId = dto.GroupId,
  8855. draftId = dto.DraftId;
  8856. _portTypeData.Add(1);
  8857. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8858. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8859. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8860. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8861. _sqlSugar.BeginTran();
  8862. try
  8863. {
  8864. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8865. if (draftDatas == null)
  8866. {
  8867. _sqlSugar.RollbackTran();
  8868. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8869. }
  8870. //验证可覆盖已有数据 两边创建人需为同一人;
  8871. int draftCreateUserId = draftDatas.CreateUserId,
  8872. formalCreateUserId = 0;
  8873. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8874. if (formalData != null)
  8875. {
  8876. formalCreateUserId = formalData.CreateUserId;
  8877. if (draftCreateUserId != formalCreateUserId)
  8878. {
  8879. _sqlSugar.RollbackTran();
  8880. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8881. }
  8882. }
  8883. //默认添加查看、编辑权限(创建人、自己)
  8884. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8885. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8886. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8887. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8888. newExterData.DiId = groupId;
  8889. newExterData.CreateUserId = userId;
  8890. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8891. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8892. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8893. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8894. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8895. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8896. //数据如果存在执行删除
  8897. if (enterExitCostInfo != null)
  8898. {
  8899. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8900. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8901. .Where(x => x.Id == enterExitCostInfo.Id)
  8902. .ExecuteCommand();
  8903. _sqlSugar.Updateable<Grp_DayAndCost>()
  8904. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8905. .Where(x => x.DiId == groupId)
  8906. .ExecuteCommand();
  8907. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8908. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8909. .Where(x => x.Diid == groupId)
  8910. .ExecuteCommand();
  8911. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8912. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8913. .Where(x => x.GroupId == groupId)
  8914. .ExecuteCommand();
  8915. }
  8916. //执行insert
  8917. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8918. if (insertId < 1)
  8919. {
  8920. _sqlSugar.RollbackTran();
  8921. return Ok(JsonView(false, "草稿数据导入失败!"));
  8922. }
  8923. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8924. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8925. #region 默认添加权限
  8926. #endregion
  8927. _sqlSugar.CommitTran();
  8928. //执行操作之后
  8929. //生成默认文件pdf并且通知人员
  8930. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8931. {
  8932. DiId = groupId,
  8933. ExportType = 1,
  8934. SubTypeId = 1005
  8935. }, "pdf");
  8936. //发送通知
  8937. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8938. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8939. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8940. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8941. //汇率信息记录
  8942. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8943. return Ok(JsonView(true));
  8944. }
  8945. catch (Exception ex)
  8946. {
  8947. _sqlSugar.RollbackTran();
  8948. return Ok(JsonView(false, ex.Message));
  8949. }
  8950. }
  8951. #endregion
  8952. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8953. /// <summary>
  8954. /// 获取币种基础数据(含逻辑处理)
  8955. /// </summary>
  8956. /// <returns></returns>
  8957. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8958. {
  8959. return await GeneralMethod.EnterExitCostInitRate();
  8960. }
  8961. /// <summary>
  8962. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8963. /// </summary>
  8964. /// <returns></returns>
  8965. [HttpPost]
  8966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8967. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8968. {
  8969. //验证城市归属并给默认值
  8970. int provinceId = dto.ProvinceId;
  8971. if (provinceId < 1) provinceId = 122;
  8972. var dataSource = await _sqlSugar
  8973. .Queryable<Sys_SetData>()
  8974. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8975. .ToListAsync();
  8976. var fileTypes = new List<EecSetDataInfoView>();
  8977. //三公费用-Word明细类型
  8978. var wordTypeData = dataSource
  8979. .Where(it => it.STid == 72)
  8980. .Select(x => new EecSetDataInfoView
  8981. {
  8982. ParentId = 1,
  8983. Id = x.Id,
  8984. Name = x.Name
  8985. })
  8986. .ToArray();
  8987. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8988. var excelTypeData = dataSource
  8989. .Where(it => it.STid == 73)
  8990. .Select(x => new EecSetDataInfoView
  8991. {
  8992. ParentId = 2,
  8993. Id = x.Id,
  8994. Name = x.Name
  8995. })
  8996. .ToArray();
  8997. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8998. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8999. fileTypes.Add(groupNameList);
  9000. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9001. //默认币种显示
  9002. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9003. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9004. return Ok(JsonView(true, "查询成功!", new
  9005. {
  9006. FileTypeData = fileTypes,
  9007. CurrencyInit = _currencyInfos,
  9008. viewPermissionData = viewPermissionData
  9009. }));
  9010. }
  9011. /// <summary>
  9012. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9013. /// </summary>
  9014. /// <returns></returns>
  9015. [HttpPost]
  9016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9017. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9018. {
  9019. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9020. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9021. RefAsync<int> total = 0;
  9022. int diId = 0;
  9023. var status = int.TryParse(dto.GroupName, out diId);
  9024. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9025. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9026. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9027. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9028. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9029. .OrderByDescending(x => x.VisitStartDate)
  9030. .Select(x => new EnterExitCostMobileGroupView()
  9031. {
  9032. Id = x.Id,
  9033. GroupName = x.TeamName,
  9034. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9035. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9036. ProvinceId = x.CityId
  9037. })
  9038. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9039. //处理省份Id
  9040. if (data.Any())
  9041. {
  9042. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9043. if (provCityDatas.Any())
  9044. {
  9045. foreach (var item in data)
  9046. {
  9047. var provinceId = item.ProvinceId;
  9048. var isDefualtVal = true;
  9049. if (provinceId > 0)
  9050. {
  9051. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9052. if (parentId != null)
  9053. {
  9054. isDefualtVal = false;
  9055. item.ProvinceId = (int)parentId;
  9056. }
  9057. }
  9058. if (isDefualtVal)
  9059. {
  9060. item.ProvinceId = 122; //默认四川
  9061. }
  9062. }
  9063. }
  9064. }
  9065. //处理是否显示
  9066. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9067. {
  9068. foreach (var item in data)
  9069. {
  9070. item.IsView = true;
  9071. }
  9072. }
  9073. return Ok(JsonView(true, "查询成功!", data, total));
  9074. }
  9075. /// <summary>
  9076. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9077. /// </summary>
  9078. /// <returns></returns>
  9079. [HttpPost]
  9080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9081. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9082. {
  9083. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9084. RefAsync<int> total = 0;
  9085. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9086. .Where(x => x.IsDel == 0 && x.STid == 66)
  9087. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9088. .Select(x => new
  9089. {
  9090. id = x.Id,
  9091. name = x.Name,
  9092. remark = x.Remark,
  9093. })
  9094. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9095. return Ok(JsonView(true, "查询成功!", data, total));
  9096. }
  9097. /// <summary>
  9098. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9099. /// </summary>
  9100. /// <returns></returns>
  9101. [HttpPost]
  9102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9103. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9104. {
  9105. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9106. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9107. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9108. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9109. var groupOtherRateData = groupRateData.TeamRates;
  9110. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9111. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9112. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9113. groupOtherRateData = groupOtherRateData
  9114. .Select(x => new TeamRateDescAddCurrencyIdView
  9115. {
  9116. CurrencyId = x.CurrencyId,
  9117. CurrencyName = x.CurrencyName,
  9118. CurrencyCode = x.CurrencyCode,
  9119. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9120. }).ToList();
  9121. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9122. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9123. }
  9124. /// <summary>
  9125. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9126. /// </summary>
  9127. /// <returns></returns>
  9128. [HttpPost]
  9129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9130. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9131. {
  9132. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9133. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9134. var tipsData = new List<int>() { 1, 2, 3 };
  9135. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9136. if (dto.TipsType == 1)
  9137. {
  9138. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9139. }
  9140. else if (dto.TipsType == 2)
  9141. {
  9142. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9143. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9144. }
  9145. else if (dto.TipsType == 3)
  9146. {
  9147. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  9148. return Ok(JsonView(true, "查询成功!", airData));
  9149. }
  9150. return Ok(JsonView(false));
  9151. }
  9152. /// <summary>
  9153. /// 团组模块 - 出入境国家费用标准-移动端 List
  9154. /// </summary>
  9155. /// <returns></returns>
  9156. [HttpPost]
  9157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9158. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9159. {
  9160. Stopwatch sw = new Stopwatch();
  9161. sw.Start();
  9162. int provinceId = dto.ProvinceId;
  9163. if (provinceId < 1) provinceId = 122; // 默认四川
  9164. RefAsync<int> total = 0;
  9165. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9166. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9167. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9168. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9169. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9170. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9171. .Select((ntf, sd, u, sd1) => new
  9172. {
  9173. Id = ntf.Id,
  9174. Area = $"{ntf.Country}-{ntf.City}",
  9175. Currency = ntf.Currency,
  9176. CurrencyCode = sd.Name,
  9177. CurrencyName = sd.Remark,
  9178. RoomCost = ntf.RoomCost,
  9179. FoodCost = ntf.FoodCost,
  9180. PublicCost = ntf.PublicCost,
  9181. TrainCost = ntf.TrainCost,
  9182. LastUpdateUserId = ntf.LastUpdateUserId,
  9183. LastUpdateUserName = u.CnName,
  9184. LastUpdateTime = ntf.LastUpdateTime
  9185. })
  9186. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9187. sw.Stop();
  9188. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9189. }
  9190. /// <summary>
  9191. /// 团组模块 - 出入境费用-移动端 - Info
  9192. /// </summary>
  9193. /// <returns></returns>
  9194. [HttpPost]
  9195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9196. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9197. {
  9198. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9199. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9200. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9201. return Ok(data);
  9202. }
  9203. /// <summary>
  9204. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9205. /// </summary>
  9206. /// <returns></returns>
  9207. [HttpPost]
  9208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9209. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9210. {
  9211. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9212. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9213. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9214. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9215. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9216. mobileInfo.DiId = dto.DiId;
  9217. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9218. if (eecInfo == null) return Ok(mobileInfo);
  9219. //验证查看权限
  9220. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9221. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9222. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9223. mobileInfo.IsAssignPerm = isSet;
  9224. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9225. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9226. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9227. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9228. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9229. {
  9230. SubId = dac.Id,
  9231. DiId = dac.DiId,
  9232. Type = dac.Type,
  9233. Days = dac.Days,
  9234. NationalTravelFeeId = dac.NationalTravelFeeId,
  9235. Arae = $"{ntf.Country}-{ntf.City}",
  9236. Cost = dac.Cost,
  9237. Currency = dac.Currency,
  9238. CurrencyName = sd.Name,
  9239. SubTotal = dac.SubTotal,
  9240. })
  9241. .ToList();
  9242. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9243. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9244. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9245. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9246. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9247. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9248. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9249. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9250. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9251. //其他款项
  9252. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9253. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9254. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9255. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9256. .OrderBy((dop, sd1, sd2) => dop.Index)
  9257. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9258. {
  9259. SubId = dop.Id,
  9260. DiId = dop.Diid,
  9261. Index = dop.Index,
  9262. SetDataId = dop.SetDataId,
  9263. SetDataName = sd1.Name,
  9264. Cost = dop.Cost,
  9265. Currency = dop.Currency,
  9266. CurrencyName = sd2.Remark,
  9267. SubTotal = dop.SubTotal,
  9268. Remark = dop.Remark,
  9269. })
  9270. .ToArray();
  9271. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9272. return Ok(mobileInfo);
  9273. }
  9274. /// <summary>
  9275. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9276. /// </summary>
  9277. /// <returns></returns>
  9278. [HttpPost]
  9279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9280. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9281. {
  9282. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9283. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9284. //验证查看权限
  9285. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9286. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9287. var userIds = await _sqlSugar
  9288. .Queryable<Grp_EnterExitCostPermission>()
  9289. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9290. .Select(x => x.UserId)
  9291. .ToArrayAsync();
  9292. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9293. var perUsersView = new List<dynamic>();
  9294. foreach (var item in perUsers)
  9295. {
  9296. bool isView1 = false;
  9297. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9298. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9299. }
  9300. return Ok(JsonView(perUsersView));
  9301. }
  9302. /// <summary>
  9303. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9304. /// </summary>
  9305. /// <returns></returns>
  9306. [HttpPost]
  9307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9308. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9309. {
  9310. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9311. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9312. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9313. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9314. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9315. //验证查看权限
  9316. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9317. //if (!isView) return Ok(JsonView(false, msg));
  9318. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9319. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9320. var subType = dto.SubType;
  9321. if (subType == 1) //1:境内费用
  9322. {
  9323. var oneData = new ChoiceOneMobileSubInfoView()
  9324. {
  9325. Id = eecInfo.Id,
  9326. ChoiceOne = eecInfo.ChoiceOne,
  9327. ChoiceOneTotalCost = eecInfo.InsidePay,
  9328. Visa = eecInfo.Visa,
  9329. VisaRemark = eecInfo.VisaRemark,
  9330. YiMiao = eecInfo.YiMiao,
  9331. HeSuan = eecInfo.HeSuan,
  9332. Service = eecInfo.Service,
  9333. Ticket = eecInfo.Ticket,
  9334. Safe = eecInfo.Safe,
  9335. FirstItemRemark = eecInfo.FirstItemRemark
  9336. };
  9337. return Ok(JsonView(oneData));
  9338. }
  9339. else if (subType == 2) //2:国际旅费
  9340. {
  9341. var twoData = new ChoiceTwoMobileSubInfoView()
  9342. {
  9343. Id = eecInfo.Id,
  9344. ChoiceTwoJJ = eecInfo.SumJJC,
  9345. OutsideJJPay = eecInfo.OutsideJJPay,
  9346. ChoiceTwoGW = eecInfo.SumGWC,
  9347. OutsideGWPay = eecInfo.OutsideGWPay,
  9348. ChoiceTwoTD = eecInfo.SumTDC,
  9349. OutsideTDPay = eecInfo.OutsideTDPay,
  9350. AirJJ = eecInfo.AirJJ,
  9351. AirGW = eecInfo.AirGW,
  9352. AirTD = eecInfo.AirTD,
  9353. CityTranffic = eecInfo.CityTranffic,
  9354. TwoItemRemark = eecInfo.TwoItemRemark
  9355. };
  9356. return Ok(JsonView(twoData));
  9357. }
  9358. else if (subType == 3) //3:住宿费
  9359. {
  9360. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9361. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9362. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9363. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9364. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9365. {
  9366. SubId = dac.Id,
  9367. DiId = dac.DiId,
  9368. Type = dac.Type,
  9369. Days = dac.Days,
  9370. NationalTravelFeeId = dac.NationalTravelFeeId,
  9371. Arae = $"{ntf.Country}-{ntf.City}",
  9372. Cost = dac.Cost,
  9373. Currency = dac.Currency,
  9374. CurrencyName = sd.Name,
  9375. SubTotal = dac.SubTotal,
  9376. })
  9377. .ToArray();
  9378. var data = new ChoiceMobileSubInfo3To6View()
  9379. {
  9380. ParentId = eecInfo.Id,
  9381. Choice = eecInfo.ChoiceThree,
  9382. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9383. Details = dayAndCostDatas
  9384. };
  9385. return Ok(JsonView(data));
  9386. }
  9387. else if (subType == 4) //4:伙食费
  9388. {
  9389. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9390. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9391. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9392. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9393. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9394. {
  9395. SubId = dac.Id,
  9396. DiId = dac.DiId,
  9397. Type = dac.Type,
  9398. Days = dac.Days,
  9399. NationalTravelFeeId = dac.NationalTravelFeeId,
  9400. Arae = $"{ntf.Country}-{ntf.City}",
  9401. Cost = dac.Cost,
  9402. Currency = dac.Currency,
  9403. CurrencyName = sd.Name,
  9404. SubTotal = dac.SubTotal,
  9405. })
  9406. .ToArray();
  9407. var data = new ChoiceMobileSubInfo3To6View()
  9408. {
  9409. ParentId = eecInfo.Id,
  9410. Choice = eecInfo.ChoiceFour,
  9411. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9412. Details = dayAndCostDatas
  9413. };
  9414. return Ok(JsonView(data));
  9415. }
  9416. else if (subType == 5) //5:公杂费
  9417. {
  9418. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9419. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9420. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9421. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9422. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9423. {
  9424. SubId = dac.Id,
  9425. DiId = dac.DiId,
  9426. Type = dac.Type,
  9427. Days = dac.Days,
  9428. NationalTravelFeeId = dac.NationalTravelFeeId,
  9429. Arae = $"{ntf.Country}-{ntf.City}",
  9430. Cost = dac.Cost,
  9431. Currency = dac.Currency,
  9432. CurrencyName = sd.Name,
  9433. SubTotal = dac.SubTotal,
  9434. })
  9435. .ToArray();
  9436. var data = new ChoiceMobileSubInfo3To6View()
  9437. {
  9438. ParentId = eecInfo.Id,
  9439. Choice = eecInfo.ChoiceFive,
  9440. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9441. Details = dayAndCostDatas
  9442. };
  9443. return Ok(JsonView(data));
  9444. }
  9445. else if (subType == 6) //6:培训费
  9446. {
  9447. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9448. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9449. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9450. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9451. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9452. {
  9453. SubId = dac.Id,
  9454. DiId = dac.DiId,
  9455. Type = dac.Type,
  9456. Days = dac.Days,
  9457. NationalTravelFeeId = dac.NationalTravelFeeId,
  9458. Arae = $"{ntf.Country}-{ntf.City}",
  9459. Cost = dac.Cost,
  9460. Currency = dac.Currency,
  9461. CurrencyName = sd.Name,
  9462. SubTotal = dac.SubTotal,
  9463. })
  9464. .ToArray();
  9465. var data = new ChoiceMobileSubInfo3To6View()
  9466. {
  9467. ParentId = eecInfo.Id,
  9468. Choice = eecInfo.ChoiceSix,
  9469. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9470. Details = dayAndCostDatas
  9471. };
  9472. return Ok(JsonView(data));
  9473. }
  9474. else if (subType == 7) //7:其他
  9475. {
  9476. //其他款项
  9477. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9478. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9479. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9480. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9481. .OrderBy((dop, sd1, sd2) => dop.Index)
  9482. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9483. {
  9484. SubId = dop.Id,
  9485. DiId = dop.Diid,
  9486. Index = dop.Index,
  9487. SetDataId = dop.SetDataId,
  9488. SetDataName = sd1.Name,
  9489. Cost = dop.Cost,
  9490. Currency = dop.Currency,
  9491. CurrencyName = sd2.Name,
  9492. SubTotal = dop.SubTotal,
  9493. Remark = dop.Remark,
  9494. })
  9495. .ToArray();
  9496. var data = new ChoiceSevenMobileSubInfoView()
  9497. {
  9498. ParentId = eecInfo.Id,
  9499. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9500. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9501. Details = otherData
  9502. };
  9503. return Ok(JsonView(data));
  9504. }
  9505. return Ok(JsonView(false));
  9506. }
  9507. #region op
  9508. /// <summary>
  9509. /// 移动端更新费用消息通知
  9510. /// </summary>
  9511. /// <param name="diid"></param>
  9512. /// <param name="id"></param>
  9513. /// <param name="currUserId"></param>
  9514. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9515. {
  9516. try
  9517. {
  9518. ////生成默认文件pdf并且通知人员
  9519. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9520. //{
  9521. // DiId = diid,
  9522. // ExportType = 1,
  9523. // SubTypeId = 1005
  9524. //}, "pdf");
  9525. ////发送通知
  9526. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9527. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9528. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9529. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9530. ////汇率信息记录
  9531. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9532. }
  9533. catch (Exception ex)
  9534. {
  9535. //记录日志
  9536. throw;
  9537. }
  9538. }
  9539. /// <summary>
  9540. /// 验证出入境费用数据是否存在
  9541. /// 不存在添加
  9542. /// </summary>
  9543. /// <param name="diId"></param>
  9544. /// <param name="currUserId"></param>
  9545. /// <returns></returns>
  9546. /// <exception cref="CustomException"></exception>
  9547. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9548. {
  9549. var parentId = 0;
  9550. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9551. if (info != null)
  9552. {
  9553. parentId = info.Id;
  9554. }
  9555. else
  9556. {
  9557. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9558. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9559. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9560. parentId = addId;
  9561. }
  9562. return parentId;
  9563. }
  9564. /// <summary>
  9565. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9566. /// </summary>
  9567. /// <returns></returns>
  9568. [HttpPost]
  9569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9570. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9571. {
  9572. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9573. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9574. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9575. //验证编辑权限
  9576. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9577. //if (!isEdit) return Ok(JsonView(false, msg));
  9578. var permissions = new List<Grp_EnterExitCostPermission>();
  9579. foreach (var userId in dto.UserIds)
  9580. {
  9581. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9582. }
  9583. if (permissions.Any())
  9584. {
  9585. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9586. {
  9587. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9588. }
  9589. _sqlSugar.BeginTran();
  9590. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9591. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9592. if (result < 1)
  9593. {
  9594. _sqlSugar.RollbackTran();
  9595. return Ok(JsonView(false));
  9596. }
  9597. _sqlSugar.CommitTran();
  9598. return Ok(JsonView(true));
  9599. }
  9600. return Ok(JsonView(false));
  9601. }
  9602. /// <summary>
  9603. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9604. /// </summary>
  9605. /// <returns></returns>
  9606. [HttpPost]
  9607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9608. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9609. {
  9610. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9611. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9612. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9613. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9614. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9615. int id = dto.Id;
  9616. if (id <= 0) //add
  9617. {
  9618. //int provinceId = dto.ProvinceId;
  9619. int groupId = dto.DiId;
  9620. //if (provinceId < 1) provinceId = 122;
  9621. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9622. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9623. if (add < 1) return Ok(JsonView(false));
  9624. id = add;
  9625. }
  9626. else //update
  9627. {
  9628. ////验证编辑权限
  9629. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9630. //if (!isEdit) return Ok(JsonView(false, msg));
  9631. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9632. if (upd < 1) return Ok(JsonView(false));
  9633. }
  9634. #region 汇率变更时更改币种相关费用
  9635. var opDayCosts = new List<Grp_DayAndCost>();
  9636. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9637. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9638. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9639. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9640. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9641. .Select((dac, sd) => new
  9642. {
  9643. dac.Id,
  9644. dac.DiId,
  9645. CurrencyCode = sd.Name,
  9646. dac.Cost
  9647. })
  9648. .ToList();
  9649. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9650. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9651. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9652. .Select((dop, sd) => new
  9653. {
  9654. dop.Id,
  9655. dop.Diid,
  9656. CurrencyCode = sd.Name,
  9657. dop.Cost
  9658. })
  9659. .ToList();
  9660. if (dayCosts.Count > 0)
  9661. {
  9662. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9663. foreach (var dc in new_dayCosts)
  9664. {
  9665. var thisCurrency = dc.Key.ToUpper();
  9666. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9667. if (thisRate == 0.00M) continue;
  9668. foreach (var dcSub in dc)
  9669. {
  9670. opDayCosts.Add(new Grp_DayAndCost()
  9671. {
  9672. Id = dcSub.Id,
  9673. DiId = dcSub.DiId,
  9674. Cost = dcSub.Cost,
  9675. SubTotal = dcSub.Cost * thisRate,
  9676. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9677. });
  9678. }
  9679. }
  9680. if (opDayCosts.Count > 0)
  9681. {
  9682. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9683. }
  9684. }
  9685. if (dayOtherCosts.Count > 0)
  9686. {
  9687. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9688. foreach (var dc in new_dayOtherCosts)
  9689. {
  9690. var thisCurrency = dc.Key.ToUpper();
  9691. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9692. if (thisRate == 0.00M) continue;
  9693. foreach (var dcSub in dc)
  9694. {
  9695. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9696. {
  9697. Id = dcSub.Id,
  9698. Diid = dcSub.Diid,
  9699. Cost = dcSub.Cost,
  9700. SubTotal = dcSub.Cost * thisRate,
  9701. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9702. });
  9703. }
  9704. }
  9705. if (opDayOtherCosts.Count > 0)
  9706. {
  9707. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9708. }
  9709. }
  9710. #endregion
  9711. //消息通知
  9712. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9713. //汇率信息记录
  9714. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9715. return Ok(JsonView(new { parentId = id }));
  9716. }
  9717. /// <summary>
  9718. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9719. /// </summary>
  9720. /// <returns></returns>
  9721. [HttpPost]
  9722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9723. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9724. {
  9725. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9726. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9727. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9728. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9729. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9730. int id = dto.Id;
  9731. if (id <= 0) //add
  9732. {
  9733. checkboxInfo.CreateUserId = dto.CurrUserId;
  9734. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9735. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9736. if (add < 1) return Ok(JsonView(false));
  9737. }
  9738. else //update
  9739. {
  9740. ////验证编辑权限
  9741. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9742. //if (!isEdit) return Ok(JsonView(false, msg));
  9743. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9744. .UpdateColumns(x => new
  9745. {
  9746. x.ChoiceOne,
  9747. x.ChoiceTwo,
  9748. x.SumJJC,
  9749. x.SumGWC,
  9750. x.SumTDC,
  9751. x.ChoiceThree,
  9752. x.ChoiceFour,
  9753. x.ChoiceFive,
  9754. x.ChoiceSix,
  9755. x.OtherExpenses_Checked
  9756. })
  9757. .Where(x => x.Id == id)
  9758. .ExecuteCommandAsync();
  9759. if (upd < 1) return Ok(JsonView(false));
  9760. }
  9761. return Ok(JsonView(new { parentId = id }));
  9762. }
  9763. /// <summary>
  9764. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9765. /// </summary>
  9766. /// <returns></returns>
  9767. [HttpPost]
  9768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9769. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9770. {
  9771. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9772. // if (provinceId < 1) provinceId = 122;
  9773. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9774. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9775. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9776. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9777. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9778. var checkboxInfo = new Grp_EnterExitCost()
  9779. {
  9780. Id = id,
  9781. //ProvinceId = provinceId,
  9782. DiId = diId,
  9783. CreateUserId = currUserId
  9784. };
  9785. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9786. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9787. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9788. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9789. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9790. if (id <= 0) //add
  9791. {
  9792. checkboxInfo.CreateUserId = dto.CurrUserId;
  9793. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9794. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9795. if (add < 1) return Ok(JsonView(false));
  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<Grp_EnterExitCost>()
  9803. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9804. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9805. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9806. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9807. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9808. .Where(x => x.Id == id)
  9809. .ExecuteCommandAsync();
  9810. if (upd < 1) return Ok(JsonView(false));
  9811. }
  9812. return Ok(JsonView(new { parentId = id }));
  9813. }
  9814. /// <summary>
  9815. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9816. /// </summary>
  9817. /// <returns></returns>
  9818. [HttpPost]
  9819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9820. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9821. {
  9822. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9823. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9824. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9825. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9826. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9827. info.FirstItemRemark = dto.FirstItemRemark;
  9828. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9829. int id = dto.Id;
  9830. if (id <= 0) //add
  9831. {
  9832. info.CreateUserId = dto.CurrUserId;
  9833. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9834. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9835. if (add < 1) return Ok(JsonView(false));
  9836. id = add;
  9837. }
  9838. else //update
  9839. {
  9840. ////验证编辑权限
  9841. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9842. //if (!isEdit) return Ok(JsonView(false, msg));
  9843. var upd = await _sqlSugar.Updateable(info)
  9844. .UpdateColumns(x => new
  9845. {
  9846. x.ChoiceOne,
  9847. x.InsidePay,
  9848. x.VisaRemark,
  9849. x.Visa,
  9850. x.Service,
  9851. x.Safe,
  9852. x.Ticket,
  9853. x.HeSuan,
  9854. x.YiMiao,
  9855. x.FirstItemRemark
  9856. })
  9857. .Where(x => x.Id == id)
  9858. .ExecuteCommandAsync();
  9859. if (upd < 1) return Ok(JsonView(false));
  9860. }
  9861. //消息通知
  9862. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9863. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9864. }
  9865. /// <summary>
  9866. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9867. /// </summary>
  9868. /// <returns></returns>
  9869. [HttpPost]
  9870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9871. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9872. {
  9873. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9874. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9875. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9876. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9877. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9878. info.DiId = dto.DiId;
  9879. //info.ProvinceId = dto.ProvinceId;
  9880. info.OutsideJJPay = dto.OutsideJJPay;
  9881. info.OutsideGWPay = dto.OutsideGWPay;
  9882. info.OutsideTDPay = dto.OutsideTDPay;
  9883. info.AirJJ = dto.AirJJ;
  9884. info.AirGW = dto.AirGW;
  9885. info.AirTD = dto.AirTD;
  9886. info.CityTranffic = dto.CityTranffic;
  9887. info.TwoItemRemark = dto.TwoItemRemark;
  9888. info.SumJJC = dto.ChoiceTwoJJ;
  9889. info.SumGWC = dto.ChoiceTwoGW;
  9890. info.SumTDC = dto.ChoiceTwoTD;
  9891. int id = dto.Id;
  9892. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9893. if (id <= 0) //add
  9894. {
  9895. info.CreateUserId = dto.CurrUserId;
  9896. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9897. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9898. if (addId <= 0) return Ok(JsonView(false));
  9899. id = addId;
  9900. }
  9901. else //update
  9902. {
  9903. ////验证编辑权限
  9904. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9905. //if (!isEdit) return Ok(JsonView(false, msg));
  9906. var upd = await _sqlSugar.Updateable(info)
  9907. .UpdateColumns(x => new
  9908. {
  9909. x.SumJJC,
  9910. x.OutsideJJPay,
  9911. x.SumGWC,
  9912. x.OutsideGWPay,
  9913. x.SumTDC,
  9914. x.OutsideTDPay,
  9915. x.AirJJ,
  9916. x.AirGW,
  9917. x.AirTD,
  9918. x.CityTranffic,
  9919. x.TwoItemRemark
  9920. })
  9921. .Where(x => x.Id == id)
  9922. .ExecuteCommandAsync();
  9923. if (upd < 1) return Ok(JsonView(false));
  9924. }
  9925. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9926. gwcItemTotal = info.AirGW + info.CityTranffic;
  9927. tdcItemTotal = info.AirTD + info.CityTranffic;
  9928. //消息通知
  9929. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9930. return Ok(JsonView(new
  9931. {
  9932. parentId = id,
  9933. choiceTwoJJ = dto.ChoiceTwoJJ,
  9934. jjcItemTotal = jjcItemTotal,
  9935. choiceTwoGW = dto.ChoiceTwoGW,
  9936. gwcItemTotal = gwcItemTotal,
  9937. choiceTwoTD = dto.ChoiceTwoTD,
  9938. tdcItemTotal = tdcItemTotal
  9939. }));
  9940. }
  9941. /// <summary>
  9942. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9943. /// </summary>
  9944. /// <returns></returns>
  9945. [HttpPost]
  9946. [ApiExplorerSettings(IgnoreApi = true)]
  9947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9948. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9949. {
  9950. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9951. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9952. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9953. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9954. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9955. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9956. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9957. var infos = infos1.Select(x => new Grp_DayAndCost
  9958. {
  9959. Id = x.Id,
  9960. DiId = dto.DiId,
  9961. Type = dto.FeeType,
  9962. Days = x.Days,
  9963. NationalTravelFeeId = x.NationalTravelFeeId,
  9964. Cost = x.Cost,
  9965. Currency = x.Currency,
  9966. SubTotal = x.SubTotal,
  9967. CreateUserId = dto.CurrUserId
  9968. })
  9969. .ToList();
  9970. var adds = infos.Where(x => x.Id <= 0).ToList();
  9971. var upds = infos.Where(x => x.Id > 0).ToList();
  9972. if (adds.Count > 0)
  9973. {
  9974. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9975. if (add < 1) return Ok(JsonView(false));
  9976. }
  9977. if (upds.Count > 0)
  9978. {
  9979. var upd = await _sqlSugar.Updateable(adds)
  9980. .UpdateColumns(x => new
  9981. {
  9982. x.Days,
  9983. x.NationalTravelFeeId,
  9984. x.Cost,
  9985. x.Currency,
  9986. x.SubTotal
  9987. })
  9988. .WhereColumns(x => new { x.Id })
  9989. .ExecuteCommandAsync();
  9990. if (upd < 1) return Ok(JsonView(false));
  9991. }
  9992. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9993. //消息通知
  9994. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9995. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9996. return Ok(JsonView(new { itemTotal = itemTotal }));
  9997. }
  9998. /// <summary>
  9999. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10000. /// </summary>
  10001. /// <returns></returns>
  10002. [HttpPost]
  10003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10004. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10005. {
  10006. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10007. int subId = dto.SubId, feeType = dto.FeeType;
  10008. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10009. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10010. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10011. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10012. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10013. subInfo.Id = subId;
  10014. subInfo.DiId = dto.DiId;
  10015. if (feeType == 3) subInfo.Type = 1;
  10016. else if (feeType == 4) subInfo.Type = 2;
  10017. else if (feeType == 5) subInfo.Type = 3;
  10018. else if (feeType == 6) subInfo.Type = 4;
  10019. subInfo.CreateUserId = dto.CurrUserId;
  10020. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10021. if (parentId < 1) return Ok(JsonView(false));
  10022. //子表op
  10023. if (subId < 1)
  10024. {
  10025. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10026. if (subAdd < 1) return Ok(JsonView(false));
  10027. }
  10028. else
  10029. {
  10030. ////验证编辑权限
  10031. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10032. //if (!isEdit) return Ok(JsonView(false, msg));
  10033. var subUpd = await _sqlSugar.Updateable(subInfo)
  10034. .UpdateColumns(x => new
  10035. {
  10036. x.Days,
  10037. x.NationalTravelFeeId,
  10038. x.Cost,
  10039. x.Currency,
  10040. x.SubTotal
  10041. })
  10042. .WhereColumns(x => new { x.Id })
  10043. .ExecuteCommandAsync();
  10044. if (subUpd < 1) return Ok(JsonView(false));
  10045. }
  10046. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10047. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10048. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10049. }
  10050. /// <summary>
  10051. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10052. /// </summary>
  10053. /// <returns></returns>
  10054. [HttpPost]
  10055. [ApiExplorerSettings(IgnoreApi = true)]
  10056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10057. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10058. {
  10059. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10060. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10061. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10062. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10063. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10064. {
  10065. Id = x.Id,
  10066. Diid = dto.DiId,
  10067. SetDataId = x.SetDataId,
  10068. Index = x.Index,
  10069. Cost = x.Cost,
  10070. Currency = x.Currency,
  10071. SubTotal = x.SubTotal,
  10072. CreateUserId = dto.CurrUserId,
  10073. Remark = x.Remark
  10074. }).ToList();
  10075. var adds = infos.Where(x => x.Id <= 0).ToList();
  10076. var upds = infos.Where(x => x.Id > 0).ToList();
  10077. if (adds.Count > 0)
  10078. {
  10079. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10080. if (add < 1) return Ok(JsonView(false));
  10081. }
  10082. if (upds.Count > 0)
  10083. {
  10084. var upd = await _sqlSugar.Updateable(adds)
  10085. .UpdateColumns(x => new
  10086. {
  10087. x.Index,
  10088. x.SetDataId,
  10089. x.Cost,
  10090. x.Currency,
  10091. x.SubTotal,
  10092. x.Remark
  10093. })
  10094. .WhereColumns(x => new { x.Id })
  10095. .ExecuteCommandAsync();
  10096. if (upd < 1) return Ok(JsonView(false));
  10097. }
  10098. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10099. //消息通知
  10100. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10101. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10102. return Ok(JsonView(new { itemTotal = itemTotal }));
  10103. }
  10104. /// <summary>
  10105. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10106. /// </summary>
  10107. /// <returns></returns>
  10108. [HttpPost]
  10109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10110. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10111. {
  10112. int subId = dto.SubId;
  10113. int diId = dto.Diid;
  10114. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10115. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10116. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10117. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10118. subInfo.Id = subId;
  10119. subInfo.Diid = dto.Diid;
  10120. subInfo.CreateUserId = dto.CurrUserId;
  10121. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10122. if (parentId < 1) return Ok(JsonView(false));
  10123. #region 子表op
  10124. if (subId < 1)//add
  10125. {
  10126. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10127. if (subAdd < 1) return Ok(JsonView(false));
  10128. }
  10129. else //upd
  10130. {
  10131. ////验证编辑权限
  10132. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10133. //if (!isEdit) return Ok(JsonView(false, msg));
  10134. var subUpd = await _sqlSugar.Updateable(subInfo)
  10135. .UpdateColumns(x => new
  10136. {
  10137. x.Index,
  10138. x.SetDataId,
  10139. x.Cost,
  10140. x.Currency,
  10141. x.SubTotal,
  10142. x.Remark
  10143. })
  10144. .WhereColumns(x => new { x.Id })
  10145. .ExecuteCommandAsync();
  10146. if (subUpd < 1) return Ok(JsonView(false));
  10147. }
  10148. #endregion
  10149. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10150. //消息通知
  10151. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10152. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10153. }
  10154. /// <summary>
  10155. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10156. /// </summary>
  10157. /// <returns></returns>
  10158. [HttpPost]
  10159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10160. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10161. {
  10162. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10163. if (data.Code != 0)
  10164. {
  10165. return Ok(JsonView(false, data.Msg));
  10166. }
  10167. return Ok(JsonView(true, "操作成功!", data.Data));
  10168. }
  10169. /// <summary>
  10170. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10171. /// </summary>
  10172. /// <param name="dto"></param>
  10173. /// <returns></returns>
  10174. [HttpPost]
  10175. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10176. {
  10177. var data = new Grp_DayOtherPrice()
  10178. {
  10179. Id = dto.Id,
  10180. IsDel = 1,
  10181. DeleteUserId = dto.DeleteUserId,
  10182. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10183. };
  10184. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10185. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10186. return Ok(JsonView(false, "删除失败!"));
  10187. }
  10188. #endregion
  10189. #endregion
  10190. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10191. /// <summary>
  10192. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10193. /// </summary>
  10194. /// <returns></returns>
  10195. [HttpGet]
  10196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10197. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10198. {
  10199. var provData = await _groupRepository.ProvinceBasicSource();
  10200. return Ok(JsonView(true, "查询成功!", provData));
  10201. }
  10202. /// <summary>
  10203. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10204. /// </summary>
  10205. /// <returns></returns>
  10206. [HttpPost]
  10207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10208. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10209. {
  10210. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10211. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10212. RefAsync<int> total = 0;
  10213. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10214. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10215. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10216. .Select(x => new
  10217. {
  10218. Id = x.Id,
  10219. DraftName = x.DraftName,
  10220. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10221. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10222. .Any()
  10223. })
  10224. .OrderByDescending(x => x.Id)
  10225. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10226. return Ok(JsonView(true, "查询成功!", data, total));
  10227. }
  10228. /// <summary>
  10229. /// 出入境费用-草稿 移动端
  10230. /// 获取币种基础数据(含逻辑处理)
  10231. /// </summary>
  10232. /// <returns></returns>
  10233. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10234. {
  10235. return await GeneralMethod.EnterExitCostInitRate();
  10236. }
  10237. /// <summary>
  10238. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10239. /// </summary>
  10240. /// <returns></returns>
  10241. [HttpPost]
  10242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10243. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10244. {
  10245. //验证城市归属并给默认值
  10246. int provinceId = dto.ProvinceId;
  10247. if (provinceId < 1) provinceId = 122;
  10248. var dataSource = await _sqlSugar
  10249. .Queryable<Sys_SetData>()
  10250. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10251. .ToListAsync();
  10252. //三公费用-Word明细类型
  10253. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10254. .Select(x => new SetDataInfoView
  10255. {
  10256. Id = x.Id,
  10257. Name = x.Name,
  10258. Remark = x.Remark
  10259. })
  10260. .ToList();
  10261. //三公费用-Excel明细类型
  10262. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10263. .Select(x => new SetDataInfoView
  10264. {
  10265. Id = x.Id,
  10266. Name = x.Name,
  10267. Remark = x.Remark
  10268. })
  10269. .ToList();
  10270. //默认币种显示
  10271. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10272. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10273. return Ok(JsonView(true, "查询成功!", new
  10274. {
  10275. WordTypeData = wordTypeData,
  10276. ExcelTypeData = excelTypeData,
  10277. CurrencyInit = _currencyInfos,
  10278. viewPermissionData = viewPermissionData
  10279. }));
  10280. }
  10281. /// <summary>
  10282. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10283. /// </summary>
  10284. /// <returns></returns>
  10285. [HttpPost]
  10286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10287. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10288. {
  10289. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10290. RefAsync<int> total = 0;
  10291. int diId = 0;
  10292. var status = int.TryParse(dto.GroupName, out diId);
  10293. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10294. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10295. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10296. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10297. .OrderByDescending(x => x.VisitStartDate)
  10298. .Select(x => new
  10299. {
  10300. Id = x.Id,
  10301. GroupName = x.TeamName
  10302. })
  10303. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10304. return Ok(JsonView(true, "查询成功!", data, total));
  10305. }
  10306. /// <summary>
  10307. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10308. /// </summary>
  10309. /// <returns></returns>
  10310. [HttpPost]
  10311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10312. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10313. {
  10314. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10315. RefAsync<int> total = 0;
  10316. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10317. .Where(x => x.IsDel == 0 && x.STid == 66)
  10318. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10319. .Select(x => new
  10320. {
  10321. id = x.Id,
  10322. name = x.Name,
  10323. remark = x.Remark,
  10324. })
  10325. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10326. return Ok(JsonView(true, "查询成功!", data, total));
  10327. }
  10328. /// <summary>
  10329. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10330. /// </summary>
  10331. /// <returns></returns>
  10332. [HttpPost]
  10333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10334. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10335. {
  10336. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10337. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10338. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10339. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10340. var groupOtherRateData = groupRateData.TeamRates;
  10341. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10342. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10343. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10344. groupOtherRateData = groupOtherRateData
  10345. .Select(x => new TeamRateDescAddCurrencyIdView
  10346. {
  10347. CurrencyId = x.CurrencyId,
  10348. CurrencyName = x.CurrencyName,
  10349. CurrencyCode = x.CurrencyCode,
  10350. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10351. }).ToList();
  10352. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10353. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10354. }
  10355. /// <summary>
  10356. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10357. /// </summary>
  10358. /// <returns></returns>
  10359. [HttpPost]
  10360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10361. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10362. {
  10363. int portType = dto.PortType;
  10364. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10365. var tipsData = new List<int>() { 1, 2, 3 };
  10366. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10367. if (dto.TipsType == 1)
  10368. {
  10369. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10370. }
  10371. else if (dto.TipsType == 2)
  10372. {
  10373. if (portType == 2)
  10374. {
  10375. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10376. }
  10377. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10378. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10379. .Select(x => x.NationalTravelFeeId)
  10380. .Distinct()
  10381. .ToListAsync();
  10382. if (portType == 2)
  10383. {
  10384. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10385. }
  10386. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10387. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10388. .Select(x => x.Country)
  10389. .Distinct()
  10390. .ToArrayAsync();
  10391. if (portType == 2)
  10392. {
  10393. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10394. }
  10395. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10396. return Ok(JsonView(true, "查询成功!", new
  10397. {
  10398. totalAmt = totalAmt,
  10399. remark = remark
  10400. }));
  10401. }
  10402. else if (dto.TipsType == 3)
  10403. {
  10404. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10405. }
  10406. return Ok(JsonView(false));
  10407. }
  10408. /// <summary>
  10409. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10410. /// </summary>
  10411. /// <returns></returns>
  10412. [HttpPost]
  10413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10414. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10415. {
  10416. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10417. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10418. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10419. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10420. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10421. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10422. var info = new Grp_EnterExitCostDraft()
  10423. {
  10424. ProvinceId = dto.ProvinceId,
  10425. DraftName = dto.DraftName,
  10426. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10427. CreateUserId = dto.CurrUserId
  10428. };
  10429. _sqlSugar.BeginTran();
  10430. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10431. if (draftId < 1)
  10432. {
  10433. _sqlSugar.RollbackTran();
  10434. return Ok(JsonView(false, "草稿创建失败!"));
  10435. }
  10436. //添加默认权限
  10437. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10438. _sqlSugar.CommitTran();
  10439. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10440. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10441. mobileInfo.Id = draftId;
  10442. mobileInfo.DraftName = dto.DraftName;
  10443. mobileInfo.Currencys = rateInfos;
  10444. mobileInfo.IsAssignPerm = assignPerm;
  10445. return Ok(JsonView(mobileInfo));
  10446. }
  10447. /// <summary>
  10448. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10449. /// </summary>
  10450. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10451. /// <summary>
  10452. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10453. /// </summary>
  10454. /// <returns></returns>
  10455. [HttpPost]
  10456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10457. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10458. {
  10459. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10460. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10461. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10462. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10463. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10464. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10465. //验证查看编辑权限
  10466. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10467. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10468. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10469. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10470. mobileInfo.IsAssignPerm = assignPerm;
  10471. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10472. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10473. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10474. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10475. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10476. {
  10477. ParentId = dac.ParentId,
  10478. SubId = dac.Id,
  10479. Type = dac.Type,
  10480. Days = dac.Days,
  10481. NationalTravelFeeId = dac.NationalTravelFeeId,
  10482. Arae = $"{ntf.Country}-{ntf.City}",
  10483. Cost = dac.Cost,
  10484. Currency = dac.Currency,
  10485. CurrencyName = sd.Name,
  10486. SubTotal = dac.SubTotal,
  10487. })
  10488. .ToList();
  10489. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10490. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10491. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10492. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10493. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10494. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10495. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10496. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10497. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10498. //其他款项
  10499. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10500. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10501. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10502. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10503. .OrderBy((dop, sd1, sd2) => dop.Index)
  10504. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10505. {
  10506. ParentId = dop.ParentId,
  10507. SubId = dop.Id,
  10508. Index = dop.Index,
  10509. SetDataId = dop.SetDataId,
  10510. SetDataName = sd1.Name,
  10511. Cost = dop.Cost,
  10512. Currency = dop.Currency,
  10513. CurrencyName = sd2.Remark,
  10514. SubTotal = dop.SubTotal,
  10515. Remark = dop.Remark,
  10516. })
  10517. .ToArray();
  10518. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10519. return Ok(mobileInfo);
  10520. }
  10521. /// <summary>
  10522. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10523. /// </summary>
  10524. /// <returns></returns>
  10525. [HttpPost]
  10526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10527. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10528. {
  10529. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10530. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10531. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10532. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10533. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10534. //验证查看编辑权限
  10535. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10536. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10537. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10538. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10539. var subType = dto.SubType;
  10540. if (subType == 1) //1:境内费用
  10541. {
  10542. var oneData = new ChoiceOneMobileSubInfoView()
  10543. {
  10544. Id = eecInfo.Id,
  10545. ChoiceOne = eecInfo.ChoiceOne,
  10546. ChoiceOneTotalCost = eecInfo.InsidePay,
  10547. Visa = eecInfo.Visa,
  10548. VisaRemark = eecInfo.VisaRemark,
  10549. YiMiao = eecInfo.YiMiao,
  10550. HeSuan = eecInfo.HeSuan,
  10551. Service = eecInfo.Service,
  10552. Ticket = eecInfo.Ticket,
  10553. Safe = eecInfo.Safe,
  10554. FirstItemRemark = eecInfo.FirstItemRemark
  10555. };
  10556. return Ok(JsonView(oneData));
  10557. }
  10558. else if (subType == 2) //2:国际旅费
  10559. {
  10560. var twoData = new ChoiceTwoMobileSubInfoView()
  10561. {
  10562. Id = eecInfo.Id,
  10563. ChoiceTwoJJ = eecInfo.SumJJC,
  10564. OutsideJJPay = eecInfo.OutsideJJPay,
  10565. ChoiceTwoGW = eecInfo.SumGWC,
  10566. OutsideGWPay = eecInfo.OutsideGWPay,
  10567. ChoiceTwoTD = eecInfo.SumTDC,
  10568. OutsideTDPay = eecInfo.OutsideTDPay,
  10569. AirJJ = eecInfo.AirJJ,
  10570. AirGW = eecInfo.AirGW,
  10571. AirTD = eecInfo.AirTD,
  10572. CityTranffic = eecInfo.CityTranffic,
  10573. TwoItemRemark = eecInfo.TwoItemRemark
  10574. };
  10575. return Ok(JsonView(twoData));
  10576. }
  10577. else if (subType == 3) //3:住宿费
  10578. {
  10579. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10580. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10581. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10582. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10583. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10584. {
  10585. ParentId = dac.ParentId,
  10586. SubId = dac.Id,
  10587. Type = dac.Type,
  10588. Days = dac.Days,
  10589. NationalTravelFeeId = dac.NationalTravelFeeId,
  10590. Arae = $"{ntf.Country}-{ntf.City}",
  10591. Cost = dac.Cost,
  10592. Currency = dac.Currency,
  10593. CurrencyName = sd.Name,
  10594. SubTotal = dac.SubTotal,
  10595. })
  10596. .ToArray();
  10597. var data = new ChoiceDraftMobileSubInfo3To6View()
  10598. {
  10599. ParentId = eecInfo.Id,
  10600. Choice = eecInfo.ChoiceThree,
  10601. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10602. Details = dayAndCostDatas
  10603. };
  10604. return Ok(JsonView(data));
  10605. }
  10606. else if (subType == 4) //4:伙食费
  10607. {
  10608. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10609. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10610. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10611. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10612. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10613. {
  10614. ParentId = dac.ParentId,
  10615. SubId = dac.Id,
  10616. Type = dac.Type,
  10617. Days = dac.Days,
  10618. NationalTravelFeeId = dac.NationalTravelFeeId,
  10619. Arae = $"{ntf.Country}-{ntf.City}",
  10620. Cost = dac.Cost,
  10621. Currency = dac.Currency,
  10622. CurrencyName = sd.Name,
  10623. SubTotal = dac.SubTotal,
  10624. })
  10625. .ToArray();
  10626. var data = new ChoiceDraftMobileSubInfo3To6View()
  10627. {
  10628. ParentId = eecInfo.Id,
  10629. Choice = eecInfo.ChoiceFour,
  10630. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10631. Details = dayAndCostDatas
  10632. };
  10633. return Ok(JsonView(data));
  10634. }
  10635. else if (subType == 5) //5:公杂费
  10636. {
  10637. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10638. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10639. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10640. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10641. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10642. {
  10643. ParentId = dac.ParentId,
  10644. SubId = dac.Id,
  10645. Type = dac.Type,
  10646. Days = dac.Days,
  10647. NationalTravelFeeId = dac.NationalTravelFeeId,
  10648. Arae = $"{ntf.Country}-{ntf.City}",
  10649. Cost = dac.Cost,
  10650. Currency = dac.Currency,
  10651. CurrencyName = sd.Name,
  10652. SubTotal = dac.SubTotal,
  10653. })
  10654. .ToArray();
  10655. var data = new ChoiceDraftMobileSubInfo3To6View()
  10656. {
  10657. ParentId = eecInfo.Id,
  10658. Choice = eecInfo.ChoiceFive,
  10659. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10660. Details = dayAndCostDatas
  10661. };
  10662. return Ok(JsonView(data));
  10663. }
  10664. else if (subType == 6) //6:培训费
  10665. {
  10666. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10667. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10668. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10669. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10670. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10671. {
  10672. ParentId = dac.ParentId,
  10673. SubId = dac.Id,
  10674. Type = dac.Type,
  10675. Days = dac.Days,
  10676. NationalTravelFeeId = dac.NationalTravelFeeId,
  10677. Arae = $"{ntf.Country}-{ntf.City}",
  10678. Cost = dac.Cost,
  10679. Currency = dac.Currency,
  10680. CurrencyName = sd.Name,
  10681. SubTotal = dac.SubTotal,
  10682. })
  10683. .ToArray();
  10684. var data = new ChoiceDraftMobileSubInfo3To6View()
  10685. {
  10686. ParentId = eecInfo.Id,
  10687. Choice = eecInfo.ChoiceSix,
  10688. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10689. Details = dayAndCostDatas
  10690. };
  10691. return Ok(JsonView(data));
  10692. }
  10693. else if (subType == 7) //7:其他
  10694. {
  10695. //其他款项
  10696. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10697. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10698. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10699. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10700. .OrderBy((dop, sd1, sd2) => dop.Index)
  10701. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10702. {
  10703. ParentId = dop.ParentId,
  10704. SubId = dop.Id,
  10705. Index = dop.Index,
  10706. SetDataId = dop.SetDataId,
  10707. SetDataName = sd1.Name,
  10708. Cost = dop.Cost,
  10709. Currency = dop.Currency,
  10710. CurrencyName = sd2.Name,
  10711. SubTotal = dop.SubTotal,
  10712. Remark = dop.Remark,
  10713. })
  10714. .ToArray();
  10715. var data = new ChoiceSevenDraftMobileSubInfoView()
  10716. {
  10717. ParentId = eecInfo.Id,
  10718. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10719. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10720. Details = otherData
  10721. };
  10722. return Ok(JsonView(data));
  10723. }
  10724. return Ok(JsonView(false));
  10725. }
  10726. #region op
  10727. /// <summary>
  10728. /// 移动端更新费用消息通知
  10729. /// </summary>
  10730. /// <param name="draftId"></param>
  10731. /// <param name="id"></param>
  10732. /// <param name="currUserId"></param>
  10733. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10734. {
  10735. try
  10736. {
  10737. ////生成默认文件pdf并且通知人员
  10738. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10739. //{
  10740. // DiId = draftId,
  10741. // ExportType = 1,
  10742. // SubTypeId = 1005
  10743. //}, "pdf");
  10744. ////发送通知
  10745. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10746. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10747. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10748. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10749. ////汇率信息记录
  10750. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10751. }
  10752. catch (Exception ex)
  10753. {
  10754. //记录日志
  10755. throw;
  10756. }
  10757. }
  10758. /// <summary>
  10759. /// 验证出入境费用数据是否存在
  10760. /// 不存在添加
  10761. /// </summary>
  10762. /// <param name="draftId"></param>
  10763. /// <param name="currUserId"></param>
  10764. /// <returns></returns>
  10765. /// <exception cref="CustomException"></exception>
  10766. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10767. {
  10768. var parentId = 0;
  10769. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10770. if (info != null) parentId = info.Id;
  10771. else
  10772. {
  10773. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10774. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10775. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10776. parentId = addId;
  10777. }
  10778. return parentId;
  10779. }
  10780. /// <summary>
  10781. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10782. /// </summary>
  10783. /// <returns></returns>
  10784. [HttpPost]
  10785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10786. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10787. {
  10788. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10789. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10790. //验证查看权限
  10791. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10792. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10793. var userIds = await _sqlSugar
  10794. .Queryable<Grp_EnterExitCostDraftPermission>()
  10795. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10796. .Select(x => x.UserId)
  10797. .ToArrayAsync();
  10798. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10799. var perUsersView = new List<dynamic>();
  10800. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10801. var viewPermissionData = new List<PermissionViewUserview>();
  10802. if (feeBasePerm.Any())
  10803. {
  10804. foreach (var item in feeBasePerm)
  10805. {
  10806. if (item.Users.Any())
  10807. {
  10808. viewPermissionData.AddRange(item.Users);
  10809. }
  10810. }
  10811. }
  10812. foreach (var item in perUsers)
  10813. {
  10814. bool isView1 = false;
  10815. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10816. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10817. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10818. }
  10819. return Ok(JsonView(perUsersView));
  10820. }
  10821. /// <summary>
  10822. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10823. /// </summary>
  10824. /// <returns></returns>
  10825. [HttpPost]
  10826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10827. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10828. {
  10829. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10830. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10831. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10832. //验证查看编辑权限
  10833. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10834. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10835. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10836. foreach (var userId in dto.UserIds)
  10837. {
  10838. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10839. }
  10840. if (permissions.Any())
  10841. {
  10842. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10843. {
  10844. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10845. }
  10846. _sqlSugar.BeginTran();
  10847. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10848. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10849. if (result < 1)
  10850. {
  10851. _sqlSugar.RollbackTran();
  10852. return Ok(JsonView(false));
  10853. }
  10854. _sqlSugar.CommitTran();
  10855. return Ok(JsonView(true));
  10856. }
  10857. return Ok(JsonView(false));
  10858. }
  10859. /// <summary>
  10860. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10861. /// </summary>
  10862. /// <returns></returns>
  10863. [HttpPost]
  10864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10865. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10866. {
  10867. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10868. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10869. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10870. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10871. int id = dto.DraftId;
  10872. if (id <= 0) //add
  10873. {
  10874. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10875. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10876. if (add < 1) return Ok(JsonView(false));
  10877. id = add;
  10878. }
  10879. else //update
  10880. {
  10881. //验证查看编辑权限
  10882. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10883. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10884. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10885. if (upd < 1) return Ok(JsonView(false));
  10886. }
  10887. return Ok(JsonView(new { parentId = id }));
  10888. }
  10889. /// <summary>
  10890. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10891. /// </summary>
  10892. /// <returns></returns>
  10893. [HttpPost]
  10894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10895. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10896. {
  10897. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10898. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10899. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10900. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10901. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10902. int id = dto.DraftId;
  10903. if (id <= 0) //add
  10904. {
  10905. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10906. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10907. if (add < 1) return Ok(JsonView(false));
  10908. id = add;
  10909. }
  10910. else //update
  10911. {
  10912. //验证查看编辑权限
  10913. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10914. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10915. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10916. if (upd < 1) return Ok(JsonView(false));
  10917. }
  10918. #region 汇率变更时更改币种相关费用
  10919. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10920. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10921. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10922. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10923. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10924. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10925. .Select((dac, sd) => new
  10926. {
  10927. dac.Id,
  10928. dac.ParentId,
  10929. CurrencyCode = sd.Name,
  10930. dac.Cost
  10931. })
  10932. .ToList();
  10933. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10934. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10935. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10936. .Select((dop, sd) => new
  10937. {
  10938. dop.Id,
  10939. dop.ParentId,
  10940. CurrencyCode = sd.Name,
  10941. dop.Cost
  10942. })
  10943. .ToList();
  10944. if (dayCosts.Count > 0)
  10945. {
  10946. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10947. foreach (var dc in new_dayCosts)
  10948. {
  10949. var thisCurrency = dc.Key.ToUpper();
  10950. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10951. if (thisRate == 0.00M) continue;
  10952. foreach (var dcSub in dc)
  10953. {
  10954. opDayCosts.Add(new Grp_DayAndCostDraft()
  10955. {
  10956. Id = dcSub.Id,
  10957. ParentId = dcSub.ParentId,
  10958. Cost = dcSub.Cost,
  10959. SubTotal = dcSub.Cost * thisRate,
  10960. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10961. });
  10962. }
  10963. }
  10964. if (opDayCosts.Count > 0)
  10965. {
  10966. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10967. }
  10968. }
  10969. if (dayOtherCosts.Count > 0)
  10970. {
  10971. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10972. foreach (var dc in new_dayOtherCosts)
  10973. {
  10974. var thisCurrency = dc.Key.ToUpper();
  10975. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10976. if (thisRate == 0.00M) continue;
  10977. foreach (var dcSub in dc)
  10978. {
  10979. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10980. {
  10981. Id = dcSub.Id,
  10982. ParentId = dcSub.ParentId,
  10983. Cost = dcSub.Cost,
  10984. SubTotal = dcSub.Cost * thisRate,
  10985. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10986. });
  10987. }
  10988. }
  10989. if (opDayOtherCosts.Count > 0)
  10990. {
  10991. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10992. }
  10993. }
  10994. #endregion
  10995. ////消息通知
  10996. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10997. ////汇率信息记录
  10998. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10999. return Ok(JsonView(new { parentId = id }));
  11000. }
  11001. /// <summary>
  11002. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11003. /// </summary>
  11004. /// <returns></returns>
  11005. [HttpPost]
  11006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11007. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11008. {
  11009. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11010. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11011. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11012. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11013. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11014. int id = dto.DraftId;
  11015. if (id <= 0) //add
  11016. {
  11017. checkboxInfo.ProvinceId = dto.ProvinceId;
  11018. checkboxInfo.CreateUserId = dto.CurrUserId;
  11019. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11020. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11021. if (add < 1) return Ok(JsonView(false));
  11022. }
  11023. else //update
  11024. {
  11025. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11026. .UpdateColumns(x => new
  11027. {
  11028. x.ChoiceOne,
  11029. x.ChoiceTwo,
  11030. x.SumJJC,
  11031. x.SumGWC,
  11032. x.SumTDC,
  11033. x.ChoiceThree,
  11034. x.ChoiceFour,
  11035. x.ChoiceFive,
  11036. x.ChoiceSix,
  11037. x.OtherExpenses_Checked
  11038. })
  11039. .Where(x => x.Id == id)
  11040. .ExecuteCommandAsync();
  11041. if (upd < 1) return Ok(JsonView(false));
  11042. }
  11043. return Ok(JsonView(new { parentId = id }));
  11044. }
  11045. /// <summary>
  11046. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11047. /// </summary>
  11048. /// <returns></returns>
  11049. [HttpPost]
  11050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11051. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11052. {
  11053. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11054. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11055. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11056. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11057. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11058. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11059. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11060. var checkboxInfo = new Grp_EnterExitCostDraft()
  11061. {
  11062. Id = draftId,
  11063. ProvinceId = dto.ProvinceId,
  11064. CreateUserId = currUserId
  11065. };
  11066. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11067. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11068. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11069. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11070. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11071. if (draftId <= 0) //add
  11072. {
  11073. checkboxInfo.CreateUserId = dto.CurrUserId;
  11074. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11075. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11076. if (add < 1) return Ok(JsonView(false));
  11077. }
  11078. else //update
  11079. {
  11080. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11081. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11082. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11083. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11084. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11085. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11086. .Where(x => x.Id == draftId)
  11087. .ExecuteCommandAsync();
  11088. if (upd < 1) return Ok(JsonView(false));
  11089. }
  11090. return Ok(JsonView(new { parentId = draftId }));
  11091. }
  11092. /// <summary>
  11093. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11094. /// </summary>
  11095. /// <returns></returns>
  11096. [HttpPost]
  11097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11098. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11099. {
  11100. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11101. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11102. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11103. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11104. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11105. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11106. info.ProvinceId = dto.ProvinceId;
  11107. info.FirstItemRemark = dto.FirstItemRemark;
  11108. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11109. if (id <= 0) //add
  11110. {
  11111. info.CreateUserId = dto.CurrUserId;
  11112. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11113. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11114. if (add < 1) return Ok(JsonView(false));
  11115. id = add;
  11116. }
  11117. else //update
  11118. {
  11119. var upd = await _sqlSugar.Updateable(info)
  11120. .UpdateColumns(x => new
  11121. {
  11122. x.ChoiceOne,
  11123. x.InsidePay,
  11124. x.VisaRemark,
  11125. x.Visa,
  11126. x.Service,
  11127. x.Safe,
  11128. x.Ticket,
  11129. x.HeSuan,
  11130. x.YiMiao,
  11131. x.FirstItemRemark
  11132. })
  11133. .Where(x => x.Id == id)
  11134. .ExecuteCommandAsync();
  11135. if (upd < 1) return Ok(JsonView(false));
  11136. }
  11137. ////消息通知
  11138. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11139. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11140. }
  11141. /// <summary>
  11142. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11143. /// </summary>
  11144. /// <returns></returns>
  11145. [HttpPost]
  11146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11147. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11148. {
  11149. int id = dto.DraftId;
  11150. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11151. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11152. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11153. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11154. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11155. info.ProvinceId = dto.ProvinceId;
  11156. info.OutsideJJPay = dto.OutsideJJPay;
  11157. info.OutsideGWPay = dto.OutsideGWPay;
  11158. info.OutsideTDPay = dto.OutsideTDPay;
  11159. info.AirJJ = dto.AirJJ;
  11160. info.AirGW = dto.AirGW;
  11161. info.AirTD = dto.AirTD;
  11162. info.CityTranffic = dto.CityTranffic;
  11163. info.TwoItemRemark = dto.TwoItemRemark;
  11164. info.SumJJC = dto.ChoiceTwoJJ;
  11165. info.SumGWC = dto.ChoiceTwoGW;
  11166. info.SumTDC = dto.ChoiceTwoTD;
  11167. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11168. if (id <= 0) //add
  11169. {
  11170. info.CreateUserId = dto.CurrUserId;
  11171. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11172. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11173. if (addId <= 0) return Ok(JsonView(false));
  11174. id = addId;
  11175. }
  11176. else //update
  11177. {
  11178. var upd = await _sqlSugar.Updateable(info)
  11179. .UpdateColumns(x => new
  11180. {
  11181. x.SumJJC,
  11182. x.OutsideJJPay,
  11183. x.SumGWC,
  11184. x.OutsideGWPay,
  11185. x.SumTDC,
  11186. x.OutsideTDPay,
  11187. x.AirJJ,
  11188. x.AirGW,
  11189. x.AirTD,
  11190. x.CityTranffic,
  11191. x.TwoItemRemark
  11192. })
  11193. .Where(x => x.Id == id)
  11194. .ExecuteCommandAsync();
  11195. if (upd < 1) return Ok(JsonView(false));
  11196. }
  11197. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11198. gwcItemTotal = info.AirGW + info.CityTranffic;
  11199. tdcItemTotal = info.AirTD + info.CityTranffic;
  11200. ////消息通知
  11201. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11202. return Ok(JsonView(new
  11203. {
  11204. parentId = id,
  11205. choiceTwoJJ = dto.ChoiceTwoJJ,
  11206. jjcItemTotal = jjcItemTotal,
  11207. choiceTwoGW = dto.ChoiceTwoGW,
  11208. gwcItemTotal = gwcItemTotal,
  11209. choiceTwoTD = dto.ChoiceTwoTD,
  11210. tdcItemTotal = tdcItemTotal
  11211. }));
  11212. }
  11213. /// <summary>
  11214. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11215. /// </summary>
  11216. /// <returns></returns>
  11217. [HttpPost]
  11218. [ApiExplorerSettings(IgnoreApi = true)]
  11219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11220. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11221. {
  11222. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11223. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11224. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11225. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11226. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11227. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11228. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11229. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11230. {
  11231. Id = x.Id,
  11232. ParentId = dto.DraftId,
  11233. Type = dto.FeeType,
  11234. Days = x.Days,
  11235. NationalTravelFeeId = x.NationalTravelFeeId,
  11236. Cost = x.Cost,
  11237. Currency = x.Currency,
  11238. SubTotal = x.SubTotal,
  11239. CreateUserId = dto.CurrUserId
  11240. })
  11241. .ToList();
  11242. var adds = infos.Where(x => x.Id <= 0).ToList();
  11243. var upds = infos.Where(x => x.Id > 0).ToList();
  11244. if (adds.Count > 0)
  11245. {
  11246. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11247. if (add < 1) return Ok(JsonView(false));
  11248. }
  11249. if (upds.Count > 0)
  11250. {
  11251. var upd = await _sqlSugar.Updateable(adds)
  11252. .UpdateColumns(x => new
  11253. {
  11254. x.Days,
  11255. x.NationalTravelFeeId,
  11256. x.Cost,
  11257. x.Currency,
  11258. x.SubTotal
  11259. })
  11260. .WhereColumns(x => new { x.Id })
  11261. .ExecuteCommandAsync();
  11262. if (upd < 1) return Ok(JsonView(false));
  11263. }
  11264. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11265. ////消息通知
  11266. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11267. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11268. return Ok(JsonView(new { itemTotal = itemTotal }));
  11269. }
  11270. /// <summary>
  11271. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11272. /// </summary>
  11273. /// <returns></returns>
  11274. [HttpPost]
  11275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11276. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11277. {
  11278. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11279. int subId = dto.SubId, feeType = dto.FeeType;
  11280. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11281. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11282. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11283. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11284. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11285. subInfo.Id = subId;
  11286. subInfo.ParentId = dto.DraftId;
  11287. if (feeType == 3) subInfo.Type = 1;
  11288. else if (feeType == 4) subInfo.Type = 2;
  11289. else if (feeType == 5) subInfo.Type = 3;
  11290. else if (feeType == 6) subInfo.Type = 4;
  11291. subInfo.CreateUserId = dto.CurrUserId;
  11292. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11293. if (parentId < 1) return Ok(JsonView(false));
  11294. //子表op
  11295. if (subId < 1)
  11296. {
  11297. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11298. if (subAdd < 1) return Ok(JsonView(false));
  11299. }
  11300. else
  11301. {
  11302. var subUpd = await _sqlSugar.Updateable(subInfo)
  11303. .UpdateColumns(x => new
  11304. {
  11305. x.Days,
  11306. x.NationalTravelFeeId,
  11307. x.Cost,
  11308. x.Currency,
  11309. x.SubTotal
  11310. })
  11311. .WhereColumns(x => new { x.Id })
  11312. .ExecuteCommandAsync();
  11313. if (subUpd < 1) return Ok(JsonView(false));
  11314. }
  11315. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11316. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11317. }
  11318. /// <summary>
  11319. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11320. /// </summary>
  11321. /// <returns></returns>
  11322. [HttpPost]
  11323. [ApiExplorerSettings(IgnoreApi = true)]
  11324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11325. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11326. {
  11327. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11328. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11329. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11330. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11331. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11332. {
  11333. Id = x.Id,
  11334. ParentId = dto.DraftId,
  11335. SetDataId = x.SetDataId,
  11336. Index = x.Index,
  11337. Cost = x.Cost,
  11338. Currency = x.Currency,
  11339. SubTotal = x.SubTotal,
  11340. CreateUserId = dto.CurrUserId,
  11341. Remark = x.Remark
  11342. }).ToList();
  11343. var adds = infos.Where(x => x.Id <= 0).ToList();
  11344. var upds = infos.Where(x => x.Id > 0).ToList();
  11345. if (adds.Count > 0)
  11346. {
  11347. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11348. if (add < 1) return Ok(JsonView(false));
  11349. }
  11350. if (upds.Count > 0)
  11351. {
  11352. var upd = await _sqlSugar.Updateable(adds)
  11353. .UpdateColumns(x => new
  11354. {
  11355. x.Index,
  11356. x.SetDataId,
  11357. x.Cost,
  11358. x.Currency,
  11359. x.SubTotal,
  11360. x.Remark
  11361. })
  11362. .WhereColumns(x => new { x.Id })
  11363. .ExecuteCommandAsync();
  11364. if (upd < 1) return Ok(JsonView(false));
  11365. }
  11366. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11367. //消息通知
  11368. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11369. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11370. return Ok(JsonView(new { itemTotal = itemTotal }));
  11371. }
  11372. /// <summary>
  11373. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11374. /// </summary>
  11375. /// <returns></returns>
  11376. [HttpPost]
  11377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11378. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11379. {
  11380. int subId = dto.SubId, id = dto.DraftId;
  11381. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11382. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11383. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11384. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11385. subInfo.Id = subId;
  11386. subInfo.ParentId = id;
  11387. subInfo.CreateUserId = dto.CurrUserId;
  11388. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11389. if (parentId < 1) return Ok(JsonView(false));
  11390. #region 子表op
  11391. if (subId < 1)//add
  11392. {
  11393. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11394. if (subAdd < 1) return Ok(JsonView(false));
  11395. }
  11396. else //upd
  11397. {
  11398. var subUpd = await _sqlSugar.Updateable(subInfo)
  11399. .UpdateColumns(x => new
  11400. {
  11401. x.Index,
  11402. x.SetDataId,
  11403. x.Cost,
  11404. x.Currency,
  11405. x.SubTotal,
  11406. x.Remark
  11407. })
  11408. .WhereColumns(x => new { x.Id })
  11409. .ExecuteCommandAsync();
  11410. if (subUpd < 1) return Ok(JsonView(false));
  11411. }
  11412. #endregion
  11413. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11414. ////消息通知
  11415. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11416. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11417. }
  11418. /// <summary>
  11419. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11420. /// </summary>
  11421. /// <returns></returns>
  11422. [HttpPost]
  11423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11424. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11425. {
  11426. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11427. if (data.Code != 0)
  11428. {
  11429. return Ok(JsonView(false, data.Msg));
  11430. }
  11431. return Ok(JsonView(true, "操作成功!", data.Data));
  11432. }
  11433. /// <summary>
  11434. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11435. /// </summary>
  11436. /// <param name="dto"></param>
  11437. /// <returns></returns>
  11438. [HttpPost]
  11439. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11440. {
  11441. var data = new Grp_DayOtherPriceDraft()
  11442. {
  11443. Id = dto.Id,
  11444. IsDel = 1,
  11445. DeleteUserId = dto.DeleteUserId,
  11446. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11447. };
  11448. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11449. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11450. return Ok(JsonView(false, "删除失败!"));
  11451. }
  11452. #endregion
  11453. #endregion
  11454. #region 团组经理模块 出入境费用报价表
  11455. /// <summary>
  11456. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11457. /// </summary>
  11458. /// <returns></returns>
  11459. [HttpPost]
  11460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11461. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11462. {
  11463. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11464. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11465. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11466. initRates.Insert(0, cnyInfo);
  11467. liveRates.Insert(0, cnyInfo);
  11468. return Ok(JsonView(true, "查询成功!", new
  11469. {
  11470. InitRates = initRates,
  11471. LiveRates = liveRates
  11472. }));
  11473. }
  11474. /// <summary>
  11475. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11476. /// </summary>
  11477. /// <returns></returns>
  11478. [HttpPost]
  11479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11480. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11481. {
  11482. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11483. }
  11484. /// <summary>
  11485. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11486. /// </summary>
  11487. /// <returns></returns>
  11488. [HttpPost]
  11489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11490. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11491. {
  11492. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11493. }
  11494. /// <summary>
  11495. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11496. /// </summary>
  11497. /// <returns></returns>
  11498. [HttpPost]
  11499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11500. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11501. {
  11502. int groupId = dto.DiId,
  11503. currUserId = dto.CurrUserId;
  11504. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11505. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11506. //验证报价数据是否存在
  11507. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11508. if (isNull != null)
  11509. {
  11510. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11511. if (!info1.Rates.Any())
  11512. {
  11513. var rates = await GeneralMethod.EnterExitCostInitRate();
  11514. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11515. info1.Rates = rates.ToArray();
  11516. }
  11517. return Ok(JsonView(info1));
  11518. }
  11519. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11520. result.GroupId = groupId;
  11521. //处理报价名称
  11522. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11523. if (groupInfo != null)
  11524. {
  11525. var visitCountry = groupInfo.VisitCountry;
  11526. if (!string.IsNullOrEmpty(visitCountry))
  11527. {
  11528. string quoteName = string.Empty;
  11529. if (visitCountry.Contains("|"))
  11530. {
  11531. var countrys = visitCountry.Split("|");
  11532. quoteName = string.Join("、", countrys);
  11533. }
  11534. else quoteName = visitCountry;
  11535. quoteName += $"团组报价表";
  11536. result.Name = quoteName;
  11537. }
  11538. }
  11539. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11540. if (info.Code != StatusCodes.Status200OK)
  11541. {
  11542. if (!result.Rates.Any())
  11543. {
  11544. var rates = await GeneralMethod.EnterExitCostInitRate();
  11545. result.Rates = rates.ToArray();
  11546. }
  11547. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11548. }
  11549. var infoView = info.Data as EnterExitCostInfoView;
  11550. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11551. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11552. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11553. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11554. var eecRates = infoView.Currencys;
  11555. //默认添加人名币
  11556. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11557. {
  11558. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11559. }
  11560. //处理团组人数
  11561. int pplNum = 1;
  11562. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11563. var views = new List<QuoteSubItemInfo>();
  11564. #region 数据填充
  11565. var intTravelCosts = new List<QuoteSubItemInfo>();
  11566. #region 机票费用 1354
  11567. int intTravelIndex = 1;
  11568. if (infoView.SumJJC == 1)
  11569. {
  11570. intTravelCosts.Add(new QuoteSubItemInfo
  11571. {
  11572. ItemId = 1354,
  11573. Index = intTravelIndex,
  11574. FeeName = "经济舱",
  11575. UnitPrice = infoView.AirJJ,
  11576. Currency = "CNY",
  11577. Quantity = 1,
  11578. PplNum = 1,
  11579. TotalAmt = infoView.AirJJ,
  11580. Remark = "",
  11581. });
  11582. intTravelIndex++;
  11583. }
  11584. if (infoView.SumGWC == 1)
  11585. {
  11586. intTravelCosts.Add(new QuoteSubItemInfo
  11587. {
  11588. ItemId = 1354,
  11589. Index = intTravelIndex,
  11590. FeeName = "公务舱",
  11591. UnitPrice = infoView.AirGW,
  11592. Currency = "CNY",
  11593. Quantity = 1,
  11594. PplNum = 1,
  11595. TotalAmt = infoView.AirGW,
  11596. Remark = "",
  11597. });
  11598. intTravelIndex++;
  11599. }
  11600. if (infoView.SumTDC == 1)
  11601. {
  11602. intTravelCosts.Add(new QuoteSubItemInfo
  11603. {
  11604. ItemId = 1354,
  11605. Index = intTravelIndex,
  11606. FeeName = "头等舱",
  11607. UnitPrice = infoView.AirTD,
  11608. Currency = "CNY",
  11609. Quantity = 1,
  11610. PplNum = 1,
  11611. TotalAmt = infoView.AirTD,
  11612. Remark = "",
  11613. });
  11614. intTravelIndex++;
  11615. }
  11616. intTravelCosts.Add(new QuoteSubItemInfo
  11617. {
  11618. ItemId = 1354,
  11619. Index = intTravelIndex,
  11620. FeeName = "城市间交通费用",
  11621. UnitPrice = infoView.CityTranffic,
  11622. Currency = "CNY",
  11623. Quantity = 1,
  11624. PplNum = pplNum,
  11625. TotalAmt = infoView.CityTranffic * pplNum,
  11626. Remark = "",
  11627. });
  11628. views.AddRange(intTravelCosts);
  11629. #endregion
  11630. var accomCosts = new List<QuoteSubItemInfo>();
  11631. #region 住宿费 1355
  11632. if (infoView.QuarterageData.Any())
  11633. {
  11634. int accomIndex = 1;
  11635. int accomItemTypeId = 1355;
  11636. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11637. foreach (var item in groupData)
  11638. {
  11639. string feeName = string.Empty;
  11640. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11641. if (countryInfo != null)
  11642. {
  11643. feeName = countryInfo.Country;
  11644. var city = countryInfo.City;
  11645. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11646. {
  11647. feeName += $"-{city}";
  11648. }
  11649. }
  11650. var hotelInfo = item.FirstOrDefault();
  11651. if (hotelInfo == null) continue;
  11652. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11653. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11654. int quantity = item.ToList().Count;
  11655. accomCosts.Add(new QuoteSubItemInfo
  11656. {
  11657. ItemId = accomItemTypeId,
  11658. Index = accomIndex,
  11659. FeeName = feeName,
  11660. UnitPrice = hotelInfo.Cost,
  11661. Currency = thisCurrency,
  11662. Quantity = quantity,
  11663. PplNum = pplNum,
  11664. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11665. Remark = "",
  11666. });
  11667. accomIndex++;
  11668. }
  11669. views.AddRange(accomCosts);
  11670. }
  11671. #endregion
  11672. var mealCosts = new List<QuoteSubItemInfo>();
  11673. #region 餐饮费 1356
  11674. if (infoView.BoardWagesData.Any())
  11675. {
  11676. var mealIndex = 1;
  11677. int mealItemTypeId = 1356;
  11678. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11679. foreach (var item in groupData)
  11680. {
  11681. string feeName = string.Empty;
  11682. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11683. if (countryInfo != null)
  11684. {
  11685. feeName = countryInfo.Country;
  11686. var city = countryInfo.City;
  11687. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11688. {
  11689. feeName += $"-{city}";
  11690. }
  11691. }
  11692. var mealInfo = item.FirstOrDefault();
  11693. if (mealInfo == null) continue;
  11694. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11695. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11696. int quantity = item.ToList().Count;
  11697. mealCosts.Add(new QuoteSubItemInfo
  11698. {
  11699. ItemId = mealItemTypeId,
  11700. Index = mealIndex,
  11701. FeeName = feeName,
  11702. UnitPrice = mealInfo.Cost,
  11703. Currency = thisCurrency,
  11704. Quantity = quantity,
  11705. PplNum = pplNum,
  11706. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11707. Remark = "",
  11708. });
  11709. mealIndex++;
  11710. }
  11711. views.AddRange(mealCosts);
  11712. }
  11713. #endregion
  11714. var miscCosts = new List<QuoteSubItemInfo>();
  11715. #region 公杂费 1364
  11716. if (infoView.MiscellaneousFeeData.Any())
  11717. {
  11718. var miscIndex = 1;
  11719. int miscItemTypeId = 1364;
  11720. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11721. foreach (var item in groupData)
  11722. {
  11723. string feeName = string.Empty;
  11724. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11725. if (countryInfo != null)
  11726. {
  11727. feeName = countryInfo.Country;
  11728. var city = countryInfo.City;
  11729. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11730. {
  11731. feeName += $"-{city}";
  11732. }
  11733. }
  11734. var miscInfo = item.FirstOrDefault();
  11735. if (miscInfo == null) continue;
  11736. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11737. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11738. int quantity = item.ToList().Count;
  11739. miscCosts.Add(new QuoteSubItemInfo
  11740. {
  11741. ItemId = miscItemTypeId,
  11742. Index = miscIndex,
  11743. FeeName = feeName,
  11744. UnitPrice = miscInfo.Cost,
  11745. Currency = thisCurrency,
  11746. Quantity = quantity,
  11747. PplNum = pplNum,
  11748. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11749. Remark = "",
  11750. });
  11751. miscIndex++;
  11752. }
  11753. views.AddRange(miscCosts);
  11754. }
  11755. #endregion
  11756. #region 签证+保险 1362
  11757. int visaInsIndex = 1;
  11758. int visaInsItemTypeId = 1362;
  11759. if (infoView.Visa > 0)
  11760. {
  11761. views.Add(new QuoteSubItemInfo()
  11762. {
  11763. ItemId = visaInsItemTypeId,
  11764. Index = visaInsIndex,
  11765. FeeName = $"签证",
  11766. UnitPrice = infoView.Visa,
  11767. Currency = $"CNY",
  11768. Quantity = 1,
  11769. PplNum = pplNum,
  11770. TotalAmt = infoView.Visa * pplNum,
  11771. Remark = "",
  11772. });
  11773. visaInsIndex++;
  11774. }
  11775. if (infoView.Safe > 0)
  11776. {
  11777. views.Add(new QuoteSubItemInfo()
  11778. {
  11779. ItemId = visaInsItemTypeId,
  11780. Index = visaInsIndex,
  11781. FeeName = $"保险",
  11782. UnitPrice = infoView.Safe,
  11783. Currency = $"CNY",
  11784. Quantity = 1,
  11785. PplNum = pplNum,
  11786. TotalAmt = infoView.Safe * pplNum,
  11787. Remark = "",
  11788. });
  11789. }
  11790. #endregion
  11791. #region 服务费 1363
  11792. int serviceFeeIndex = 1;
  11793. int serviceFeeItemTypeId = 1363;
  11794. if (infoView.Service > 0)
  11795. {
  11796. views.Add(new QuoteSubItemInfo()
  11797. {
  11798. ItemId = serviceFeeItemTypeId,
  11799. Index = serviceFeeIndex,
  11800. FeeName = $"服务费",
  11801. UnitPrice = infoView.Service,
  11802. Currency = $"CNY",
  11803. Quantity = 1,
  11804. PplNum = pplNum,
  11805. TotalAmt = infoView.Service * pplNum,
  11806. Remark = "",
  11807. });
  11808. }
  11809. #endregion
  11810. #endregion
  11811. if (result.FeeItems.Any())
  11812. {
  11813. result.FeeItems.Select(x =>
  11814. {
  11815. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11816. if (feeInfos.Any()) x.Infos = feeInfos;
  11817. return x;
  11818. }
  11819. ).OrderBy(x => x.Index)
  11820. .ToList();
  11821. if (!result.Rates.Any())
  11822. {
  11823. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  11824. else
  11825. {
  11826. var rates = await GeneralMethod.EnterExitCostInitRate();
  11827. rates.Insert(0,new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11828. result.Rates = rates.ToArray();
  11829. }
  11830. }
  11831. }
  11832. return Ok(JsonView(result));
  11833. }
  11834. /// <summary>
  11835. /// 团组模块 - 出入境费用报价表 - Info
  11836. /// </summary>
  11837. /// <returns></returns>
  11838. [HttpPost]
  11839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11840. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11841. {
  11842. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11843. if (!info.Rates.Any())
  11844. {
  11845. var rates = await GeneralMethod.EnterExitCostInitRate();
  11846. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11847. info.Rates = rates.ToArray();
  11848. }
  11849. return Ok(JsonView(info));
  11850. }
  11851. /// <summary>
  11852. /// 团组模块 - 出入境费用报价表 - OP
  11853. /// </summary>
  11854. /// <returns></returns>
  11855. [HttpPost]
  11856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11857. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11858. {
  11859. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11860. }
  11861. /// <summary>
  11862. /// 团组模块 - 出入境费用报价表 - 删除 项
  11863. /// </summary>
  11864. /// <returns></returns>
  11865. [HttpPost]
  11866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11867. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11868. {
  11869. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11870. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11871. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11872. }
  11873. /// <summary>
  11874. /// 团组模块 - 出入境费用报价表 - 导出
  11875. /// </summary>
  11876. /// <returns></returns>
  11877. [HttpPost]
  11878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11879. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11880. {
  11881. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11882. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11883. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11884. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11885. var rates = info.Rates;
  11886. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11887. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11888. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11889. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11890. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11891. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11892. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  11893. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  11894. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  11895. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  11896. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  11897. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  11898. //获取模板
  11899. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11900. var designer = new WorkbookDesigner();
  11901. designer.Workbook = new Workbook(tempPath);
  11902. designer.SetDataSource("QuoteName", info.Name);
  11903. designer.SetDataSource("CompanyTitle", "公司名称");
  11904. designer.SetDataSource("CompanyLabel", "");
  11905. #region 国际旅费
  11906. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  11907. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  11908. {
  11909. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11910. StringBuilder label = new StringBuilder();
  11911. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11912. if (infos.Any())
  11913. {
  11914. label.Append(infos.Sum(x => x.PplNum));
  11915. label.Append("人全程机票:");
  11916. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11917. label.AppendLine("元");
  11918. }
  11919. foreach (var item in intTravelCosts.Infos)
  11920. {
  11921. label.Append(item.FeeName);
  11922. label.Append(":");
  11923. label.Append(item.UnitPrice.TruncDecimals(2));
  11924. label.Append("元/人*");
  11925. label.Append(item.PplNum);
  11926. label.AppendLine("人");
  11927. }
  11928. if (label.HasValue())
  11929. {
  11930. label.Append("\r\n以上小计:");
  11931. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11932. label.Append("元");
  11933. }
  11934. designer.SetDataSource("IntTravelLabel", label.ToString());
  11935. }
  11936. #endregion
  11937. #region 住宿费
  11938. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  11939. if (accomCosts!=null && accomCosts.Infos.Any())
  11940. {
  11941. string currencyName = string.Empty,
  11942. countryName = string.Empty;
  11943. decimal rate = 1.0000M;
  11944. StringBuilder label = new StringBuilder();
  11945. label.AppendLine("全程五星酒店,每人1间房");
  11946. foreach (var item in accomCosts.Infos)
  11947. {
  11948. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  11949. string name = string.Empty, thisCountryName = string.Empty;
  11950. if (item.FeeName.Contains("-"))
  11951. {
  11952. var feeName = item.FeeName.Split('-');
  11953. thisCountryName = feeName[0];
  11954. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  11955. name = feeName[1];
  11956. }
  11957. else name = item.FeeName;
  11958. string thisFeeName = string.Empty;
  11959. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  11960. else thisFeeName = $"\r\n{name}:";
  11961. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11962. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11963. rate = rateInfo?.Rate ?? 1.0000M;
  11964. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  11965. label.AppendLine(subLabel);
  11966. }
  11967. if (label.HasValue())
  11968. {
  11969. //以上小计:52440元(美金汇率:7.5 )
  11970. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  11971. label.AppendLine(subLabel);
  11972. }
  11973. designer.SetDataSource("AccomLabel", label.ToString());
  11974. }
  11975. #endregion
  11976. #region 餐饮费
  11977. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  11978. if (mealCosts != null && mealCosts.Infos.Any())
  11979. {
  11980. string currencyName = string.Empty;
  11981. decimal rate = 1.0000M;
  11982. StringBuilder label = new StringBuilder();
  11983. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  11984. foreach (var item in mealCosts.Infos)
  11985. {
  11986. string name = string.Empty;
  11987. if (item.FeeName.Contains("-"))
  11988. {
  11989. var feeName = item.FeeName.Split('-');
  11990. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11991. }
  11992. else name = $"\r\n{item.FeeName}:";
  11993. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11994. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11995. rate = rateInfo?.Rate ?? 1.0000M;
  11996. label.Append(name);
  11997. label.Append(item.UnitPrice.TruncDecimals(2));
  11998. label.Append(currencyName);
  11999. label.Append("/天*");
  12000. label.Append(item.Quantity.ToString("#0"));
  12001. label.Append("*");
  12002. label.Append(item.PplNum);
  12003. label.Append("人\r\n");
  12004. }
  12005. if (label.HasValue())
  12006. {
  12007. label.Append("\r\n以上小计:");
  12008. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12009. label.Append("元\r\n(");
  12010. label.Append("汇率:");
  12011. label.Append(rate.TruncDecimals(4));
  12012. label.Append(")");
  12013. }
  12014. designer.SetDataSource("MealLabel", label.ToString());
  12015. }
  12016. #endregion
  12017. #region 车辆安排
  12018. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12019. if (vehArranges!=null&&vehArranges.Infos.Any())
  12020. {
  12021. string currencyName = string.Empty;
  12022. //decimal rate = 1.0000M;
  12023. StringBuilder label = new StringBuilder();
  12024. foreach (var item in vehArranges.Infos)
  12025. {
  12026. label.AppendLine();
  12027. label.AppendLine();
  12028. label.Append(item.FeeName);
  12029. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12030. }
  12031. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12032. }
  12033. #endregion
  12034. #region 邀请函发放对象
  12035. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12036. designer.SetDataSource("InviteToContent", "");
  12037. #endregion
  12038. #region 邀请函费
  12039. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12040. StringBuilder is_label = new StringBuilder();
  12041. if (inviteCosts != null&&inviteCosts.Infos.Any())
  12042. {
  12043. string currencyName = string.Empty;
  12044. decimal rate = 1.0000M;
  12045. foreach (var item in inviteCosts.Infos)
  12046. {
  12047. //乌兹别克斯坦:2000美金
  12048. currencyName = item.Currency;
  12049. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12050. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12051. is_label.AppendLine(label);
  12052. }
  12053. if (is_label.HasValue())
  12054. {
  12055. //以上小计:28500元(美金汇率:7.5)
  12056. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2),"元", currencyName, rate.TruncDecimals(4));
  12057. is_label.AppendLine(label);
  12058. }
  12059. }
  12060. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12061. #endregion
  12062. #region 邀请函发放时间
  12063. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12064. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12065. #endregion
  12066. #region 公务活动(含翻译)
  12067. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12068. StringBuilder oa_label = new StringBuilder();
  12069. if (officialActs != null && officialActs.Infos.Any())
  12070. {
  12071. string currencyName = string.Empty;
  12072. decimal rate = 1.0000M;
  12073. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12074. foreach (var item in officialActs.Infos)
  12075. {
  12076. //乌兹别克斯坦:1000美金/场
  12077. currencyName = item.Currency;
  12078. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12079. string label_remark = string.Empty;
  12080. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12081. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12082. }
  12083. label_content += "*总费用中未含超出公务活动价格";
  12084. //8场公务活动(以上小计:60000元)
  12085. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12086. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12087. oa_label.AppendLine(label_title);
  12088. oa_label.AppendLine(label_content);
  12089. }
  12090. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12091. #endregion
  12092. #region 签证+保险
  12093. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12094. StringBuilder vi_label = new StringBuilder();
  12095. if (visaIns != null && visaIns.Infos.Any())
  12096. {
  12097. foreach (var item in visaIns.Infos)
  12098. {
  12099. //签证:500元/人
  12100. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12101. vi_label.AppendLine(label);
  12102. }
  12103. if (vi_label.HasValue())
  12104. {
  12105. //以上小计:6000元
  12106. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12107. vi_label.AppendLine(label);
  12108. }
  12109. }
  12110. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12111. #endregion
  12112. #region 服务费
  12113. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12114. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12115. #endregion
  12116. #region 公杂费
  12117. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12118. StringBuilder pm_label = new StringBuilder();
  12119. if (pubMiscs != null && pubMiscs.Infos.Any())
  12120. {
  12121. string currencyName = string.Empty,
  12122. countryName = string.Empty;
  12123. decimal rate = 1.0000M;
  12124. foreach (var item in pubMiscs.Infos)
  12125. {
  12126. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12127. string name = string.Empty, thisCountryName = string.Empty;
  12128. if (item.FeeName.Contains("-"))
  12129. {
  12130. var feeName = item.FeeName.Split('-');
  12131. thisCountryName = feeName[0];
  12132. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12133. name = feeName[1];
  12134. }
  12135. else name = item.FeeName;
  12136. string thisFeeName = string.Empty;
  12137. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12138. else thisFeeName = $"\r\n{name}:";
  12139. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12140. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12141. rate = rateInfo?.Rate ?? 1.0000M;
  12142. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12143. pm_label.AppendLine(label);
  12144. }
  12145. if (pm_label.HasValue())
  12146. {
  12147. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12148. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12149. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12150. pm_label.AppendLine(string.Format("部分发放成员"));
  12151. }
  12152. }
  12153. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12154. #endregion
  12155. #region 税费
  12156. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12157. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12158. #endregion
  12159. #region 合计(单位:元)
  12160. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12161. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12162. #endregion
  12163. #region 汇率 Remark
  12164. var rate_label = new StringBuilder();
  12165. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12166. foreach (var item in rateGroups)
  12167. {
  12168. //美元汇率按\r\n1:7.5
  12169. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12170. rate_label.AppendLine(label);
  12171. }
  12172. designer.SetDataSource("RateLabel", rate_label.ToString());
  12173. #endregion
  12174. designer.Process();
  12175. //文件名
  12176. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12177. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12178. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12179. return Ok(JsonView(true, "成功", url));
  12180. }
  12181. #endregion
  12182. #region 签证费用录入
  12183. /// <summary>
  12184. /// 根据diid查询签证费用列表
  12185. /// </summary>
  12186. /// <param name="dto"></param>
  12187. /// <returns></returns>
  12188. [HttpPost]
  12189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12190. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12191. {
  12192. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12193. if (groupData.Code != 0)
  12194. {
  12195. return Ok(JsonView(false, groupData.Msg));
  12196. }
  12197. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12198. }
  12199. /// <summary>
  12200. /// 根据签证费用Id查询单条数据及c表数据
  12201. /// </summary>
  12202. /// <param name="dto"></param>
  12203. /// <returns></returns>
  12204. [HttpPost]
  12205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12206. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12207. {
  12208. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12209. if (groupData.Code != 0)
  12210. {
  12211. return Ok(JsonView(false, groupData.Msg));
  12212. }
  12213. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12214. }
  12215. /// <summary>
  12216. /// 签证费用删除
  12217. /// </summary>
  12218. /// <param name="dto"></param>
  12219. /// <returns></returns>
  12220. [HttpPost]
  12221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12222. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12223. {
  12224. _sqlSugar.BeginTran();
  12225. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12226. if (!res)
  12227. {
  12228. _sqlSugar.RollbackTran();
  12229. return Ok(JsonView(false, "删除失败"));
  12230. }
  12231. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12232. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12233. .SetColumns(a => new Grp_CreditCardPayment()
  12234. {
  12235. IsDel = 1,
  12236. DeleteUserId = dto.DeleteUserId,
  12237. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12238. })
  12239. .ExecuteCommand();
  12240. if (resSub < 1)
  12241. {
  12242. _sqlSugar.RollbackTran();
  12243. return Ok(JsonView(false, "删除失败"));
  12244. }
  12245. _sqlSugar.CommitTran();
  12246. return Ok(JsonView(true, "删除成功!"));
  12247. }
  12248. /// <summary>
  12249. /// 签证费用录入下拉框初始化
  12250. /// </summary>
  12251. /// <returns></returns>
  12252. [HttpPost]
  12253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12254. public async Task<IActionResult> VisaPriceAddSelect()
  12255. {
  12256. //支付方式
  12257. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12258. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12259. //币种
  12260. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12261. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12262. //乘客类型
  12263. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12264. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12265. //卡类型
  12266. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12267. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12268. //代办费类型
  12269. var agencyFeeTypeData = new List<dynamic>() {
  12270. new { id = 0 , Text = "未选择" },
  12271. new { id = 1 , Text = "小公务" },
  12272. new { id = 2 , Text = "大公务" },
  12273. };
  12274. //签证费用标准国家Data
  12275. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12276. var data = new
  12277. {
  12278. Payment = _Payment,
  12279. CurrencyList = _CurrencyList,
  12280. PassengerType = _PassengerType,
  12281. BankCard = _BankCard,
  12282. AgencyFeeType = agencyFeeTypeData,
  12283. CountryFeeData = visaCountryFeeData
  12284. };
  12285. return Ok(JsonView(true, "查询成功!", data));
  12286. }
  12287. /// <summary>
  12288. /// 签证费用录入操作(Status:1.新增,2.修改)
  12289. /// </summary>
  12290. /// <param name="dto"></param>
  12291. /// <returns></returns>
  12292. [HttpPost]
  12293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12294. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12295. {
  12296. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12297. if (groupData.Code != 0)
  12298. {
  12299. return Ok(JsonView(false, groupData.Msg));
  12300. }
  12301. #region 应用推送
  12302. try
  12303. {
  12304. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12305. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12306. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12307. //2024-10-21 新增LZ UID
  12308. var userIds = new List<int>() { 21 };
  12309. string title = $"系统通知";
  12310. string content = "";
  12311. var diId = dto.DiId;
  12312. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12313. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12314. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12315. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12316. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12317. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12318. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12319. }
  12320. catch (Exception ex)
  12321. {
  12322. }
  12323. #endregion
  12324. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12325. }
  12326. #endregion
  12327. #region 签证提成录入
  12328. /// <summary>
  12329. /// 签证提成录入
  12330. /// 基础数据
  12331. /// </summary>
  12332. /// <returns></returns>
  12333. [HttpGet]
  12334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12335. public async Task<IActionResult> VisaCommissionInit()
  12336. {
  12337. return Ok(await _visaCommissionRep.Init());
  12338. }
  12339. /// <summary>
  12340. /// 签证提成录入
  12341. /// Item
  12342. /// </summary>
  12343. /// <param name="_dto"></param>
  12344. /// <returns></returns>
  12345. [HttpPost]
  12346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12347. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12348. {
  12349. var validator = new VisaCommissionItemDtoValidator();
  12350. var validatorRes = await validator.ValidateAsync(_dto);
  12351. if (!validatorRes.IsValid)
  12352. {
  12353. StringBuilder sb = new StringBuilder();
  12354. foreach (var item in validatorRes.Errors)
  12355. {
  12356. sb.AppendLine(item.ErrorMessage);
  12357. }
  12358. return Ok(JsonView(false, sb.ToString()));
  12359. }
  12360. return Ok(await _visaCommissionRep.Item(_dto));
  12361. }
  12362. /// <summary>
  12363. /// 签证提成录入
  12364. /// Save
  12365. /// </summary>
  12366. /// <param name="_dto"></param>
  12367. /// <returns></returns>
  12368. [HttpPost]
  12369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12370. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12371. {
  12372. //参数验证
  12373. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12374. foreach (var item in _dto.Items)
  12375. {
  12376. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12377. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12378. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12379. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12380. }
  12381. return Ok(await _visaCommissionRep.Save(_dto));
  12382. }
  12383. /// <summary>
  12384. /// 签证提成录入
  12385. /// Create
  12386. /// </summary>
  12387. /// <param name="_dto"></param>
  12388. /// <returns></returns>
  12389. [HttpPost]
  12390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12391. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12392. {
  12393. var validator = new VisaCommissionCreateDtoValidator();
  12394. var validatorRes = await validator.ValidateAsync(_dto);
  12395. if (!validatorRes.IsValid)
  12396. {
  12397. StringBuilder sb = new StringBuilder();
  12398. foreach (var item in validatorRes.Errors)
  12399. {
  12400. sb.AppendLine(item.ErrorMessage);
  12401. }
  12402. return Ok(JsonView(false, sb.ToString()));
  12403. }
  12404. return Ok(await _visaCommissionRep.Create(_dto));
  12405. }
  12406. /// <summary>
  12407. /// 签证提成录入
  12408. /// Put(编辑)
  12409. /// </summary>
  12410. /// <param name="id"></param>
  12411. /// <param name="_dto"></param>
  12412. /// <returns></returns>
  12413. [HttpPut]
  12414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12415. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12416. {
  12417. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12418. var validator = new VisaCommissionCreateDtoValidator();
  12419. var validatorRes = await validator.ValidateAsync(_dto);
  12420. if (!validatorRes.IsValid)
  12421. {
  12422. StringBuilder sb = new StringBuilder();
  12423. foreach (var item in validatorRes.Errors)
  12424. {
  12425. sb.AppendLine(item.ErrorMessage);
  12426. }
  12427. return Ok(JsonView(false, sb.ToString()));
  12428. }
  12429. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12430. }
  12431. /// <summary>
  12432. /// 签证提成录入
  12433. /// Del
  12434. /// </summary>
  12435. /// <param name="id"></param>
  12436. /// <param name="currUserId"></param>
  12437. /// <returns></returns>
  12438. [HttpPost]
  12439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12440. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12441. {
  12442. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12443. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12444. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12445. }
  12446. #endregion
  12447. #region op费用录入
  12448. /// <summary>
  12449. /// 根据diid查询op费用列表
  12450. /// </summary>
  12451. /// <param name="dto"></param>
  12452. /// <returns></returns>
  12453. [HttpPost]
  12454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12455. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12456. {
  12457. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12458. if (groupData.Code != 0)
  12459. {
  12460. return Ok(JsonView(false, groupData.Msg));
  12461. }
  12462. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12463. }
  12464. /// <summary>
  12465. /// 根据op费用Id查询单条数据及c表数据
  12466. /// </summary>
  12467. /// <param name="dto"></param>
  12468. /// <returns></returns>
  12469. [HttpPost]
  12470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12471. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12472. {
  12473. try
  12474. {
  12475. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12476. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12477. var data = new
  12478. {
  12479. CarTouristGuideGround = _groupData,
  12480. CreditCardPayment = _creditCardPayment
  12481. };
  12482. return Ok(JsonView(true, "查询成功!", data));
  12483. }
  12484. catch (Exception ex)
  12485. {
  12486. return Ok(JsonView(false, "程序错误!"));
  12487. }
  12488. }
  12489. /// <summary>
  12490. /// op费用删除
  12491. /// </summary>
  12492. /// <param name="dto"></param>
  12493. /// <returns></returns>
  12494. [HttpPost]
  12495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12496. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12497. {
  12498. try
  12499. {
  12500. _sqlSugar.BeginTran();
  12501. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12502. if (!res)
  12503. {
  12504. return Ok(JsonView(false, "删除失败"));
  12505. }
  12506. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12507. {
  12508. IsDel = 1,
  12509. DeleteUserId = dto.DeleteUserId,
  12510. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12511. }).ExecuteCommandAsync();
  12512. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12513. {
  12514. IsDel = 1,
  12515. DeleteUserId = dto.DeleteUserId,
  12516. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12517. }).ExecuteCommandAsync();
  12518. #region 删除超支相关数据
  12519. //删除导入的超支数据
  12520. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12521. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12522. {
  12523. IsDel = 1,
  12524. DeleteUserId = dto.DeleteUserId,
  12525. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12526. }).ExecuteCommand();
  12527. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12528. {
  12529. IsDel = 1,
  12530. DeleteUserId = dto.DeleteUserId,
  12531. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12532. }).ExecuteCommand();
  12533. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12534. {
  12535. IsDel = 1,
  12536. DeleteUserId = dto.DeleteUserId,
  12537. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12538. }).ExecuteCommand();
  12539. #endregion
  12540. _sqlSugar.CommitTran();
  12541. return Ok(JsonView(true, "删除成功!"));
  12542. }
  12543. catch (Exception ex)
  12544. {
  12545. _sqlSugar.RollbackTran();
  12546. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12547. }
  12548. }
  12549. /// <summary>
  12550. /// op费用录入操作(Status:1.新增,2.修改)
  12551. /// </summary>
  12552. /// <param name="dto"></param>
  12553. /// <returns></returns>
  12554. [HttpPost]
  12555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12556. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12557. {
  12558. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12559. if (groupData.Code != 0)
  12560. {
  12561. return Ok(JsonView(false, groupData.Msg));
  12562. }
  12563. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12564. }
  12565. /// <summary>
  12566. /// 填写费用详细页面初始化绑定
  12567. /// </summary>
  12568. /// <param name="dto"></param>
  12569. /// <returns></returns>
  12570. [HttpPost]
  12571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12572. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12573. {
  12574. try
  12575. {
  12576. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12577. if (groupData.Code != 0)
  12578. {
  12579. return Ok(JsonView(false, groupData.Msg));
  12580. }
  12581. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12582. }
  12583. catch (Exception ex)
  12584. {
  12585. return Ok(JsonView(false, ex.Message));
  12586. }
  12587. }
  12588. /// <summary>
  12589. /// 根据op费用Id查询详细数据
  12590. /// </summary>
  12591. /// <param name="dto"></param>
  12592. /// <returns></returns>
  12593. [HttpPost]
  12594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12595. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12596. {
  12597. try
  12598. {
  12599. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12600. if (groupData.Code != 0)
  12601. {
  12602. return Ok(JsonView(false, groupData.Msg));
  12603. }
  12604. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12605. }
  12606. catch (Exception ex)
  12607. {
  12608. return Ok(JsonView(false, ex.Message));
  12609. }
  12610. }
  12611. /// <summary>
  12612. /// OP费用录入填写详情
  12613. /// </summary>
  12614. /// <param name="dto"></param>
  12615. /// <returns></returns>
  12616. [HttpPost]
  12617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12618. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12619. {
  12620. try
  12621. {
  12622. #region 参数校验
  12623. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12624. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12625. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12626. #endregion
  12627. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12628. if (groupData.Code != 0)
  12629. {
  12630. return Ok(JsonView(false, groupData.Msg));
  12631. }
  12632. //自动审核
  12633. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12634. #region 应用推送
  12635. try
  12636. {
  12637. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12638. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12639. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12640. //2024-10-21 新增LZ UID
  12641. var userIds = new List<int>() { 21 };
  12642. string title = $"系统通知";
  12643. var diId = dto.DiId;
  12644. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12645. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12646. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12647. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12648. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12649. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12650. }
  12651. catch (Exception ex)
  12652. {
  12653. }
  12654. #endregion
  12655. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12656. }
  12657. catch (Exception ex)
  12658. {
  12659. return Ok(JsonView(false, ex.Message));
  12660. }
  12661. }
  12662. /// <summary>
  12663. /// 获取三公详细所有城市
  12664. /// </summary>
  12665. /// <returns></returns>
  12666. [HttpGet]
  12667. public IActionResult OpCarCityResult()
  12668. {
  12669. var jw = JsonView(false);
  12670. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12671. {
  12672. x.Id,
  12673. x.Country,
  12674. x.City,
  12675. }).ToList();
  12676. if (data.Count > 0)
  12677. {
  12678. jw = JsonView(true, "获取成功!", data);
  12679. }
  12680. else
  12681. {
  12682. jw.Msg = "城市数据为空!";
  12683. jw.Data = new string[0];
  12684. }
  12685. return Ok(jw);
  12686. }
  12687. /// <summary>
  12688. /// 导出地接费用明细
  12689. /// </summary>
  12690. /// <param name="dto"></param>
  12691. /// <returns></returns>
  12692. [HttpPost]
  12693. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12694. {
  12695. var jw = JsonView(false);
  12696. if (dto.Diid < 1)
  12697. {
  12698. jw.Msg = "请输入正确的diid!";
  12699. return Ok(jw);
  12700. }
  12701. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12702. if (group == null)
  12703. {
  12704. jw.Msg = "未找到团组信息!";
  12705. return Ok(jw);
  12706. }
  12707. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12708. if (localGuideArr.Count == 0)
  12709. {
  12710. jw.Msg = "该团组暂无地接信息!";
  12711. return Ok(jw);
  12712. }
  12713. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12714. var overspendSoure = new Dictionary<int, int>
  12715. {
  12716. { 91, 982 }, //车
  12717. { 92 , 1059} ,//导游
  12718. { 994 , 1073}, //翻译
  12719. { 988 , 1074 }, //早餐
  12720. { 93 , 1075 }, //午餐
  12721. { 989 , 1076 }, //晚餐
  12722. };
  12723. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12724. foreach (var groupArr in localGroup)
  12725. {
  12726. var keyValue = groupArr.Key;
  12727. if (int.TryParse(keyValue, out int cityid))
  12728. {
  12729. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12730. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12731. }
  12732. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12733. foreach (var item in groupArr)
  12734. {
  12735. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12736. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12737. new Grp_CarTouristGuideGroundReservationsContentExtend
  12738. {
  12739. Count = a.Count,
  12740. CreateTime = a.CreateTime,
  12741. CreateUserId = a.CreateUserId,
  12742. CTGGRId = a.CTGGRId,
  12743. Currency = a.Currency,
  12744. DatePrice = a.DatePrice,
  12745. DeleteTime = a.DeleteTime,
  12746. DeleteUserId = a.DeleteUserId,
  12747. DiId = a.DiId,
  12748. Id = a.Id,
  12749. IsDel = a.IsDel,
  12750. Price = a.Price,
  12751. PriceContent = a.PriceContent,
  12752. Remark = a.Remark,
  12753. SId = a.SId,
  12754. SidName = b.Name,
  12755. Units = a.Units,
  12756. }
  12757. ).ToList();
  12758. if (content.Count > 0)
  12759. {
  12760. contentArr.Add(content);
  12761. }
  12762. }
  12763. //open excel
  12764. //set excel
  12765. //save excel
  12766. try
  12767. {
  12768. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12769. IWorkbook workbook;
  12770. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12771. {
  12772. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12773. }
  12774. else
  12775. {
  12776. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12777. }
  12778. ISheet sheet = workbook.GetSheetAt(0);
  12779. var rowStartIndex = 2;
  12780. var clounmCount = 10;
  12781. var initStyleRow = sheet.GetRow(2);
  12782. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12783. //var overspendArrDetail =
  12784. var existsId = new List<CarCompare>();
  12785. var lastElem = arr.Last();
  12786. var thisSid = -1;
  12787. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12788. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12789. {
  12790. Name = "未知币种!",
  12791. Remark = "未知币种!",
  12792. };
  12793. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12794. Action cloneRowFn = () =>
  12795. {
  12796. rowStartIndex++;
  12797. var cloneRow = sheet.CreateRow(rowStartIndex);
  12798. // 复制样式
  12799. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12800. {
  12801. ICell sourceCell = initStyleRow.GetCell(i);
  12802. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12803. // 确保单元格存在样式
  12804. if (sourceCell.CellStyle != null)
  12805. {
  12806. targetCell.CellStyle = sourceCell.CellStyle;
  12807. }
  12808. }
  12809. };
  12810. var mergeRow = () =>
  12811. {
  12812. for (int i = 2; i < sheet.LastRowNum; i++)
  12813. {
  12814. var row = sheet.GetRow(i);
  12815. var cellFirst = row.GetCell(0);
  12816. var thisIndex = i + 1;
  12817. while (thisIndex < sheet.LastRowNum)
  12818. {
  12819. var nextRow = sheet.GetRow(thisIndex);
  12820. var nextCellFirst = nextRow.GetCell(0);
  12821. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12822. {
  12823. thisIndex++;
  12824. }
  12825. else
  12826. {
  12827. break;
  12828. }
  12829. }
  12830. thisIndex--;
  12831. if (thisIndex != i)
  12832. {
  12833. //合并row
  12834. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12835. i, // 起始行索引(0-based)
  12836. thisIndex, // 结束行索引(0-based)
  12837. 0, // 起始列索引(0-based)
  12838. 0 // 结束列索引(0-based)
  12839. );
  12840. sheet.AddMergedRegion(cellRangeAddress);
  12841. i = thisIndex;
  12842. }
  12843. }
  12844. };
  12845. var chaoshiNumber = 0;
  12846. var totalNumber = 0.00M;
  12847. string lastStr = "";
  12848. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12849. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12850. {
  12851. b.IsAuditGM,
  12852. x.Id,
  12853. x.Area,
  12854. b.PayPercentage,
  12855. b.PayMoney,
  12856. }).ToList();
  12857. string yesPayment = "", noPayment = "";
  12858. foreach (var item in queryCarArrByCityAndDiid)
  12859. {
  12860. if (item.IsAuditGM == 1)
  12861. {
  12862. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12863. }
  12864. else
  12865. {
  12866. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12867. }
  12868. }
  12869. lastStr = yesPayment + noPayment;
  12870. foreach (var item in arr)
  12871. {
  12872. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12873. {
  12874. if (thisSid != item.SId)
  12875. {
  12876. if (thisSid == -1)
  12877. {
  12878. thisSid = item.SId;
  12879. }
  12880. else
  12881. {
  12882. //合并小计行
  12883. //创建合并区域的实例
  12884. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12885. rowStartIndex, // 起始行索引(0-based)
  12886. rowStartIndex, // 结束行索引(0-based)
  12887. 0, // 起始列索引(0-based)
  12888. 3 // 结束列索引(0-based)
  12889. );
  12890. sheet.AddMergedRegion(cellRangeAddress);
  12891. var CellStyle = workbook.CreateCellStyle();
  12892. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12893. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12894. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12895. for (int i = 0; i <= clounmCount; i++)
  12896. {
  12897. if (i > 6)
  12898. {
  12899. var CellStyle1 = workbook.CreateCellStyle();
  12900. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12901. IFont Font = workbook.CreateFont(); // 创建字体
  12902. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12903. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12904. CellStyle1.SetFont(Font);
  12905. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12906. }
  12907. else
  12908. {
  12909. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12910. }
  12911. }
  12912. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12913. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12914. //超时合计
  12915. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12916. //超时数
  12917. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12918. //超时合计费用
  12919. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12920. thisSid = item.SId;
  12921. cloneRowFn();
  12922. chaoshiNumber = 0;
  12923. totalNumber = 0;
  12924. }
  12925. }
  12926. IRow row = sheet.GetRow(rowStartIndex);
  12927. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12928. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12929. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12930. if (isOpenOverspendSoure)
  12931. {
  12932. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12933. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12934. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12935. }
  12936. for (int i = 0; i <= clounmCount; i++)
  12937. {
  12938. var cell = row.GetCell(i);
  12939. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12940. if (cell == null)
  12941. {
  12942. cell = row.CreateCell(i);
  12943. }
  12944. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12945. fontRed.CloneStyleFrom(cell.CellStyle);
  12946. IFont Font = workbook.CreateFont(); // 创建字体
  12947. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  12948. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12949. fontRed.SetFont(Font);
  12950. byte[] rgb = new byte[3] { 255, 242, 204 };
  12951. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  12952. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  12953. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  12954. if (workbook is XSSFWorkbook)
  12955. {
  12956. BackgroundColor255_242_204.FillForegroundColor = 0;
  12957. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  12958. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12959. }
  12960. else
  12961. {
  12962. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  12963. }
  12964. if (i == 1 || i > 6)
  12965. {
  12966. if (i > 6)
  12967. {
  12968. fontRed.FillForegroundColor = 0;
  12969. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  12970. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12971. }
  12972. cell.CellStyle = fontRed;
  12973. }
  12974. if (i > 2 && i < 7)
  12975. {
  12976. cell.CellStyle = BackgroundColor255_242_204;
  12977. }
  12978. cell.SetCellValue(setCellValue); //写入单元格
  12979. }
  12980. if (overspendSoure.ContainsKey(thisSid))
  12981. {
  12982. var overspendId = overspendSoure[thisSid];
  12983. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12984. }
  12985. cloneRowFn();
  12986. existsId.Add(new CarCompare
  12987. {
  12988. DataPrice = item.DatePrice.ObjToDate(),
  12989. Sid = item.SId
  12990. });
  12991. }
  12992. if (item.Equals(lastElem))
  12993. {
  12994. //合并小计行
  12995. //创建合并区域的实例
  12996. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12997. rowStartIndex, // 起始行索引(0-based)
  12998. rowStartIndex, // 结束行索引(0-based)
  12999. 0, // 起始列索引(0-based)
  13000. 3 // 结束列索引(0-based)
  13001. );
  13002. sheet.AddMergedRegion(cellRangeAddress);
  13003. var CellStyle = workbook.CreateCellStyle();
  13004. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13005. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13006. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13007. for (int i = 0; i <= clounmCount; i++)
  13008. {
  13009. if (i > 6)
  13010. {
  13011. var CellStyle1 = workbook.CreateCellStyle();
  13012. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13013. IFont Font = workbook.CreateFont(); // 创建字体
  13014. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13015. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13016. CellStyle1.SetFont(Font);
  13017. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13018. }
  13019. else
  13020. {
  13021. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13022. }
  13023. }
  13024. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13025. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13026. //超时合计
  13027. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13028. //超时数
  13029. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13030. //超时合计费用
  13031. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13032. cloneRowFn();
  13033. // 创建合并区域的实例
  13034. cellRangeAddress = new CellRangeAddress(
  13035. rowStartIndex, // 起始行索引(0-based)
  13036. rowStartIndex, // 结束行索引(0-based)
  13037. 0, // 起始列索引(0-based)
  13038. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13039. );
  13040. // 添加合并区域
  13041. sheet.AddMergedRegion(cellRangeAddress);
  13042. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13043. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13044. }
  13045. }
  13046. mergeRow();
  13047. // 保存修改后的Excel文件到新文件
  13048. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13049. // new FileStream(newFilePath, FileMode.CreateNew)
  13050. using (var stream = new MemoryStream())
  13051. {
  13052. workbook.Write(stream, true);
  13053. stream.Flush();
  13054. stream.Seek(0, SeekOrigin.Begin);
  13055. MemoryStream memoryStream = new MemoryStream();
  13056. stream.CopyTo(memoryStream);
  13057. memoryStream.Seek(0, SeekOrigin.Begin);
  13058. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13059. }
  13060. workbook.Close();
  13061. workbook.Dispose();
  13062. }
  13063. catch (Exception ex)
  13064. {
  13065. jw.Msg = "出现异常!" + ex.Message;
  13066. return Ok(jw);
  13067. }
  13068. }
  13069. if (Zips.Count > 0)
  13070. {
  13071. IOOperatorHelper io = new IOOperatorHelper();
  13072. var byts = io.ConvertZipStream(Zips);
  13073. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13074. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13075. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13076. }
  13077. else
  13078. {
  13079. jw.Msg = "暂无生成文件!";
  13080. }
  13081. return Ok(jw);
  13082. }
  13083. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13084. {
  13085. string outStr = string.Empty;
  13086. switch (i)
  13087. {
  13088. case 0:
  13089. outStr = arr[0].SidName;
  13090. break;
  13091. case 1:
  13092. outStr = arr[0].DataPriceStr;
  13093. break;
  13094. case 2:
  13095. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13096. break;
  13097. case 4:
  13098. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13099. break;
  13100. case 7:
  13101. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13102. {
  13103. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13104. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13105. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13106. }
  13107. break;
  13108. case 8:
  13109. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13110. {
  13111. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13112. }
  13113. break;
  13114. case 9:
  13115. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13116. {
  13117. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13118. }
  13119. break;
  13120. case 10:
  13121. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13122. {
  13123. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13124. }
  13125. break;
  13126. }
  13127. return outStr;
  13128. }
  13129. #region OP行程单
  13130. /// <summary>
  13131. /// OP行程单初始化
  13132. /// </summary>
  13133. /// <param name="dto"></param>
  13134. /// <returns></returns>
  13135. [HttpPost]
  13136. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13137. {
  13138. var jw = JsonView(false);
  13139. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13140. var group = groupList.First();
  13141. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13142. if (group == null)
  13143. {
  13144. jw.Msg = "暂无团组!";
  13145. return Ok(jw);
  13146. }
  13147. group = groupList.Find(x => x.Id == diid);
  13148. if (group == null)
  13149. {
  13150. jw.Msg = "请输入正确的团组ID!";
  13151. return Ok(jw);
  13152. }
  13153. string city = string.Empty;
  13154. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13155. if (blackCode.Count > 0)
  13156. {
  13157. var black = blackCode.First();
  13158. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13159. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13160. if (blackSp.Length > 0)
  13161. {
  13162. try
  13163. {
  13164. var cityArrCode = new List<string>(20);
  13165. foreach (var item in blackSp)
  13166. {
  13167. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13168. var IndexSelect = itemSp[2];
  13169. var cityArrCodeLength = cityArrCode.Count - 1;
  13170. var startCity = IndexSelect.Substring(0, 3);
  13171. if (cityArrCodeLength > 0)
  13172. {
  13173. var arrEndCity = cityArrCode[cityArrCodeLength];
  13174. if (arrEndCity != startCity)
  13175. {
  13176. cityArrCode.Add(startCity.ToUpper());
  13177. }
  13178. }
  13179. else
  13180. {
  13181. cityArrCode.Add(startCity.ToUpper());
  13182. }
  13183. var endCity = IndexSelect.Substring(3, 3);
  13184. cityArrCode.Add(endCity.ToUpper());
  13185. }
  13186. var cityThree = string.Empty;
  13187. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13188. cityThree = cityThree.TrimEnd(',');
  13189. if (string.IsNullOrWhiteSpace(cityThree))
  13190. {
  13191. throw new
  13192. Exception("error");
  13193. }
  13194. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13195. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13196. foreach (var item in cityArrCode)
  13197. {
  13198. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13199. if (find != null)
  13200. {
  13201. city += find.City + "/";
  13202. }
  13203. else
  13204. {
  13205. city += item + "三字码未收入/";
  13206. }
  13207. }
  13208. city = city.TrimEnd('/');
  13209. }
  13210. catch (Exception e)
  13211. {
  13212. city = "黑屏代码格式不正确!";
  13213. }
  13214. }
  13215. }
  13216. else
  13217. {
  13218. city = "未录入黑屏代码";
  13219. }
  13220. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13221. {
  13222. Date = x.Date,
  13223. Days = x.Days,
  13224. Diffgroup = x.Diffgroup,
  13225. Diid = x.Diid,
  13226. Traffic_First = x.Traffic_First,
  13227. Traffic_Second = x.Traffic_Second,
  13228. Trip = x.Trip,
  13229. WeekDay = x.WeekDay,
  13230. Id = x.Id
  13231. }).ToList();
  13232. jw.Data = new
  13233. {
  13234. groupList = groupList.Select(x => new
  13235. {
  13236. x.Id,
  13237. x.TeamName,
  13238. x.TourCode
  13239. }).ToList(),
  13240. groupInfo = new
  13241. {
  13242. group.VisitDays,
  13243. group.TourCode,
  13244. group.VisitPNumber,
  13245. group.TeamName,
  13246. city
  13247. },
  13248. OpTravelList
  13249. };
  13250. jw.Code = 200;
  13251. jw.Msg = "操作成功!";
  13252. return Ok(jw);
  13253. }
  13254. /// <summary>
  13255. /// 删除团组行程单
  13256. /// </summary>
  13257. /// <returns></returns>
  13258. [HttpPost]
  13259. public IActionResult DelTravel(DelOpTravelDto dto)
  13260. {
  13261. var jw = JsonView(false);
  13262. if (dto.UserId <= 0 || dto.Diid <= 0)
  13263. {
  13264. jw.Msg = "请输入正确的参数!";
  13265. return Ok(jw);
  13266. }
  13267. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13268. .SetColumns(x => new Grp_TravelList
  13269. {
  13270. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13271. DeleteUserId = dto.UserId,
  13272. IsDel = 1,
  13273. }).ExecuteCommand();
  13274. jw = JsonView(true);
  13275. return Ok(jw);
  13276. }
  13277. /// <summary>
  13278. /// 行程单保存
  13279. /// </summary>
  13280. /// <returns></returns>
  13281. [HttpPost]
  13282. public IActionResult TravelSave(TravelSaveDto dto)
  13283. {
  13284. var jw = JsonView(false);
  13285. if (dto.Arr.Count > 0)
  13286. {
  13287. try
  13288. {
  13289. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13290. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13291. .ToList();
  13292. _sqlSugar.BeginTran();
  13293. foreach (var item in dto.Arr)
  13294. {
  13295. if (item.Id == 0)
  13296. {
  13297. throw new Exception("请传入正确的Id");
  13298. }
  13299. //比较上一次的差异
  13300. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13301. if (findTravel != null)
  13302. {
  13303. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13304. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13305. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13306. }
  13307. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13308. .SetColumns(x => new Grp_TravelList
  13309. {
  13310. Trip = item.Trip
  13311. }).ExecuteCommand();
  13312. }
  13313. _sqlSugar.CommitTran();
  13314. jw = JsonView(true);
  13315. }
  13316. catch (Exception ex)
  13317. {
  13318. _sqlSugar.RollbackTran();
  13319. jw.Msg = "程序异常!" + ex.Message;
  13320. }
  13321. }
  13322. else
  13323. {
  13324. jw.Msg = "请传入正确的参数!";
  13325. }
  13326. return Ok(jw);
  13327. }
  13328. private string CheckStr(string original, string changed)
  13329. {
  13330. // 创建diff_match_patch对象
  13331. var dmp = new diff_match_patch();
  13332. // 计算差异
  13333. List<Diff> diffs = dmp.diff_main(original, changed);
  13334. // 清理和合并差异
  13335. dmp.diff_cleanupSemantic(diffs);
  13336. // 使用StringBuilder构建最终的字符串
  13337. StringBuilder finalString = new StringBuilder();
  13338. // 输出差异结果,并构建变动后的字符串
  13339. foreach (Diff diff in diffs)
  13340. {
  13341. switch (diff.operation)
  13342. {
  13343. case Operation.EQUAL:
  13344. // 相等的部分,直接添加到最终字符串
  13345. finalString.Append(diff.text);
  13346. break;
  13347. case Operation.INSERT:
  13348. // 插入的部分,添加标记并添加到最终字符串
  13349. finalString.Append("[++]" + diff.text + "[++]");
  13350. break;
  13351. case Operation.DELETE:
  13352. // 删除的部分,不添加到最终字符串
  13353. //finalString.Append("[++]" + diff.text + "[++]");
  13354. break;
  13355. }
  13356. }
  13357. // 输出变动后的字符串
  13358. return finalString.ToString();
  13359. }
  13360. private class tagContent
  13361. {
  13362. public DateTime Date { get; set; }
  13363. public string StartTag { get; set; }
  13364. public string EndTag { get; set; }
  13365. public string Content { get; set; }
  13366. public static int tagLength { get { return 3; } }
  13367. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13368. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13369. public bool IsFinally { get; set; }
  13370. }
  13371. private List<string> ExtractContentBetweenTags(string input, string tag)
  13372. {
  13373. List<string> results = new List<string>();
  13374. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13375. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13376. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13377. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13378. string[] strValueArr = new string[1];
  13379. foreach (System.Text.RegularExpressions.Match match in matches)
  13380. {
  13381. var strValue = match.Groups[1].Value;
  13382. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13383. }
  13384. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13385. return results;
  13386. }
  13387. /// <summary>
  13388. /// 导出行程单
  13389. /// </summary>
  13390. /// <param name="dto"></param>
  13391. /// <returns></returns>
  13392. [HttpPost]
  13393. public IActionResult ExportTravel(ExportTravelDto dto)
  13394. {
  13395. var jw = JsonView(false);
  13396. jw.Data = "";
  13397. int diid = 0;
  13398. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13399. if (Find == null)
  13400. {
  13401. jw.Msg = "请选择正确的团组!";
  13402. return Ok(jw);
  13403. }
  13404. else
  13405. {
  13406. diid = Find.Id;
  13407. }
  13408. //数据源
  13409. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13410. DataTable dtBlack = null;
  13411. try
  13412. {
  13413. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13414. }
  13415. catch (Exception)
  13416. {
  13417. jw.Msg = "机票黑屏代码有误!";
  13418. return Ok(jw);
  13419. }
  13420. string CityStr = string.Empty;
  13421. if (dtBlack.Rows.Count == 0)
  13422. {
  13423. jw.Msg = "机票黑屏代码有误!";
  13424. return Ok(jw);
  13425. }
  13426. else
  13427. {
  13428. foreach (DataRow row in dtBlack.Rows)
  13429. {
  13430. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13431. {
  13432. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13433. return Ok(jw);
  13434. }
  13435. }
  13436. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13437. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13438. }
  13439. // 指定的文字
  13440. var targetTextDic = new Dictionary<string, List<string>>();
  13441. //创建数据源Table
  13442. DataTable dtSource = new DataTable();
  13443. dtSource.Columns.Add("Days", typeof(string));
  13444. dtSource.Columns.Add("Date", typeof(string));
  13445. dtSource.Columns.Add("Week", typeof(string));
  13446. dtSource.Columns.Add("Traffic", typeof(string));
  13447. dtSource.Columns.Add("Trip", typeof(string));
  13448. //获取数据,放到datatable
  13449. foreach (var item in _travelList)
  13450. {
  13451. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13452. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13453. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13454. .Replace("[++]", string.Empty);
  13455. DataRow dr = dtSource.NewRow();
  13456. dr["Days"] = item.Days;
  13457. dr["Date"] = item.Date;
  13458. dr["Week"] = item.WeekDay;
  13459. dr["Traffic"] = item.Traffic_First
  13460. + "\r\n"
  13461. + item.Traffic_Second;
  13462. dr["Trip"] = item.Trip;
  13463. dtSource.Rows.Add(dr);
  13464. }
  13465. Dictionary<string, string> dic = new Dictionary<string, string>();
  13466. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13467. dic.Add("City", CityStr);
  13468. dic.Add("Days", Find.VisitDays.ToString());
  13469. dic.Add("DeleCode", Find.TourCode);
  13470. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13471. //模板路径
  13472. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13473. //载入模板
  13474. Document doc = null;
  13475. DocumentBuilder builder = null;
  13476. try
  13477. {
  13478. //载入模板
  13479. doc = new Document(tempPath);
  13480. builder = new DocumentBuilder(doc);
  13481. }
  13482. catch (Exception)
  13483. {
  13484. jw.Msg = "模板位置不存在!";
  13485. return Ok(jw);
  13486. }
  13487. foreach (var key in dic.Keys)
  13488. {
  13489. Bookmark bookmark = doc.Range.Bookmarks[key];
  13490. if (bookmark != null)
  13491. {
  13492. builder.MoveToBookmark(key);
  13493. builder.Write(dic[key]);
  13494. }
  13495. }
  13496. //获取word里所有表格
  13497. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13498. //获取所填表格的序数
  13499. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13500. try
  13501. {
  13502. //循环赋值
  13503. for (int i = 0; i < dtSource.Rows.Count; i++)
  13504. {
  13505. builder.MoveToCell(0, i + 1, 0, 0);
  13506. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13507. builder.MoveToCell(0, i + 1, 1, 0);
  13508. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13509. builder.MoveToCell(0, i + 1, 2, 0);
  13510. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13511. var trip = dtSource.Rows[i]["Trip"].ToString();
  13512. builder.MoveToCell(0, i + 1, 3, 0);
  13513. builder.Write(trip);
  13514. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13515. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13516. // 获取特定索引的段落
  13517. Paragraph paragraph = (Paragraph)paragraphs[0];
  13518. Run run = paragraph.Runs[0];
  13519. Aspose.Words.Font font = run.Font;
  13520. font.Name = "黑体";
  13521. //设置双休红色
  13522. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13523. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13524. paragraph = (Paragraph)paragraphs[1];
  13525. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13526. {
  13527. run = paragraph.Runs[0];
  13528. font = run.Font;
  13529. font.Color = Color.Red;
  13530. }
  13531. }
  13532. }
  13533. catch (Exception ex)
  13534. {
  13535. }
  13536. //删除多余行
  13537. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13538. {
  13539. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13540. }
  13541. var targetTextList = new List<string>();
  13542. // 遍历文档中的表格
  13543. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13544. {
  13545. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13546. {
  13547. var cellIndex = 0;
  13548. foreach (Cell cell in row.Cells)
  13549. {
  13550. if (cellIndex == 1 && row.Cells.Count == 4)
  13551. {
  13552. foreach (var target in targetTextDic.Keys)
  13553. {
  13554. if (cell.GetText().Contains(target))
  13555. {
  13556. targetTextList = targetTextDic[target];
  13557. break;
  13558. }
  13559. }
  13560. }
  13561. // 遍历单元格中的所有段落
  13562. foreach (Paragraph paragraph in cell.Paragraphs)
  13563. {
  13564. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13565. List<Run> runs = new List<Run>();
  13566. foreach (Run run in paragraph.Runs)
  13567. {
  13568. runs.Add(run);
  13569. }
  13570. foreach (Run run in runs)
  13571. {
  13572. foreach (var targetText in targetTextList)
  13573. {
  13574. // 检查文字是否包含指定文字
  13575. if (run.Text.Contains(targetText))
  13576. {
  13577. // 将包含的部分设置为红色
  13578. HighlightText(run, targetText, Color.Red);
  13579. }
  13580. }
  13581. }
  13582. }
  13583. cellIndex++;
  13584. }
  13585. }
  13586. }
  13587. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13588. if (!Directory.Exists(savePath))
  13589. {
  13590. try
  13591. {
  13592. Directory.CreateDirectory(savePath);
  13593. }
  13594. catch
  13595. {
  13596. }
  13597. }
  13598. string path = savePath + Find.TeamName + "出访日程";
  13599. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13600. try
  13601. {
  13602. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13603. string postfix = ".docx";
  13604. if (dto.IsPDF == 1)
  13605. {
  13606. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13607. postfix = ".pdf";
  13608. }
  13609. doc.Save(path + postfix, saveFormat);
  13610. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13611. }
  13612. catch (Exception)
  13613. {
  13614. jw = JsonView(false);
  13615. }
  13616. return Ok(jw);
  13617. }
  13618. /// <summary>
  13619. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13620. /// </summary>
  13621. /// <param name="num"></param>
  13622. /// <returns></returns>
  13623. string GetNum(string num)
  13624. {
  13625. string str = "";
  13626. switch (num)
  13627. {
  13628. case "1":
  13629. str = "一";
  13630. break;
  13631. case "2":
  13632. str = "二";
  13633. break;
  13634. case "3":
  13635. str = "三";
  13636. break;
  13637. case "4":
  13638. str = "四";
  13639. break;
  13640. case "5":
  13641. str = "五";
  13642. break;
  13643. case "6":
  13644. str = "六";
  13645. break;
  13646. case "7":
  13647. str = "七";
  13648. break;
  13649. case "8":
  13650. str = "八";
  13651. break;
  13652. case "9":
  13653. str = "九";
  13654. break;
  13655. case "10":
  13656. str = "十";
  13657. break;
  13658. case "11":
  13659. str = "十一";
  13660. break;
  13661. case "12":
  13662. str = "十二";
  13663. break;
  13664. case "一":
  13665. str = "1";
  13666. break;
  13667. case "二":
  13668. str = "2";
  13669. break;
  13670. case "三":
  13671. str = "3";
  13672. break;
  13673. case "四":
  13674. str = "4";
  13675. break;
  13676. case "五":
  13677. str = "5";
  13678. break;
  13679. case "六":
  13680. str = "6";
  13681. break;
  13682. case "七":
  13683. str = "7";
  13684. break;
  13685. case "八":
  13686. str = "8";
  13687. break;
  13688. case "九":
  13689. str = "9";
  13690. break;
  13691. case "十":
  13692. str = "10";
  13693. break;
  13694. case "十一":
  13695. str = "11";
  13696. break;
  13697. case "十二":
  13698. str = "12";
  13699. break;
  13700. }
  13701. return str;
  13702. }
  13703. // 高亮包含指定文字的部分
  13704. void HighlightText(Run run, string targetText, Color color)
  13705. {
  13706. string text = run.Text;
  13707. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13708. if (startIndex >= 0)
  13709. {
  13710. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13711. // 前部分
  13712. if (startIndex > 0)
  13713. {
  13714. Run beforeRun = (Run)run.Clone(true);
  13715. beforeRun.Text = text.Substring(0, startIndex);
  13716. parentParagraph.InsertBefore(beforeRun, run);
  13717. }
  13718. // 匹配部分
  13719. Run matchRun = (Run)run.Clone(true);
  13720. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13721. matchRun.Font.Color = color;
  13722. parentParagraph.InsertBefore(matchRun, run);
  13723. // 后部分
  13724. if (startIndex + targetText.Length < text.Length)
  13725. {
  13726. Run afterRun = (Run)run.Clone(true);
  13727. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13728. parentParagraph.InsertBefore(afterRun, run);
  13729. }
  13730. // 删除原始Run
  13731. run.Remove();
  13732. }
  13733. }
  13734. #endregion
  13735. #endregion
  13736. #region 团组成本
  13737. /// <summary>
  13738. /// 团组成本数据初始化
  13739. /// </summary>
  13740. /// <param name="dto"></param>
  13741. /// <returns></returns>
  13742. [HttpPost]
  13743. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13744. {
  13745. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13746. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13747. WHEN COUNT(*) >= 0 THEN 'True'
  13748. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13749. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13750. ").ToList(); //团组列表
  13751. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13752. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13753. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13754. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13755. if (groupinfoValue != null)
  13756. {
  13757. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13758. var spArr = new string[1] { countryArr };
  13759. if (countryArr.Contains("|"))
  13760. {
  13761. spArr = countryArr.Split("|");
  13762. }
  13763. else if (countryArr.Contains("、"))
  13764. {
  13765. spArr = countryArr.Split("、");
  13766. }
  13767. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13768. {
  13769. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13770. if (dbQueryCountry != null)
  13771. {
  13772. visaCountryInfoArr.Add(dbQueryCountry);
  13773. }
  13774. }
  13775. }
  13776. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13777. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13778. #region 屏蔽黑屏代码生成
  13779. //var create = _GroupCostRepository.
  13780. // CreateGroupCostByBlackCode(dto.Diid);
  13781. //if (groupCost.Count == 0 && create.Code == 0)
  13782. //{
  13783. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13784. //}
  13785. #endregion
  13786. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13787. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13788. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13789. groupCostMap = groupCostMap.Select(x =>
  13790. {
  13791. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13792. {
  13793. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13794. }
  13795. return x;
  13796. }).ToList();
  13797. //GroupCostParameter.Add(new
  13798. // Grp_GroupCostParameter());
  13799. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13800. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13801. return Ok(JsonView(new
  13802. {
  13803. groupList,
  13804. groupInfo,
  13805. groupChecks,
  13806. groupCost = groupCostMap,
  13807. hotelNumber,
  13808. GroupCostParameter = GroupCostParameterMap,
  13809. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13810. {
  13811. x.VisaCountry,
  13812. x.VisaPrice,
  13813. x.Id,
  13814. }).ToList(),
  13815. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13816. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  13817. hotelIsTrue = hotelIsTrue,
  13818. }));
  13819. }
  13820. /// <summary>
  13821. /// 团组成本信息保存
  13822. /// </summary>
  13823. /// <param name="dto"></param>
  13824. /// <returns></returns>
  13825. [HttpPost]
  13826. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13827. {
  13828. if (dto.Diid <= 0 || dto.Userid <= 0)
  13829. {
  13830. return Ok(JsonView(false));
  13831. }
  13832. JsonView jw = null;
  13833. bool isTrue = false;
  13834. #region 复制团组成本
  13835. //if (dto.Diid == 2581)
  13836. //{
  13837. // dto.Diid = 2599;
  13838. // dto.CheckBoxs.ForEach(x =>
  13839. // {
  13840. // x.Diid = 2599;
  13841. // });
  13842. // dto.GroupCosts.ForEach(x =>
  13843. // {
  13844. // x.Diid = 2599;
  13845. // });
  13846. // dto.CostTypeHotelNumbers.ForEach(x =>
  13847. // {
  13848. // x.Diid = 2599;
  13849. // });
  13850. // dto.GroupCostParameters.ForEach(x =>
  13851. // {
  13852. // x.DiId = 2599;
  13853. // });
  13854. //}
  13855. #endregion
  13856. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13857. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13858. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13859. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13860. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13861. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13862. try
  13863. {
  13864. _sqlSugar.BeginTran();
  13865. isTrue = await _GroupCostRepository.
  13866. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13867. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13868. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13869. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13870. _sqlSugar.CommitTran();
  13871. jw = JsonView(true, "保存成功!", isTrue);
  13872. }
  13873. catch (Exception)
  13874. {
  13875. _sqlSugar.RollbackTran();
  13876. jw = JsonView(false);
  13877. }
  13878. return Ok(jw);
  13879. }
  13880. /// <summary>
  13881. /// 司兼导数据
  13882. /// </summary>
  13883. /// <param name="dto"></param>
  13884. /// <returns></returns>
  13885. [HttpPost]
  13886. public IActionResult GetCarGuides(CarGuidesDto dto)
  13887. {
  13888. JsonView jw = null;
  13889. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13890. jw = JsonView(true, "获取成功!", Data);
  13891. return Ok(jw);
  13892. }
  13893. /// <summary>
  13894. /// 导游数据
  13895. /// </summary>
  13896. /// <param name="dto"></param>
  13897. /// <returns></returns>
  13898. [HttpPost]
  13899. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  13900. {
  13901. JsonView jw = null;
  13902. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  13903. // 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
  13904. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  13905. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  13906. jw = JsonView(true, "获取成功!", Data);
  13907. return Ok(jw);
  13908. }
  13909. /// <summary>
  13910. /// 成本车数据
  13911. /// </summary>
  13912. /// <param name="dto"></param>
  13913. /// <returns></returns>
  13914. [HttpPost]
  13915. public IActionResult GetCarInfo(CarGuidesDto dto)
  13916. {
  13917. JsonView jw = null;
  13918. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  13919. jw = JsonView(true, "获取成功!", Data);
  13920. return Ok(jw);
  13921. }
  13922. /// <summary>
  13923. /// 景点数据
  13924. /// </summary>
  13925. /// <param name="dto"></param>
  13926. /// <returns></returns>
  13927. [HttpPost]
  13928. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  13929. {
  13930. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  13931. return Ok(JsonView(true, "获取成功!", Data));
  13932. }
  13933. /// <summary>
  13934. /// 成本通知
  13935. /// </summary>
  13936. /// <param name="dto"></param>
  13937. /// <returns></returns>
  13938. [HttpPost]
  13939. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  13940. {
  13941. if (dto.Diid < 0)
  13942. {
  13943. return Ok(JsonView(false));
  13944. }
  13945. JsonView jw = null;
  13946. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  13947. if (GroupCostParameter != null)
  13948. {
  13949. int IsShare = 0;
  13950. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  13951. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  13952. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  13953. string msg = string.Empty;
  13954. if (isTrue)
  13955. {
  13956. if (IsShare == 0)
  13957. {
  13958. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  13959. }
  13960. else
  13961. {
  13962. #region 企微通知对应岗位用户
  13963. try
  13964. {
  13965. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  13966. }
  13967. catch (Exception ex)
  13968. {
  13969. }
  13970. #endregion
  13971. msg = "通知成功,其他模块操作人员可见此成本信息!";
  13972. }
  13973. jw = JsonView(isTrue, msg, new { IsShare });
  13974. }
  13975. else
  13976. {
  13977. msg = "修改失败!";
  13978. jw = JsonView(isTrue, msg);
  13979. }
  13980. }
  13981. else
  13982. {
  13983. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  13984. }
  13985. return Ok(jw);
  13986. }
  13987. /// <summary>
  13988. /// 导出报价单
  13989. /// </summary>
  13990. /// <param name="dto"></param>
  13991. /// <returns></returns>
  13992. [HttpPost]
  13993. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  13994. {
  13995. if (dto.Diid == 0)
  13996. {
  13997. return Ok(JsonView(false, "请传递团组id"));
  13998. }
  13999. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14000. if (deleInfo.Code != 0)
  14001. {
  14002. return Ok(JsonView(false, "团组信息查询失败!"));
  14003. }
  14004. var di = deleInfo.Data as DelegationInfoWebView;
  14005. if (di != null)
  14006. {
  14007. di.TeamName = di.TeamName.Replace("|", "、");
  14008. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14009. //文件名
  14010. string strFileName = di.TeamName + "-收款账单.doc";
  14011. //获取模板
  14012. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14013. //载入模板
  14014. Document doc = new Document(tmppath);
  14015. decimal TotalPrice = 0.00M;
  14016. string itemStr = string.Empty;
  14017. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14018. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14019. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14020. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14021. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14022. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14023. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14024. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14025. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14026. foreach (var cost in groupCostType)
  14027. {
  14028. var List = cost.ToList();
  14029. if (cost.Key == "A")
  14030. {
  14031. foreach (var ListItem in List)
  14032. {
  14033. if (ListItem.number > 0)
  14034. {
  14035. if (ListItem.code.Contains("TBR"))
  14036. {
  14037. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14038. }
  14039. else
  14040. {
  14041. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14042. }
  14043. TotalPrice += (ListItem.number * ListItem.price);
  14044. }
  14045. }
  14046. }
  14047. else
  14048. {
  14049. itemStr = itemStr.Insert(0, "A段\r\n");
  14050. itemStr += "B段\r\n";
  14051. foreach (var ListItem in List)
  14052. {
  14053. if (ListItem.number > 0)
  14054. {
  14055. if (ListItem.code.Contains("TBR"))
  14056. {
  14057. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14058. }
  14059. else
  14060. {
  14061. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14062. }
  14063. TotalPrice += (ListItem.number * ListItem.price);
  14064. }
  14065. }
  14066. }
  14067. }
  14068. #region 替换Word模板书签内容
  14069. Dictionary<string, string> marks = new Dictionary<string, string>();
  14070. marks.Add("To", di.ClientUnit);//付款方
  14071. marks.Add("ToTel", di.TellPhone);//付款方电话
  14072. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14073. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14074. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14075. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14076. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14077. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14078. marks.Add("PayItemContent", itemStr);//详细信息
  14079. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14080. #endregion
  14081. ////注
  14082. //if (doc.Range.Bookmarks["Attention"] != null)
  14083. //{
  14084. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14085. // mark.Text = frList[0].Attention;
  14086. //}
  14087. foreach (var item in marks.Keys)
  14088. {
  14089. if (doc.Range.Bookmarks[item] != null)
  14090. {
  14091. Bookmark mark = doc.Range.Bookmarks[item];
  14092. mark.Text = marks[item];
  14093. }
  14094. }
  14095. byte[] bytes = null;
  14096. using (MemoryStream stream = new MemoryStream())
  14097. {
  14098. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14099. bytes = stream.ToArray();
  14100. }
  14101. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14102. return Ok(JsonView(true, "", new
  14103. {
  14104. Data = bytes,
  14105. strFileName,
  14106. }));
  14107. }
  14108. else
  14109. {
  14110. return Ok(JsonView(false, "团组信息不存在!"));
  14111. }
  14112. }
  14113. /// <summary>
  14114. /// 导出团组成本
  14115. /// </summary>
  14116. /// <param name="dto"></param>
  14117. /// <returns></returns>
  14118. [HttpPost]
  14119. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14120. {
  14121. var jw = JsonView(false);
  14122. if (dto.Diid == 0)
  14123. {
  14124. return Ok(JsonView(false, "请传递团组id"));
  14125. }
  14126. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14127. if (deleInfo.Code != 0)
  14128. {
  14129. return Ok(JsonView(false, "团组信息查询失败!"));
  14130. }
  14131. var di = deleInfo.Data as DelegationInfoWebView;
  14132. if (di == null)
  14133. {
  14134. return Ok(JsonView(false, "团组信息查询失败!"));
  14135. }
  14136. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14137. WorkbookDesigner designer = new WorkbookDesigner();
  14138. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14139. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14140. for (int i = 0; i < List_GC.Count; i++)
  14141. {
  14142. GroupCost_Excel gc = new GroupCost_Excel();
  14143. gc.Id = List_GC[i].Id;
  14144. gc.Diid = List_GC[i].Diid.ToString();
  14145. gc.DAY = List_GC[i].DAY;
  14146. string week = "";
  14147. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14148. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14149. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14150. gc.ITIN = List_GC[i].ITIN;
  14151. gc.CarType = List_GC[i].CarType;
  14152. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14153. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14154. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14155. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14156. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14157. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14158. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14159. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14160. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14161. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14162. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14163. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14164. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14165. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14166. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14167. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14168. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14169. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14170. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14171. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14172. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14173. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14174. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14175. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14176. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14177. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14178. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14179. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14180. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14181. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14182. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14183. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14184. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14185. List_GC1.Add(gc);
  14186. }
  14187. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14188. dt.TableName = "TB";
  14189. //报表标题等不用dt的值
  14190. designer.SetDataSource("TeamName", dto.title.TeamName);
  14191. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14192. designer.SetDataSource("Tax", dto.title.Tax);
  14193. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14194. designer.SetDataSource("Currency", dto.title.Currency);
  14195. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14196. designer.SetDataSource("Rate", dto.title.Rate);
  14197. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14198. var Aparams = hotels.Find(x => x.Type == "Default");
  14199. if (Aparams == null)
  14200. {
  14201. return Ok(jw);
  14202. }
  14203. //酒店数量
  14204. var txtSGRNumber = Aparams.SGR.ToString();
  14205. var txtTBRNumber = Aparams.TBR.ToString();
  14206. var txtJSESNumber = Aparams.JSES.ToString();
  14207. var txtSUITENumbe = Aparams.SUITE.ToString();
  14208. if (dto.costType == "B")
  14209. {
  14210. Aparams = hotels.Find(x => x.Type == "A");
  14211. var Bparams = hotels.Find(x => x.Type == "B");
  14212. if (Aparams == null || Bparams == null)
  14213. {
  14214. return Ok(jw);
  14215. }
  14216. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14217. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14218. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14219. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14220. }
  14221. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14222. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14223. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14224. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14225. var ws = designer.Workbook.Worksheets[0];
  14226. int Row = List_GC.Count;
  14227. int startIndex = 11;
  14228. int HideRows = 0;
  14229. List<int> hideRowsList = new List<int>();
  14230. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14231. #region A段left数据
  14232. var left = dto.leftInfo.Find(x => x.Type == "A");
  14233. if (left == null)
  14234. {
  14235. return Ok(jw);
  14236. }
  14237. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14238. if (leftBindData != null)
  14239. {
  14240. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14241. designer.SetDataSource("VisaRS", leftBindData.rs);
  14242. designer.SetDataSource("VisaXS", leftBindData.xs);
  14243. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14244. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14245. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14246. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14247. designer.SetDataSource("VisaZLR", ((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("保险"));
  14256. if (leftBindData != null)
  14257. {
  14258. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14259. designer.SetDataSource("BXRS", leftBindData.rs);
  14260. designer.SetDataSource("BXXS", leftBindData.xs);
  14261. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14262. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14263. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14264. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14265. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14266. }
  14267. else
  14268. {
  14269. hideRowsList.Add(Row + startIndex + HideRows);
  14270. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14271. }
  14272. HideRows += 2;
  14273. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14274. if (leftBindData != null)
  14275. {
  14276. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14277. designer.SetDataSource("HSRS", leftBindData.rs);
  14278. designer.SetDataSource("HSXS", leftBindData.xs);
  14279. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14280. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14281. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14282. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14283. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14284. }
  14285. else
  14286. {
  14287. hideRowsList.Add(Row + startIndex + HideRows);
  14288. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14289. }
  14290. HideRows += 2;
  14291. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14292. if (leftBindData != null)
  14293. {
  14294. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14295. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14296. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14297. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14298. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14299. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14300. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14301. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14302. }
  14303. else
  14304. {
  14305. hideRowsList.Add(Row + startIndex + HideRows);
  14306. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14307. }
  14308. HideRows += 2;
  14309. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14310. if (leftBindData != null)
  14311. {
  14312. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14313. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14314. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14315. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14316. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14317. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14318. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14319. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14320. }
  14321. else
  14322. {
  14323. hideRowsList.Add(Row + startIndex + HideRows);
  14324. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14325. }
  14326. HideRows += 2;
  14327. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14328. if (leftBindData != null)
  14329. {
  14330. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14331. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14332. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14333. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14334. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14335. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14336. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14337. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14338. }
  14339. else
  14340. {
  14341. hideRowsList.Add(Row + startIndex + HideRows);
  14342. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14343. }
  14344. HideRows += 2;
  14345. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14346. if (leftBindData != null)
  14347. {
  14348. ////TBR
  14349. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14350. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14351. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14352. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14353. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14354. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14355. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14356. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14357. }
  14358. else
  14359. {
  14360. hideRowsList.Add(Row + startIndex + HideRows);
  14361. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14362. }
  14363. HideRows += 2;
  14364. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14365. if (leftBindData != null)
  14366. {
  14367. ////SGR
  14368. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14369. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14370. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14371. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14372. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14373. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14374. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14375. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14376. }
  14377. else
  14378. {
  14379. hideRowsList.Add(Row + startIndex + HideRows);
  14380. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14381. }
  14382. HideRows += 2;
  14383. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14384. if (leftBindData != null)
  14385. {
  14386. ////JS/ES
  14387. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14388. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14389. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14390. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14391. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14392. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14393. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14394. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14395. }
  14396. else
  14397. {
  14398. hideRowsList.Add(Row + startIndex + HideRows);
  14399. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14400. }
  14401. HideRows += 2;
  14402. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14403. if (leftBindData != null)
  14404. {
  14405. ////SUITE
  14406. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14407. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14408. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14409. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14410. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14411. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14412. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14413. designer.SetDataSource("HotelSUITEZLR", ((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. HideRows += 2;
  14421. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14422. if (leftBindData != null)
  14423. {
  14424. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14425. designer.SetDataSource("DJRS", leftBindData.rs);
  14426. designer.SetDataSource("DJXS", leftBindData.xs);
  14427. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14428. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14429. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14430. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14431. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14432. }
  14433. else
  14434. {
  14435. hideRowsList.Add(Row + startIndex + HideRows);
  14436. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14437. }
  14438. HideRows += 2;
  14439. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14440. if (leftBindData != null)
  14441. {
  14442. designer.SetDataSource("HCPCB", leftBindData.cb);
  14443. designer.SetDataSource("HCPRS", leftBindData.rs);
  14444. designer.SetDataSource("HCPXS", leftBindData.xs);
  14445. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14446. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14447. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14448. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14449. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14450. }
  14451. else
  14452. {
  14453. hideRowsList.Add(Row + startIndex + HideRows);
  14454. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14455. }
  14456. HideRows += 2;
  14457. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14458. if (leftBindData != null)
  14459. {
  14460. designer.SetDataSource("CPCB", leftBindData.cb);
  14461. designer.SetDataSource("CPRS", leftBindData.rs);
  14462. designer.SetDataSource("CPXS", leftBindData.xs);
  14463. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14464. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14465. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14466. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14467. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14468. }
  14469. else
  14470. {
  14471. hideRowsList.Add(Row + startIndex + HideRows);
  14472. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14473. }
  14474. HideRows += 2;
  14475. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14476. if (leftBindData != null)
  14477. {
  14478. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14479. designer.SetDataSource("GWRS", leftBindData.rs);
  14480. designer.SetDataSource("GWXS", leftBindData.xs);
  14481. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14482. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14483. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14484. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14485. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14486. }
  14487. else
  14488. {
  14489. hideRowsList.Add(Row + startIndex + HideRows);
  14490. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14491. }
  14492. HideRows += 2;
  14493. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14494. if (leftBindData != null)
  14495. {
  14496. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14497. designer.SetDataSource("LYJRS", leftBindData.rs);
  14498. designer.SetDataSource("LYJXS", leftBindData.xs);
  14499. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14500. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14501. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14502. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14503. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14504. }
  14505. else
  14506. {
  14507. hideRowsList.Add(Row + startIndex + HideRows);
  14508. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14509. }
  14510. #endregion
  14511. #region A段Right信息
  14512. var right = dto.rightInfo.Find(x => x.Type == "A");
  14513. if (right == null)
  14514. {
  14515. return Ok(jw);
  14516. }
  14517. HideRows += 4;
  14518. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14519. if (rightBindData != null)
  14520. {
  14521. //经济舱 + 双人间 TBR
  14522. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14523. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14524. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14525. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14526. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14527. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14528. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14529. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14530. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14531. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14532. }
  14533. else
  14534. {
  14535. hideRowsList.Add(Row + startIndex + HideRows);
  14536. }
  14537. HideRows += 2;
  14538. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14539. if (rightBindData != null)
  14540. {
  14541. //经济舱 + 单人间 SGR
  14542. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14543. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14544. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14545. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14546. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14547. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14548. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14549. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14550. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14551. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14552. }
  14553. else
  14554. {
  14555. hideRowsList.Add(Row + startIndex + HideRows);
  14556. }
  14557. HideRows += 2;
  14558. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14559. if (rightBindData != null)
  14560. {
  14561. //公务舱 + 单人间 SGR
  14562. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14563. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14564. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14565. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14566. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14567. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14568. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14569. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14570. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14571. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14572. }
  14573. else
  14574. {
  14575. hideRowsList.Add(Row + startIndex + HideRows);
  14576. }
  14577. HideRows += 2;
  14578. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14579. if (rightBindData != null)
  14580. {
  14581. //公务舱 + 小套房 JSES
  14582. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14583. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14584. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14585. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14586. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14587. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14588. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14589. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14590. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14591. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14592. }
  14593. else
  14594. {
  14595. hideRowsList.Add(Row + startIndex + HideRows);
  14596. }
  14597. HideRows += 2;
  14598. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14599. if (rightBindData != null)
  14600. {
  14601. //公务舱 + 小套房 JSES
  14602. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14603. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14604. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14605. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14606. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14607. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14608. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14609. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14610. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14611. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14612. }
  14613. else
  14614. {
  14615. hideRowsList.Add(Row + startIndex + HideRows);
  14616. }
  14617. HideRows += 2;
  14618. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14619. if (rightBindData != null)
  14620. {
  14621. //经济舱 + 大套房
  14622. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14623. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14624. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14625. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14626. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14627. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14628. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14629. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14630. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14631. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14632. }
  14633. else
  14634. {
  14635. hideRowsList.Add(Row + startIndex + HideRows);
  14636. }
  14637. HideRows += 2;
  14638. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14639. if (rightBindData != null)
  14640. {
  14641. //头等舱 + 小套房 JSES
  14642. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14643. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14644. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14645. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14646. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14647. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14648. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14649. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14650. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14651. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14652. }
  14653. else
  14654. {
  14655. hideRowsList.Add(Row + startIndex + HideRows);
  14656. }
  14657. HideRows += 2;
  14658. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14659. if (rightBindData != null)
  14660. {
  14661. //头等舱 + 大套房
  14662. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14663. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14664. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14665. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14666. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14667. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14668. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14669. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14670. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14671. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14672. }
  14673. else
  14674. {
  14675. hideRowsList.Add(Row + startIndex + HideRows);
  14676. }
  14677. #endregion
  14678. #region B段标题清空
  14679. designer.SetDataSource("CostBDRCB", "");
  14680. designer.SetDataSource("CostBRS", "");
  14681. designer.SetDataSource("CostBXS", "");
  14682. designer.SetDataSource("CostBZCB", "");
  14683. designer.SetDataSource("CostBDRBJ", "");
  14684. designer.SetDataSource("CostBZBJ", "");
  14685. designer.SetDataSource("CostBDRLR", "");
  14686. designer.SetDataSource("CostBZLR", "");
  14687. designer.SetDataSource("CostBDRCBOM", "");
  14688. designer.SetDataSource("CostBRSOM", "");
  14689. designer.SetDataSource("CostBZCBOM", "");
  14690. designer.SetDataSource("CostBDRBJOM", "");
  14691. designer.SetDataSource("CostBZBJOM", "");
  14692. designer.SetDataSource("CostBDRLROM", "");
  14693. designer.SetDataSource("CostBZLROM", "");
  14694. #endregion
  14695. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14696. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14697. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14698. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14699. designer.SetDataSource("DJName", "地接(CNY)");
  14700. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14701. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14702. designer.SetDataSource("GWName", "公务(CNY)");
  14703. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14704. designer.SetDataSource("LYJName", "零用金(CNY)");
  14705. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14706. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14707. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14708. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14709. designer.SetDataSource("BXName", "保险(CNY)");
  14710. designer.SetDataSource("VisaName", "签证(CNY)");
  14711. #region B段基本数据
  14712. if (dto.costType == "B")
  14713. {
  14714. left = dto.leftInfo.Find(x => x.Type == "B");
  14715. if (left == null)
  14716. {
  14717. return Ok(jw);
  14718. }
  14719. #region B段left数据
  14720. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14721. if (leftBindData != null)
  14722. {
  14723. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14724. designer.SetDataSource("BHSRS", leftBindData.rs);
  14725. designer.SetDataSource("BHSXS", leftBindData.xs);
  14726. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14727. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14728. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14729. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14730. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14731. }
  14732. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14733. if (leftBindData != null)
  14734. {
  14735. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14736. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14737. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14738. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14739. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14740. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14741. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14742. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14743. }
  14744. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14745. if (leftBindData != null)
  14746. {
  14747. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14748. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14749. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14750. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14751. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14752. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14753. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14754. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14755. }
  14756. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14757. if (leftBindData != null)
  14758. {
  14759. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14760. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14761. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14762. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14763. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14764. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14765. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14766. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14767. }
  14768. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14769. if (leftBindData != null)
  14770. {
  14771. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14772. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14773. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14774. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14775. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14776. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14777. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14778. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14779. }
  14780. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14781. if (leftBindData != null)
  14782. {
  14783. designer.SetDataSource("BCPCB", leftBindData.cb);
  14784. designer.SetDataSource("BCPRS", leftBindData.rs);
  14785. designer.SetDataSource("BCPXS", leftBindData.xs);
  14786. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14787. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14788. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14789. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14790. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14791. }
  14792. //TBR
  14793. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14794. if (leftBindData != null)
  14795. {
  14796. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14797. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14798. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14799. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14800. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14801. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14802. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14803. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14804. }
  14805. //SGR
  14806. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14807. if (leftBindData != null)
  14808. {
  14809. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  14810. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  14811. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  14812. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14813. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14814. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14815. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14816. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14817. }
  14818. //JS/ES
  14819. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14820. if (leftBindData != null)
  14821. {
  14822. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  14823. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14824. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14825. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14826. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14827. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14828. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14829. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14830. }
  14831. //SUITE
  14832. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14833. if (leftBindData != null)
  14834. {
  14835. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14836. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14837. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14838. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14839. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14840. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14841. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14842. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14843. }
  14844. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14845. if (leftBindData != null)
  14846. {
  14847. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14848. designer.SetDataSource("BDJRS", leftBindData.rs);
  14849. designer.SetDataSource("BDJXS", leftBindData.xs);
  14850. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14851. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14852. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14853. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14854. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14855. }
  14856. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14857. if (leftBindData != null)
  14858. {
  14859. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14860. designer.SetDataSource("BGWRS", leftBindData.rs);
  14861. designer.SetDataSource("BGWXS", leftBindData.xs);
  14862. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14863. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14864. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14865. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14866. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14867. }
  14868. #region 优化方案
  14869. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14870. //excelBind.Add("零用金", new {
  14871. //cb="",
  14872. //rs="",
  14873. //xs ="",
  14874. //zcb = "",
  14875. //});
  14876. #endregion
  14877. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14878. if (leftBindData != null)
  14879. {
  14880. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14881. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14882. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14883. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14884. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14885. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14886. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14887. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14888. }
  14889. #endregion
  14890. #region B段Right信息
  14891. right = dto.rightInfo.Find(x => x.Type == "B");
  14892. if (right == null)
  14893. {
  14894. return Ok(jw);
  14895. }
  14896. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14897. if (rightBindData != null)
  14898. {
  14899. //经济舱 + 双人间 TBR
  14900. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  14901. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  14902. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14903. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  14904. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14905. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14906. designer.SetDataSource("BlblJJCTBRZLR", (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("经济舱 SGR"));
  14912. if (rightBindData != null)
  14913. {
  14914. //经济舱 + 单人间 SGR
  14915. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  14916. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  14917. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14918. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  14919. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14920. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14921. designer.SetDataSource("BlblJJCSGRZLR", (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. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14927. if (rightBindData != null)
  14928. {
  14929. //公务舱 + 单人间 SGR
  14930. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  14931. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  14932. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14933. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  14934. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14935. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14936. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14937. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14938. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14939. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14940. }
  14941. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14942. if (rightBindData != null)
  14943. {
  14944. //公务舱 + 小套房 JSES
  14945. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  14946. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  14947. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14948. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  14949. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14950. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14951. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14952. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14953. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14954. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14955. }
  14956. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14957. if (rightBindData != null)
  14958. {
  14959. //公务舱 + 小套房 JSES
  14960. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  14961. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  14962. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14963. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  14964. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14965. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14966. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14967. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14968. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14969. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14970. }
  14971. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14972. if (rightBindData != null)
  14973. {
  14974. //经济舱 + 大套房
  14975. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  14976. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  14977. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14978. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  14979. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14980. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14981. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14982. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14983. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14984. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14985. }
  14986. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14987. if (rightBindData != null)
  14988. {
  14989. //头等舱 + 小套房 JSES
  14990. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  14991. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  14992. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14993. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  14994. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14995. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14996. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14997. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14998. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14999. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15000. }
  15001. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15002. if (rightBindData != null)
  15003. {
  15004. //头等舱 + 大套房
  15005. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15006. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15007. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15008. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15009. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15010. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15011. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15012. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15013. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15014. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15015. }
  15016. #endregion
  15017. #region 标题
  15018. designer.SetDataSource("CostBDRCB", "单人成本");
  15019. designer.SetDataSource("CostBRS", "人数");
  15020. designer.SetDataSource("CostBXS", "系数");
  15021. designer.SetDataSource("CostBZCB", "总成本");
  15022. designer.SetDataSource("CostBDRBJ", "单人报价");
  15023. designer.SetDataSource("CostBZBJ", "总报价");
  15024. designer.SetDataSource("CostBDRLR", "单人利润");
  15025. designer.SetDataSource("CostBZLR", "总利润");
  15026. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15027. designer.SetDataSource("CostBRSOM", "人数");
  15028. designer.SetDataSource("CostBZCBOM", "总成本");
  15029. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15030. designer.SetDataSource("CostBZBJOM", "总报价");
  15031. designer.SetDataSource("CostBDRLROM", "单人利润");
  15032. designer.SetDataSource("CostBZLROM", "总利润");
  15033. #endregion
  15034. }
  15035. #endregion
  15036. designer.SetDataSource("TzZCB2", TzZCB2);
  15037. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15038. designer.SetDataSource("TzZLR2", TzZLR2);
  15039. string[] dataSourceKeys = new string[]
  15040. {
  15041. "VF",
  15042. "TGS",
  15043. "TGOF",
  15044. "TGM",
  15045. "TGA",
  15046. "TGTF",
  15047. "TGEF",
  15048. "CFM",
  15049. "CFOF",
  15050. "B",
  15051. "L",
  15052. "D",
  15053. "TBR",
  15054. "SGR",
  15055. "JSES",
  15056. "Suite",
  15057. "TV",
  15058. "1L",
  15059. "IF",
  15060. "EF",
  15061. "BRF",
  15062. "TE",
  15063. "TGT",
  15064. "DRVT",
  15065. "PC",
  15066. "TLF",
  15067. "ECT"
  15068. };
  15069. foreach (var item in dataSourceKeys)
  15070. {
  15071. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15072. if (find != null)
  15073. {
  15074. designer.SetDataSource(item, find.text);
  15075. }
  15076. else
  15077. {
  15078. designer.SetDataSource(item, 0);
  15079. }
  15080. }
  15081. designer.SetDataSource(dt);
  15082. //根据数据源处理生成报表内容
  15083. designer.Process();
  15084. designer.Workbook.Worksheets[0].Name = "清单";
  15085. Worksheet sheet = designer.Workbook.Worksheets[0];
  15086. foreach (var Rowindex in hideRowsList)
  15087. {
  15088. ws.Cells.HideRows(Rowindex, 2);
  15089. }
  15090. byte[] bytes = null;
  15091. string strFileName = di.TeamName + "-团组-成本.xls";
  15092. using (MemoryStream stream = new MemoryStream())
  15093. {
  15094. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15095. bytes = stream.ToArray();
  15096. }
  15097. return Ok(JsonView(true, "", new
  15098. {
  15099. Data = bytes,
  15100. strFileName,
  15101. }));
  15102. }
  15103. /// <summary>
  15104. /// 导出客户报表
  15105. /// </summary>
  15106. /// <returns></returns>
  15107. [HttpPost]
  15108. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15109. {
  15110. var jw = JsonView(false);
  15111. if (dto.Diid == 0)
  15112. {
  15113. return Ok(JsonView(false, "请传递团组id"));
  15114. }
  15115. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15116. if (deleInfo.Code != 0)
  15117. {
  15118. return Ok(JsonView(false, "团组信息查询失败!"));
  15119. }
  15120. var di = deleInfo.Data as DelegationInfoWebView;
  15121. if (di == null)
  15122. {
  15123. return Ok(JsonView(false, "团组信息查询失败!"));
  15124. }
  15125. //文件名
  15126. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15127. //获取模板
  15128. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15129. //载入模板
  15130. Document doc = new Document(tmppath);
  15131. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15132. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15133. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15134. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15135. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15136. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15137. if (AParameter == null)
  15138. {
  15139. return Ok(JsonView(false, "系数不存在!"));
  15140. }
  15141. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15142. , TzAirDesc, TzZCost;
  15143. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15144. = TzAirDesc = TzZCost = string.Empty;
  15145. TzNumber = AParameter.CostTypenumber.ToString();
  15146. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15147. CarGuides1 = dto.CarGuides1;
  15148. Meal = dto.Meal;
  15149. SubsidizedMeals = dto.SubsidizedMeals;
  15150. NightRepair = dto.NightRepair;
  15151. AttractionsTickets = dto.AttractionsTickets;
  15152. MiscellaneousFees = dto.MiscellaneousFees;
  15153. ATip = dto.ATip;
  15154. TzHotelDesc = "";
  15155. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15156. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15157. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15158. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15159. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15160. TzAirDesc = "";
  15161. TzZCost = dto.TzZCost;
  15162. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15163. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15164. var index = 1;
  15165. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15166. foreach (var item in TzHotelDescArr)
  15167. {
  15168. if (AinfoArr != null)
  15169. {
  15170. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15171. if (Ainfo != null)
  15172. {
  15173. if (int.Parse(Ainfo.rs) <= 0)
  15174. {
  15175. continue;
  15176. }
  15177. var hotelText = string.Empty;
  15178. switch (item)
  15179. {
  15180. case "SGR":
  15181. hotelText = "单人间";
  15182. break;
  15183. case "JSES":
  15184. hotelText = "小套房";
  15185. break;
  15186. case "SUITE":
  15187. hotelText = "套房";
  15188. break;
  15189. case "TBR":
  15190. hotelText = "双人间";
  15191. break;
  15192. }
  15193. if (item != "TBR")
  15194. {
  15195. 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";
  15196. }
  15197. else
  15198. {
  15199. 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";
  15200. }
  15201. index++;
  15202. }
  15203. }
  15204. }
  15205. index = 1;
  15206. foreach (var item in TzAirDescArr)
  15207. {
  15208. if (AinfoArr != null)
  15209. {
  15210. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15211. if (Ainfo != null)
  15212. {
  15213. if (int.Parse(Ainfo.rs) <= 0)
  15214. {
  15215. continue;
  15216. }
  15217. 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";
  15218. index++;
  15219. }
  15220. }
  15221. }
  15222. if (dto.costType == "B")
  15223. {
  15224. if (BParameter == null)
  15225. {
  15226. return Ok(JsonView(false, "B段系数不存在!"));
  15227. }
  15228. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15229. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15230. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15231. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15232. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15233. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15234. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15235. foreach (var item in TzHotelDescArr)
  15236. {
  15237. if (AinfoArr != null)
  15238. {
  15239. TzHotelDesc += "B段信息 \r\n";
  15240. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15241. if (Ainfo != null)
  15242. {
  15243. if (int.Parse(Ainfo.rs) <= 0)
  15244. {
  15245. continue;
  15246. }
  15247. var hotelText = string.Empty;
  15248. switch (item)
  15249. {
  15250. case "SGR":
  15251. hotelText = "单人间";
  15252. break;
  15253. case "JSES":
  15254. hotelText = "小套房";
  15255. break;
  15256. case "SUITE":
  15257. hotelText = "套房";
  15258. break;
  15259. case "TBR":
  15260. hotelText = "双人间";
  15261. break;
  15262. }
  15263. if (item != "TBR")
  15264. {
  15265. 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";
  15266. }
  15267. else
  15268. {
  15269. 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";
  15270. }
  15271. index++;
  15272. }
  15273. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15274. }
  15275. }
  15276. index = 1;
  15277. foreach (var item in TzAirDescArr)
  15278. {
  15279. if (AinfoArr != null)
  15280. {
  15281. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15282. if (Ainfo != null)
  15283. {
  15284. if (int.Parse(Ainfo.rs) <= 0)
  15285. {
  15286. continue;
  15287. }
  15288. 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";
  15289. index++;
  15290. }
  15291. }
  15292. }
  15293. }
  15294. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15295. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15296. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15297. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15298. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15299. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15300. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15301. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15302. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15303. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15304. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15305. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15306. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15307. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15308. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15309. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15310. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15311. DickeyValue.Add("TzZCost", TzZCost);
  15312. foreach (var key in DickeyValue.Keys)
  15313. {
  15314. if (doc.Range.Bookmarks[key] != null)
  15315. {
  15316. Bookmark mark = doc.Range.Bookmarks[key];
  15317. mark.Text = DickeyValue[key];
  15318. }
  15319. }
  15320. byte[] bytes = null;
  15321. string strFileName = di.TeamName + "-客户报价.doc";
  15322. using (MemoryStream stream = new MemoryStream())
  15323. {
  15324. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15325. bytes = stream.ToArray();
  15326. }
  15327. return Ok(JsonView(true, "", new
  15328. {
  15329. Data = bytes,
  15330. strFileName,
  15331. }));
  15332. }
  15333. /// <summary>
  15334. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15335. /// </summary>
  15336. /// <param name="dto"></param>
  15337. /// <returns></returns>
  15338. [HttpPost]
  15339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15340. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15341. {
  15342. try
  15343. {
  15344. #region 参数验证
  15345. if (dto.DiId < 0)
  15346. {
  15347. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15348. }
  15349. List<int> cTableIds = new List<int>() {
  15350. 76 ,//酒店预订
  15351. 77 ,//行程
  15352. 79 ,//车/导游地接
  15353. 80 ,//签证
  15354. 81 ,//邀请/公务活
  15355. 82 ,//团组客户保险
  15356. 85 ,//机票预订
  15357. 98 ,//其他款项
  15358. 285 ,//收款退还
  15359. 751 ,//酒店早餐
  15360. 1015 // 超支费用
  15361. };
  15362. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15363. {
  15364. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15365. }
  15366. #endregion
  15367. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15368. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15369. if (_GroupCostParameters.Count <= 0)
  15370. {
  15371. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15372. }
  15373. if (_GroupCostParameters[0].IsShare == 0)
  15374. {
  15375. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15376. }
  15377. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15378. //处理date为空问题
  15379. if (_GroupCosts.Count > 0)
  15380. {
  15381. for (int i = 0; i < _GroupCosts.Count; i++)
  15382. {
  15383. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15384. {
  15385. if (i > 0)
  15386. {
  15387. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15388. }
  15389. }
  15390. }
  15391. }
  15392. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15393. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15394. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15395. string currCode = "";
  15396. #region currCode 验证
  15397. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15398. if (isInt)
  15399. {
  15400. var currData = currDatas.Find(it => it.Id == intCurrency);
  15401. if (currData != null)
  15402. {
  15403. currCode = currData.Name;
  15404. }
  15405. }
  15406. else
  15407. {
  15408. currCode = _GroupCostParameters[0].Currency.Trim();
  15409. }
  15410. #endregion
  15411. //op,酒店单段模式存储
  15412. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15413. {
  15414. CurrencyCode = currCode,
  15415. Rate = _GroupCostParameters[0].Rate,
  15416. CostType = _GroupCostParameters[0].CostType,
  15417. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15418. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15419. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15420. };
  15421. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15422. if (_GroupCostParameters.Count == 2)
  15423. {
  15424. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15425. }
  15426. foreach (var item in _GroupCostParameters)
  15427. {
  15428. decimal _rate = 1;
  15429. decimal _rate1 = item.Rate;
  15430. decimal _scale = 1;
  15431. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15432. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15433. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15434. //if (userInfo != null)
  15435. //{
  15436. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15437. // {
  15438. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15439. // {
  15440. // _scale = 1.00M;
  15441. // }
  15442. // }
  15443. //}
  15444. #endregion
  15445. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15446. {
  15447. CurrencyCode = currCode,
  15448. Rate = _rate1,
  15449. CostType = item.CostType,
  15450. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15451. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15452. CostTypeNumber = item.CostTypenumber
  15453. };
  15454. if (_GroupCostParameters.Count > 1)
  15455. {
  15456. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15457. }
  15458. else
  15459. {
  15460. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15461. }
  15462. if (dto.CTable == 79)//
  15463. {
  15464. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15465. modulePromptInfo.TotalCost = item.DJCB;
  15466. }
  15467. List<string> costTypes = new List<string>() { "A", "B" };
  15468. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15469. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15470. if (_GroupCostsDuplicates.Count() == 1)
  15471. {
  15472. _GroupCostsTypeData = _GroupCosts;
  15473. }
  15474. else
  15475. {
  15476. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15477. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15478. }
  15479. /*
  15480. * 76 酒店预订
  15481. * 77 行程
  15482. * 79 车/导游地接
  15483. * 80 签证
  15484. * 81 邀请/公务活动
  15485. * 82 团组客户保险
  15486. * 85 机票预订
  15487. * 98 其他款项
  15488. * 285 收款退还
  15489. * 751 酒店早餐
  15490. * 1015 超支费用
  15491. */
  15492. switch (dto.CTable)
  15493. {
  15494. case 76: // 酒店预订
  15495. _ModuleSubPromptInfo.AddRange(
  15496. _GroupCostsTypeData.Select(it => new
  15497. {
  15498. it.DAY,
  15499. it.Date,
  15500. it.ACCON,
  15501. it.ITIN,
  15502. it.SGR,
  15503. it.TBR,
  15504. it.JS_ES,
  15505. it.Suite
  15506. })
  15507. );
  15508. break;
  15509. case 79: // 车/导游地接
  15510. _ModuleSubPromptInfo.AddRange(
  15511. _GroupCostsTypeData.Select(it => new
  15512. {
  15513. Date = it.Date, //日期
  15514. CarFee = it.CarCost * _rate * _scale, //车费用
  15515. CarType = it.CarType, //车型
  15516. DriverFee = it.CFS * _rate * _scale, //司机工资
  15517. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15518. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15519. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15520. GuideFee = it.TGS * _rate * _scale, //导游费用
  15521. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15522. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15523. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15524. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15525. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15526. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15527. Breakfast = it.B * _rate * _scale, //早餐费
  15528. Lunch = it.L * _rate * _scale, //午餐费
  15529. Dinner = it.D * _rate * _scale, //晚餐费
  15530. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15531. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15532. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15533. TicketFee = it.EF * _rate * _scale, //门票费
  15534. TicketRemark = it.EFR, //门票费描述
  15535. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15536. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15537. SpentCash = it.PC * _rate * _scale, //零用金
  15538. LeadersFee = it.TLF * _rate * _scale, //领队费
  15539. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15540. })
  15541. );
  15542. break;
  15543. case 85: // 机票
  15544. List<dynamic> datas = new List<dynamic>();
  15545. datas.Add(
  15546. new
  15547. {
  15548. AirType = "经济舱",
  15549. AirNum = item.JJCRS,
  15550. AirDRCB = item.JJCCB,
  15551. AirZCB = (item.JJCRS * item.JJCCB)
  15552. }
  15553. );
  15554. datas.Add(
  15555. new
  15556. {
  15557. AirType = "公务舱",
  15558. AirNum = item.GWCRS,
  15559. AirDRCB = item.GWCCB,
  15560. AirZCB = (item.GWCRS * item.GWCCB)
  15561. }
  15562. );
  15563. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15564. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15565. modulePromptInfo.Data = new
  15566. {
  15567. airFeeData = datas,
  15568. airInitData = initDatas
  15569. };
  15570. _ModulePromptInfos.Add(modulePromptInfo);
  15571. break;
  15572. default:
  15573. break;
  15574. }
  15575. }
  15576. if (dto.CTable != 85)
  15577. {
  15578. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15579. _ModulePromptInfos.Add(_ModulePromptInfo);
  15580. }
  15581. _view.ModulePromptInfos = _ModulePromptInfos;
  15582. return Ok(JsonView(true, "操作成功!", _view));
  15583. }
  15584. catch (Exception ex)
  15585. {
  15586. return Ok(JsonView(false, ex.Message));
  15587. }
  15588. }
  15589. /// <summary>
  15590. /// 根据黑屏代码重新生成行程
  15591. /// </summary>
  15592. /// <param name="dto"></param>
  15593. /// <returns></returns>
  15594. [HttpPost]
  15595. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15596. {
  15597. var jw = JsonView(false,"Error");
  15598. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15599. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15600. .Select(x=> new
  15601. {
  15602. x.Id,
  15603. x.Title
  15604. })
  15605. .ToList();
  15606. if (Create.Any())
  15607. {
  15608. jw.Msg = "获取成功!";
  15609. jw.Code = 200;
  15610. jw.Data = new
  15611. {
  15612. BlackCodeListSelect = Create,
  15613. blackCodeIsTrue = true
  15614. };
  15615. }
  15616. else
  15617. {
  15618. jw.Code = 400;
  15619. jw.Data = new
  15620. {
  15621. BlackCodeListSelect = Create,
  15622. blackCodeIsTrue = false,
  15623. };
  15624. }
  15625. return Ok(jw);
  15626. }
  15627. /// <summary>
  15628. /// 根据黑屏代码Id重新生成行程
  15629. /// </summary>
  15630. /// <param name="dto"></param>
  15631. /// <returns></returns>
  15632. [HttpPost]
  15633. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15634. {
  15635. var jw = JsonView(false, "Error");
  15636. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15637. if (result.Code == 0)
  15638. {
  15639. jw.Msg = "获取成功!";
  15640. jw.Code = 200;
  15641. jw.Data = new
  15642. {
  15643. groupCost = result.Data,
  15644. blackCodeIsTrue = true
  15645. };
  15646. }
  15647. else
  15648. {
  15649. jw.Code = 400;
  15650. jw.Data = new
  15651. {
  15652. groupCost = result.Data,
  15653. blackCodeIsTrue = false,
  15654. };
  15655. }
  15656. return Ok(jw);
  15657. }
  15658. /// <summary>
  15659. /// 成本获取OP历史车费用
  15660. /// </summary>
  15661. /// <param name="dto"></param>
  15662. /// <returns></returns>
  15663. [HttpPost]
  15664. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15665. {
  15666. var jw = JsonView(false);
  15667. try
  15668. {
  15669. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15670. //获取现有所有车的数据
  15671. if (!dto.Param.IsNullOrWhiteSpace())
  15672. {
  15673. string sql = $@"
  15674. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15675. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15676. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15677. 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
  15678. AND gctggr.ServiceEndTime is not NULL
  15679. ORDER by gctggrc.id DESC
  15680. ";
  15681. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15682. var numeberResult = await Task.Run(() =>
  15683. {
  15684. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15685. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15686. return numberArr;
  15687. });
  15688. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15689. foreach (var item in numeberResult)
  15690. {
  15691. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15692. {
  15693. Country = "数据异常!",
  15694. City = string.Empty,
  15695. };
  15696. item.Area = find.Country + " " + find.City;
  15697. }
  15698. dbResult.AddRange(numeberResult);
  15699. if (dto.Param.Contains("、"))
  15700. {
  15701. var sp = dto.Param.Split("、");
  15702. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15703. .Where(x =>
  15704. {
  15705. return System.Array.Exists(sp, e =>
  15706. {
  15707. bool where = false;
  15708. if (x.Area != null)
  15709. {
  15710. where = x.Area.Contains(e);
  15711. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15712. {
  15713. return false;
  15714. }
  15715. }
  15716. if (x.PriceName != null && !where)
  15717. {
  15718. where = x.PriceName.Contains(e);
  15719. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15720. {
  15721. return false;
  15722. }
  15723. }
  15724. return where;
  15725. });
  15726. }).ToList();
  15727. }
  15728. else
  15729. {
  15730. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15731. .Where(x =>
  15732. {
  15733. bool where = false;
  15734. if (x.Area != null)
  15735. {
  15736. where = x.Area.Contains(dto.Param);
  15737. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15738. {
  15739. return false;
  15740. }
  15741. }
  15742. if (x.PriceName != null && !where)
  15743. {
  15744. where = x.PriceName.Contains(dto.Param);
  15745. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15746. {
  15747. return false;
  15748. }
  15749. }
  15750. return where;
  15751. }
  15752. )
  15753. .ToList();
  15754. }
  15755. }
  15756. var view = dbResult.Select(x =>
  15757. {
  15758. decimal dp = 0.00M;
  15759. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15760. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15761. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15762. {
  15763. if (startB && endB)
  15764. {
  15765. var timesp = endD.Subtract(startD);
  15766. if ((timesp.Days + 1) != 0)
  15767. {
  15768. dp = x.Price / (timesp.Days + 1);
  15769. }
  15770. }
  15771. }
  15772. else
  15773. {
  15774. dp = x.Price;
  15775. }
  15776. return new
  15777. {
  15778. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15779. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15780. x.Area,
  15781. x.id,
  15782. price = x.Price.ToString("F2"),
  15783. x.PriceName,
  15784. x.PriceContent,
  15785. x.TeamName,
  15786. x.DatePrice,
  15787. dayPrice = dp.ToString("F2"),
  15788. };
  15789. }).OrderByDescending(x => x.id).ToList();
  15790. jw = JsonView(true, "获取成功!", view);
  15791. }
  15792. catch (Exception e)
  15793. {
  15794. jw = JsonView(false, e.Message);
  15795. }
  15796. return Ok(jw);
  15797. }
  15798. [HttpPost]
  15799. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15800. {
  15801. var jw = JsonView(true);
  15802. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15803. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15804. {
  15805. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15806. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15807. WHEN COUNT(*) >= 0 THEN 'True'
  15808. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15809. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15810. ")
  15811. .ToList();
  15812. }
  15813. else
  15814. {
  15815. string likeKey = string.Empty;
  15816. foreach (var item in dto.Keyword)
  15817. {
  15818. likeKey += "%" + item;
  15819. }
  15820. likeKey += "%";
  15821. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15822. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15823. WHEN COUNT(*) >= 0 THEN 'True'
  15824. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15825. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15826. ")
  15827. .ToList();
  15828. }
  15829. if (matches.Any())
  15830. {
  15831. jw.Data = matches;
  15832. }
  15833. else
  15834. {
  15835. jw.Code = 201;
  15836. jw.Msg = "empty list";
  15837. jw.Data = new List<string>(1);
  15838. }
  15839. return Ok(jw);
  15840. }
  15841. /// <summary>
  15842. /// 报价Word下载
  15843. /// </summary>
  15844. /// <param name="dto"></param>
  15845. /// <returns></returns>
  15846. [HttpPost]
  15847. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  15848. {
  15849. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  15850. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  15851. if (di == null)
  15852. {
  15853. return Ok(JsonView(false, "团组不存在!"));
  15854. }
  15855. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15856. if (mainPrice == null || mainPrice.IsShare == 0)
  15857. {
  15858. return Ok(JsonView(false, "团组成本不存在!"));
  15859. }
  15860. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  15861. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  15862. if (costTypeHotelNumbers == null)
  15863. {
  15864. return Ok(JsonView(false, "团组成本不存在!"));
  15865. }
  15866. //文件名
  15867. string strFileName = di.TeamName + "-收款账单.doc";
  15868. //获取模板
  15869. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15870. //载入模板
  15871. Document doc = new Document(tmppath);
  15872. decimal allPrice = 0.00M;
  15873. string itemStr = string.Empty;
  15874. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15875. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  15876. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  15877. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  15878. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  15879. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  15880. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  15881. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  15882. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  15883. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  15884. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  15885. {
  15886. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  15887. ("BXRS", "BXCB", "BXXS", "bx"),
  15888. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  15889. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  15890. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  15891. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  15892. ("CPRS", "CPCB", "CPXS", "cp") ,
  15893. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  15894. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  15895. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  15896. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  15897. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  15898. ("DJRS", "DJCB", "DJXS", "dj") ,
  15899. ("GWRS", "GWCB", "GWXS", "gw") ,
  15900. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  15901. };
  15902. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  15903. var rightSum = 0.00M;
  15904. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  15905. {
  15906. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  15907. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  15908. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  15909. if (prefix == "tbr")
  15910. {
  15911. rsValue *= 2;
  15912. cbValue /= 2;
  15913. }
  15914. if (OtherCostPropertyBJ.Contains(prefix))
  15915. {
  15916. rightSum += cbValue * xsValue;
  15917. }
  15918. }
  15919. var hotelRooms = new Dictionary<string, int>
  15920. {
  15921. { "SGR", costTypeHotelNumbers.SGR },
  15922. { "TBR", costTypeHotelNumbers.TBR },
  15923. { "JSES", costTypeHotelNumbers.JSES },
  15924. { "SUITE", costTypeHotelNumbers.SUITE }
  15925. };
  15926. var flights = new Dictionary<string, int>
  15927. {
  15928. { "经济舱", mainPrice.JJCRS },
  15929. { "公务舱", mainPrice.GWCRS },
  15930. { "头等舱", mainPrice.TDCRS }
  15931. };
  15932. var flightRoomMatchingRules = new Dictionary<string, string[]>
  15933. {
  15934. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  15935. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  15936. { "头等舱", new[] { "SUITE", "JSES" } }
  15937. };
  15938. var result = new Dictionary<string, int>();
  15939. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  15940. foreach (var flight in flights.Keys)
  15941. {
  15942. // 获取当前舱位的匹配规则
  15943. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  15944. {
  15945. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  15946. }
  15947. }
  15948. #region right计算
  15949. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  15950. {
  15951. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  15952. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  15953. airHotelPriceList.Add(new
  15954. AirHotelPrice
  15955. {
  15956. Name = "经济舱TBR",
  15957. Price = rightSum + air + hotel,
  15958. Count = result["经济舱TBR"] * 2
  15959. });
  15960. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  15961. }
  15962. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  15963. {
  15964. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  15965. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  15966. airHotelPriceList.Add(new
  15967. AirHotelPrice
  15968. {
  15969. Name = "经济舱SGR",
  15970. Price = rightSum + air + hotel,
  15971. Count = result["经济舱SGR"]
  15972. });
  15973. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  15974. }
  15975. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  15976. {
  15977. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  15978. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  15979. airHotelPriceList.Add(new
  15980. AirHotelPrice
  15981. {
  15982. Name = "公务舱SGR",
  15983. Price = rightSum + air + hotel,
  15984. Count = result["公务舱SGR"]
  15985. });
  15986. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  15987. }
  15988. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  15989. {
  15990. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  15991. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  15992. airHotelPriceList.Add(new
  15993. AirHotelPrice
  15994. {
  15995. Name = "公务舱JSES",
  15996. Price = rightSum + air + hotel,
  15997. Count = result["公务舱JSES"]
  15998. });
  15999. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16000. }
  16001. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16002. {
  16003. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16004. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16005. airHotelPriceList.Add(new
  16006. AirHotelPrice
  16007. {
  16008. Name = "公务舱SUITE",
  16009. Price = rightSum + air + hotel,
  16010. Count = result["公务舱SUITE"]
  16011. });
  16012. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16013. }
  16014. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16015. {
  16016. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16017. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16018. airHotelPriceList.Add(new
  16019. AirHotelPrice
  16020. {
  16021. Name = "经济舱SUITE",
  16022. Price = rightSum + air + hotel,
  16023. Count = result["经济舱SUITE"]
  16024. });
  16025. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16026. }
  16027. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16028. {
  16029. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16030. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16031. airHotelPriceList.Add(new
  16032. AirHotelPrice
  16033. {
  16034. Name = "头等舱JSES",
  16035. Price = rightSum + air + hotel,
  16036. Count = result["头等舱JSES"]
  16037. });
  16038. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16039. }
  16040. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16041. {
  16042. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16043. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16044. airHotelPriceList.Add(new
  16045. AirHotelPrice
  16046. {
  16047. Name = "头等舱SUITE",
  16048. Price = rightSum + air + hotel,
  16049. Count = result["头等舱SUITE"]
  16050. });
  16051. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16052. }
  16053. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16054. {
  16055. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16056. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16057. airHotelPriceList.Add(new
  16058. AirHotelPrice
  16059. {
  16060. Name = "经济舱JSES",
  16061. Price = rightSum + air + hotel,
  16062. Count = result["经济舱JSES"]
  16063. });
  16064. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16065. }
  16066. #endregion
  16067. foreach (var item in airSouer.Keys)
  16068. {
  16069. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16070. if (find != null && find.Count > 0)
  16071. {
  16072. if (item.Contains("TBR"))
  16073. {
  16074. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16075. }
  16076. else
  16077. {
  16078. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16079. }
  16080. }
  16081. }
  16082. #region 替换Word模板书签内容
  16083. Dictionary<string, string> marks = new Dictionary<string, string>();
  16084. marks.Add("To", di.ClientUnit);//付款方
  16085. marks.Add("ToTel", di.TellPhone);//付款方电话
  16086. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16087. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16088. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16089. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16090. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16091. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16092. marks.Add("PayItemContent", itemStr);//详细信息
  16093. marks.Add("Total", allPrice.ToString("F2"));//合计
  16094. #endregion
  16095. foreach (var item in marks.Keys)
  16096. {
  16097. if (doc.Range.Bookmarks[item] != null)
  16098. {
  16099. Bookmark mark = doc.Range.Bookmarks[item];
  16100. mark.Text = marks[item];
  16101. }
  16102. }
  16103. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16104. doc.Save(savePaht);
  16105. var jw = new JsonView();
  16106. jw.Msg = "生成成功!";
  16107. jw.Code = 200;
  16108. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16109. return Ok(jw);
  16110. }
  16111. /// <summary>
  16112. /// 详细报价费用Excel下载
  16113. /// </summary>
  16114. /// <param name="dto"></param>
  16115. /// <returns></returns>
  16116. [HttpPost]
  16117. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16118. {
  16119. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16120. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16121. if (di == null)
  16122. {
  16123. return Ok(JsonView(false, "团组不存在!"));
  16124. }
  16125. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16126. if (mainPrice == null || mainPrice.IsShare == 0)
  16127. {
  16128. return Ok(JsonView(false, "团组成本不存在!"));
  16129. }
  16130. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16131. .FirstAsync(x=>x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16132. if (costTypeHotelNumbers == null)
  16133. {
  16134. return Ok(JsonView(false, "团组成本不存在!"));
  16135. }
  16136. WorkbookDesigner designer = new WorkbookDesigner();
  16137. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16138. List<int> hideRowsList = new List<int>();
  16139. int conterStartIndex = 3;
  16140. int rowIndex = conterStartIndex;
  16141. designer.SetDataSource("GroupName", di.TeamName);
  16142. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16143. {
  16144. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16145. ("BXRS", "BXCB", "BXXS", "bx"),
  16146. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16147. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16148. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16149. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16150. ("CPRS", "CPCB", "CPXS", "cp") ,
  16151. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16152. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16153. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16154. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16155. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16156. ("DJRS", "DJCB", "DJXS", "dj") ,
  16157. ("GWRS", "GWCB", "GWXS", "gw") ,
  16158. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16159. };
  16160. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16161. var rightSum = 0.00M;
  16162. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16163. {
  16164. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16165. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16166. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16167. if (prefix == "tbr")
  16168. {
  16169. rsValue *= 2;
  16170. cbValue /= 2;
  16171. }
  16172. if (OtherCostPropertyBJ.Contains(prefix))
  16173. {
  16174. rightSum += cbValue * xsValue;
  16175. }
  16176. if (rsValue == 0)
  16177. {
  16178. hideRowsList.Add(rowIndex);
  16179. }
  16180. else
  16181. {
  16182. designer.SetDataSource($"{prefix}rs", rsValue);
  16183. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16184. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16185. }
  16186. rowIndex += 2;
  16187. }
  16188. var hotelRooms = new Dictionary<string, int>
  16189. {
  16190. { "SGR", costTypeHotelNumbers.SGR },
  16191. { "TBR", costTypeHotelNumbers.TBR },
  16192. { "JSES", costTypeHotelNumbers.JSES },
  16193. { "SUITE", costTypeHotelNumbers.SUITE }
  16194. };
  16195. var flights = new Dictionary<string, int>
  16196. {
  16197. { "经济舱", mainPrice.JJCRS },
  16198. { "公务舱", mainPrice.GWCRS },
  16199. { "头等舱", mainPrice.TDCRS }
  16200. };
  16201. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16202. {
  16203. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16204. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16205. { "头等舱", new[] { "SUITE", "JSES" } }
  16206. };
  16207. var result = new Dictionary<string, int>();
  16208. foreach (var flight in flights.Keys)
  16209. {
  16210. // 获取当前舱位的匹配规则
  16211. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16212. {
  16213. MatchRooms(ref hotelRooms,ref flights, roomTypes, flight,ref result);
  16214. }
  16215. }
  16216. var allPrice = 0.00M;
  16217. #region right计算
  16218. int airRowIndex = 35;
  16219. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16220. {
  16221. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16222. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16223. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16224. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16225. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16226. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16227. }
  16228. else
  16229. {
  16230. hideRowsList.Add(airRowIndex);
  16231. }
  16232. airRowIndex += 2;
  16233. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16234. {
  16235. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16236. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16237. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16238. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16239. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16240. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16241. }
  16242. else
  16243. {
  16244. hideRowsList.Add(airRowIndex);
  16245. }
  16246. airRowIndex += 2;
  16247. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16248. {
  16249. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16250. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16251. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16252. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16253. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16254. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16255. }
  16256. else
  16257. {
  16258. hideRowsList.Add(airRowIndex);
  16259. }
  16260. airRowIndex += 2;
  16261. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16262. {
  16263. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16264. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16265. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16266. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16267. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16268. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16269. }
  16270. else
  16271. {
  16272. hideRowsList.Add(airRowIndex);
  16273. }
  16274. airRowIndex += 2;
  16275. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16276. {
  16277. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16278. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16279. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16280. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16281. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16282. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16283. }
  16284. else
  16285. {
  16286. hideRowsList.Add(airRowIndex);
  16287. }
  16288. airRowIndex += 2;
  16289. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16290. {
  16291. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16292. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16293. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16294. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16295. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16296. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16297. }
  16298. else
  16299. {
  16300. hideRowsList.Add(airRowIndex);
  16301. }
  16302. airRowIndex += 2;
  16303. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16304. {
  16305. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16306. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16307. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16308. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16309. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16310. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16311. }
  16312. else
  16313. {
  16314. hideRowsList.Add(airRowIndex);
  16315. }
  16316. airRowIndex += 2;
  16317. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16318. {
  16319. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16320. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16321. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16322. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16323. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16324. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16325. }
  16326. else
  16327. {
  16328. hideRowsList.Add(airRowIndex);
  16329. }
  16330. airRowIndex += 2;
  16331. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16332. {
  16333. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16334. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16335. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16336. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16337. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16338. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16339. }
  16340. else
  16341. {
  16342. hideRowsList.Add(airRowIndex);
  16343. }
  16344. #endregion
  16345. designer.SetDataSource("AllPrice","总金额:" + allPrice.ToString("#0.00"));
  16346. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName +"_详细报批费用.xls";
  16347. var ws = designer.Workbook.Worksheets[0];
  16348. foreach (var Rowindex in hideRowsList)
  16349. {
  16350. ws.Cells.HideRows(Rowindex, 2);
  16351. }
  16352. designer.Process();
  16353. designer.Workbook.Save(savePaht);
  16354. return Ok(JsonView(true, "生成成功!", new
  16355. {
  16356. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16357. }));
  16358. }
  16359. private void MatchRooms(ref Dictionary<string, int> hotelRooms,ref Dictionary<string, int> flights, string[] roomTypes, string flightType,ref Dictionary<string, int> result)
  16360. {
  16361. foreach (var roomType in roomTypes)
  16362. {
  16363. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16364. {
  16365. hotelRooms[roomType]--;
  16366. flights[flightType]--;
  16367. if (roomType == "TBR")
  16368. {
  16369. flights[flightType]--; // 双人间在减少1
  16370. }
  16371. string key = flightType + roomType;
  16372. if (result.Keys.Contains(key))
  16373. {
  16374. result[key]++;
  16375. }
  16376. else
  16377. {
  16378. result.Add(key, 1);
  16379. }
  16380. }
  16381. }
  16382. }
  16383. private class AirHotelPrice
  16384. {
  16385. public string Name { get; set; }
  16386. public decimal Price { get; set; }
  16387. public int Count { get; set; }
  16388. }
  16389. #endregion
  16390. #region 酒店预订 新 雷怡 2023-12-28 17:45
  16391. /// <summary>
  16392. /// 酒店预订
  16393. /// 酒店费用列表 根据团组Id查询
  16394. /// </summary>
  16395. /// <param name="_dto"></param>
  16396. /// <returns></returns>
  16397. [HttpPost]
  16398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16399. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16400. {
  16401. #region 参数验证
  16402. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16403. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16404. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16405. #region 团组操作权限验证 76 酒店预定模块
  16406. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16407. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16408. #endregion
  16409. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16410. #region 页面操作权限验证
  16411. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16412. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16413. #endregion
  16414. #endregion
  16415. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16416. }
  16417. /// <summary>
  16418. /// 酒店预订
  16419. /// 基础数据
  16420. /// </summary>
  16421. /// <param name="_dto"></param>
  16422. /// <returns></returns>
  16423. [HttpPost]
  16424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16425. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16426. {
  16427. #region 参数验证
  16428. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16429. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16430. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16431. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16432. #region 页面操作权限验证
  16433. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16434. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16435. #endregion
  16436. #region 团组操作权限验证 76 酒店预定模块
  16437. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16438. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16439. #endregion
  16440. #endregion
  16441. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16442. }
  16443. /// <summary>
  16444. /// 酒店预订
  16445. /// 创建 入住卷号码
  16446. /// </summary>
  16447. /// <param name="_dto"></param>
  16448. /// <returns></returns>
  16449. [HttpPost]
  16450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16451. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16452. {
  16453. #region 参数验证
  16454. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16455. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16456. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16457. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16458. #region 页面操作权限验证
  16459. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16460. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16461. #endregion
  16462. #region 团组操作权限验证 76 酒店预定模块
  16463. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16464. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16465. #endregion
  16466. #endregion
  16467. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16468. if (data.Code != 0)
  16469. {
  16470. return Ok(JsonView(false, data.Msg));
  16471. }
  16472. return Ok(JsonView(true, data.Msg, data.Data));
  16473. }
  16474. /// <summary>
  16475. /// 酒店预订
  16476. /// 详情
  16477. /// </summary>
  16478. /// <param name="_dto"></param>
  16479. /// <returns></returns>
  16480. [HttpPost]
  16481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16482. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16483. {
  16484. #region 参数验证
  16485. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16486. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16487. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16488. #region 团组操作权限验证 76 酒店预定模块
  16489. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16490. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16491. #endregion
  16492. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16493. #region 页面操作权限验证
  16494. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16495. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16496. #endregion
  16497. #endregion
  16498. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16499. }
  16500. /// <summary>
  16501. /// 酒店预订
  16502. /// Add Or Edit
  16503. /// </summary>
  16504. /// <param name="_dto"></param>
  16505. /// <returns></returns>
  16506. [HttpPost]
  16507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16508. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16509. {
  16510. #region 参数验证
  16511. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16512. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16513. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16514. #region 团组操作权限验证 76 酒店预定模块
  16515. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16516. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16517. #endregion
  16518. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16519. #region 页面操作权限验证
  16520. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16521. if (_dto.Id == 0) // Add
  16522. {
  16523. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16524. }
  16525. else if (_dto.Id > 1) // Edit
  16526. {
  16527. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16528. }
  16529. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16530. #endregion
  16531. #endregion
  16532. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16533. if (_view.Code != 200)
  16534. {
  16535. return Ok(_view);
  16536. }
  16537. #region 成本无酒店价格数据进入超支
  16538. _sqlSugar.BeginTran();
  16539. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16540. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16541. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16542. for (int i = 0; i < groupCost.Count; i++)
  16543. {
  16544. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16545. {
  16546. groupCost[i].Date = groupCost[i - 1].Date;
  16547. }
  16548. }
  16549. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16550. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16551. List<Fin_GroupExtraCostDto_OP>();
  16552. if (start_Bool && end_Bool)
  16553. {
  16554. while (start_Time < end_Time)
  16555. {
  16556. foreach (var item in groupCost_Grp)
  16557. {
  16558. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16559. {
  16560. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16561. {
  16562. extraCostList.Add(new
  16563. Fin_GroupExtraCostDto_OP
  16564. {
  16565. Area = _dto.AreaId,
  16566. coefficient = 1.5M,
  16567. createUser = _dto.UserId,
  16568. currency = _dto.CardPriceCurrency,
  16569. diId = _dto.DiId,
  16570. ManagerConfirm = 0,
  16571. SupervisorConfirm = 0,
  16572. SYsupervisorConfirm = 0,
  16573. editType = 1,
  16574. PortType = 1,
  16575. price = _dto.CardPrice,
  16576. PriceCount = 1,
  16577. priceType = 1027,
  16578. priceDetailType = 1044,
  16579. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16580. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16581. });
  16582. }
  16583. }
  16584. }
  16585. start_Time = start_Time.AddDays(1);
  16586. }
  16587. }
  16588. if (extraCostList.Any())
  16589. {
  16590. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16591. }
  16592. _sqlSugar.CommitTran();
  16593. #endregion
  16594. #region 应用推送
  16595. try
  16596. {
  16597. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16598. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16599. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16600. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16601. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16602. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16603. var diId = _dto.DiId;
  16604. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16605. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16606. #region 操作记录
  16607. var opInfo = new Crm_TableOperationRecord()
  16608. {
  16609. TableName = "Grp_HotelReservations",
  16610. PortType = _dto.PortType,
  16611. DataId = hotelId,
  16612. CreateUserId = _dto.UserId
  16613. };
  16614. //var opStatus = OperationEnum.NoOperation;
  16615. if (_dto.Id < 1) //添加操作
  16616. {
  16617. opInfo.OperationItem = OperationEnum.Add;
  16618. }
  16619. else if (_dto.Id > 0)
  16620. {
  16621. opInfo.OperationItem = OperationEnum.Edit;
  16622. }
  16623. string opRemark = string.Empty;
  16624. if (ccpInfo != null)
  16625. {
  16626. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16627. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16628. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16629. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16630. }
  16631. opInfo.Remark = opRemark;
  16632. await _tableorRep.AddAsync(opInfo);
  16633. #endregion
  16634. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16635. //2024-10-21 新增LZ UID
  16636. var userIds = new List<int>() { 21 };
  16637. string title = $"费用审核";
  16638. string content = "";
  16639. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16640. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16641. try
  16642. {
  16643. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  16644. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  16645. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  16646. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  16647. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  16648. }
  16649. catch (Exception ex)
  16650. {
  16651. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  16652. }
  16653. }
  16654. catch (Exception ex)
  16655. {
  16656. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  16657. }
  16658. try
  16659. {
  16660. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16661. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16662. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16663. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16664. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16665. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16666. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16667. //自动审核
  16668. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  16669. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  16670. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  16671. //2024-10-21 新增LZ UID
  16672. var userIds = new List<int>() { 21 };
  16673. string title = $"系统通知";
  16674. var diId = _dto.DiId;
  16675. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16676. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16677. string content = "";
  16678. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16679. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16680. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16681. }
  16682. catch (Exception ex)
  16683. {
  16684. }
  16685. #endregion
  16686. return Ok(_view);
  16687. }
  16688. /// <summary>
  16689. /// 酒店自动审核测试
  16690. /// Add Or Edit
  16691. /// </summary>
  16692. /// <param name="diid"></param>
  16693. /// <param name="dataId"></param>
  16694. /// <returns></returns>
  16695. [HttpPost]
  16696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16697. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  16698. {
  16699. #region 应用推送
  16700. try
  16701. {
  16702. //自动审核
  16703. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  16704. }
  16705. catch (Exception ex)
  16706. {
  16707. return Ok(JsonView(false, "操作失败"));
  16708. }
  16709. #endregion
  16710. return Ok(JsonView(false, "操作成功"));
  16711. }
  16712. /// <summary>
  16713. /// 酒店预订
  16714. /// Del
  16715. /// </summary>
  16716. /// <param name="_dto"></param>
  16717. /// <returns></returns>
  16718. [HttpPost]
  16719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16720. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  16721. {
  16722. #region 参数验证
  16723. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16724. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16725. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16726. #region 团组操作权限验证 76 酒店预定模块
  16727. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16728. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16729. #endregion
  16730. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16731. #region 页面操作权限验证
  16732. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16733. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16734. #endregion
  16735. #endregion
  16736. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  16737. #region 操作记录
  16738. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  16739. {
  16740. TableName = "Grp_HotelReservations",
  16741. PortType = _dto.PortType,
  16742. OperationItem = OperationEnum.Del,
  16743. DataId = _dto.Id,
  16744. CreateUserId = _dto.UserId
  16745. });
  16746. #endregion
  16747. return Ok(data);
  16748. }
  16749. /// <summary>
  16750. /// 酒店预订
  16751. /// 生成VOUCHER
  16752. /// 2024.05.06 之前版本
  16753. /// </summary>
  16754. /// <param name="_dto"></param>
  16755. /// <returns></returns>
  16756. [HttpPost]
  16757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16758. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  16759. {
  16760. try
  16761. {
  16762. #region 参数验证
  16763. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16764. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16765. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16766. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  16767. #region 团组操作权限验证 76 酒店预定模块
  16768. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16769. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16770. #endregion
  16771. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16772. #region 页面操作权限验证
  16773. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16774. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16775. #endregion
  16776. #endregion
  16777. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  16778. //判断数据是否完整
  16779. if (hr != null)
  16780. {
  16781. if (!string.IsNullOrEmpty(hr.DetermineNo))
  16782. {
  16783. string strFileName = "HotelStatement/";
  16784. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16785. if (dele != null)
  16786. strFileName += dele.TourCode;
  16787. //载入模板
  16788. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  16789. Document doc = new Document(sss);
  16790. DocumentBuilder builder = new DocumentBuilder(doc);
  16791. #region 替换Word模板书签内容
  16792. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  16793. //入住卷预定号码
  16794. if (doc.Range.Bookmarks["VNO"] != null)
  16795. {
  16796. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16797. mark.Text = hr.CheckNumber;
  16798. }
  16799. //酒店时间
  16800. if (doc.Range.Bookmarks["Date"] != null)
  16801. {
  16802. Bookmark mark = doc.Range.Bookmarks["Date"];
  16803. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16804. }
  16805. //团号
  16806. if (doc.Range.Bookmarks["TNo"] != null)
  16807. {
  16808. Bookmark mark = doc.Range.Bookmarks["TNo"];
  16809. mark.Text = dele.TourCode;
  16810. }
  16811. //预定号码
  16812. if (doc.Range.Bookmarks["BookingId"] != null)
  16813. {
  16814. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  16815. mark.Text = hr.ReservationsNo;
  16816. }
  16817. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  16818. {
  16819. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  16820. mark.Text = hr.DetermineNo;
  16821. }
  16822. //酒店城市
  16823. if (doc.Range.Bookmarks["City"] != null)
  16824. {
  16825. Bookmark mark = doc.Range.Bookmarks["City"];
  16826. mark.Text = hr.City;
  16827. }
  16828. //酒店名称
  16829. if (doc.Range.Bookmarks["HName"] != null)
  16830. {
  16831. Bookmark mark = doc.Range.Bookmarks["HName"];
  16832. mark.Text = hr.HotelName;
  16833. }
  16834. //酒店地址
  16835. if (doc.Range.Bookmarks["Address"] != null)
  16836. {
  16837. Bookmark mark = doc.Range.Bookmarks["Address"];
  16838. mark.Text = hr.HotelAddress;
  16839. }
  16840. //酒店电话
  16841. if (doc.Range.Bookmarks["Tel"] != null)
  16842. {
  16843. Bookmark mark = doc.Range.Bookmarks["Tel"];
  16844. mark.Text = hr.HotelTel;
  16845. }
  16846. //酒店传真
  16847. if (doc.Range.Bookmarks["Fax"] != null)
  16848. {
  16849. Bookmark mark = doc.Range.Bookmarks["Fax"];
  16850. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  16851. {
  16852. mark.Text = hr.HotelFax;
  16853. }
  16854. }
  16855. //入住时间
  16856. if (doc.Range.Bookmarks["CIn"] != null)
  16857. {
  16858. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16859. Bookmark mark = doc.Range.Bookmarks["CIn"];
  16860. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  16861. }
  16862. //退房时间
  16863. if (doc.Range.Bookmarks["COut"] != null)
  16864. {
  16865. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16866. Bookmark mark = doc.Range.Bookmarks["COut"];
  16867. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16868. }
  16869. //客户名称
  16870. if (doc.Range.Bookmarks["GName"] != null)
  16871. {
  16872. string guestName = "";
  16873. string[] clients = new string[] { };
  16874. if (hr.GuestName.Contains(","))
  16875. {
  16876. clients = hr.GuestName.Split(",");
  16877. }
  16878. else
  16879. {
  16880. clients = new string[] { hr.GuestName };
  16881. }
  16882. List<int> clientIds_int = new List<int>();
  16883. if (clients.Length > 0)
  16884. {
  16885. foreach (var item in clients)
  16886. {
  16887. if (item.IsNumeric())
  16888. {
  16889. clientIds_int.Add(int.Parse(item));
  16890. }
  16891. }
  16892. }
  16893. if (clientIds_int.Count > 0)
  16894. {
  16895. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  16896. foreach (var client in _clientDatas)
  16897. {
  16898. //男
  16899. if (client.Sex == 0) guestName += $"Mr.";
  16900. //女
  16901. else if (client.Sex == 1) guestName += $"Ms.";
  16902. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  16903. {
  16904. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  16905. }
  16906. //guestName += $"{client.Pinyin},";
  16907. }
  16908. if (guestName.Length > 0)
  16909. {
  16910. guestName = guestName.Substring(0, guestName.Length - 1);
  16911. }
  16912. }
  16913. else
  16914. {
  16915. guestName = hr.GuestName;
  16916. }
  16917. Bookmark mark = doc.Range.Bookmarks["GName"];
  16918. mark.Text = guestName;
  16919. }
  16920. //房间介绍
  16921. if (doc.Range.Bookmarks["ROOM"] != null)
  16922. {
  16923. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  16924. mark.Text = hr.RoomExplanation;
  16925. }
  16926. //报价描述
  16927. if (doc.Range.Bookmarks["NOTE"] != null)
  16928. {
  16929. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  16930. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  16931. if (ss != null)
  16932. mark.Text = ss.Name;
  16933. }
  16934. //入住时间
  16935. if (doc.Range.Bookmarks["CheckIn"] != null)
  16936. {
  16937. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16938. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  16939. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16940. }
  16941. //退房时间
  16942. if (doc.Range.Bookmarks["CheckOut"] != null)
  16943. {
  16944. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16945. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  16946. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16947. }
  16948. //日期
  16949. if (doc.Range.Bookmarks["DT"] != null)
  16950. {
  16951. Bookmark mark = doc.Range.Bookmarks["DT"];
  16952. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16953. }
  16954. //名称
  16955. if (doc.Range.Bookmarks["VName"] != null)
  16956. {
  16957. Bookmark mark = doc.Range.Bookmarks["VName"];
  16958. mark.Text = hr.HotelName;
  16959. }
  16960. //号码
  16961. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  16962. {
  16963. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  16964. mark.Text = hr.CheckNumber;
  16965. }
  16966. #endregion
  16967. strFileName += "VOUCHER.doc";
  16968. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16969. doc.Save(fileDir);
  16970. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16971. return Ok(JsonView(true, "操作成功!", Url));
  16972. }
  16973. else
  16974. {
  16975. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  16976. }
  16977. }
  16978. else
  16979. {
  16980. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  16981. }
  16982. }
  16983. catch (Exception ex)
  16984. {
  16985. return Ok(JsonView(false, ex.Message));
  16986. }
  16987. }
  16988. /// <summary>
  16989. /// 酒店预订
  16990. /// 生成VOUCHER
  16991. /// 2024.05.06 之后版本
  16992. /// </summary>
  16993. /// <param name="_dto"></param>
  16994. /// <returns></returns>
  16995. [HttpPost]
  16996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16997. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  16998. {
  16999. #region 参数验证
  17000. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17001. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17002. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17003. #region 团组操作权限验证 76 酒店预定模块
  17004. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17005. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17006. #endregion
  17007. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17008. #region 页面操作权限验证
  17009. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17010. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17011. #endregion
  17012. #endregion
  17013. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17014. //判断数据是否完整
  17015. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17016. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17017. string strFileName = "HotelStatement/";
  17018. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17019. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17020. #region 数据处理
  17021. List<int> guestIds = new List<int>();
  17022. //int index = 0;
  17023. foreach (var item in hrDtas)
  17024. {
  17025. if (item.GuestName.Contains(","))
  17026. {
  17027. string[] guestIdArr = item.GuestName.Split(',');
  17028. foreach (var guestIdStr in guestIdArr)
  17029. {
  17030. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17031. if (guestBool)
  17032. {
  17033. guestIds.Add(guestId);
  17034. }
  17035. }
  17036. }
  17037. else guestNames += item.GuestName;
  17038. var voucherInfo = new HotelVoucherInfoView()
  17039. {
  17040. HotelName = item.HotelName,
  17041. CheckInDate = item.CheckInDate,
  17042. CheckOutDate = item.CheckOutDate,
  17043. ConfirmationNumber = item.DetermineNo.Trim(),
  17044. RoomType = item.RoomExplanation
  17045. };
  17046. vouchers.Add(voucherInfo);
  17047. }
  17048. if (guestIds.Count > 0)
  17049. {
  17050. guestIds = guestIds.Distinct().ToList();
  17051. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17052. if (guestDatas.Count > 0)
  17053. {
  17054. guestNames = "";
  17055. foreach (var guest in guestDatas)
  17056. {
  17057. string guestName = "";
  17058. if (guest.Sex == 0) guestName += @"MR.";
  17059. else if (guest.Sex == 1) guestName += @"MS.";
  17060. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17061. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17062. guestNames += @$"{guestName.Trim()}、";
  17063. }
  17064. if (guestNames.Length > 0)
  17065. {
  17066. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17067. }
  17068. }
  17069. }
  17070. #endregion
  17071. //载入模板
  17072. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17073. Document doc = new Document(sss);
  17074. DocumentBuilder builder = new DocumentBuilder(doc);
  17075. if (doc.Range.Bookmarks["GuestName"] != null)
  17076. {
  17077. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17078. mark.Text = guestNames;
  17079. }
  17080. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17081. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17082. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17083. for (int i = 1; i <= vouchers.Count; i++)
  17084. {
  17085. HotelVoucherInfoView hviv = vouchers[i - 1];
  17086. builder.MoveToCell(0, i, 0, 0);
  17087. builder.Write(hviv.HotelName);
  17088. builder.MoveToCell(0, i, 1, 0);
  17089. builder.Write(hviv.CheckInDate);
  17090. builder.MoveToCell(0, i, 2, 0);
  17091. builder.Write(hviv.CheckOutDate);
  17092. builder.MoveToCell(0, i, 3, 0);
  17093. builder.Write(hviv.RoomType);
  17094. builder.MoveToCell(0, i, 4, 0);
  17095. builder.Write(hviv.ConfirmationNumber);
  17096. }
  17097. //删除多余行
  17098. int currRowIndex = vouchers.Count + 1;
  17099. int delRows = 21 - currRowIndex;
  17100. if (delRows > 0)
  17101. {
  17102. for (int i = 0; i < delRows; i++)
  17103. {
  17104. table.Rows.RemoveAt(currRowIndex);
  17105. //cultivateRowIndex++;
  17106. }
  17107. }
  17108. strFileName += "VOUCHER.docx";
  17109. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17110. doc.Save(fileDir);
  17111. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17112. return Ok(JsonView(true, "操作成功!", Url));
  17113. }
  17114. /// <summary>
  17115. /// 酒店预订
  17116. /// 生成VOUCHER 批量生成
  17117. /// New
  17118. /// </summary>
  17119. /// <param name="_dto"></param>
  17120. /// <returns></returns>
  17121. [HttpPost]
  17122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17123. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17124. {
  17125. #region 参数验证
  17126. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17127. if (_dto.PageId < 1) _dto.PageId = 28;
  17128. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17129. #region 团组操作权限验证 76 酒店预定模块
  17130. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17131. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17132. #endregion
  17133. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17134. #region 页面操作权限验证
  17135. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17136. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17137. #endregion
  17138. #endregion
  17139. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17140. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17141. .OrderBy(x => x.CheckInDate)
  17142. .ToListAsync();
  17143. //判断数据是否完整
  17144. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17145. string strFileName = "HotelStatement/";
  17146. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17147. if (dele != null)
  17148. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17149. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17150. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17151. .Where(it => it.IsDel == 0)
  17152. .ToListAsync();
  17153. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17154. for (int i = 0; i < hrDtas.Count; i++)
  17155. {
  17156. string guestNames = string.Empty;
  17157. List<int> guestIds = new List<int>();
  17158. var item = hrDtas[i];
  17159. //处理客户姓名
  17160. if (item.GuestName.Contains(","))
  17161. {
  17162. string[] guestIdArr = item.GuestName.Split(',');
  17163. foreach (var guestIdStr in guestIdArr)
  17164. if (int.TryParse(guestIdStr, out int guestId))
  17165. guestIds.Add(guestId);
  17166. }
  17167. else
  17168. {
  17169. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17170. if (guestIdBool)
  17171. {
  17172. guestIds.Add(guestId);
  17173. }
  17174. //NaN
  17175. if (item.GuestName.Contains("NaN"))
  17176. {
  17177. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17178. }
  17179. }
  17180. if (guestIds.Count > 0)
  17181. {
  17182. guestIds = guestIds.Distinct().ToList();
  17183. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17184. if (guestDatas1.Count > 0)
  17185. {
  17186. guestNames = "";
  17187. foreach (var guest in guestDatas1)
  17188. {
  17189. string guestName = "";
  17190. if (guest.Sex == 0) guestName += @"MR.";
  17191. else if (guest.Sex == 1) guestName += @"MS.";
  17192. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17193. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17194. guestNames += @$"{guestName.Trim()}、";
  17195. }
  17196. if (guestNames.Length > 0)
  17197. {
  17198. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17199. }
  17200. }
  17201. }
  17202. //if (!string.IsNullOrEmpty(guestNames))
  17203. //{
  17204. hrDtas[i].GuestName = guestNames;
  17205. //}
  17206. }
  17207. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17208. Document doc = new Document();
  17209. DocumentBuilder builder = new DocumentBuilder(doc);
  17210. try
  17211. {
  17212. builder.MoveToDocumentStart();
  17213. foreach (var item in hrDtas)
  17214. {
  17215. //标题
  17216. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17217. builder.ParagraphFormat.LineSpacing = 1;
  17218. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17219. builder.ParagraphFormat.Style.Font.Size = 9;
  17220. builder.ParagraphFormat.Style.Font.Bold = true;
  17221. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17222. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17223. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17224. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17225. builder.ParagraphFormat.LineSpacing = 1;
  17226. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17227. builder.ParagraphFormat.Style.Font.Size = 9;
  17228. builder.ParagraphFormat.Style.Font.Bold = true;
  17229. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17230. builder.StartTable();
  17231. // 设置边框颜色
  17232. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17233. //设置边框样式
  17234. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17235. //表格
  17236. #region 第一行
  17237. builder.InsertCell();
  17238. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17239. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17240. //builder.CellFormat.AllowAutoFit = false;
  17241. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17242. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17243. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17244. builder.CellFormat.WrapText = true; //自动换行
  17245. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17246. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17247. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17248. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17249. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17250. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17251. builder.Write("TOUR NO:");
  17252. builder.InsertCell();
  17253. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17254. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17255. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17256. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17257. builder.ParagraphFormat.Style.Font.Bold = false;
  17258. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17259. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17260. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17261. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17262. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17263. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17264. builder.Write($"{dele?.TourCode ?? "-"}");
  17265. builder.InsertCell();
  17266. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17267. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17268. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17269. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17270. builder.ParagraphFormat.Style.Font.Bold = false;
  17271. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17272. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17273. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17274. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17275. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17276. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17277. builder.Write($"CITY:");
  17278. builder.InsertCell();
  17279. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17280. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17281. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17282. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17283. builder.ParagraphFormat.Style.Font.Bold = false;
  17284. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17285. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17286. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17287. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17288. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17289. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17290. builder.Write($"{item.City}");
  17291. builder.EndRow();
  17292. #endregion
  17293. #region 第二行
  17294. builder.InsertCell();
  17295. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17296. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17297. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17298. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17299. builder.ParagraphFormat.Style.Font.Bold = false;
  17300. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17301. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17302. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17303. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17304. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17305. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17306. builder.Write("CONFIRMATION NO:");
  17307. builder.InsertCell();
  17308. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17309. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17310. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17311. builder.ParagraphFormat.Style.Font.Bold = false;
  17312. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17313. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17314. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17315. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17316. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17317. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17318. builder.CellFormat.VerticalMerge = CellMerge.None;
  17319. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17320. builder.Write($"{item.DetermineNo}");
  17321. builder.InsertCell();
  17322. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17323. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17324. builder.InsertCell();
  17325. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17326. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17327. builder.EndRow();
  17328. #endregion
  17329. #region 第三行
  17330. builder.InsertCell();
  17331. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17332. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17333. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17334. builder.ParagraphFormat.Style.Font.Bold = false;
  17335. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17336. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17337. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17338. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17339. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17340. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17341. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17342. builder.Write($"HOTEL NAME:");
  17343. builder.InsertCell();
  17344. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17345. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17346. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17347. builder.ParagraphFormat.Style.Font.Bold = false;
  17348. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17349. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17350. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17351. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17352. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17353. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17354. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17355. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17356. builder.Write($"{item.HotelName}");
  17357. builder.InsertCell();
  17358. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17359. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17360. builder.InsertCell();
  17361. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17362. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17363. builder.EndRow();
  17364. #endregion
  17365. #region 第四行
  17366. builder.InsertCell();
  17367. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17368. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17369. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17370. builder.ParagraphFormat.Style.Font.Bold = false;
  17371. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17372. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17373. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17374. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17375. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17376. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17377. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17378. builder.Write($"HOTEL ADDRESS:");
  17379. builder.InsertCell();
  17380. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17381. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17382. builder.ParagraphFormat.Style.Font.Size = 8;
  17383. builder.ParagraphFormat.Style.Font.Bold = false;
  17384. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17385. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17386. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17387. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17388. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17389. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17390. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17391. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17392. builder.Write($"{item.HotelAddress}");
  17393. builder.InsertCell();
  17394. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17395. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17396. builder.InsertCell();
  17397. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17398. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17399. builder.EndRow();
  17400. #endregion
  17401. #region 第五行
  17402. builder.InsertCell();
  17403. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17404. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17405. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17406. builder.ParagraphFormat.Style.Font.Bold = false;
  17407. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17408. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17409. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17410. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17411. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17412. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17413. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17414. builder.Write("TEL:");
  17415. builder.InsertCell();
  17416. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17417. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17418. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17419. builder.ParagraphFormat.Style.Font.Bold = false;
  17420. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17421. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17422. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17423. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17424. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17425. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17426. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17427. builder.Write($"{item.HotelTel}");
  17428. builder.InsertCell();
  17429. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17430. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17431. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17432. builder.ParagraphFormat.Style.Font.Bold = false;
  17433. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17434. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17435. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17436. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17437. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17438. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17439. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17440. builder.Write($"FAX:");
  17441. builder.InsertCell();
  17442. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17443. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17444. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17445. builder.ParagraphFormat.Style.Font.Bold = false;
  17446. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17447. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17448. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17449. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17450. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17451. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17452. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17453. builder.Write($"{item.HotelFax}");
  17454. builder.EndRow();
  17455. #endregion
  17456. #region 第六行
  17457. builder.InsertCell();
  17458. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17459. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17460. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17461. builder.ParagraphFormat.Style.Font.Bold = false;
  17462. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17463. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17464. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17465. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17466. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17467. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17468. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17469. builder.Write("CHECK IN:");
  17470. builder.InsertCell();
  17471. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17472. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17473. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17474. builder.ParagraphFormat.Style.Font.Bold = false;
  17475. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17476. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17477. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17478. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17479. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17480. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17481. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17482. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17483. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17484. builder.Write($"{checkInStr}");
  17485. builder.InsertCell();
  17486. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17487. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17488. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17489. builder.ParagraphFormat.Style.Font.Bold = false;
  17490. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17491. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17492. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17493. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17494. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17495. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17496. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17497. builder.Write($"CHECK OUT:");
  17498. builder.InsertCell();
  17499. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  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.Left;//对齐
  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. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17511. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17512. builder.Write($"{checkOutStr}");
  17513. builder.EndRow();
  17514. #endregion
  17515. #region 第七行
  17516. builder.InsertCell();
  17517. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17518. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17519. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17520. builder.ParagraphFormat.Style.Font.Bold = false;
  17521. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17522. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17523. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17524. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17525. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17526. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17527. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17528. builder.Write($"GUEST NAME:");
  17529. builder.InsertCell();
  17530. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17531. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17532. builder.ParagraphFormat.Style.Font.Size = 8;
  17533. builder.ParagraphFormat.Style.Font.Bold = false;
  17534. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17535. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17536. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17537. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17538. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17539. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17540. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17541. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17542. builder.Write($"{item.GuestName}");
  17543. builder.InsertCell();
  17544. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17545. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17546. builder.InsertCell();
  17547. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17548. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17549. builder.EndRow();
  17550. #endregion
  17551. #region 第八行
  17552. builder.InsertCell();
  17553. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17554. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17555. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17556. builder.ParagraphFormat.Style.Font.Bold = false;
  17557. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17558. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17559. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17560. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17561. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17562. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17563. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17564. builder.Write($"ROOM TYPE:");
  17565. builder.InsertCell();
  17566. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17567. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17568. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17569. builder.ParagraphFormat.Style.Font.Bold = false;
  17570. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17571. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17572. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17573. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17574. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17575. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17576. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17577. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17578. builder.Write($"{item.RoomExplanation}");
  17579. builder.InsertCell();
  17580. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17581. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17582. builder.InsertCell();
  17583. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17584. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17585. builder.EndRow();
  17586. #endregion
  17587. #region 第九行
  17588. builder.InsertCell();
  17589. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17590. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17591. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17592. builder.ParagraphFormat.Style.Font.Bold = false;
  17593. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17594. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17595. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17596. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17597. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17598. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17599. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17600. builder.Write($"NOTE:");
  17601. builder.InsertCell();
  17602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17603. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17604. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17605. builder.ParagraphFormat.Style.Font.Bold = false;
  17606. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17607. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17608. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17609. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17610. 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.");
  17611. builder.InsertCell();
  17612. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17613. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17614. builder.InsertCell();
  17615. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17616. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17617. builder.EndRow();
  17618. #endregion
  17619. builder.EndTable();
  17620. //换行
  17621. builder.Writeln("");
  17622. builder.Writeln("");
  17623. }
  17624. #region 获取文档中的所有表格 设置文字自适应
  17625. // 获取文档中的所有表格。
  17626. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17627. {
  17628. // 遍历表格中的所有行。
  17629. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17630. {
  17631. foreach (Cell cell in row.Cells)
  17632. {
  17633. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17634. cellFormat.Width = 0;
  17635. }
  17636. }
  17637. }
  17638. #endregion
  17639. #region 设置页眉
  17640. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  17641. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  17642. if (System.IO.File.Exists(voucherHeaderPath))
  17643. {
  17644. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  17645. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  17646. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  17647. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  17648. // 调整图片位置
  17649. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  17650. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  17651. shape.Top = 50; // 将图片距离页眉上边缘的距离
  17652. shape.Left = 0; // 将图片距离页面左边缘的距离
  17653. shape.Width = 81; // 设置图片宽度
  17654. shape.Height = 36; // 设置图片高度
  17655. }
  17656. //靠右
  17657. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17658. //// 设置页脚上下边距
  17659. //builder.PageSetup.HeaderDistance = 42;
  17660. // 添加页眉线
  17661. Aspose.Words.Border borderHeader = null;
  17662. try
  17663. {
  17664. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  17665. }
  17666. catch (Exception e)
  17667. {
  17668. // TODO Auto-generated catch block
  17669. //e.printStackTrace();
  17670. }
  17671. borderHeader.Shadow = true;
  17672. borderHeader.DistanceFromText = 2;
  17673. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  17674. #endregion
  17675. }
  17676. catch (Exception ex)
  17677. {
  17678. }
  17679. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17680. doc.Save(fileDir);
  17681. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17682. return Ok(JsonView(true, "操作成功!", Url));
  17683. }
  17684. /// <summary>
  17685. /// 酒店预订
  17686. /// 生成 预定成本 Excel
  17687. /// </summary>
  17688. /// <param name="_dto"></param>
  17689. /// <returns></returns>
  17690. [HttpPost]
  17691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17692. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  17693. {
  17694. #region 参数验证
  17695. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  17696. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  17697. if (!vadalitorRes.IsValid)
  17698. {
  17699. var errors = new StringBuilder();
  17700. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  17701. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  17702. }
  17703. #region 团组操作权限验证 76 酒店预定模块
  17704. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17705. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17706. #endregion
  17707. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17708. #region 页面操作权限验证
  17709. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17710. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17711. #endregion
  17712. #endregion
  17713. decimal _rate = 1.00M;
  17714. string _currency = string.Empty;
  17715. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  17716. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17717. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  17718. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17719. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  17720. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  17721. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  17722. if (_GroupCostParameter == null)
  17723. {
  17724. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  17725. bool isIntType = int.TryParse(_currency, out int currId);
  17726. if (isIntType)
  17727. {
  17728. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17729. }
  17730. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17731. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17732. if (currInfo == null)
  17733. {
  17734. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17735. }
  17736. else _rate = currInfo.Rate;
  17737. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  17738. {
  17739. _rate = _GroupCostParameter.Rate;
  17740. }
  17741. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17742. //string strFileName = "HotelStatement/";
  17743. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17744. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17745. var rateDatas = new List<dynamic>();
  17746. #region 数据处理
  17747. foreach (var item in hrDtas)
  17748. {
  17749. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17750. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17751. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17752. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17753. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17754. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  17755. {
  17756. continue;
  17757. }
  17758. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17759. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  17760. string singleRoomFeeStr = string.Empty,
  17761. doubleRoomFeeStr = string.Empty,
  17762. suiteRoomFeeStr = string.Empty,
  17763. otherRoomFeeStr = string.Empty,
  17764. payMoneyStr = string.Empty,
  17765. cardPriceStr = string.Empty;
  17766. if (roomCurr.Equals("CNY"))
  17767. {
  17768. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  17769. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17770. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17771. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17772. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17773. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  17774. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  17775. }
  17776. else
  17777. {
  17778. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17779. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17780. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17781. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17782. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17783. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17784. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17785. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17786. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17787. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17788. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  17789. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  17790. if (ccpPaymentCurrency.Equals("CNY"))
  17791. {
  17792. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  17793. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17794. }
  17795. else
  17796. {
  17797. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17798. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17799. }
  17800. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17801. if (hotelcardPriceCurrency.Equals("CNY"))
  17802. {
  17803. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17804. }
  17805. else
  17806. {
  17807. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  17808. }
  17809. }
  17810. string breakfastPriceStr = string.Empty,
  17811. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17812. governmentRentStr = string.Empty,
  17813. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17814. cityTaxStr = string.Empty,
  17815. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17816. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  17817. if (!string.IsNullOrEmpty(breakfastCurrency1))
  17818. {
  17819. if (breakfastCurrency1.Equals("CNY"))
  17820. {
  17821. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17822. }
  17823. else
  17824. {
  17825. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  17826. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  17827. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  17828. }
  17829. }
  17830. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17831. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  17832. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  17833. {
  17834. if (governmentRentCurrency.Equals("CNY"))
  17835. {
  17836. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17837. }
  17838. else
  17839. {
  17840. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  17841. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  17842. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  17843. }
  17844. }
  17845. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17846. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  17847. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  17848. {
  17849. if (cityTaxStrCurrency1.Equals("CNY"))
  17850. {
  17851. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17852. }
  17853. else
  17854. {
  17855. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  17856. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  17857. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  17858. }
  17859. }
  17860. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17861. int payDId = roomInfo?.PayDId ?? 0;
  17862. pcfds.Add(new HotelReservations_PCFD_View()
  17863. {
  17864. City = item.City,
  17865. HotelName = item.HotelName,
  17866. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17867. // SingleRoomCount = item.SingleRoomCount,
  17868. SingleRoomPrice = singleRoomFeeStr,
  17869. // DoubleRoomCount = item.DoubleRoomCount,
  17870. DoubleRoomPrice = doubleRoomFeeStr,
  17871. //SuiteRoomCount = item.SuiteRoomCount,
  17872. SuiteRoomPrice = suiteRoomFeeStr,
  17873. OtherRoomPrice = otherRoomFeeStr,
  17874. //OtherRoomCount = item.OtherRoomCount,
  17875. BreakfastPrice = breakfastPriceStr,
  17876. GovernmentRent = governmentRentStr,
  17877. CityTax = cityTaxStr,
  17878. RoomExplanation = item.RoomExplanation,
  17879. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17880. PayTime = roomInfo?.ConsumptionDate,
  17881. BankNo = roomInfo?.BankNo,
  17882. PayMoney = payMoneyStr,
  17883. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17884. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17885. CardPrice = cardPriceStr,
  17886. Remark = ccpInfo.Remark
  17887. });
  17888. }
  17889. #endregion
  17890. //载入模板
  17891. WorkbookDesigner designer = new WorkbookDesigner();
  17892. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17893. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17894. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17895. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17896. var rateDatas1 = rateDatas.Distinct();
  17897. var rateStr = string.Empty;
  17898. foreach (var item in rateDatas1)
  17899. {
  17900. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  17901. }
  17902. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  17903. designer.SetDataSource("Opertor", userInfo.CnName);
  17904. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17905. dt.TableName = "ViewMyHotelReservations";
  17906. designer.SetDataSource(dt);
  17907. designer.Process();
  17908. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17909. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17910. designer.Workbook.Save(serverPath);
  17911. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17912. #region 删除指定行
  17913. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17914. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17915. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17916. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17917. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17918. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17919. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17920. cssIndex = dt.Columns["CityTax"].Ordinal,
  17921. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17922. remarkIndex = dt.Columns["Remark"].Ordinal;
  17923. //删除指定列
  17924. foreach (DataRow item in dt.Rows)
  17925. {
  17926. string singleStr = item["SingleRoomPrice"].ToString();
  17927. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17928. if (containsDigitButNotZero1) singleDel = false;
  17929. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17930. string doubleStr = item["DoubleRoomPrice"].ToString();
  17931. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17932. if (containsDigitButNotZero2) doubleDel = false;
  17933. string suiteStr = item["SuiteRoomPrice"].ToString();
  17934. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17935. if (containsDigitButNotZero3) suiteDel = false;
  17936. string otherStr = item["OtherRoomPrice"].ToString();
  17937. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17938. if (containsDigitButNotZero4) otherDel = false;
  17939. string zcStr = item["BreakfastPrice"].ToString();
  17940. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17941. if (containsDigitButNotZero5) zcDel = false;
  17942. string dsStr = item["GovernmentRent"].ToString();
  17943. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17944. if (containsDigitButNotZero6) dsDel = false;
  17945. string cssStr = item["CityTax"].ToString();
  17946. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17947. if (containsDigitButNotZero7) cssDel = false;
  17948. string cpStr = item["ConsumptionPatterns"].ToString();
  17949. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  17950. string remarkStr = item["Remark"].ToString();
  17951. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  17952. }
  17953. DeleteColumn(serverPath, remarkIndex, remarkDel);
  17954. DeleteColumn(serverPath, cpIndex, cpDel);
  17955. DeleteColumn(serverPath, dsIndex, dsDel);
  17956. DeleteColumn(serverPath, cssIndex, cssDel);
  17957. DeleteColumn(serverPath, zcIndex, zcDel);
  17958. DeleteColumn(serverPath, otherIndex, otherDel);
  17959. DeleteColumn(serverPath, suiteIndex, suiteDel);
  17960. DeleteColumn(serverPath, doubleIndex, doubleDel);
  17961. DeleteColumn(serverPath, singleIndex, singleDel);
  17962. #endregion
  17963. //只保留第一个表格
  17964. DeleteSheet(serverPath);
  17965. return Ok(JsonView(true, "操作成功", url = rst));
  17966. }
  17967. else
  17968. {
  17969. _currency = _GroupCostParameter.Currency;
  17970. bool isIntType = int.TryParse(_currency, out int currId);
  17971. if (isIntType)
  17972. {
  17973. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17974. }
  17975. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17976. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17977. if (currInfo == null)
  17978. {
  17979. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17980. }
  17981. if (!_currency.ToUpper().Equals("CNY"))
  17982. {
  17983. _rate = _GroupCostParameter.Rate;
  17984. }
  17985. _rate = currInfo.Rate;
  17986. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17987. //string strFileName = "HotelStatement/";
  17988. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17989. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17990. #region 数据处理
  17991. foreach (var item in hrDtas)
  17992. {
  17993. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17994. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17995. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17996. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17997. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17998. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17999. string singleRoomFeeStr = string.Empty,
  18000. doubleRoomFeeStr = string.Empty,
  18001. suiteRoomFeeStr = string.Empty,
  18002. otherRoomFeeStr = string.Empty,
  18003. payMoneyStr = string.Empty,
  18004. cardPriceStr = string.Empty;
  18005. if (roomCurr.Equals(_currency))
  18006. {
  18007. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18008. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18009. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18010. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18011. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18012. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18013. }
  18014. else
  18015. {
  18016. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18017. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18018. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18019. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18020. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18021. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18022. }
  18023. string breakfastPriceStr = string.Empty,
  18024. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18025. governmentRentStr = string.Empty,
  18026. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18027. cityTaxStrStr = string.Empty,
  18028. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18029. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18030. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18031. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18032. int payDId = roomInfo?.PayDId ?? 0;
  18033. pcfds.Add(new HotelReservations_PCFD_View()
  18034. {
  18035. City = item.City,
  18036. HotelName = item.HotelName,
  18037. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18038. // SingleRoomCount = item.SingleRoomCount,
  18039. SingleRoomPrice = singleRoomFeeStr,
  18040. // DoubleRoomCount = item.DoubleRoomCount,
  18041. DoubleRoomPrice = doubleRoomFeeStr,
  18042. //SuiteRoomCount = item.SuiteRoomCount,
  18043. SuiteRoomPrice = suiteRoomFeeStr,
  18044. OtherRoomPrice = otherRoomFeeStr,
  18045. //OtherRoomCount = item.OtherRoomCount,
  18046. BreakfastPrice = breakfastPriceStr,
  18047. GovernmentRent = governmentRentStr,
  18048. CityTax = cityTaxStrStr,
  18049. RoomExplanation = item.RoomExplanation,
  18050. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18051. PayTime = roomInfo?.ConsumptionDate,
  18052. BankNo = roomInfo?.BankNo,
  18053. PayMoney = payMoneyStr,
  18054. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18055. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18056. CardPrice = cardPriceStr,
  18057. Remark = ccpInfo.Remark
  18058. });
  18059. }
  18060. #endregion
  18061. //载入模板
  18062. WorkbookDesigner designer = new WorkbookDesigner();
  18063. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18064. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18065. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18066. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18067. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18068. designer.SetDataSource("Opertor", userInfo.CnName);
  18069. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18070. dt.TableName = "ViewMyHotelReservations";
  18071. designer.SetDataSource(dt);
  18072. designer.Process();
  18073. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18074. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18075. designer.Workbook.Save(serverPath);
  18076. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18077. #region 删除指定行
  18078. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18079. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18080. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18081. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18082. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18083. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18084. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18085. cssIndex = dt.Columns["CityTax"].Ordinal,
  18086. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18087. remarkIndex = dt.Columns["Remark"].Ordinal;
  18088. //删除指定列
  18089. foreach (DataRow item in dt.Rows)
  18090. {
  18091. string singleStr = item["SingleRoomPrice"].ToString();
  18092. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18093. if (containsDigitButNotZero1) singleDel = false;
  18094. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18095. string doubleStr = item["DoubleRoomPrice"].ToString();
  18096. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18097. if (containsDigitButNotZero2) doubleDel = false;
  18098. string suiteStr = item["SuiteRoomPrice"].ToString();
  18099. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18100. if (containsDigitButNotZero3) suiteDel = false;
  18101. string otherStr = item["OtherRoomPrice"].ToString();
  18102. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18103. if (containsDigitButNotZero4) otherDel = false;
  18104. string zcStr = item["BreakfastPrice"].ToString();
  18105. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18106. if (containsDigitButNotZero5) zcDel = false;
  18107. string dsStr = item["GovernmentRent"].ToString();
  18108. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18109. if (containsDigitButNotZero6) dsDel = false;
  18110. string cssStr = item["CityTax"].ToString();
  18111. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18112. if (containsDigitButNotZero7) cssDel = false;
  18113. string cpStr = item["ConsumptionPatterns"].ToString();
  18114. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18115. string remarkStr = item["Remark"].ToString();
  18116. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18117. }
  18118. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18119. DeleteColumn(serverPath, cpIndex, cpDel);
  18120. DeleteColumn(serverPath, dsIndex, dsDel);
  18121. DeleteColumn(serverPath, cssIndex, cssDel);
  18122. DeleteColumn(serverPath, zcIndex, zcDel);
  18123. DeleteColumn(serverPath, otherIndex, otherDel);
  18124. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18125. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18126. DeleteColumn(serverPath, singleIndex, singleDel);
  18127. #endregion
  18128. //只保留第一个表格
  18129. DeleteSheet(serverPath);
  18130. return Ok(JsonView(true, "操作成功", url = rst));
  18131. }
  18132. //return Ok(JsonView(false));
  18133. }
  18134. /// <summary>
  18135. /// 删除指定列
  18136. /// </summary>
  18137. /// <param name="file"></param>
  18138. /// <param name="columnIndex"></param>
  18139. /// <param name="isDel"></param>
  18140. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18141. {
  18142. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18143. //wb.Save(file);
  18144. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18145. if (sheet1 != null)
  18146. {
  18147. if (isDel)
  18148. {
  18149. Cells cells = sheet1.Cells;
  18150. cells.DeleteColumn(columnIndex);
  18151. }
  18152. }
  18153. wb.Save(file);
  18154. }
  18155. /// <summary>
  18156. /// 删除sheet
  18157. /// </summary>
  18158. /// <param name="file"></param>
  18159. /// <param name="sheetName"></param>
  18160. private void DeleteSheet(string file, string sheetName = "")
  18161. {
  18162. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18163. //wb.Save(file);
  18164. List<string> sheets = new List<string>();
  18165. foreach (var item in wb.Worksheets)
  18166. {
  18167. sheets.Add(item.Name);
  18168. }
  18169. if (sheets.Count > 0)
  18170. {
  18171. sheets.RemoveAt(0);//不删除第一个sheet
  18172. foreach (var item in sheets)
  18173. {
  18174. wb.Worksheets.RemoveAt(item);
  18175. }
  18176. }
  18177. wb.Save(file);
  18178. }
  18179. /// <summary>
  18180. /// 酒店预订
  18181. /// 确认单
  18182. /// </summary>
  18183. /// <param name="_dto"></param>
  18184. /// <returns></returns>
  18185. [HttpPost]
  18186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18187. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18188. {
  18189. try
  18190. {
  18191. #region 参数验证
  18192. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18193. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18194. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18195. #region 团组操作权限验证 76 酒店预定模块
  18196. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18197. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18198. #endregion
  18199. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18200. #region 页面操作权限验证
  18201. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18202. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18203. #endregion
  18204. #endregion
  18205. //团组信息
  18206. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18207. //酒店数据
  18208. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18209. if (listhoteldata.Count < 0)
  18210. {
  18211. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18212. }
  18213. //利datatable存储
  18214. DataTable dt = new DataTable();
  18215. dt.Columns.Add("CheckInDate", typeof(string));
  18216. dt.Columns.Add("City", typeof(string));
  18217. dt.Columns.Add("Hotel", typeof(string));
  18218. dt.Columns.Add("Room", typeof(string));
  18219. for (int i = 0; i < listhoteldata.Count; i++)
  18220. {
  18221. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18222. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18223. while (dayStart < dayEnd)
  18224. {
  18225. string temp = "";
  18226. DataRow row = dt.NewRow();
  18227. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18228. row["City"] = listhoteldata[i].City;
  18229. row["Hotel"] = listhoteldata[i].HotelName;
  18230. if (listhoteldata[i].SingleRoomCount > 0)
  18231. {
  18232. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18233. }
  18234. if (listhoteldata[i].DoubleRoomCount > 0)
  18235. {
  18236. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18237. }
  18238. if (listhoteldata[i].SuiteRoomCount > 0)
  18239. {
  18240. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18241. }
  18242. if (listhoteldata[i].OtherRoomCount > 0)
  18243. {
  18244. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18245. }
  18246. row["Room"] = temp;
  18247. dt.Rows.Add(row);
  18248. dayStart = dayStart.AddDays(1);
  18249. }
  18250. }
  18251. Dictionary<string, string> dic = new Dictionary<string, string>();
  18252. dic.Add("Dele", di.TeamName);
  18253. dic.Add("City", di.VisitCountry);
  18254. //模板路径
  18255. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18256. //载入模板
  18257. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18258. DocumentBuilder builder = new DocumentBuilder(doc);
  18259. foreach (var key in dic.Keys)
  18260. {
  18261. builder.MoveToBookmark(key);
  18262. builder.Write(dic[key]);
  18263. }
  18264. //获取word里所有表格
  18265. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18266. //获取所填表格的序数
  18267. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18268. var rowStart = tableOne.Rows[0]; //获取第1行
  18269. //循环赋值
  18270. for (int i = 0; i < dt.Rows.Count; i++)
  18271. {
  18272. builder.MoveToCell(0, i + 1, 0, 0);
  18273. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18274. builder.MoveToCell(0, i + 1, 1, 0);
  18275. builder.Write(dt.Rows[i]["City"].ToString());
  18276. builder.MoveToCell(0, i + 1, 2, 0);
  18277. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18278. builder.MoveToCell(0, i + 1, 3, 0);
  18279. builder.Write(dt.Rows[i]["Room"].ToString());
  18280. }
  18281. //删除多余行
  18282. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18283. {
  18284. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18285. }
  18286. string strFileName = di.TeamName + "酒店确认单.doc";
  18287. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18288. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18289. return Ok(JsonView(true, "成功", url));
  18290. }
  18291. catch (Exception ex)
  18292. {
  18293. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18294. }
  18295. }
  18296. #endregion
  18297. #region 团组状态
  18298. /// <summary>
  18299. /// 团组状态列表 Page
  18300. /// </summary>
  18301. /// <param name="dto">团组列表请求dto</param>
  18302. /// <returns></returns>
  18303. [HttpPost]
  18304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18305. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18306. {
  18307. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18308. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18309. {
  18310. string sqlWhere = string.Empty;
  18311. if (dto.IsSure == 0) //未完成
  18312. {
  18313. sqlWhere += string.Format(@" And IsSure = 0");
  18314. }
  18315. else if (dto.IsSure == 1) //已完成
  18316. {
  18317. sqlWhere += string.Format(@" And IsSure = 1");
  18318. }
  18319. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18320. {
  18321. string tj = dto.SearchCriteria;
  18322. 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}%')",
  18323. tj, tj, tj, tj, tj);
  18324. }
  18325. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18326. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18327. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18328. From (
  18329. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18330. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18331. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18332. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18333. From Grp_DelegationInfo gdi
  18334. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18335. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18336. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18337. Where gdi.IsDel = 0 {0}
  18338. ) temp ", sqlWhere);
  18339. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18340. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18341. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18342. }
  18343. else
  18344. {
  18345. return Ok(JsonView(false, "查询失败"));
  18346. }
  18347. }
  18348. /// <summary>
  18349. /// 团组状态
  18350. /// 设置操作完成
  18351. /// </summary>
  18352. /// <param name="dto">团组列表请求dto</param>
  18353. /// <returns></returns>
  18354. [HttpPost]
  18355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18356. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18357. {
  18358. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18359. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18360. {
  18361. Id = dto.Id,
  18362. IsSure = 1
  18363. };
  18364. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18365. .UpdateColumns(it => new { it.IsSure })
  18366. .WhereColumns(it => new { it.Id })
  18367. .ExecuteCommandAsync();
  18368. if (result > 0)
  18369. {
  18370. return Ok(JsonView(true, "操作完成!"));
  18371. }
  18372. return Ok(JsonView(false, "操作失败!"));
  18373. }
  18374. #endregion
  18375. #region 保险费用录入
  18376. /// <summary>
  18377. /// 根据团组Id查询保险费用列表
  18378. /// </summary>
  18379. /// <param name="dto"></param>
  18380. /// <returns></returns>
  18381. [HttpPost]
  18382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18383. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18384. {
  18385. Result groupData = await _customersRep.CustomersByDiId(dto);
  18386. if (groupData.Code != 0)
  18387. {
  18388. return Ok(JsonView(false, groupData.Msg));
  18389. }
  18390. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18391. }
  18392. /// <summary>
  18393. /// 根据保险费用Id查询保险费用详细
  18394. /// </summary>
  18395. /// <param name="dto"></param>
  18396. /// <returns></returns>
  18397. [HttpPost]
  18398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18399. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18400. {
  18401. try
  18402. {
  18403. Result groupData = await _customersRep.CustomersById(dto);
  18404. if (groupData.Code != 0)
  18405. {
  18406. return Ok(JsonView(false, groupData.Msg));
  18407. }
  18408. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18409. }
  18410. catch (Exception ex)
  18411. {
  18412. return Ok(JsonView(false, ex.Message));
  18413. }
  18414. }
  18415. /// <summary>
  18416. /// 保险费用录入页面初始化绑定
  18417. /// </summary>
  18418. /// <param name="dto"></param>
  18419. /// <returns></returns>
  18420. [HttpPost]
  18421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18422. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18423. {
  18424. try
  18425. {
  18426. Result groupData = await _customersRep.CustomersInitialize(dto);
  18427. if (groupData.Code != 0)
  18428. {
  18429. return Ok(JsonView(false, groupData.Msg));
  18430. }
  18431. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18432. }
  18433. catch (Exception ex)
  18434. {
  18435. return Ok(JsonView(false, ex.Message));
  18436. }
  18437. }
  18438. /// <summary>
  18439. /// 保险费用操作(Status:1.新增,2.修改)
  18440. /// </summary>
  18441. /// <param name="dto"></param>
  18442. /// <returns></returns>
  18443. [HttpPost]
  18444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18445. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18446. {
  18447. Result groupData = await _customersRep.OpCustomers(dto);
  18448. if (groupData.Code != 0)
  18449. {
  18450. return Ok(JsonView(false, groupData.Msg));
  18451. }
  18452. #region 应用推送
  18453. try
  18454. {
  18455. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18456. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18457. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18458. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18459. //自动审核
  18460. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18461. //2024-10-21 新增LZ UID
  18462. var userIds = new List<int>() { 21 };
  18463. string title = $"系统通知";
  18464. var diId = dto.DiId;
  18465. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18466. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18467. string content = "";
  18468. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18469. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18470. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18471. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18472. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18473. }
  18474. catch (Exception ex)
  18475. {
  18476. }
  18477. #endregion
  18478. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18479. }
  18480. /// <summary>
  18481. /// 保险文件上传
  18482. /// </summary>
  18483. /// <param name="file"></param>
  18484. /// <returns></returns>
  18485. [HttpPost]
  18486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18487. public async Task<IActionResult> UploadCus(IFormFile file)
  18488. {
  18489. try
  18490. {
  18491. if (file != null)
  18492. {
  18493. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18494. //文件名称
  18495. string projectFileName = file.FileName;
  18496. //上传的文件的路径
  18497. string filePath = "";
  18498. if (!Directory.Exists(fileDir))
  18499. {
  18500. Directory.CreateDirectory(fileDir);
  18501. }
  18502. //上传的文件的路径
  18503. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18504. using (FileStream fs = System.IO.File.Create(filePath))
  18505. {
  18506. file.CopyTo(fs);
  18507. fs.Flush();
  18508. }
  18509. return Ok(JsonView(true, "上传成功!", projectFileName));
  18510. }
  18511. else
  18512. {
  18513. return Ok(JsonView(false, "上传失败!"));
  18514. }
  18515. }
  18516. catch (Exception ex)
  18517. {
  18518. return Ok(JsonView(false, "程序错误!"));
  18519. throw;
  18520. }
  18521. }
  18522. /// <summary>
  18523. /// 保险删除指定文件
  18524. /// </summary>
  18525. /// <param name="dto"></param>
  18526. /// <returns></returns>
  18527. [HttpPost]
  18528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18529. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18530. {
  18531. try
  18532. {
  18533. string filePath = "";
  18534. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18535. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18536. //int id = 0;
  18537. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18538. // 删除该文件
  18539. try
  18540. {
  18541. System.IO.File.Delete(filePath);
  18542. 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()
  18543. {
  18544. Attachment = "",
  18545. }).ExecuteCommandAsync();
  18546. if (result != 0)
  18547. {
  18548. return Ok(JsonView(true, "成功!"));
  18549. }
  18550. else
  18551. {
  18552. return Ok(JsonView(false, "失败!"));
  18553. }
  18554. }
  18555. catch (Exception)
  18556. {
  18557. 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()
  18558. {
  18559. Attachment = "",
  18560. }).ExecuteCommandAsync();
  18561. if (result != 0)
  18562. {
  18563. return Ok(JsonView(true, "成功!"));
  18564. }
  18565. else
  18566. {
  18567. return Ok(JsonView(false, "失败!"));
  18568. }
  18569. }
  18570. }
  18571. catch (Exception ex)
  18572. {
  18573. return Ok(JsonView(false, "程序错误!"));
  18574. throw;
  18575. }
  18576. }
  18577. /// <summary>
  18578. /// 保险费用操作(删除)
  18579. /// </summary>
  18580. /// <param name="dto"></param>
  18581. /// <returns></returns>
  18582. [HttpPost]
  18583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18584. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18585. {
  18586. try
  18587. {
  18588. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18589. if (!res)
  18590. {
  18591. return Ok(JsonView(false, "删除失败"));
  18592. }
  18593. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18594. {
  18595. IsDel = 1,
  18596. DeleteUserId = dto.DeleteUserId,
  18597. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18598. }).ExecuteCommandAsync();
  18599. return Ok(JsonView(true, "删除成功!"));
  18600. }
  18601. catch (Exception ex)
  18602. {
  18603. return Ok(JsonView(false, "程序错误!"));
  18604. throw;
  18605. }
  18606. }
  18607. #endregion
  18608. #region 接团客户名单 PageId 104
  18609. /// <summary>
  18610. /// 接团客户名单
  18611. /// 迁移数据(慎用!)
  18612. /// </summary>
  18613. /// <returns></returns>
  18614. [HttpPost]
  18615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18616. public async Task<IActionResult> PostTourClientListChange()
  18617. {
  18618. try
  18619. {
  18620. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18621. //var groupClinetData1
  18622. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18623. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18624. int updateCount = 0;
  18625. if (oldOAClientList.Count > 0)
  18626. {
  18627. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18628. _sqlSugar.BeginTran();
  18629. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18630. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18631. foreach (var item in oldOAClientList)
  18632. {
  18633. int comId = 0;
  18634. string format = "yyyy-MM-dd HH:mm:ss";
  18635. string data11 = "1990-01-01 00:00";
  18636. var data1 = IsValidDate(item.OPdate, format);
  18637. if (data1) data11 = item.OPdate;
  18638. //客户公司验证
  18639. if (!string.IsNullOrEmpty(item.Company))
  18640. {
  18641. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  18642. if (clientComInfo == null) // add
  18643. {
  18644. var addInfo = new Crm_CustomerCompany()
  18645. {
  18646. CompanyAbbreviation = "",
  18647. CompanyFullName = item.Company,
  18648. Address = "",
  18649. PostCodes = "",
  18650. LastedOpUserId = item.OPer,
  18651. LastedOpDt = Convert.ToDateTime(data11),
  18652. CreateUserId = item.OPer,
  18653. CreateTime = Convert.ToDateTime(data11),
  18654. IsDel = 0
  18655. };
  18656. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  18657. if (comId1 > 0) comId = comId1;
  18658. }
  18659. else comId = clientComInfo.Id;
  18660. }
  18661. //客户人员验证
  18662. int clientId = 0;
  18663. string name = item.LastName + item.Name;
  18664. if (!string.IsNullOrEmpty(name))
  18665. {
  18666. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  18667. if (clientInfo == null)
  18668. {
  18669. DateTime? dateTime = null;
  18670. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  18671. if (isDt) dateTime = birthDayDt;
  18672. var addInfo1 = new Crm_DeleClient()
  18673. {
  18674. CrmCompanyId = comId,
  18675. DiId = -1,
  18676. LastName = item.LastName,
  18677. FirstName = item.Name,
  18678. OldName = "",
  18679. Pinyin = item.Pinyin,
  18680. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  18681. Marriage = 0,
  18682. Phone = item.Phone,
  18683. Job = item.Job,
  18684. BirthDay = dateTime
  18685. };
  18686. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  18687. if (clientId1 > 0) clientId = clientId1;
  18688. }
  18689. else clientId = clientInfo.Id;
  18690. }
  18691. if (clientId < 1)
  18692. {
  18693. continue;
  18694. }
  18695. int airType = 0;
  18696. if (item.AirType == "超经舱") airType = 459;
  18697. else if (item.AirType == "公务舱") airType = 458;
  18698. else if (item.AirType == "经济舱") airType = 460;
  18699. else if (item.AirType == "其他") airType = 565;
  18700. else if (item.AirType == "头等舱") airType = 457;
  18701. var _TourClientListEntity = new Grp_TourClientList()
  18702. {
  18703. DiId = item.Diid,
  18704. ClientId = clientId,
  18705. CreateUserId = item.OPer,
  18706. CreateTime = Convert.ToDateTime(data11),
  18707. Remark = item.Remark,
  18708. IsDel = item.Isdel,
  18709. ShippingSpaceTypeId = airType,
  18710. ShippingSpaceSpecialNeeds = item.AirRemark,
  18711. HotelSpecialNeeds = item.RoomType
  18712. };
  18713. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  18714. if (_TourClientList > 0)
  18715. {
  18716. updateCount++;
  18717. }
  18718. }
  18719. _sqlSugar.CommitTran();
  18720. }
  18721. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  18722. }
  18723. catch (Exception ex)
  18724. {
  18725. _sqlSugar.RollbackTran();
  18726. return Ok(JsonView(false, ex.Message));
  18727. }
  18728. //return Ok(JsonView(true));
  18729. }
  18730. private bool IsValidDate(string dateString, string format)
  18731. {
  18732. DateTime dateValue;
  18733. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  18734. return valid;
  18735. }
  18736. /// <summary>
  18737. /// 接团客户名单
  18738. /// 根据团组Id查询List
  18739. /// </summary>
  18740. /// <param name="_dto"></param>
  18741. /// <returns></returns>
  18742. [HttpPost]
  18743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18744. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  18745. {
  18746. #region 参数验证
  18747. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  18748. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  18749. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  18750. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18751. #region 页面操作权限验证
  18752. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18753. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18754. #endregion
  18755. #endregion
  18756. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  18757. if (viewData.Code != 0)
  18758. {
  18759. return Ok(JsonView(false, viewData.Msg));
  18760. }
  18761. return Ok(JsonView(viewData.Data));
  18762. }
  18763. /// <summary>
  18764. /// 接团客户名单
  18765. /// 基础数据 Init
  18766. /// </summary>
  18767. /// <param name="_dto"></param>
  18768. /// <returns></returns>
  18769. [HttpPost]
  18770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18771. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  18772. {
  18773. #region 参数验证
  18774. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18775. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18776. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18777. #region 页面操作权限验证
  18778. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18779. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18780. #endregion
  18781. #endregion
  18782. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  18783. }
  18784. /// <summary>
  18785. /// 接团客户名单
  18786. /// 根据 Id查询 Details
  18787. /// </summary>
  18788. /// <param name="_dto"></param>
  18789. /// <returns></returns>
  18790. [HttpPost]
  18791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18792. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  18793. {
  18794. #region 参数验证
  18795. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18796. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18797. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18798. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18799. #region 页面操作权限验证
  18800. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18801. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18802. #endregion
  18803. #endregion
  18804. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18805. if (viewData.Code != 0)
  18806. {
  18807. return Ok(JsonView(false, viewData.Msg));
  18808. }
  18809. return Ok(JsonView(viewData.Data));
  18810. }
  18811. /// <summary>
  18812. /// 接团客户名单
  18813. /// Add Or Edit
  18814. /// </summary>
  18815. /// <param name="_dto"></param>
  18816. /// <returns></returns>
  18817. [HttpPost]
  18818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18819. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  18820. {
  18821. #region 参数验证
  18822. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18823. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18824. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18825. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18826. #region 页面操作权限验证
  18827. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18828. if (_dto.Id == 0) //添加
  18829. {
  18830. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18831. }
  18832. else if (_dto.Id >= 0) //修改
  18833. {
  18834. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18835. }
  18836. #endregion
  18837. #endregion
  18838. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  18839. if (viewData.Code != 0)
  18840. {
  18841. return Ok(JsonView(false, viewData.Msg));
  18842. }
  18843. return Ok(JsonView(true));
  18844. }
  18845. /// <summary>
  18846. /// 接团客户名单
  18847. /// json字符串 AddMultiple(添加多个)
  18848. /// </summary>
  18849. /// <param name="_dto"></param>
  18850. /// <returns></returns>
  18851. [HttpPost]
  18852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18853. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  18854. {
  18855. #region 参数验证
  18856. string jsonLabel = _dto.JsonLabel;
  18857. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18858. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18859. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18860. #region 页面操作权限验证
  18861. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18862. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18863. #endregion
  18864. #endregion
  18865. var request = new TourClientListAddMultipleDto();
  18866. request.DiId = _dto.DiId;
  18867. request.UserId = _dto.UserId;
  18868. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  18869. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  18870. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  18871. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  18872. var infos = new List<TourClientListInfo>();
  18873. foreach (var data in datas)
  18874. {
  18875. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  18876. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  18877. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  18878. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  18879. {
  18880. continue;
  18881. }
  18882. infos.Add(new TourClientListInfo()
  18883. {
  18884. IsAccompany = 1,
  18885. LastName = lastName,
  18886. FirstName = firstName,
  18887. Pinyin = lastNameEn + @"/" + firstNameEn,
  18888. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  18889. CompanyFullName = data.CompanyFullName,
  18890. Job = data.Job
  18891. });
  18892. }
  18893. if (infos.Any())
  18894. {
  18895. var viewData = await _tourClientListRep._AddMultiple(request);
  18896. if (viewData.Code != 0)
  18897. {
  18898. return Ok(JsonView(false, viewData.Msg));
  18899. }
  18900. return Ok(JsonView(true));
  18901. }
  18902. return Ok(JsonView(false));
  18903. }
  18904. /// <summary>
  18905. /// 接团客户名单
  18906. /// AddMultiple(添加多个)
  18907. /// </summary>
  18908. /// <param name="_dto"></param>
  18909. /// <returns></returns>
  18910. [HttpPost]
  18911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18912. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  18913. {
  18914. #region 参数验证
  18915. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18916. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18917. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18918. #region 页面操作权限验证
  18919. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18920. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18921. #endregion
  18922. #endregion
  18923. var viewData = await _tourClientListRep._AddMultiple(_dto);
  18924. if (viewData.Code != 0)
  18925. {
  18926. return Ok(JsonView(false, viewData.Msg));
  18927. }
  18928. return Ok(JsonView(true));
  18929. }
  18930. /// <summary>
  18931. /// 接团客户名单
  18932. /// Del
  18933. /// </summary>
  18934. /// <param name="_dto"></param>
  18935. /// <returns></returns>
  18936. [HttpPost]
  18937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18938. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  18939. {
  18940. #region 参数验证
  18941. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18942. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18943. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18944. #region 页面操作权限验证
  18945. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18946. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18947. #endregion
  18948. #endregion
  18949. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  18950. if (viewData.Code != 0)
  18951. {
  18952. return Ok(JsonView(false, viewData.Msg));
  18953. }
  18954. return Ok(JsonView(true));
  18955. }
  18956. /// <summary>
  18957. /// 接团客户名单
  18958. /// 文件下载 客户名单
  18959. /// </summary>
  18960. /// <param name="_dto"></param>
  18961. /// <returns></returns>
  18962. [HttpPost]
  18963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18964. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  18965. {
  18966. #region 参数验证
  18967. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18968. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18969. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  18970. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18971. #region 页面操作权限验证
  18972. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18973. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18974. #endregion
  18975. #endregion
  18976. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  18977. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  18978. From Grp_TourClientList tcl
  18979. Left Join
  18980. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  18981. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  18982. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  18983. From Crm_DeleClient dc
  18984. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  18985. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  18986. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  18987. Where dc.IsDel = 0) temp
  18988. On temp.DcId =tcl.ClientId
  18989. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  18990. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  18991. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  18992. //载入模板
  18993. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  18994. if (_dto.Language == 1)
  18995. {
  18996. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  18997. }
  18998. //载入模板
  18999. var doc = new Document(tempPath);
  19000. DocumentBuilder builder = new DocumentBuilder(doc);
  19001. //获取word里所有表格
  19002. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19003. //获取所填表格的序数
  19004. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19005. var rowStart = tableOne.Rows[0]; //获取第1行
  19006. if (_dto.Language == 0)
  19007. {
  19008. //循环赋值
  19009. for (int i = 0; i < DcList.Count; i++)
  19010. {
  19011. EncryptionProcessor.DecryptProperties(DcList[i]);
  19012. builder.MoveToCell(0, i + 1, 0, 0);
  19013. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19014. builder.MoveToCell(0, i + 1, 1, 0);
  19015. int sex = DcList[i].Sex;
  19016. string sexStr = string.Empty;
  19017. if (sex == 0) sexStr = "男";
  19018. else if (sex == 1) sexStr = "女";
  19019. else sexStr = "未设置";
  19020. builder.Write(sexStr);
  19021. builder.MoveToCell(0, i + 1, 2, 0);
  19022. string birthDay = DcList[i].BirthDay;
  19023. string birthDayStr = string.Empty;
  19024. if (!string.IsNullOrEmpty(birthDay))
  19025. {
  19026. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19027. }
  19028. builder.Write(birthDayStr);
  19029. builder.MoveToCell(0, i + 1, 3, 0);
  19030. string company = "";
  19031. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19032. {
  19033. company = DcList[i].CompanyFullName.ToString();
  19034. }
  19035. builder.Write(company);
  19036. builder.MoveToCell(0, i + 1, 4, 0);
  19037. builder.Write(DcList[i].Job);
  19038. }
  19039. }
  19040. else if (_dto.Language == 1)
  19041. {
  19042. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19043. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19044. List<string> transArrayStr = new List<string>();
  19045. string transStrRes1 = "";
  19046. for (int i = 0; i < DcList.Count; i++)
  19047. {
  19048. var dc = DcList[i];
  19049. EncryptionProcessor.DecryptProperties(dc);
  19050. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19051. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19052. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19053. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19054. else transStrRes1 += $"{str1}|";
  19055. }
  19056. //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";
  19057. string transStrRes = "";
  19058. if (transStrRes1.Length > 0)
  19059. {
  19060. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19061. }
  19062. //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
  19063. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19064. //List<string> transArray = new List<string> { };
  19065. List<TranslateInfo> transArray = new List<TranslateInfo>();
  19066. if (transStrRes.Contains("|"))
  19067. {
  19068. string[] transArray1 = transStrRes.Split('|');
  19069. if (transArray1.Length > 0)
  19070. {
  19071. foreach (var item in transArray1)
  19072. {
  19073. if (item.Contains("&"))
  19074. {
  19075. string[] transArray2 = item.Split('&');
  19076. int index = 0;
  19077. string companyName = "", job = "";
  19078. if (transArray2.Length > 0)
  19079. {
  19080. bool success = int.TryParse(transArray2[0].Trim(), out index);
  19081. if (1 < transArray2.Length) companyName = transArray2[1];
  19082. if (2 < transArray2.Length) job = transArray2[2];
  19083. }
  19084. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19085. }
  19086. }
  19087. }
  19088. }
  19089. //循环赋值
  19090. for (int i = 0; i < DcList.Count; i++)
  19091. {
  19092. string PYName = "";
  19093. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19094. {
  19095. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19096. string PY_First = DcList[i].Pinyin.Split('/')[1];
  19097. PYName = PY_First + " " + PY_Last;
  19098. }
  19099. else
  19100. {
  19101. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19102. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19103. PYName = PY_First + " " + PY_Last;
  19104. }
  19105. builder.MoveToCell(0, i + 1, 0, 0);
  19106. builder.Write(PYName);
  19107. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19108. builder.MoveToCell(0, i + 1, 1, 0);
  19109. builder.Write(sex);
  19110. DateTime birthDt;
  19111. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19112. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19113. builder.MoveToCell(0, i + 1, 2, 0);
  19114. builder.Write(birthday);
  19115. string company = string.Empty, job = string.Empty;
  19116. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19117. if (dcTransInfo != null)
  19118. {
  19119. company = dcTransInfo.CompanyName;
  19120. job = dcTransInfo.Job;
  19121. }
  19122. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19123. {
  19124. //查询对照表
  19125. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19126. if (tempCec != null)
  19127. {
  19128. company = tempCec.enName;
  19129. }
  19130. //翻译
  19131. else
  19132. {
  19133. }
  19134. }
  19135. builder.MoveToCell(0, i + 1, 3, 0);
  19136. builder.Write(company);
  19137. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19138. {
  19139. //查询对照表
  19140. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19141. if (tempPec != null)
  19142. {
  19143. job = tempPec.enName;
  19144. }
  19145. //翻译
  19146. else
  19147. {
  19148. }
  19149. }
  19150. builder.MoveToCell(0, i + 1, 4, 0);
  19151. builder.Write(job);
  19152. }
  19153. }
  19154. //删除多余行
  19155. while (tableOne.Rows.Count > DcList.Count + 1)
  19156. {
  19157. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19158. }
  19159. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19160. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19161. doc.Save(fileDir);
  19162. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19163. return Ok(JsonView(true, "操作成功!", Url));
  19164. }
  19165. private class TranslateInfo
  19166. {
  19167. public int Index { get; set; }
  19168. public string CompanyName { get; set; }
  19169. public string Job { get; set; }
  19170. }
  19171. [HttpPost]
  19172. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19173. {
  19174. if (files.Count == 0)
  19175. {
  19176. return Ok(JsonView(false, "文件为空"));
  19177. }
  19178. KiMiApiClient KiMiApi = new KiMiApiClient();
  19179. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19180. if (seedConter.Count == 0)
  19181. {
  19182. return Ok(JsonView(false, "上传结果为空!"));
  19183. }
  19184. var messages = new List<SeedMessages>
  19185. {
  19186. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19187. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19188. };
  19189. messages.InsertRange(1, seedConter);
  19190. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19191. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19192. string clients = kimiApiResult_JObject["content"].ToString();
  19193. string startStr = "```json", endStr = "```";
  19194. // 判断并清除开头部分
  19195. if (clients.StartsWith(startStr))
  19196. {
  19197. clients = clients.Remove(0, startStr.Length);
  19198. }
  19199. // 判断并清除结尾部分
  19200. if (clients.EndsWith(endStr))
  19201. {
  19202. clients = clients.Remove(clients.Length - endStr.Length);
  19203. }
  19204. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19205. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19206. {
  19207. {"姓", "LastName" },
  19208. {"名", "FirstName" },
  19209. {"姓名拼音", "Pinyin" },
  19210. {"性别", "Sex" },
  19211. {"单位", "CompanyFullName" },
  19212. {"职务", "Job" },
  19213. {"出生日期", "Birthday" },
  19214. };
  19215. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19216. foreach (var item in clients_JObject)
  19217. {
  19218. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19219. foreach (var field in clientFieldMap.Keys)
  19220. {
  19221. if (item.TryGetValue(field, out JToken value))
  19222. {
  19223. var getValue = value.ToString();
  19224. System.Type type = cdc.GetType();
  19225. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19226. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19227. propertyInfo.SetValue(cdc, propertyValue);
  19228. }
  19229. }
  19230. crmClients.Add(cdc);
  19231. }
  19232. return Ok(JsonView(new
  19233. {
  19234. fileCount = files.Count,
  19235. UploadCount = seedConter.Count,
  19236. ApiResult = clients,
  19237. CrmClients = crmClients
  19238. }));
  19239. }
  19240. #endregion
  19241. #region 团组倒推表
  19242. /// <summary>
  19243. /// 倒推表基础数据
  19244. /// Init
  19245. /// </summary>
  19246. /// <returns></returns>
  19247. [HttpPost]
  19248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19249. public async Task<IActionResult> PostInvertedListInit()
  19250. {
  19251. var viewData = await _invertedListRep._Init();
  19252. if (viewData.Code != 0)
  19253. {
  19254. return Ok(JsonView(false, viewData.Msg));
  19255. }
  19256. return Ok(JsonView(viewData.Data));
  19257. }
  19258. /// <summary>
  19259. /// 倒推表
  19260. /// Info
  19261. /// </summary>
  19262. /// <param name="dto"></param>
  19263. /// <returns></returns>
  19264. [HttpPost]
  19265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19266. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19267. {
  19268. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19269. if (viewData.Code != 0)
  19270. {
  19271. return Ok(JsonView(false, viewData.Msg));
  19272. }
  19273. return Ok(JsonView(viewData.Data));
  19274. }
  19275. /// <summary>
  19276. /// 倒推表
  19277. /// Create
  19278. /// </summary>
  19279. /// <param name="dto"></param>
  19280. /// <returns></returns>
  19281. [HttpPost]
  19282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19283. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19284. {
  19285. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19286. if (viewData.Code != 0)
  19287. {
  19288. return Ok(JsonView(false, viewData.Msg));
  19289. }
  19290. return Ok(JsonView(viewData.Data));
  19291. }
  19292. /// <summary>
  19293. /// 倒推表
  19294. /// Update
  19295. /// </summary>
  19296. /// <param name="dto"></param>
  19297. /// <returns></returns>
  19298. [HttpPost]
  19299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19300. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19301. {
  19302. var viewData = await _invertedListRep._Update(dto);
  19303. if (viewData.Code != 0)
  19304. {
  19305. return Ok(JsonView(false, viewData.Msg));
  19306. }
  19307. return Ok(JsonView(viewData.Data));
  19308. }
  19309. /// <summary>
  19310. /// 倒推表
  19311. /// File Download
  19312. /// </summary>
  19313. /// <param name="dto"></param>
  19314. /// <returns></returns>
  19315. [HttpPost]
  19316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19317. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19318. {
  19319. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19320. if (info2.Code != 0)
  19321. {
  19322. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19323. }
  19324. var info1 = info2.Data as InvertedListInfoView;
  19325. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19326. string teamName = "";
  19327. if (info != null) teamName = info.TeamName;
  19328. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19329. var doc = new Document();
  19330. var builder = new DocumentBuilder(doc);
  19331. #region old insert
  19332. ////载入模板
  19333. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19334. //Document doc = new Document(tempPath);
  19335. //DocumentBuilder builder = new DocumentBuilder(doc);
  19336. //利用键值对存放数据
  19337. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19338. //dic.Add("TeamName", teamName);
  19339. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19340. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19341. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19342. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19343. //dic.Add("SQRemark", info1.ApprovalRemark);
  19344. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19345. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19346. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19347. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19348. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19349. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19350. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19351. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19352. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19353. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19354. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19355. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19356. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19357. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19358. //#region 填充word模板书签内容
  19359. //foreach (var key in dic.Keys)
  19360. //{
  19361. // builder.MoveToBookmark(key);
  19362. // builder.Write(dic[key]);
  19363. //}
  19364. //#endregion
  19365. #endregion
  19366. #region New Insert
  19367. string titleFont = $"仿宋",
  19368. contentFont = $"仿宋";
  19369. var fontColor = Color.FromArgb(64, 64, 64);
  19370. //设置标题 团组名称
  19371. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19372. builder.Font.Name = titleFont;
  19373. builder.Font.Color = fontColor;
  19374. builder.Font.Size = 12;
  19375. builder.Font.Bold = true;
  19376. builder.Writeln(teamName);
  19377. //设置副标题 团组出访时间
  19378. builder.Font.Size = 12;
  19379. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19380. builder.Writeln();
  19381. var backgroundColor = Color.FromArgb(199, 199, 199);
  19382. var table = builder.StartTable();
  19383. builder.InsertCell();
  19384. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19385. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19386. builder.CellFormat.Borders.LineWidth = 1;
  19387. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19388. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19389. builder.RowFormat.Height = 40;
  19390. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19391. builder.Font.Name = contentFont;
  19392. builder.Font.Size = 12;
  19393. builder.Font.Bold = true;
  19394. builder.Font.Color = fontColor;
  19395. builder.Write("时间");
  19396. builder.InsertCell();
  19397. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19398. builder.Write("流程");
  19399. builder.InsertCell();
  19400. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19401. builder.Write("说明");
  19402. builder.EndRow();
  19403. //报批资料准备
  19404. if (info1.IsSelectedAirportd)
  19405. {
  19406. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19407. }
  19408. //报批/提供送签资料
  19409. if (info1.IsSelectedApprovalData)
  19410. {
  19411. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19412. }
  19413. //出批件护照办理
  19414. if (info1.IsSelectedIssueApproval)
  19415. {
  19416. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19417. }
  19418. //签证资料准备
  19419. if (info1.IsSelectedVisaInfo)
  19420. {
  19421. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19422. }
  19423. //送签
  19424. if (info1.IsSelectedSendVisa)
  19425. {
  19426. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19427. }
  19428. //出签
  19429. if (info1.IsSelectedIssueVisa)
  19430. {
  19431. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19432. }
  19433. //机票
  19434. if (info1.IsSelectedAirTicket)
  19435. {
  19436. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19437. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19438. }
  19439. //酒店
  19440. if (info1.IsSelectedHotel)
  19441. {
  19442. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19443. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19444. }
  19445. //开行前会
  19446. if (info1.IsSelectedPreTripMeeting)
  19447. {
  19448. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19449. }
  19450. //送机
  19451. if (info1.IsSelectedAirportdDropOff)
  19452. {
  19453. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19454. }
  19455. builder.EndTable();
  19456. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19457. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19458. for (int i = 0; i < table.Rows.Count; i++)
  19459. {
  19460. var row = table.Rows[i];
  19461. //设置宽度
  19462. row.Cells[0].CellFormat.Width = 20.00;
  19463. row.Cells[1].CellFormat.Width = 30.00;
  19464. row.Cells[2].CellFormat.Width = 50.00;
  19465. if (i != 0)
  19466. {
  19467. //边框设置
  19468. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19469. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19470. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19471. }
  19472. }
  19473. #region 页脚插入图片
  19474. // 创建页脚
  19475. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19476. doc.FirstSection.HeadersFooters.Add(footer);
  19477. Paragraph para = new Paragraph(doc);
  19478. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19479. footer.AppendChild(para);
  19480. builder.MoveTo(para);
  19481. string imagePath = "./Images/FMGJ_Log.png";
  19482. builder.InsertImage(imagePath);
  19483. #endregion
  19484. #endregion
  19485. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19486. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19487. string filePath = fileDir + $@"InvertedList/{fileName}";
  19488. doc.Save(filePath);
  19489. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19490. return Ok(JsonView(true, "操作成功!", Url));
  19491. }
  19492. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19493. {
  19494. var fontColor = Color.FromArgb(64, 64, 64);
  19495. builder.InsertCell();
  19496. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19497. builder.RowFormat.Height = 40;
  19498. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19499. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19500. builder.Font.Name = fontName;
  19501. builder.Font.Size = 8;
  19502. builder.Font.Bold = true;
  19503. builder.Font.Color = fontColor;
  19504. builder.Write(dateTime);
  19505. builder.InsertCell();
  19506. builder.Font.Size = 9;
  19507. builder.Font.Bold = true;
  19508. builder.Font.Color = fontColor;
  19509. builder.Write(content);
  19510. builder.InsertCell();
  19511. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19512. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19513. builder.Font.Size = 9;
  19514. builder.Font.Bold = false;
  19515. builder.Font.Color = fontColor;
  19516. builder.Write(reamrk);
  19517. builder.EndRow();
  19518. }
  19519. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19520. {
  19521. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19522. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19523. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19524. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19525. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19526. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19527. }
  19528. #endregion
  19529. #region 会务倒推表
  19530. /// <summary>
  19531. /// 会务倒推表
  19532. /// Init
  19533. /// </summary>
  19534. /// <returns></returns>
  19535. [HttpPost]
  19536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19537. public async Task<IActionResult> InforRetrogressTableInit()
  19538. {
  19539. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19540. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19541. return Ok(JsonView(false, groupData.Msg));
  19542. }
  19543. /// <summary>
  19544. /// 会务倒推表
  19545. /// ExcelDownload
  19546. /// </summary>
  19547. /// <param name="dto"></param>
  19548. /// <returns></returns>
  19549. [HttpPost]
  19550. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19552. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19553. {
  19554. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19555. var validatorRes = await validator.ValidateAsync(dto);
  19556. if (!validatorRes.IsValid)
  19557. {
  19558. StringBuilder sb = new StringBuilder();
  19559. foreach (var item in validatorRes.Errors)
  19560. {
  19561. sb.AppendLine(item.ErrorMessage);
  19562. }
  19563. return Ok(JsonView(false, sb.ToString()));
  19564. }
  19565. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  19566. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  19567. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  19568. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  19569. #region Excel
  19570. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  19571. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  19572. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  19573. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  19574. var fileNamePrefix = string.Empty;
  19575. if (days >= 30)
  19576. {
  19577. tempPath += $"会务工作倒推进度表(30天).xlsx";
  19578. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  19579. }
  19580. else if (days < 30 && days > 7)
  19581. {
  19582. tempPath += $"会务工作倒推进度表(15天).xlsx";
  19583. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  19584. }
  19585. else if (days <= 7)
  19586. {
  19587. tempPath += $"会务工作倒推进度表(7天).xlsx";
  19588. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  19589. }
  19590. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  19591. fileName = CommonFun.ValidFileName(fileName);
  19592. //载入模板
  19593. WorkbookDesigner designer = new WorkbookDesigner();
  19594. designer.Workbook = new Workbook(tempPath);
  19595. designer.Process();
  19596. if (!Directory.Exists(savePath))
  19597. {
  19598. Directory.CreateDirectory(savePath);
  19599. }
  19600. string serverPath = $"{savePath}{fileName}";
  19601. designer.Workbook.Save(serverPath);
  19602. string rst = $"{servicePath}{ftpPath}{fileName}";
  19603. #endregion
  19604. return Ok(JsonView(new { url = rst }));
  19605. }
  19606. #endregion
  19607. #region 三公签证费用(签证费、代办费)
  19608. /// <summary>
  19609. /// 三公签证费用(签证费、代办费)
  19610. /// List
  19611. /// </summary>
  19612. /// <returns></returns>
  19613. [HttpPost]
  19614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19615. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  19616. {
  19617. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  19618. if (_view.Code != 0)
  19619. {
  19620. return Ok(JsonView(false, _view.Msg));
  19621. }
  19622. return Ok(JsonView(true, "操作成功!", _view.Data));
  19623. }
  19624. /// <summary>
  19625. /// 三公签证费用(签证费、代办费)
  19626. /// Add Or Update
  19627. /// </summary>
  19628. /// <returns></returns>
  19629. [HttpPost]
  19630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19631. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  19632. {
  19633. var _view = await _visaFeeInfoRep._Update(_dto);
  19634. if (_view.Code != 0)
  19635. {
  19636. return Ok(JsonView(false, _view.Msg));
  19637. }
  19638. return Ok(JsonView(true, _view.Msg));
  19639. }
  19640. #endregion
  19641. #region 酒店询价
  19642. /// <summary>
  19643. /// 酒店询价
  19644. /// Init
  19645. /// </summary>
  19646. /// <returns></returns>
  19647. [HttpPost]
  19648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19649. public async Task<IActionResult> PostHotelInquiryInit()
  19650. {
  19651. var res = await _hotelInquiryRep._Init();
  19652. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19653. return Ok(JsonView(true, res.Msg, res.Data));
  19654. }
  19655. /// <summary>
  19656. /// 酒店询价
  19657. /// page Item
  19658. /// </summary>
  19659. /// <param name="_dto"></param>
  19660. /// <returns></returns>
  19661. [HttpPost]
  19662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19663. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  19664. {
  19665. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  19666. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19667. var view = res.Data as PageDataViewBase;
  19668. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  19669. }
  19670. /// <summary>
  19671. /// 酒店询价
  19672. /// info
  19673. /// </summary>
  19674. /// <param name="_dto"></param>
  19675. /// <returns></returns>
  19676. [HttpPost]
  19677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19678. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  19679. {
  19680. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  19681. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19682. return Ok(JsonView(true, res.Msg, res.Data));
  19683. }
  19684. /// <summary>
  19685. /// 酒店询价
  19686. /// Add Or Edit
  19687. /// </summary>
  19688. /// <param name="_dto"></param>
  19689. /// <returns></returns>
  19690. [HttpPost]
  19691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19692. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  19693. {
  19694. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  19695. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19696. return Ok(JsonView(true, res.Msg, res.Data));
  19697. }
  19698. /// <summary>
  19699. /// 酒店询价
  19700. /// Del
  19701. /// </summary>
  19702. /// <param name="_dto"></param>
  19703. /// <returns></returns>
  19704. [HttpPost]
  19705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19706. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  19707. {
  19708. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  19709. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19710. return Ok(JsonView(true, res.Msg, res.Data));
  19711. }
  19712. #endregion
  19713. #region 下载匹配op行程单
  19714. /// <summary>
  19715. /// 匹配op行程单
  19716. /// Init
  19717. /// </summary>
  19718. /// <param name="dto">团组列表请求dto</param>
  19719. /// <returns></returns>
  19720. [HttpPost]
  19721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19722. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  19723. {
  19724. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19725. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19726. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  19727. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  19728. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  19729. .Where(it => it.IsDel == 0)
  19730. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  19731. .OrderByDescending(it => it.VisitStartDate)
  19732. .ToList();
  19733. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  19734. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  19735. var diids = groupInfos.Select(it => it.Id).ToList();
  19736. List<string> countrys = new List<string>();
  19737. foreach (var item in country)
  19738. {
  19739. var data = _groupRepository.FormartTeamName(item);
  19740. var dataArray = _groupRepository.GroupSplitCountry(data);
  19741. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  19742. }
  19743. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  19744. List<string> areaArray = new List<string>(); //GetGroupCityLine
  19745. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  19746. foreach (var item in areaItem)
  19747. {
  19748. string areaStr = item.Value;
  19749. if (!string.IsNullOrEmpty(areaStr))
  19750. {
  19751. string[] str1 = areaStr.Split("-");
  19752. if (str1.Length > 0)
  19753. {
  19754. areaArray.AddRange(str1);
  19755. }
  19756. }
  19757. }
  19758. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  19759. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  19760. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  19761. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  19762. .ToList();
  19763. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  19764. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  19765. .Where(it => countriesIds.Contains(it.Id))
  19766. .Select(it => new { it.Id, Name = it.Name_CN })
  19767. .ToList();
  19768. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  19769. .Select(it => it.TeamName).ToList();
  19770. stopwatch.Stop();
  19771. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  19772. }
  19773. ///// <summary>
  19774. ///// 匹配op行程单
  19775. ///// Init 查询区域数据
  19776. ///// </summary>
  19777. ///// <param name="dto">团组列表请求dto</param>
  19778. ///// <returns></returns>
  19779. //[HttpPost]
  19780. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19781. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  19782. //{
  19783. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19784. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  19785. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  19786. // if (string.IsNullOrEmpty(countriesDataStr))
  19787. // {
  19788. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  19789. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  19790. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  19791. // }
  19792. // else
  19793. // {
  19794. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  19795. // }
  19796. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  19797. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  19798. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  19799. // List<dynamic> childList = new List<dynamic>();
  19800. // int parentId = dto.CountriesId;
  19801. // if (provinceData.Count > 1)
  19802. // {
  19803. // foreach (var item1 in provinceData)
  19804. // {
  19805. // List<dynamic> childList1 = new List<dynamic>();
  19806. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  19807. // foreach (var item2 in citiesData1)
  19808. // {
  19809. // List<dynamic> childList2 = new List<dynamic>();
  19810. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19811. // foreach (var item3 in countiesData1)
  19812. // {
  19813. // childList2.Add(new
  19814. // {
  19815. // id = item3.Id,
  19816. // parentId = item2.Id,
  19817. // level = "district",
  19818. // name = item3.Name_CN,
  19819. // });
  19820. // }
  19821. // childList1.Add(new
  19822. // {
  19823. // id = item2.Id,
  19824. // parentId = item1.Id,
  19825. // level = "city",
  19826. // name = item2.Name_CN,
  19827. // childList = childList2
  19828. // });
  19829. // }
  19830. // childList.Add(new
  19831. // {
  19832. // id = item1.Id,
  19833. // parentId = parentId,
  19834. // level = "province",
  19835. // name = item1.Name_CN,
  19836. // childList = childList1
  19837. // });
  19838. // }
  19839. // //城市
  19840. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  19841. // foreach (var item2 in citiesData2)
  19842. // {
  19843. // List<dynamic> childList22 = new List<dynamic>();
  19844. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19845. // foreach (var item3 in countiesData1)
  19846. // {
  19847. // childList22.Add(new
  19848. // {
  19849. // id = item3.Id,
  19850. // parentId = item2.Id,
  19851. // level = "district",
  19852. // name = item3.Name_CN,
  19853. // });
  19854. // }
  19855. // childList.Add(new
  19856. // {
  19857. // id = item2.Id,
  19858. // parentId = parentId,
  19859. // level = "city",
  19860. // name = item2.Name_CN,
  19861. // childList = childList22
  19862. // });
  19863. // }
  19864. // }
  19865. // else
  19866. // {
  19867. // foreach (var item2 in citiesData)
  19868. // {
  19869. // string cname = item2.Name_CN;
  19870. // List<dynamic> childList1 = new List<dynamic>();
  19871. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19872. // foreach (var item3 in countiesData1)
  19873. // {
  19874. // childList1.Add(new
  19875. // {
  19876. // Id = item3.Id,
  19877. // parentId = item2.Id,
  19878. // level = "district",
  19879. // name = item3.Name_CN
  19880. // });
  19881. // }
  19882. // childList.Add(new
  19883. // {
  19884. // id = item2.Id,
  19885. // parentId = parentId,
  19886. // level = "city",
  19887. // name = item2.Name_CN,
  19888. // childList = childList1
  19889. // });
  19890. // }
  19891. // }
  19892. // stopwatch.Stop();
  19893. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  19894. //}
  19895. /// <summary>
  19896. /// 匹配op行程单
  19897. /// 接团信息列表 Page
  19898. /// </summary>
  19899. /// <param name="dto">团组列表请求dto</param>
  19900. /// <returns></returns>
  19901. [HttpPost]
  19902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19903. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  19904. {
  19905. var swatch = new Stopwatch();
  19906. swatch.Start();
  19907. #region 参数验证
  19908. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19909. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19910. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19911. #region 页面操作权限验证
  19912. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19913. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  19914. #endregion
  19915. #endregion
  19916. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19917. {
  19918. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  19919. //string sqlWhere = "";
  19920. if (!string.IsNullOrEmpty(dto.Country))
  19921. {
  19922. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  19923. }
  19924. if (!string.IsNullOrEmpty(dto.Area))
  19925. {
  19926. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  19927. }
  19928. if (!string.IsNullOrEmpty(dto.TeamName))
  19929. {
  19930. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  19931. }
  19932. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  19933. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  19934. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  19935. swatch.Stop();
  19936. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  19937. }
  19938. else
  19939. {
  19940. return Ok(JsonView(false, "查询失败"));
  19941. }
  19942. }
  19943. /// <summary>
  19944. /// 匹配op行程单
  19945. /// 行程单下载
  19946. /// </summary>
  19947. /// <param name="dto">团组列表请求dto</param>
  19948. /// <returns></returns>
  19949. [HttpPost]
  19950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19951. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  19952. {
  19953. #region 参数验证
  19954. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19955. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19956. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19957. #region 页面操作权限验证
  19958. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19959. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  19960. #endregion
  19961. #endregion
  19962. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19963. {
  19964. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  19965. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  19966. }
  19967. else
  19968. {
  19969. return Ok(JsonView(false, "下载失败!"));
  19970. }
  19971. }
  19972. #endregion
  19973. #region 国家信息 数据 注释
  19974. //[HttpPost]
  19975. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  19976. //{
  19977. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  19978. // foreach (var item in dto)
  19979. // {
  19980. // infos.Add(new Grp_GroupsTaskAssignment()
  19981. // {
  19982. // DIId = item,
  19983. // CTId = 82,
  19984. // UId = 248,
  19985. // IsEnable = 1,
  19986. // CreateUserId = 233,
  19987. // CreateTime = DateTime.Now,
  19988. // IsDel = 0
  19989. // });
  19990. // infos.Add(new Grp_GroupsTaskAssignment()
  19991. // {
  19992. // DIId = item,
  19993. // CTId = 82,
  19994. // UId = 286,
  19995. // IsEnable = 1,
  19996. // CreateUserId = 233,
  19997. // CreateTime = DateTime.Now,
  19998. // IsDel = 0
  19999. // });
  20000. // }
  20001. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20002. // return Ok("操作成功");
  20003. //}
  20004. //public class paramJsonDto
  20005. //{
  20006. // public List<CountriesInfo> str { get; set; }
  20007. //}
  20008. //[HttpPost]
  20009. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20010. //{
  20011. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20012. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20013. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20014. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20015. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20016. // _sqlSugar.BeginTran();
  20017. // int countitiesIndex = 0;
  20018. // foreach (var item in dto.str)
  20019. // {
  20020. // dynamic data = item.c;
  20021. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20022. // if (data != null)
  20023. // {
  20024. // countitiesIndex++;
  20025. // foreach (var item1 in data)
  20026. // {
  20027. // string cnname = item1.cn;
  20028. // string enname = item1.en;
  20029. // Sys_Cities provinceInfo = new Sys_Cities()
  20030. // {
  20031. // CountriesId = countriesId,
  20032. // Name_CN = cnname,
  20033. // Name_EN = enname,
  20034. // ParentId = 0,
  20035. // IsCapital = 1,
  20036. // CreateUserId = 208,
  20037. // CreateTime = DateTime.Now,
  20038. // IsDel = 0
  20039. // };
  20040. // if (item1.lv == "province") //省份
  20041. // {
  20042. // provinceInfo.Level = 1;
  20043. // int provinceId = 0;
  20044. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20045. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20046. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20047. // var data1 = item1.c;
  20048. // foreach (var item2 in data1)
  20049. // {
  20050. // if (item2.lv == "city")
  20051. // {
  20052. // string citycnname = item2.cn;
  20053. // string cityenname = item2.en;
  20054. // Sys_Cities cityInfo = new Sys_Cities()
  20055. // {
  20056. // CountriesId = countriesId,
  20057. // ParentId = provinceId,
  20058. // Level = 2,
  20059. // Name_CN = citycnname,
  20060. // Name_EN = cityenname,
  20061. // IsCapital = 1,
  20062. // CreateUserId = 208,
  20063. // CreateTime = DateTime.Now,
  20064. // IsDel = 0
  20065. // };
  20066. // if (item2.c != null)
  20067. // {
  20068. // int cityId = 0;
  20069. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20070. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20071. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20072. // foreach (var item3 in item2.c)
  20073. // {
  20074. // if (item3.lv == "district")
  20075. // {
  20076. // var districtInfo = new Sys_Cities()
  20077. // {
  20078. // CountriesId = countriesId,
  20079. // Name_CN = item3.cn,
  20080. // Name_EN = item3.en,
  20081. // Level = 3,
  20082. // ParentId = cityId,
  20083. // IsCapital = 1,
  20084. // CreateUserId = 208,
  20085. // CreateTime = DateTime.Now,
  20086. // IsDel = 0
  20087. // };
  20088. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20089. // //{
  20090. // districts.Add(districtInfo);
  20091. // //}
  20092. // }
  20093. // }
  20094. // }
  20095. // else
  20096. // {
  20097. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20098. // //{
  20099. // cities.Add(cityInfo);
  20100. // //}
  20101. // }
  20102. // }
  20103. // }
  20104. // }
  20105. // else if (item1.lv == "city")//城市
  20106. // {
  20107. // provinceInfo.Level = 2;
  20108. // if (item1.c != null)
  20109. // {
  20110. // int cityId = 0;
  20111. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20112. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20113. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20114. // foreach (var item3 in item1.c)
  20115. // {
  20116. // if (item3.lv == "district")
  20117. // {
  20118. // var districtInfo = new Sys_Cities()
  20119. // {
  20120. // CountriesId = countriesId,
  20121. // Name_CN = item3.cn,
  20122. // Name_EN = item3.en,
  20123. // Level = 3,
  20124. // ParentId = cityId,
  20125. // IsCapital = 1,
  20126. // CreateUserId = 208,
  20127. // CreateTime = DateTime.Now,
  20128. // IsDel = 0
  20129. // };
  20130. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20131. // //{
  20132. // districts.Add(districtInfo);
  20133. // //}
  20134. // }
  20135. // }
  20136. // }
  20137. // else
  20138. // {
  20139. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20140. // //{
  20141. // cities.Add(provinceInfo);
  20142. // //}
  20143. // }
  20144. // }
  20145. // }
  20146. // }
  20147. // }
  20148. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20149. // cities = cities.Distinct().ToList();
  20150. // districts = districts.Distinct().ToList();
  20151. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20152. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20153. // cities.AddRange(districts);
  20154. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20155. // //_sqlSugar.RollbackTran();
  20156. // _sqlSugar.CommitTran();
  20157. // return Ok(JsonView(false, "操作成功!"));
  20158. //}
  20159. //[HttpPost]
  20160. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20161. //{
  20162. // List<CountitiesInfo> infos = dto.MyProperty;
  20163. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20164. // _sqlSugar.BeginTran();
  20165. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20166. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20167. // foreach (var item in infos)
  20168. // {
  20169. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20170. // if (countryInfo != null)
  20171. // {
  20172. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20173. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20174. // if (cityInfo1 != null)
  20175. // {
  20176. // cityInfo1.IsCapital = 0;
  20177. // cityInfos.Add(cityInfo1);
  20178. // }
  20179. // }
  20180. // }
  20181. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20182. // .UpdateColumns(it => it.IsCapital)
  20183. // .WhereColumns(it => it.Id)
  20184. // .ExecuteCommand();
  20185. // //_sqlSugar.RollbackTran();
  20186. // _sqlSugar.CommitTran();
  20187. // return Ok(JsonView(false, "操作成功!"));
  20188. //}
  20189. //public class CounrtiesDto
  20190. //{
  20191. // public List<CountitiesInfo> MyProperty { get; set; }
  20192. //}
  20193. //public class CountitiesInfo
  20194. //{
  20195. // /// <summary>
  20196. // /// 圣约翰
  20197. // /// </summary>
  20198. // public string capital_name_chinese { get; set; }
  20199. // /// <summary>
  20200. // ///
  20201. // /// </summary>
  20202. // public string capital_name { get; set; }
  20203. // /// <summary>
  20204. // ///
  20205. // /// </summary>
  20206. // public string country_type { get; set; }
  20207. // /// <summary>
  20208. // /// 安提瓜和巴布达
  20209. // /// </summary>
  20210. // public string country_name_chinese { get; set; }
  20211. // /// <summary>
  20212. // /// 安提瓜和巴布达
  20213. // /// </summary>
  20214. // public string country_name_chinese_short { get; set; }
  20215. // /// <summary>
  20216. // /// 安提瓜和巴布达
  20217. // /// </summary>
  20218. // public string country_name_chinese_UN { get; set; }
  20219. // /// <summary>
  20220. // ///
  20221. // /// </summary>
  20222. // public string country_name_english_abbreviation { get; set; }
  20223. // /// <summary>
  20224. // ///
  20225. // /// </summary>
  20226. // public string country_name_english_formal { get; set; }
  20227. // /// <summary>
  20228. // ///
  20229. // /// </summary>
  20230. // public string country_name_english_UN { get; set; }
  20231. // /// <summary>
  20232. // ///
  20233. // /// </summary>
  20234. // public string continent_name { get; set; }
  20235. // /// <summary>
  20236. // ///
  20237. // /// </summary>
  20238. // public string subregion_name { get; set; }
  20239. // /// <summary>
  20240. // ///
  20241. // /// </summary>
  20242. // public string country_code2 { get; set; }
  20243. // /// <summary>
  20244. // ///
  20245. // /// </summary>
  20246. // public string country_code3 { get; set; }
  20247. // /// <summary>
  20248. // ///
  20249. // /// </summary>
  20250. // public string phone_code { get; set; }
  20251. //}
  20252. //public class CountriesInfo : BasicInfo
  20253. //{
  20254. // public List<CitiesInfo> c { get; set; }
  20255. //}
  20256. //public class CitiesInfo : BasicInfo
  20257. //{
  20258. // public List<AreaInfo> c { get; set; }
  20259. //}
  20260. //public class AreaInfo : BasicInfo
  20261. //{
  20262. // public List<AreaInfo> c { get; set; }
  20263. //}
  20264. //public class BasicInfo
  20265. //{
  20266. // public string code { get; set; }
  20267. // public string cn { get; set; }
  20268. // public string lv { get; set; }
  20269. // public string en { get; set; }
  20270. //}
  20271. #endregion
  20272. #region 查看邀请方
  20273. /// <summary>
  20274. /// 查看邀请方
  20275. /// 邀请方信息 Init
  20276. /// </summary>
  20277. /// <param name="dto"></param>
  20278. /// <returns></returns>
  20279. [HttpPost]
  20280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20281. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20282. {
  20283. string sqlWhere = string.Empty;
  20284. if (!string.IsNullOrEmpty(dto.Search))
  20285. {
  20286. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20287. }
  20288. string sql = string.Format($@"Select
  20289. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20290. Id,
  20291. UnitName
  20292. From Res_InvitationOfficialActivityData
  20293. Where IsDel = 0
  20294. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20295. RefAsync<int> total = 0;
  20296. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20297. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20298. }
  20299. /// <summary>
  20300. /// 查看邀请方
  20301. /// 国家信息 Init
  20302. /// </summary>
  20303. /// <param name="dto"></param>
  20304. /// <returns></returns>
  20305. [HttpPost]
  20306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20307. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20308. {
  20309. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20310. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20311. var diids = groupInfos.Select(it => it.Id).ToList();
  20312. List<string> countrys = new List<string>();
  20313. foreach (var item in country)
  20314. {
  20315. var data = _groupRepository.FormartTeamName(item);
  20316. var dataArray = _groupRepository.GroupSplitCountry(data);
  20317. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20318. }
  20319. countrys = countrys.Distinct().ToList();
  20320. for (int i = 0; i < countrys.Count; i++)
  20321. {
  20322. string item = countrys[i];
  20323. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20324. {
  20325. countrys.Remove(item);
  20326. i--;
  20327. }
  20328. }
  20329. RefAsync<int> total = 0;
  20330. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20331. .Where(it => countrys.Contains(it.Name_CN))
  20332. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20333. .Select(it => new { id = it.Id, name = it.Name_CN })
  20334. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20335. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20336. }
  20337. /// <summary>
  20338. /// 查看邀请方
  20339. /// 城市信息 Init
  20340. /// </summary>
  20341. /// <param name="dto"></param>
  20342. /// <returns></returns>
  20343. [HttpPost]
  20344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20345. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20346. {
  20347. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20348. RefAsync<int> total = 0;
  20349. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20350. .Where(it => it.CountriesId == dto.CountiesId)
  20351. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20352. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20353. .Select(it => new { id = it.Id, name = it.Name_CN })
  20354. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20355. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20356. }
  20357. /// <summary>
  20358. /// 查看邀请方
  20359. /// 团组名称 Init
  20360. /// </summary>
  20361. /// <param name="dto"></param>
  20362. /// <returns></returns>
  20363. [HttpPost]
  20364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20365. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20366. {
  20367. var watch = new Stopwatch();
  20368. watch.Start();
  20369. RefAsync<int> total = 0;
  20370. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20371. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20372. .Where((oa, di) => oa.IsDel == 0)
  20373. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20374. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20375. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20376. .Distinct()
  20377. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20378. watch.Stop();
  20379. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20380. }
  20381. /// <summary>
  20382. /// 查看邀请方
  20383. /// 团组 & 邀请方信息
  20384. /// </summary>
  20385. /// <param name="dto"></param>
  20386. /// <returns></returns>
  20387. [HttpPost]
  20388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20389. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20390. {
  20391. var watch = new Stopwatch();
  20392. watch.Start();
  20393. RefAsync<int> total = 0;
  20394. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20395. .AS("Grp_DelegationInfo")
  20396. .Includes(x => x.InvitingInfos)
  20397. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20398. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20399. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20400. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20401. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20402. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20403. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20404. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20405. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20406. infos.ForEach(x =>
  20407. {
  20408. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20409. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20410. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20411. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20412. });
  20413. watch.Stop();
  20414. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20415. }
  20416. #endregion
  20417. #region 报批行程
  20418. /// <summary>
  20419. /// 报批行程初始化
  20420. /// </summary>
  20421. /// <param name="dto"></param>
  20422. /// <returns></returns>
  20423. [HttpPost]
  20424. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20425. {
  20426. const int chiNumber = 5;
  20427. var jw = JsonView(false);
  20428. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20429. var group = groupList.First();
  20430. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20431. group = groupList.First(x => x.Id == diid);
  20432. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20433. .Where(x => x.DiId == diid && x.IsDel == 0)
  20434. .ToArray();
  20435. var count = 1;
  20436. foreach (var item in blackCodeList)
  20437. {
  20438. if (string.IsNullOrWhiteSpace(item.Title))
  20439. {
  20440. item.Title = "未设置名称数据" + count;
  20441. }
  20442. count++;
  20443. };
  20444. if (group == null)
  20445. {
  20446. jw.Msg = "暂无团组!";
  20447. return Ok(jw);
  20448. }
  20449. var data = new
  20450. {
  20451. groupList = groupList.Select(x => new
  20452. {
  20453. x.TeamName,
  20454. x.Id
  20455. }),
  20456. content = new ArrayList(),
  20457. groupInfo = new
  20458. {
  20459. group.VisitDays,
  20460. group.TourCode,
  20461. group.VisitPNumber,
  20462. group.TeamName,
  20463. group.Id,
  20464. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20465. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  20466. },
  20467. blackCodeList = blackCodeList.Select(x => new
  20468. {
  20469. x.Title,
  20470. x.Id
  20471. }),
  20472. FileTempList = new ArrayList()
  20473. {
  20474. new { Index = 1,FileName = "旧模板" },
  20475. new { Index = 2,FileName = "省外办" },
  20476. new { Index = 3,FileName = "市外办" },
  20477. }
  20478. };
  20479. var resultArr = new ArrayList();
  20480. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20481. #region 默认不生成行程
  20482. //if (content.Count == 0)
  20483. //{
  20484. // var stay = "-";
  20485. // var cityPath = "-";
  20486. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20487. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20488. // .ToList();
  20489. // //添加城市路径以及住宿地
  20490. // //黑屏代码数据
  20491. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20492. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20493. // {
  20494. // jw = JsonView(true, "黑屏代码有误!", data);
  20495. // return Ok(jw);
  20496. // }
  20497. // data = data with
  20498. // {
  20499. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20500. // {
  20501. // x.Title,
  20502. // x.Id,
  20503. // }).ToArray())
  20504. // };
  20505. // foreach (DataRow row in dtBlack.Rows)
  20506. // {
  20507. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20508. // {
  20509. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20510. // return Ok(jw);
  20511. // }
  20512. // }
  20513. // //黑屏代码获取时间区间
  20514. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20515. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20516. // _sqlSugar.BeginTran();
  20517. // for (int i = 0; i < timeArr.Count; i++)
  20518. // {
  20519. // stay = "-";
  20520. // cityPath = "-";
  20521. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20522. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20523. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20524. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20525. // if (tbSelect.Length > 0)
  20526. // {
  20527. // List<string> threeCodeStr = new List<string>();
  20528. // foreach (var item in tbSelect)
  20529. // {
  20530. // var threeCode = item["Three"].ToString() ?? "";
  20531. // if (threeCode.Length == 6)
  20532. // {
  20533. // var start = threeCode.Substring(0, 3);
  20534. // var end = threeCode.Substring(3, 3);
  20535. // if (threeCodeStr.Count == 0)
  20536. // {
  20537. // threeCodeStr.Add(start);
  20538. // threeCodeStr.Add(end);
  20539. // }
  20540. // else
  20541. // {
  20542. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20543. // {
  20544. // threeCodeStr.Add(end);
  20545. // }
  20546. // else
  20547. // {
  20548. // threeCodeStr.Add(start);
  20549. // threeCodeStr.Add(end);
  20550. // }
  20551. // }
  20552. // }
  20553. // }
  20554. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20555. // var last = threeCodeStr.Last();
  20556. // foreach (var item in threeCodeStr)
  20557. // {
  20558. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20559. // if (item.Equals(last))
  20560. // {
  20561. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20562. // }
  20563. // }
  20564. // cityPath = cityPath.Trim('-');
  20565. // }
  20566. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  20567. // appro.Diid = diid ?? -1;
  20568. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20569. // appro.Id = thisId;
  20570. // appro.CreateUserId = dto.UserId;
  20571. // appro.CreateTime = DateTime.Now;
  20572. // content.Add(appro);
  20573. // }
  20574. // _sqlSugar.CommitTran();
  20575. //}
  20576. #endregion
  20577. foreach (var x in content)
  20578. {
  20579. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  20580. if (chiList.Count < chiNumber)
  20581. {
  20582. for (int i = chiList.Count; i < chiNumber; i++)
  20583. {
  20584. chiList.Add(new Grp_ApprovalTravelDetails());
  20585. }
  20586. }
  20587. resultArr.Add(new
  20588. {
  20589. x.Id,
  20590. x.Date,
  20591. x.Diid,
  20592. chiList = chiList.Select(x1 => new
  20593. {
  20594. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20595. x1.Details,
  20596. x1.ParentId,
  20597. x1.Id
  20598. })
  20599. });
  20600. }
  20601. data = data with
  20602. {
  20603. content = resultArr,
  20604. };
  20605. jw = JsonView(true, "获取成功!", data);
  20606. return Ok(jw);
  20607. }
  20608. /// <summary>
  20609. /// 报批行程删除
  20610. /// </summary>
  20611. /// <param name="dto"></param>
  20612. /// <returns></returns>
  20613. [HttpPost]
  20614. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  20615. {
  20616. var jw = JsonView(false);
  20617. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20618. if (group == null)
  20619. {
  20620. jw.Msg = "团组参数有误!";
  20621. return Ok(jw);
  20622. }
  20623. try
  20624. {
  20625. _sqlSugar.BeginTran();
  20626. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  20627. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  20628. {
  20629. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20630. DeleteUserId = dto.uesrId,
  20631. IsDel = 1
  20632. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  20633. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  20634. {
  20635. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20636. DeleteUserId = dto.uesrId,
  20637. IsDel = 1
  20638. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  20639. _sqlSugar.CommitTran();
  20640. jw = JsonView(true, "删除成功");
  20641. }
  20642. catch (Exception ex)
  20643. {
  20644. jw = JsonView(false, ex.Message);
  20645. }
  20646. return Ok(jw);
  20647. }
  20648. /// <summary>
  20649. /// 报批行程保存
  20650. /// </summary>
  20651. /// <param name="dto"></param>
  20652. /// <returns></returns>
  20653. [HttpPost]
  20654. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  20655. {
  20656. var jw = JsonView(false);
  20657. var Find = dto.Arr.Find(x => x.id == 0);
  20658. if (Find != null)
  20659. {
  20660. jw.Msg = "生成的ID为0!";
  20661. return Ok(jw);
  20662. }
  20663. foreach (var item in dto.Arr)
  20664. {
  20665. foreach (var chi in item.chiList)
  20666. {
  20667. if (chi.parentId == 0)
  20668. {
  20669. chi.parentId = item.id;
  20670. }
  20671. }
  20672. }
  20673. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  20674. _sqlSugar.BeginTran();
  20675. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  20676. {
  20677. var parentIds = dto.Arr.Select(x => x.id).ToList();
  20678. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  20679. {
  20680. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20681. DeleteUserId = dto.UserId,
  20682. IsDel = 1
  20683. }).ExecuteCommand();
  20684. }
  20685. try
  20686. {
  20687. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  20688. {
  20689. CreateTime = DateTime.Now,
  20690. CreateUserId = dto.UserId,
  20691. Details = x.details,
  20692. ParentId = x.parentId,
  20693. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20694. Remark = "",
  20695. IsDel = 0
  20696. }).ToList()).ExecuteCommand();
  20697. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  20698. {
  20699. Id = x.id,
  20700. Details = x.details,
  20701. ParentId = x.parentId,
  20702. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20703. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  20704. {
  20705. Details = x.Details,
  20706. ParentId = x.ParentId,
  20707. Time = x.Time
  20708. }).ExecuteCommand();
  20709. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  20710. {
  20711. Id = x.id,
  20712. Date = x.date,
  20713. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  20714. {
  20715. Date = x.Date
  20716. }).ExecuteCommand();
  20717. _sqlSugar.CommitTran();
  20718. jw = JsonView(true, "保存成功!");
  20719. }
  20720. catch (Exception ex)
  20721. {
  20722. _sqlSugar.RollbackTran();
  20723. jw = JsonView(false, "保存失败!" + ex.Message);
  20724. }
  20725. return Ok(jw);
  20726. }
  20727. /// <summary>
  20728. /// 报批行程生成
  20729. /// </summary>
  20730. /// <param name="dto"></param>
  20731. /// <returns></returns>
  20732. [HttpPost]
  20733. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  20734. {
  20735. var jw = JsonView(false);
  20736. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20737. if (group == null)
  20738. {
  20739. jw.Msg = "暂无该团组!";
  20740. return Ok(jw);
  20741. }
  20742. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  20743. //黑屏代码数据
  20744. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  20745. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20746. {
  20747. jw.Msg = "黑屏代码有误!";
  20748. return Ok(jw);
  20749. }
  20750. foreach (DataRow row in dtBlack.Rows)
  20751. {
  20752. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20753. {
  20754. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  20755. return Ok(jw);
  20756. }
  20757. }
  20758. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  20759. var resultArr = new ArrayList();
  20760. //if (officialActivitiesArr.Count == 0)
  20761. //{
  20762. // jw.Msg = "暂无公务出访信息!";
  20763. // return Ok(jw);
  20764. //}
  20765. try
  20766. {
  20767. _sqlSugar.BeginTran();
  20768. DeleteApprovalJourney(new
  20769. Domain.Dtos.Groups.DeleteApprovalJourney
  20770. {
  20771. Diid = dto.Diid,
  20772. uesrId = dto.Userid
  20773. });
  20774. var stay = "-";
  20775. var cityPath = "-";
  20776. var arriveCountry = string.Empty;
  20777. //添加城市路径以及住宿地
  20778. //黑屏代码获取时间区间
  20779. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20780. var empty = "【未收入该三字码!请机票同事录入】";
  20781. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20782. #region 配置公务活动时间
  20783. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  20784. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  20785. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  20786. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  20787. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  20788. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20789. {
  20790. 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" }),
  20791. 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"}),
  20792. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20793. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  20794. };
  20795. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20796. {
  20797. 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" }),
  20798. 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"}),
  20799. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20800. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  20801. };
  20802. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  20803. {
  20804. 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" }),
  20805. 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"}),
  20806. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  20807. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  20808. };
  20809. #endregion
  20810. var nextDayNum = 0;
  20811. for (int i = 0; i < timeArr.Count; i++)
  20812. {
  20813. stay = "-";
  20814. cityPath = "-";
  20815. var chiarr = new List<Grp_ApprovalTravelDetails>();
  20816. DateTime NewData = DateTime.Parse(timeArr[i]);
  20817. //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();
  20818. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20819. if (nextDayNum > 0)
  20820. {
  20821. nextDayNum--;
  20822. }
  20823. if (tbSelect.Length > 0)
  20824. {
  20825. List<string> threeCodeStr = new List<string>();
  20826. bool isTrade = false;
  20827. string trip = string.Empty;
  20828. foreach (var item in tbSelect)
  20829. {
  20830. if (nextDayNum == 0)
  20831. {
  20832. nextDayNum = Convert.ToInt32(item["Sign"]);
  20833. }
  20834. var airStartTime = item["StartTime"].ToString() ?? "0000";
  20835. var airEndTime = item["EndTime"].ToString() ?? "0000";
  20836. var takeOffTime = DateTime.Parse(timeArr[i]);
  20837. var fallToTime = DateTime.Parse(timeArr[i]);
  20838. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  20839. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  20840. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  20841. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  20842. if (nextDayNum > 0)
  20843. {
  20844. fallToTime = fallToTime.AddDays(nextDayNum);
  20845. }
  20846. trip = string.Empty;
  20847. var start = string.Empty;
  20848. var end = string.Empty;
  20849. var threeCode = item["Three"].ToString() ?? "";
  20850. if (threeCode.Length == 6)
  20851. {
  20852. start = threeCode.Substring(0, 3);
  20853. end = threeCode.Substring(3, 3);
  20854. if (threeCodeStr.Count == 0)
  20855. {
  20856. threeCodeStr.Add(start);
  20857. threeCodeStr.Add(end);
  20858. }
  20859. else
  20860. {
  20861. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20862. {
  20863. threeCodeStr.Add(end);
  20864. }
  20865. else
  20866. {
  20867. threeCodeStr.Add(start);
  20868. threeCodeStr.Add(end);
  20869. }
  20870. }
  20871. }
  20872. //处理机票信息
  20873. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  20874. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  20875. if (start_Object == null)
  20876. {
  20877. start_Object = new Res_ThreeCode()
  20878. {
  20879. AirPort = empty,
  20880. AirPort_En = empty,
  20881. City = empty,
  20882. Country = empty,
  20883. Four = empty,
  20884. Three = empty,
  20885. };
  20886. }
  20887. if (end_Object == null)
  20888. {
  20889. end_Object = new Res_ThreeCode()
  20890. {
  20891. AirPort = empty,
  20892. AirPort_En = empty,
  20893. City = empty,
  20894. Country = empty,
  20895. Four = empty,
  20896. Three = empty,
  20897. };
  20898. }
  20899. //机型判断
  20900. string airModel = item["AirModel"].ToString();
  20901. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  20902. string flightTime = item["FlightTime"].ToString();
  20903. flightTime = ParseBlackTime(flightTime);
  20904. //航班号
  20905. string flightcode = item["Fliagtcode"].ToString();
  20906. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  20907. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  20908. if (aircompany == null)
  20909. {
  20910. aircompany = new Res_AirCompany
  20911. {
  20912. CnName = hsEmpty,
  20913. EnName = hsEmpty,
  20914. ShortCode = hsEmpty,
  20915. };
  20916. }
  20917. //航班前公务安排
  20918. if (tbSelect.First().Equals(item) && i != 0)
  20919. {
  20920. foreach (var takeoff in takeoffTimes)
  20921. {
  20922. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  20923. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  20924. {
  20925. foreach (var addTime in takeoff.Item2)
  20926. {
  20927. chiarr.Add(new Grp_ApprovalTravelDetails
  20928. {
  20929. Time = addTime,
  20930. CreateTime = DateTime.Now,
  20931. CreateUserId = dto.Userid,
  20932. ParentId = 0,
  20933. Details = "公务活动"
  20934. });
  20935. }
  20936. break;
  20937. }
  20938. }
  20939. }
  20940. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  20941. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  20942. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  20943. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  20944. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  20945. if (isTrade)
  20946. {
  20947. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  20948. trip += "(转机不出机场)。";
  20949. }
  20950. //else
  20951. //{
  20952. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  20953. //}
  20954. chiarr.Add(new Grp_ApprovalTravelDetails
  20955. {
  20956. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  20957. CreateTime = DateTime.Now,
  20958. CreateUserId = dto.Userid,
  20959. ParentId = 0,
  20960. Details = trip
  20961. });
  20962. //最后一条到达的时间安排公务
  20963. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  20964. {
  20965. bool isCheckCountry = false;
  20966. if (end_Object.Country != arriveCountry)
  20967. {
  20968. arriveCountry = end_Object.Country;
  20969. isCheckCountry = true;
  20970. }
  20971. if (nextDayNum == 0)
  20972. {
  20973. //需要入境的情况
  20974. if (isCheckCountry)
  20975. {
  20976. foreach (var fallTime in fallTimesCheckCountry)
  20977. {
  20978. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20979. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20980. {
  20981. foreach (var addTime in fallTime.Item2)
  20982. {
  20983. chiarr.Add(new Grp_ApprovalTravelDetails
  20984. {
  20985. Time = addTime,
  20986. CreateTime = DateTime.Now,
  20987. CreateUserId = dto.Userid,
  20988. ParentId = 0,
  20989. Details = "公务活动"
  20990. });
  20991. }
  20992. break;
  20993. }
  20994. }
  20995. }
  20996. else
  20997. {
  20998. foreach (var fallTime in fallTimesNotCheckCountry)
  20999. {
  21000. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21001. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21002. {
  21003. foreach (var addTime in fallTime.Item2)
  21004. {
  21005. chiarr.Add(new Grp_ApprovalTravelDetails
  21006. {
  21007. Time = addTime,
  21008. CreateTime = DateTime.Now,
  21009. CreateUserId = dto.Userid,
  21010. ParentId = 0,
  21011. Details = "公务活动"
  21012. });
  21013. }
  21014. break;
  21015. }
  21016. }
  21017. }
  21018. }
  21019. }
  21020. }
  21021. //添加乘车语句
  21022. //chiarr.Add(new Grp_ApprovalTravelDetails
  21023. //{
  21024. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21025. // CreateTime = DateTime.Now,
  21026. // CreateUserId = dto.Userid,
  21027. // ParentId = 0,
  21028. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21029. //});
  21030. //if (i != timeArr.Count - 1)
  21031. //{
  21032. // fallToTime = fallToTime.AddHours(2.5);
  21033. // foreach (var item in Times)
  21034. // {
  21035. // //排列公务时间
  21036. // if (fallToTime.Hour < item.Item1)
  21037. // {
  21038. // chiarr.Add(new Grp_ApprovalTravelDetails
  21039. // {
  21040. // Time = $"{item.Item2} - {item.Item3}",
  21041. // CreateTime = DateTime.Now,
  21042. // CreateUserId = dto.Userid,
  21043. // ParentId = 0,
  21044. // Details = "公务活动"
  21045. // });
  21046. // }
  21047. // }
  21048. //}
  21049. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21050. var last = threeCodeStr.Last();
  21051. foreach (var item in threeCodeStr)
  21052. {
  21053. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21054. if (item.Equals(last))
  21055. {
  21056. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21057. }
  21058. }
  21059. cityPath = cityPath.Trim('-');
  21060. }
  21061. else
  21062. {
  21063. foreach (var item in Times)
  21064. {
  21065. chiarr.Add(new Grp_ApprovalTravelDetails
  21066. {
  21067. Time = $"{item.Item2} - {item.Item3}",
  21068. CreateTime = DateTime.Now,
  21069. CreateUserId = dto.Userid,
  21070. ParentId = 0,
  21071. Details = "公务活动"
  21072. });
  21073. }
  21074. }
  21075. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21076. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21077. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21078. appro.Diid = dto.Diid;
  21079. appro.CreateUserId = dto.Userid;
  21080. appro.CreateTime = DateTime.Now;
  21081. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21082. appro.Id = thisId;
  21083. //foreach (var item in gwinfo)
  21084. //{
  21085. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21086. // chi.Details = "拜访" + item.Client;
  21087. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21088. // {
  21089. // chi.Details += "," + item.ReqSample;
  21090. // }
  21091. // chi.ParentId = thisId;
  21092. // chi.Time = item.Time;
  21093. // chiarr.Add(chi);
  21094. //}
  21095. if (chiarr.Count < 6)
  21096. {
  21097. for (int j = chiarr.Count; j < 6; j++)
  21098. {
  21099. chiarr.Add(new
  21100. Grp_ApprovalTravelDetails());
  21101. }
  21102. }
  21103. resultArr.Add(new
  21104. {
  21105. appro.Id,
  21106. appro.Date,
  21107. appro.Diid,
  21108. chiList = chiarr.Select(x1 => new
  21109. {
  21110. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21111. x1.Details,
  21112. x1.ParentId,
  21113. x1.Id
  21114. })
  21115. });
  21116. }
  21117. _sqlSugar.CommitTran();
  21118. jw = JsonView(true, "生成成功!", resultArr);
  21119. }
  21120. catch (Exception ex)
  21121. {
  21122. jw.Code = 400;
  21123. jw.Msg = "生成失败!" + ex.Message;
  21124. }
  21125. return Ok(jw);
  21126. }
  21127. /// <summary>
  21128. /// 报批行程word导出
  21129. /// </summary>
  21130. /// <param name="dto"></param>
  21131. /// <returns></returns>
  21132. [HttpPost]
  21133. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21134. {
  21135. var jw = JsonView(false);
  21136. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21137. if (group == null)
  21138. {
  21139. jw.Msg = "暂无该团组!";
  21140. return Ok(jw);
  21141. }
  21142. //模板路径
  21143. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21144. var fileName = string.Empty;
  21145. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21146. bool bold = false;
  21147. if (dto.FileIndex == 1)
  21148. {
  21149. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21150. }
  21151. else if (dto.FileIndex == 2)
  21152. {
  21153. fileName = "省外办-报批.docx";
  21154. bold = false;
  21155. titleFont = "方正黑体简体";
  21156. timeFont = "Times New Roman";
  21157. contentFont = "方正仿宋_GBK";
  21158. }
  21159. else if (dto.FileIndex == 3)
  21160. {
  21161. fileName = "市外办-报批.docx";
  21162. titleFont = "方正黑体简体";
  21163. timeFont = "Times New Roman";
  21164. contentFont = "方正仿宋简体";
  21165. }
  21166. tempPath = tempPath + fileName;
  21167. //载入模板
  21168. Document doc = new Document(tempPath);
  21169. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21170. //获取所填表格的序数
  21171. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21172. Aspose.Words.Tables.Row titleRowClone = null;
  21173. Aspose.Words.Tables.Row CenterRowClone = null;
  21174. int index = 0;
  21175. int indexChi = 0;
  21176. int SetIndex = 0;
  21177. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21178. //获取数据,放到datatable
  21179. foreach (var item in ApprovalTravelArr)
  21180. {
  21181. if (index > 0)
  21182. {
  21183. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21184. tableOne.AppendChild(titleRowClone);
  21185. }
  21186. var textTime = item.Date;
  21187. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21188. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21189. SetIndex++;
  21190. if (ChiRep.Count > 0)
  21191. {
  21192. foreach (var itemChi in ChiRep)
  21193. {
  21194. var txtTime = itemChi.Time;
  21195. var txtDetail = itemChi.Details;
  21196. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21197. {
  21198. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21199. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21200. //indexChi++;
  21201. //SetIndex++;
  21202. break;
  21203. }
  21204. if (indexChi > 0)
  21205. {
  21206. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21207. tableOne.AppendChild(CenterRowClone);
  21208. }
  21209. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21210. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21211. indexChi++;
  21212. SetIndex++;
  21213. }
  21214. }
  21215. //else
  21216. //{
  21217. // if (indexChi > 0)
  21218. // {
  21219. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21220. // tableOne.AppendChild(CenterRowClone);
  21221. // }
  21222. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21223. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21224. // indexChi++;
  21225. // SetIndex++;
  21226. //}
  21227. index++;
  21228. }
  21229. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21230. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21231. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21232. jw.Code = 200;
  21233. jw.Msg = "";
  21234. return Ok(jw);
  21235. }
  21236. private string ParseBlackTime(string time)
  21237. {
  21238. // 匹配可能只有分钟的情况
  21239. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21240. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21241. if (match.Success)
  21242. {
  21243. string hours = match.Groups[1].Value;
  21244. string minutes = match.Groups[2].Value;
  21245. // 如果小时部分为空,则只显示分钟
  21246. if (string.IsNullOrEmpty(hours))
  21247. {
  21248. return $"{minutes}分钟";
  21249. }
  21250. // 如果分钟部分为空,则只显示小时
  21251. else if (string.IsNullOrEmpty(minutes))
  21252. {
  21253. return $"{hours}小时";
  21254. }
  21255. // 否则显示完整格式
  21256. else
  21257. {
  21258. return $"{hours}小时{minutes}分钟";
  21259. }
  21260. }
  21261. else
  21262. {
  21263. return "未知时长";
  21264. }
  21265. }
  21266. private string intToString(int numberVal)
  21267. {
  21268. string numberval = numberVal.ToString();
  21269. Dictionary<char, string> Number = new Dictionary<char, string>();
  21270. Number.Add('1', "一");
  21271. Number.Add('2', "二");
  21272. Number.Add('3', "三");
  21273. Number.Add('4', "四");
  21274. Number.Add('5', "五");
  21275. Number.Add('6', "六");
  21276. Number.Add('7', "七");
  21277. Number.Add('8', "八");
  21278. Number.Add('9', "九");
  21279. string stringNumberVal = string.Empty;
  21280. for (int i = 0; i < numberval.Length; i++)
  21281. {
  21282. if (i == 0)
  21283. {
  21284. stringNumberVal += Number[numberval[i]];
  21285. }
  21286. else if (i >= 1)
  21287. {
  21288. if (numberval[i] == '0')
  21289. {
  21290. stringNumberVal = "十";
  21291. }
  21292. else
  21293. {
  21294. stringNumberVal += "十" + Number[numberval[i]];
  21295. }
  21296. }
  21297. }
  21298. return stringNumberVal;
  21299. }
  21300. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21301. {
  21302. //获取table中的某个单元格,从0开始
  21303. Cell lshCell = table.Rows[rows].Cells[cells];
  21304. //将单元格中段落移除
  21305. foreach (Paragraph item in lshCell.Paragraphs)
  21306. {
  21307. lshCell.Paragraphs.Remove(item);
  21308. }
  21309. if (val.Contains("\r\n"))
  21310. {
  21311. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21312. foreach (var item in spArr)
  21313. {
  21314. //新建一个段落
  21315. Paragraph p = new Paragraph(doc);
  21316. var r = new Run(doc, item);
  21317. //设置字体
  21318. if (!string.IsNullOrEmpty(font))
  21319. {
  21320. r.Font.Name = font;
  21321. }
  21322. r.Font.Bold = bold;
  21323. //把设置的值赋给之前新建的段落
  21324. p.AppendChild(r);
  21325. //将此段落加到单元格内
  21326. lshCell.AppendChild(p);
  21327. }
  21328. }
  21329. else
  21330. {
  21331. //新建一个段落
  21332. Paragraph p = new Paragraph(doc);
  21333. var r = new Run(doc, val);
  21334. //设置字体
  21335. if (!string.IsNullOrEmpty(font))
  21336. {
  21337. r.Font.Name = font;
  21338. }
  21339. r.Font.Bold = bold;
  21340. //把设置的值赋给之前新建的段落
  21341. p.AppendChild(r);
  21342. //将此段落加到单元格内
  21343. lshCell.AppendChild(p);
  21344. }
  21345. }
  21346. //[HttpPost]
  21347. //public async Task<IActionResult> ServerHttp(string paramStr)
  21348. //{
  21349. // paramStr = paramStr.TrimEnd('\'');
  21350. // paramStr = paramStr.TrimStart('\'');
  21351. // JsonView jw = JsonView(false);
  21352. // JObject param = JObject.Parse(paramStr);
  21353. // if (!param.ContainsKey("url"))
  21354. // {
  21355. // jw.Msg = "url null";
  21356. // return Ok(jw);
  21357. // }
  21358. // string url = param["url"]!.ToString();
  21359. // var methon = "get";
  21360. // Dictionary<string, string> headValues = null;
  21361. // string bodyStr = string.Empty;
  21362. // if (param.ContainsKey("methon"))
  21363. // {
  21364. // methon = param["methon"]!.ToString().ToLower();
  21365. // }
  21366. // if (param.ContainsKey("header"))
  21367. // {
  21368. // var header = param["header"]!.ToString();
  21369. // JObject headerJobject = JObject.Parse(header);
  21370. // headValues = new Dictionary<string, string>();
  21371. // foreach (JProperty item in headerJobject.Properties())
  21372. // {
  21373. // var value = item.Value.ToString();
  21374. // var head = item.Path;
  21375. // headValues.Add(head, value);
  21376. // }
  21377. // }
  21378. // HttpClient client = new HttpClient();
  21379. // string responseString = string.Empty;
  21380. // StringContent content = null;
  21381. // if (headValues != null)
  21382. // {
  21383. // foreach (var item in headValues.Keys)
  21384. // {
  21385. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  21386. // {
  21387. // if (param.ContainsKey("body"))
  21388. // {
  21389. // bodyStr = param["body"]!.ToString();
  21390. // }
  21391. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  21392. // }
  21393. // else
  21394. // {
  21395. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  21396. // }
  21397. // }
  21398. // }
  21399. // try
  21400. // {
  21401. // if (methon == "get")
  21402. // {
  21403. // responseString = await client.GetStringAsync(url);
  21404. // }
  21405. // else if (methon == "post")
  21406. // {
  21407. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  21408. // {
  21409. // Content = content
  21410. // };
  21411. // var response = await client.SendAsync(request);
  21412. // try
  21413. // {
  21414. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  21415. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  21416. // {
  21417. // using (StreamReader reader = new StreamReader(gzipStream))
  21418. // {
  21419. // responseString = await reader.ReadToEndAsync();
  21420. // }
  21421. // }
  21422. // }
  21423. // catch (Exception)
  21424. // {
  21425. // responseString = await response.Content.ReadAsStringAsync();
  21426. // }
  21427. // }
  21428. // else
  21429. // {
  21430. // responseString = "methon error";
  21431. // }
  21432. // jw = JsonView(true, "success", responseString);
  21433. // }
  21434. // catch (Exception ex)
  21435. // {
  21436. // jw.Msg = "error " + ex.Message;
  21437. // jw.Data = ex.StackTrace;
  21438. // }
  21439. // finally
  21440. // {
  21441. // client.Dispose();
  21442. // }
  21443. // return Ok(jw);
  21444. //}
  21445. #endregion
  21446. #region 团组接待意见调查
  21447. /// <summary>
  21448. /// 团组接待意见调查 - 信息管理
  21449. /// 基础数据(团组)
  21450. /// </summary>
  21451. /// <returns></returns>
  21452. [HttpGet]
  21453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21454. public async Task<IActionResult> OpinionaireInit()
  21455. {
  21456. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21457. .Select(x => new
  21458. {
  21459. x.Id,
  21460. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21461. })
  21462. .OrderByDescending(x => x.Id)
  21463. .ToListAsync();
  21464. return Ok(JsonView(groupData, groupData.Count));
  21465. }
  21466. /// <summary>
  21467. /// 团组接待意见调查 - 信息管理
  21468. /// 列表
  21469. /// </summary>
  21470. /// <param name="groupId"></param>
  21471. /// <returns></returns>
  21472. [HttpGet("{groupId}")]
  21473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21474. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21475. {
  21476. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21477. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21478. .Select(x => new
  21479. {
  21480. x.Id,
  21481. x.TourGuideName,
  21482. x.CityName,
  21483. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21484. x.CreateTime
  21485. })
  21486. .OrderBy(x => x.Id)
  21487. .ToListAsync();
  21488. return Ok(JsonView(data));
  21489. }
  21490. /// <summary>
  21491. /// 团组接待意见调查 - 信息管理
  21492. /// 保存
  21493. /// </summary>
  21494. /// <param name="dto"></param>
  21495. /// <returns></returns>
  21496. [HttpPost]
  21497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21498. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21499. {
  21500. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21501. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21502. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21503. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21504. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21505. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21506. _opinionaireRep.BeginTran();
  21507. if (addData != null && addData.Count > 0)
  21508. {
  21509. foreach (var item in addData)
  21510. {
  21511. item.CreateUserId = currUserInfo.UserId;
  21512. item.DiId = dto.DiId;
  21513. }
  21514. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21515. }
  21516. if (updData != null && updData.Count > 0)
  21517. {
  21518. var upd = await _opinionaireRep._sqlSugar
  21519. .Updateable(updData)
  21520. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21521. .WhereColumns(x => new { x.Id })
  21522. .ExecuteCommandAsync();
  21523. }
  21524. _opinionaireRep.CommitTran();
  21525. return Ok(JsonView("操作成功!"));
  21526. }
  21527. /// <summary>
  21528. /// 团组接待意见调查 - 信息管理
  21529. /// 删除
  21530. /// </summary>
  21531. /// <param name="id"></param>
  21532. /// <returns></returns>
  21533. [HttpDelete("{id}")]
  21534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21535. public async Task<IActionResult> OpinionaireManageDel(int id)
  21536. {
  21537. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21538. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21539. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21540. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21541. if (!del) return Ok(JsonView("操作失败!"));
  21542. return Ok(JsonView("操作成功!"));
  21543. }
  21544. /// <summary>
  21545. /// 团组接待意见调查 - 用户
  21546. /// 列表
  21547. /// </summary>
  21548. /// <param name="diId"></param>
  21549. /// <returns></returns>
  21550. [HttpGet("{diId}")]
  21551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21552. public async Task<IActionResult> OpinionaireUserList(int diId)
  21553. {
  21554. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21555. var sql = string.Format(@"
  21556. SELECT
  21557. o.Id,
  21558. o.DiId,
  21559. di.TeamName AS 'GroupName',
  21560. di.VisitPNumber AS 'PeopleNumber',
  21561. di.ClientName AS 'LeadGroup',
  21562. di.VisitCountry AS 'Travel',
  21563. di.VisitDays AS 'Days',
  21564. o.CityName,
  21565. o.TourGuideName,
  21566. o.Catering,
  21567. o.CateringReason,
  21568. o.Stay,
  21569. o.StayReason,
  21570. o.[Route],
  21571. o.RouteReason,
  21572. o.OfficialActivity,
  21573. o.OfficialActivityReason,
  21574. o.TourGuide,
  21575. o.TourGuideReason,
  21576. o.[Translate],
  21577. o.TranslateReason,
  21578. o.Trip,
  21579. o.TripReason,
  21580. o.ESFileName,
  21581. o.SignatureDate,
  21582. o.Remark
  21583. FROM
  21584. Grp_Opinionaire o
  21585. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21586. WHERE
  21587. o.IsDel = 0
  21588. AND o.DiId = {0}
  21589. ORDER BY
  21590. o.Id ASC", diId);
  21591. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21592. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21593. return Ok(JsonView(data));
  21594. }
  21595. /// <summary>
  21596. /// 团组接待意见调查 - 用户
  21597. /// 保存
  21598. /// </summary>
  21599. /// <param name="dto"></param>
  21600. /// <returns></returns>
  21601. [HttpPost]
  21602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21603. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21604. {
  21605. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21606. foreach (var item in dto)
  21607. {
  21608. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21609. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21610. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21611. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21612. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21613. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21614. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21615. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21616. }
  21617. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21618. if (!Directory.Exists(filePathBase))
  21619. {
  21620. Directory.CreateDirectory(filePathBase);
  21621. }
  21622. #region 上传文件
  21623. var filePaths = new List<string>();
  21624. foreach (var item in dto)
  21625. {
  21626. var file = item.File;
  21627. // 将文件保存到指定位置
  21628. var filePath = Path.Combine(filePathBase, file.FileName);
  21629. using (var stream = new FileStream(filePath, FileMode.Create))
  21630. {
  21631. await file.CopyToAsync(stream);
  21632. }
  21633. //验证文件是否上传成功
  21634. if (!System.IO.File.Exists(filePath))
  21635. {
  21636. foreach (var filePathStr in filePaths)
  21637. {
  21638. System.IO.File.Delete(filePathStr);
  21639. }
  21640. return Ok(JsonView(false, "文件上传失败!"));
  21641. }
  21642. item.ESFileName = file.FileName;
  21643. }
  21644. #endregion
  21645. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  21646. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  21647. .UpdateColumns(x => new
  21648. {
  21649. x.Catering,
  21650. x.CateringReason,
  21651. x.Stay,
  21652. x.StayReason,
  21653. x.Route,
  21654. x.RouteReason,
  21655. x.OfficialActivity,
  21656. x.OfficialActivityReason,
  21657. x.TourGuide,
  21658. x.TourGuideReason,
  21659. x.Translate,
  21660. x.TranslateReason,
  21661. x.Trip,
  21662. x.TripReason,
  21663. x.ESFileName,
  21664. x.SignatureDate,
  21665. x.Remark
  21666. })
  21667. .WhereColumns(x => new { x.Id })
  21668. .ExecuteCommandAsync();
  21669. if (upd < 1)
  21670. {
  21671. foreach (var filePathStr in filePaths)
  21672. {
  21673. System.IO.File.Delete(filePathStr);
  21674. }
  21675. return Ok(JsonView(false));
  21676. }
  21677. return Ok(JsonView(true));
  21678. }
  21679. #endregion
  21680. #region 团组餐厅相关信息
  21681. /// <summary>
  21682. /// 团组相关餐厅信息
  21683. /// 基础数据(团组)
  21684. /// </summary>
  21685. /// <returns></returns>
  21686. [HttpGet]
  21687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21688. public async Task<IActionResult> RestaurantInit()
  21689. {
  21690. return Ok(await _restaurantRep.InitAsync());
  21691. }
  21692. /// <summary>
  21693. /// 团组相关餐厅信息
  21694. /// Item
  21695. /// </summary>
  21696. /// <param name="dto"></param>
  21697. /// <returns></returns>
  21698. [HttpPost]
  21699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21700. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  21701. {
  21702. int portType = dto.PortType,
  21703. groupId = dto.GroupId;
  21704. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21705. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21706. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  21707. }
  21708. /// <summary>
  21709. /// 团组相关餐厅信息
  21710. /// List
  21711. /// </summary>
  21712. /// <param name="dto"></param>
  21713. /// <returns></returns>
  21714. [HttpPost]
  21715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21716. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  21717. {
  21718. int portType = dto.PortType,
  21719. groupId = dto.GroupId;
  21720. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21721. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21722. var sql = string.Format(@" SELECT
  21723. ri.Id,
  21724. ri.GroupId,
  21725. ri.Date,
  21726. ri.StartTime,
  21727. ri.EndTime,
  21728. CASE WHEN ri.Type = 1 THEN '早餐'
  21729. WHEN ri.Type = 2 THEN '午餐'
  21730. WHEN ri.Type = 3 THEN '晚餐'
  21731. ELSE '其他'
  21732. END AS 'Type',
  21733. ri.Name,
  21734. ri.Address,
  21735. ri.Tel,
  21736. ri.Remark,
  21737. ri.CreateTime,
  21738. u.CnName AS CreateUserName
  21739. FROM
  21740. Grp_RestaurantInfo ri
  21741. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  21742. WHERE
  21743. ri.IsDel = 0
  21744. AND ri.GroupId = {0}
  21745. ORDER BY
  21746. ri.Date ASC
  21747. ", groupId);
  21748. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  21749. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  21750. return Ok(JsonView(infos));
  21751. }
  21752. /// <summary>
  21753. /// 团组相关餐厅信息
  21754. /// Info
  21755. /// </summary>
  21756. /// <param name="dto"></param>
  21757. /// <returns></returns>
  21758. [HttpPost]
  21759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21760. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  21761. {
  21762. int portType = dto.PortType,
  21763. id = dto.Id;
  21764. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21765. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21766. return Ok(await _restaurantRep.InfoAsync(portType, id));
  21767. }
  21768. /// <summary>
  21769. /// 团组相关餐厅信息
  21770. /// Op
  21771. /// </summary>
  21772. /// <param name="dto"></param>
  21773. /// <returns></returns>
  21774. [HttpPost]
  21775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21776. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  21777. {
  21778. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21779. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21780. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  21781. return Ok(await _restaurantRep.OpAsync(dto));
  21782. }
  21783. /// <summary>
  21784. /// 团组相关餐厅信息
  21785. /// Del
  21786. /// </summary>
  21787. /// <param name="dto"></param>
  21788. /// <returns></returns>
  21789. [HttpPost]
  21790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21791. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  21792. {
  21793. int userId = dto.DeleteUserId;
  21794. var id = dto.Id;
  21795. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21796. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21797. return Ok(await _restaurantRep.DelAsync(dto));
  21798. }
  21799. #endregion
  21800. // /// <summary>
  21801. // ///
  21802. // /// </summary>
  21803. // /// <param name="_dto"></param>
  21804. // /// <returns></returns>
  21805. // [HttpPost]
  21806. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21807. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21808. // {
  21809. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21810. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  21811. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  21812. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21813. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  21814. // dic_psg.Add("客人", 974);
  21815. // dic_psg.Add("司机", 975);
  21816. // dic_psg.Add("导游", 976);
  21817. // dic_psg.Add("公司内部人员", 977);
  21818. // dic_psg.Add("司机/导游/公司内部人员", 978);
  21819. // foreach (var item in list_visa)
  21820. // {
  21821. // Grp_VisaInfo temp = new Grp_VisaInfo();
  21822. // temp.Id = item.Id;
  21823. // temp.DIId = item.DIId;
  21824. // temp.VisaClient = item.VisaClient;
  21825. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  21826. // temp.VisaCurrency = item.VisaCurrency;
  21827. // temp.IsThird = item.IsThird;
  21828. // if (dic_psg.ContainsKey(item.PassengerType))
  21829. // {
  21830. // temp.PassengerType = dic_psg[item.PassengerType];
  21831. // }
  21832. // else {
  21833. // temp.PassengerType = -1;
  21834. // }
  21835. // temp.VisaNumber = item.VisaNumber;
  21836. // temp.VisaFreeNumber = item.VisaFreeNumber;
  21837. // temp.CreateUserId = item.Operators;
  21838. // DateTime dt_ct;
  21839. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  21840. // if (b_ct)
  21841. // {
  21842. // temp.CreateTime = dt_ct;
  21843. // }
  21844. // else
  21845. // {
  21846. // temp.CreateTime = DateTime.Now;
  21847. // }
  21848. // temp.DeleteTime = "";
  21849. // temp.DeleteUserId = 0;
  21850. // temp.Remark = item.Remark;
  21851. // if (string.IsNullOrEmpty(temp.Remark)) {
  21852. // temp.Remark = "";
  21853. // }
  21854. // temp.IsDel = item.IsDel;
  21855. // temp.VisaDescription = item.VisaAttachment;
  21856. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  21857. //([Id]
  21858. // ,[DIId]
  21859. // ,[VisaClient]
  21860. // ,[VisaPrice]
  21861. // ,[VisaCurrency]
  21862. // ,[IsThird]
  21863. // ,[PassengerType]
  21864. // ,[VisaNumber]
  21865. // ,[VisaFreeNumber]
  21866. // ,[CreateUserId]
  21867. // ,[CreateTime]
  21868. // ,[DeleteTime]
  21869. // ,[DeleteUserId]
  21870. // ,[Remark]
  21871. // ,[IsDel]
  21872. // ,[visaDescription])
  21873. // VALUES
  21874. // ({0},{1},'{2}',{3},{4}
  21875. //,{5},{6},{7},{8},{9}
  21876. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  21877. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  21878. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  21879. //);
  21880. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  21881. // }
  21882. // return Ok(JsonView(true, "操作成功!"));
  21883. // }
  21884. /// <summary>
  21885. /// 123132123
  21886. /// </summary>
  21887. /// <param name="_dto"></param>
  21888. /// <returns></returns>
  21889. [HttpPost]
  21890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21891. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21892. {
  21893. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21894. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  21895. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  21896. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21897. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  21898. dicDetail.Add(789, 1034);
  21899. dicDetail.Add(790, 1035);
  21900. dicDetail.Add(791, 1036);
  21901. dicDetail.Add(792, 1037);
  21902. dicDetail.Add(793, 1038);
  21903. dicDetail.Add(794, 1039);
  21904. dicDetail.Add(795, 1040);
  21905. dicDetail.Add(796, 1041);
  21906. dicDetail.Add(797, 1042);
  21907. dicDetail.Add(798, 1043);
  21908. dicDetail.Add(801, 1044);
  21909. dicDetail.Add(802, 1045);
  21910. dicDetail.Add(803, 1046);
  21911. Dictionary<int, int> dic = new Dictionary<int, int>();
  21912. dic.Add(806, 1027);
  21913. dic.Add(807, 1028);
  21914. dic.Add(808, 1029);
  21915. dic.Add(809, 1030);
  21916. dic.Add(810, 1031);
  21917. dic.Add(811, 1032);
  21918. dic.Add(812, 1033);
  21919. foreach (var item in list_visa)
  21920. {
  21921. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  21922. temp.Coefficient = item.coefficient;
  21923. DateTime dtCrt;
  21924. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  21925. if (b1)
  21926. {
  21927. temp.CreateTime = dtCrt;
  21928. }
  21929. else
  21930. {
  21931. temp.CreateTime = DateTime.Now;
  21932. }
  21933. temp.CreateUserId = item.Operators;
  21934. temp.DeleteTime = "";
  21935. temp.DeleteUserId = 0;
  21936. temp.DiId = int.Parse(item.DIID);
  21937. temp.FilePath = item.FilePath;
  21938. temp.IsDel = item.IsDel;
  21939. temp.Price = item.Price;
  21940. temp.PriceCount = 1;
  21941. temp.PriceCurrency = item.Currency;
  21942. int detailId = 0;
  21943. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  21944. {
  21945. detailId = dicDetail[item.PriceTypeDetail];
  21946. }
  21947. temp.PriceDetailType = detailId;
  21948. temp.PriceDt = DateTime.Now;
  21949. temp.PriceName = item.PriceName;
  21950. temp.PriceSum = item.Price;
  21951. int tid = 0;
  21952. if (dic.ContainsKey(item.PriceType))
  21953. {
  21954. tid = dic[item.PriceType];
  21955. }
  21956. temp.PriceType = tid;
  21957. temp.Remark = item.Remark;
  21958. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  21959. }
  21960. return Ok(JsonView(true, "操作成功!"));
  21961. }
  21962. [HttpPost]
  21963. public IActionResult TimeTest()
  21964. {
  21965. var jw = JsonView(false, "error");
  21966. _sqlSugar.BeginTran();
  21967. try
  21968. {
  21969. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  21970. .Select(x => new Crm_NewClientData
  21971. {
  21972. Id = x.Id,
  21973. Client = x.Client,
  21974. Contact = x.Contact,
  21975. Location = x.Location,
  21976. })
  21977. .ToList();
  21978. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  21979. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  21980. Stopwatch stopwatch = new Stopwatch();
  21981. // 开始计时
  21982. stopwatch.Start();
  21983. foreach (var item in clientList)
  21984. {
  21985. EncryptionProcessor.DecryptProperties(item);
  21986. }
  21987. stopwatch.Stop();
  21988. jw.Code = 200;
  21989. jw.Data = stopwatch.ElapsedMilliseconds;
  21990. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  21991. }
  21992. catch (Exception ex)
  21993. {
  21994. jw.Code = 400;
  21995. jw.Msg = ex.Message;
  21996. }
  21997. return Ok(jw);
  21998. }
  21999. }
  22000. }