GroupsController.cs 833 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using EyeSoft.Collections.Generic;
  7. using EyeSoft.IO;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.SignalR;
  10. using MySqlX.XDevAPI.Relational;
  11. using NetUV.Core.Handles;
  12. using NPOI.HSSF.UserModel;
  13. using NPOI.POIFS.Crypt.Dsig;
  14. using NPOI.POIFS.Properties;
  15. using NPOI.SS.Format;
  16. using NPOI.SS.Formula.Functions;
  17. using NPOI.SS.UserModel;
  18. using NPOI.SS.Util;
  19. using NPOI.XSSF.UserModel;
  20. using OASystem.API.Middlewares;
  21. using OASystem.API.OAMethodLib;
  22. using OASystem.API.OAMethodLib.APNs;
  23. using OASystem.API.OAMethodLib.File;
  24. using OASystem.API.OAMethodLib.Hub.HubClients;
  25. using OASystem.API.OAMethodLib.Hub.Hubs;
  26. using OASystem.API.OAMethodLib.JuHeAPI;
  27. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  28. using OASystem.Domain.AesEncryption;
  29. using OASystem.Domain.Dtos.CRM;
  30. using OASystem.Domain.Dtos.FileDto;
  31. using OASystem.Domain.Dtos.Financial;
  32. using OASystem.Domain.Dtos.Groups;
  33. using OASystem.Domain.Entities.Customer;
  34. using OASystem.Domain.Entities.Financial;
  35. using OASystem.Domain.Entities.Groups;
  36. using OASystem.Domain.ViewModels;
  37. using OASystem.Domain.ViewModels.Financial;
  38. using OASystem.Domain.ViewModels.Groups;
  39. using OASystem.Domain.ViewModels.Statistics;
  40. using OASystem.Infrastructure.Repositories.CRM;
  41. using OASystem.Infrastructure.Repositories.Financial;
  42. using OASystem.Infrastructure.Repositories.Groups;
  43. using OfficeOpenXml;
  44. using Org.BouncyCastle.Asn1.Ocsp;
  45. using Quartz.Util;
  46. using SqlSugar;
  47. using SqlSugar.Extensions;
  48. using System.Collections;
  49. using System.Data;
  50. using System.Data.OleDb;
  51. using System.Diagnostics;
  52. using System.Globalization;
  53. using System.IO;
  54. using System.IO.Compression;
  55. using System.Net.Http;
  56. using System.Reflection.PortableExecutable;
  57. using System.Security.Cryptography;
  58. using Ubiety.Dns.Core;
  59. using static NPOI.POIFS.Crypt.CryptoFunctions;
  60. using static OASystem.API.OAMethodLib.JWTHelper;
  61. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  62. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  63. using Bookmark = Aspose.Words.Bookmark;
  64. using Cell = Aspose.Words.Tables.Cell;
  65. using Table = Aspose.Words.Tables.Table;
  66. namespace OASystem.API.Controllers
  67. {
  68. /// <summary>
  69. /// 团组相关
  70. /// </summary>
  71. //[Authorize]
  72. [Route("api/[controller]/[action]")]
  73. public class GroupsController : ControllerBase
  74. {
  75. private readonly ILogger<GroupsController> _logger;
  76. private readonly GrpScheduleRepository _grpScheduleRep;
  77. private readonly IMapper _mapper;
  78. private readonly DelegationInfoRepository _groupRepository;
  79. private readonly TaskAssignmentRepository _taskAssignmentRep;
  80. private readonly AirTicketResRepository _airTicketResRep;
  81. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  82. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  83. private readonly DelegationEnDataRepository _delegationEnDataRep;
  84. private readonly DelegationVisaRepository _delegationVisaRep;
  85. private readonly VisaPriceRepository _visaPriceRep;
  86. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  87. private readonly HotelPriceRepository _hotelPriceRep;
  88. private readonly CustomersRepository _customersRep;
  89. private readonly MessageRepository _message;
  90. private readonly SqlSugarClient _sqlSugar;
  91. private readonly TourClientListRepository _tourClientListRep;
  92. private readonly TeamRateRepository _teamRateRep;
  93. #region 成本相关
  94. private readonly CheckBoxsRepository _checkBoxs;
  95. private readonly GroupCostRepository _GroupCostRepository;
  96. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  97. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  98. #endregion
  99. private readonly SetDataRepository _setDataRep;
  100. private string url;
  101. private string path;
  102. private readonly EnterExitCostRepository _enterExitCostRep;
  103. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  104. private readonly UsersRepository _usersRep;
  105. private readonly IJuHeApiService _juHeApi;
  106. private readonly InvertedListRepository _invertedListRep;
  107. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  108. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  109. private readonly ThreeCodeRepository _threeCodeRepository;
  110. private readonly HotelInquiryRepository _hotelInquiryRep;
  111. private readonly FeeAuditRepository _feeAuditRep;
  112. private readonly VisaCommissionRepository _visaCommissionRep;
  113. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  114. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  115. private readonly List<CurrencyInfo> _currencyInit;
  116. private readonly List<int> _portTypeData;
  117. private readonly TableOperationRecordRepository _tableorRep;
  118. public GroupsController(
  119. ILogger<GroupsController> logger,
  120. IMapper mapper,
  121. IHubContext<ChatHub, IChatClient> hubContext,
  122. SqlSugarClient sqlSugar,
  123. GrpScheduleRepository grpScheduleRep,
  124. DelegationInfoRepository groupRepository,
  125. TaskAssignmentRepository taskAssignmentRep,
  126. AirTicketResRepository airTicketResRep,
  127. DecreasePaymentsRepository decreasePaymentsRep,
  128. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  129. DelegationEnDataRepository delegationEnDataRep,
  130. EnterExitCostRepository enterExitCostRep,
  131. DelegationVisaRepository delegationVisaRep,
  132. MessageRepository message,
  133. VisaPriceRepository visaPriceRep,
  134. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  135. CheckBoxsRepository checkBoxs,
  136. GroupCostRepository GroupCostRepository,
  137. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  138. GroupCostParameterRepository GroupCostParameterRepository,
  139. HotelPriceRepository hotelPriceRep,
  140. CustomersRepository customersRep,
  141. SetDataRepository setDataRep,
  142. TourClientListRepository tourClientListRep,
  143. TeamRateRepository teamRateRep,
  144. UsersRepository usersRep, IJuHeApiService juHeApi,
  145. InvertedListRepository invertedListRep,
  146. VisaFeeInfoRepository visaFeeInfoRep,
  147. TicketBlackCodeRepository ticketBlackCodeRep,
  148. HotelInquiryRepository hotelInquiryRep,
  149. ThreeCodeRepository threeCodeRepository,
  150. FeeAuditRepository feeAuditRep,
  151. VisaCommissionRepository visaCommissionRep,
  152. ForeignReceivablesRepository ffrRep,
  153. OpinionaireRepository opinionaireRep,
  154. TableOperationRecordRepository tableorRep
  155. )
  156. {
  157. _logger = logger;
  158. _mapper = mapper;
  159. _grpScheduleRep = grpScheduleRep;
  160. _groupRepository = groupRepository;
  161. _taskAssignmentRep = taskAssignmentRep;
  162. _airTicketResRep = airTicketResRep;
  163. _sqlSugar = sqlSugar;
  164. url = AppSettingsHelper.Get("ExcelBaseUrl");
  165. path = AppSettingsHelper.Get("ExcelBasePath");
  166. if (!System.IO.Directory.Exists(path))
  167. {
  168. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  169. }
  170. _decreasePaymentsRep = decreasePaymentsRep;
  171. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  172. _delegationEnDataRep = delegationEnDataRep;
  173. _enterExitCostRep = enterExitCostRep;
  174. _delegationVisaRep = delegationVisaRep;
  175. _message = message;
  176. _visaPriceRep = visaPriceRep;
  177. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  178. _checkBoxs = checkBoxs;
  179. _GroupCostRepository = GroupCostRepository;
  180. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  181. _GroupCostParameterRepository = GroupCostParameterRepository;
  182. _hotelPriceRep = hotelPriceRep;
  183. _customersRep = customersRep;
  184. _setDataRep = setDataRep;
  185. _tourClientListRep = tourClientListRep;
  186. _teamRateRep = teamRateRep;
  187. _hubContext = hubContext;
  188. _usersRep = usersRep;
  189. _juHeApi = juHeApi;
  190. _invertedListRep = invertedListRep;
  191. _visaFeeInfoRep = visaFeeInfoRep;
  192. _ticketBlackCodeRep = ticketBlackCodeRep;
  193. _hotelInquiryRep = hotelInquiryRep;
  194. _threeCodeRepository = threeCodeRepository;
  195. _feeAuditRep = feeAuditRep;
  196. _visaCommissionRep = visaCommissionRep;
  197. _ffrRep = ffrRep;
  198. _opinionaireRep = opinionaireRep;
  199. _currencyInit = new List<CurrencyInfo>()
  200. {
  201. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  202. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  203. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  204. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  205. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  206. };
  207. _portTypeData = new List<int>() { 2, 3 };
  208. _tableorRep = tableorRep;
  209. }
  210. #region 流程管控
  211. /// <summary>
  212. /// 获取团组流程管控信息
  213. /// </summary>
  214. /// <param name="paras">参数Json字符串</param>
  215. /// <returns></returns>
  216. [HttpPost]
  217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  218. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  219. {
  220. if (string.IsNullOrEmpty(_jsonDto.Paras))
  221. {
  222. return Ok(JsonView(false, "参数为空"));
  223. }
  224. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  225. if (_ScheduleDto != null)
  226. {
  227. if (_ScheduleDto.SearchType == 2)//获取列表
  228. {
  229. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  230. return Ok(JsonView(_grpScheduleViewList));
  231. }
  232. else//获取对象
  233. {
  234. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  235. if (_grpScheduleView != null)
  236. {
  237. return Ok(JsonView(_grpScheduleView));
  238. }
  239. }
  240. }
  241. else
  242. {
  243. return Ok(JsonView(false, "参数反序列化失败"));
  244. }
  245. return Ok(JsonView(false, "暂无数据!"));
  246. }
  247. /// <summary>
  248. /// 修改团组流程管控详细表数据
  249. /// </summary>
  250. /// <param name="paras"></param>
  251. /// <returns></returns>
  252. [HttpPost]
  253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  254. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  255. {
  256. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  257. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  258. .SetColumns(it => it.Duty == _detail.Duty)
  259. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  260. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  261. .SetColumns(it => it.JobContent == _detail.JobContent)
  262. .SetColumns(it => it.Remark == _detail.Remark)
  263. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  264. .Where(s => s.Id == dto.Id)
  265. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  266. .ExecuteCommandAsync();
  267. if (result > 0)
  268. {
  269. return Ok(JsonView(true, "保存成功!"));
  270. }
  271. return Ok(JsonView(false, "保存失败!"));
  272. }
  273. /// <summary>
  274. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  275. /// </summary>
  276. /// <param name="dto"></param>
  277. /// <returns></returns>
  278. [HttpPost]
  279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  280. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  281. {
  282. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  283. _detail.IsDel = 1;
  284. _detail.DeleteUserId = dto.Duty;
  285. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  286. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  287. .SetColumns(it => it.IsDel == _detail.IsDel)
  288. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  289. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  290. .Where(it => it.Id == dto.Id)
  291. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  292. //.WhereColumns(s => s.Id == dto.Id)
  293. .ExecuteCommandAsync();
  294. if (result > 0)
  295. {
  296. return Ok(JsonView(true, "删除成功!"));
  297. }
  298. return Ok(JsonView(false, "删除失败!"));
  299. }
  300. /// <summary>
  301. /// 增加团组流程管控详细表数据
  302. /// </summary>
  303. /// <param name="dto"></param>
  304. /// <returns></returns>
  305. [HttpPost]
  306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  307. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  308. {
  309. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  310. if (DateTime.Now < _detail.ExpectBeginDt)
  311. {
  312. _detail.StepStatus = 0;
  313. }
  314. else
  315. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  316. _detail.StepStatus = 1;
  317. }
  318. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  319. if (result > 0)
  320. {
  321. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  322. return Ok(JsonView(true, "添加成功!", _result));
  323. }
  324. return Ok(JsonView(false, "添加失败!"));
  325. }
  326. #endregion
  327. #region 团组基本信息
  328. /// <summary>
  329. /// 接团信息列表
  330. /// </summary>
  331. /// <param name="dto">团组列表请求dto</param>
  332. /// <returns></returns>
  333. [HttpPost]
  334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  335. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  336. {
  337. var groupData = await _groupRepository.GetGroupList(dto);
  338. if (groupData.Code != 0)
  339. {
  340. return Ok(JsonView(false, groupData.Msg));
  341. }
  342. return Ok(JsonView(groupData.Data));
  343. }
  344. /// <summary>
  345. /// 分页查询团组列表
  346. /// </summary>
  347. /// <param name="dto"></param>
  348. /// <returns></returns>
  349. [HttpPost]
  350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  351. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  352. {
  353. var watch = new Stopwatch();
  354. watch.Start();
  355. RefAsync<int> total = 0;
  356. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  357. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  358. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  359. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  360. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  361. .Distinct()
  362. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  363. watch.Stop();
  364. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  365. }
  366. /// <summary>
  367. /// 接团信息列表 Page
  368. /// </summary>
  369. /// <param name="dto">团组列表请求dto</param>
  370. /// <returns></returns>
  371. [HttpPost]
  372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  373. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  374. {
  375. #region 参数验证
  376. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  377. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  378. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  379. #region 页面操作权限验证
  380. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  381. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  382. #endregion
  383. #endregion
  384. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  385. {
  386. string sqlWhere = string.Empty;
  387. if (dto.IsSure == 0) //未完成
  388. {
  389. sqlWhere += string.Format(@" And IsSure = 0");
  390. }
  391. else if (dto.IsSure == 1) //已完成
  392. {
  393. sqlWhere += string.Format(@" And IsSure = 1");
  394. }
  395. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  396. {
  397. string tj = dto.SearchCriteria;
  398. 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}%')",
  399. tj, tj, tj, tj, tj);
  400. }
  401. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  402. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  403. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  404. JietuanOperator,IsSure,CreateTime,IsBid
  405. From (
  406. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  407. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  408. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  409. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  410. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  411. From Grp_DelegationInfo gdi
  412. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  413. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  414. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  415. Where gdi.IsDel = 0 {0}
  416. ) temp", sqlWhere);
  417. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  418. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  419. #region 处理所属部门
  420. /*
  421. * 1.sq 和 gyy 等显示 市场部
  422. * 2.王鸽和主管及张总还有管理员号统一国交部
  423. * 2-1. 4 管理员 ,21 张海麟
  424. */
  425. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  426. List<int> userIds1 = new List<int>() { 4, 21 };
  427. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  428. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  429. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  430. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  431. .ToList();
  432. foreach (var item in _DelegationList)
  433. {
  434. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  435. }
  436. #endregion
  437. var _view = new
  438. {
  439. PageFuncAuth = pageFunAuthView,
  440. Data = _DelegationList
  441. };
  442. return Ok(JsonView(true, "查询成功!", _view, total));
  443. }
  444. else
  445. {
  446. return Ok(JsonView(false, "查询失败"));
  447. }
  448. }
  449. /// <summary>
  450. /// 团组列表
  451. /// </summary>
  452. /// <returns></returns>
  453. [HttpPost]
  454. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  455. {
  456. #region 参数验证
  457. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  458. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  459. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  460. #region 页面操作权限验证
  461. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  462. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  463. #endregion
  464. #endregion
  465. if (dto.PortType != 1 && dto.PortType != 2)
  466. {
  467. return Ok(JsonView(false, "查询失败!"));
  468. }
  469. string orderbyStr = "order by gdi.CreateTime Desc";
  470. string sqlWhere = string.Empty;
  471. if (dto.IsSure == 0) //未完成
  472. {
  473. sqlWhere += string.Format(@" And IsSure = 0");
  474. }
  475. else if (dto.IsSure == 1) //已完成
  476. {
  477. sqlWhere += string.Format(@" And IsSure = 1");
  478. }
  479. //团组类型
  480. if (dto.TeamDid > 0)
  481. {
  482. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  483. }
  484. //团组名称
  485. if (!string.IsNullOrEmpty(dto.TeamName))
  486. {
  487. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  488. }
  489. //客户名称
  490. if (!string.IsNullOrEmpty(dto.ClientName))
  491. {
  492. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  493. }
  494. //客户单位
  495. if (!string.IsNullOrEmpty(dto.ClientUnit))
  496. {
  497. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  498. }
  499. //出访时间
  500. if (!string.IsNullOrEmpty(dto.visitDataTime))
  501. {
  502. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  503. orderbyStr = "order by gdi.VisitDate";
  504. }
  505. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  506. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  507. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  508. JietuanOperator,IsSure,CreateTime
  509. From (
  510. Select row_number() over({0}) as Row_Number,
  511. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  512. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  513. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  514. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  515. From Grp_DelegationInfo gdi
  516. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  517. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  518. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  519. Where gdi.IsDel = 0 {1}
  520. ) temp ", orderbyStr, sqlWhere);
  521. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  522. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  523. #region 处理所属部门
  524. /*
  525. * 1.sq 和 gyy 等显示 市场部
  526. * 2.王鸽和主管及张总还有管理员号统一国交部
  527. * 2-1. 4 管理员 ,21 张海麟
  528. */
  529. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  530. List<int> userIds1 = new List<int>() { 4, 21 };
  531. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  532. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  533. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  534. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  535. .ToList();
  536. foreach (var item in _DelegationList)
  537. {
  538. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  539. }
  540. #endregion
  541. var _view = new
  542. {
  543. PageFuncAuth = pageFunAuthView,
  544. Data = _DelegationList
  545. };
  546. return Ok(JsonView(true, "查询成功!", _view, total));
  547. }
  548. /// <summary>
  549. /// 接团信息详情
  550. /// </summary>
  551. /// <param name="dto">团组info请求dto</param>
  552. /// <returns></returns>
  553. [HttpPost]
  554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  555. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  556. {
  557. var groupData = await _groupRepository.GetGroupInfo(dto);
  558. if (groupData.Code != 0)
  559. {
  560. return Ok(JsonView(false, groupData.Msg));
  561. }
  562. return Ok(JsonView(groupData.Data));
  563. }
  564. /// <summary>
  565. /// 接团信息 编辑添加
  566. /// 基础信息数据源
  567. /// </summary>
  568. /// <param name="dto"></param>
  569. /// <returns></returns>
  570. [HttpPost]
  571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  572. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  573. {
  574. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  575. if (groupData.Code != 0)
  576. {
  577. return Ok(JsonView(false, groupData.Msg));
  578. }
  579. return Ok(JsonView(groupData.Data));
  580. }
  581. /// <summary>
  582. /// 接团信息 操作(增改)
  583. /// </summary>
  584. /// <param name="dto"></param>
  585. /// <returns></returns>
  586. [HttpPost]
  587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  588. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  589. {
  590. try
  591. {
  592. decimal ffrPrice = 0.00M;
  593. DateTime? visitDt = null;
  594. if (dto.Status == 2)
  595. {
  596. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  597. if (groupInfo != null)
  598. {
  599. ffrPrice = groupInfo.PaymentMoney;
  600. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  601. }
  602. }
  603. var groupData = await _groupRepository.GroupOperation(dto);
  604. if (groupData.Code != 0)
  605. {
  606. return Ok(JsonView(false, groupData.Msg));
  607. }
  608. int diId = 0;
  609. //添加时 默认加入团组汇率
  610. if (dto.Status == 1) //添加
  611. {
  612. diId = groupData.Data;
  613. //添加默认币种
  614. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  615. //默认分配权限
  616. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  617. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  618. var _managerIds = new List<int>() { 22, 32, 21 };
  619. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  620. if (userIds.Count > 0)
  621. {
  622. userIds.Add(208);
  623. //创建团组管控
  624. GroupStepForDelegation.CreateWorkStep(diId);
  625. //发送消息
  626. string groupName = dto.TeamName;
  627. string createGroupUser = string.Empty;
  628. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  629. if (userInfo != null) createGroupUser = userInfo.CnName;
  630. string title = $"系统通知";
  631. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  632. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  633. }
  634. //默认创建倒推表
  635. await _invertedListRep._Create(dto.UserId, diId);
  636. }
  637. else if (dto.Status == 2)
  638. {
  639. diId = dto.Id;
  640. }
  641. #region 签证人员团组时间通知
  642. #region 计算出访起止时间
  643. var startTime = new DateTime();
  644. var endTime = new DateTime();
  645. if (DateTime.TryParse(dto.VisitDate, out startTime))
  646. {
  647. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  648. }
  649. #endregion
  650. if (diId > 0)
  651. {
  652. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  653. }
  654. #endregion
  655. #region 团组操作默认添加/修改收款账单
  656. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  657. {
  658. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  659. .Where(x => x.IsDel == 0 &&
  660. x.Diid == diId &&
  661. x.Remark.Equals("预付款")
  662. )
  663. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  664. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  665. .FirstAsync();
  666. ffrInfo = new Fin_ForeignReceivables()
  667. {
  668. Diid = diId,
  669. PriceName = dto.ClientUnit,
  670. Price = dto.PaymentMoney,
  671. Count = 1,
  672. Unit = $"元",
  673. ItemSumPrice = dto.PaymentMoney,
  674. Rate = 1.0000M,
  675. Currency = 836,
  676. AddingWay = 0,
  677. CreateUserId = dto.UserId,
  678. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  679. Remark = $"预付款"
  680. };
  681. if (ffrInfo == null) //Add
  682. {
  683. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  684. }
  685. else //修改
  686. {
  687. await _sqlSugar.Updateable(ffrInfo)
  688. .UpdateColumns(x => new
  689. {
  690. x.PriceName,
  691. x.Price,
  692. x.ItemSumPrice,
  693. x.CreateTime,
  694. x.CreateUserId
  695. })
  696. .WhereColumns(x => x.Id)
  697. .ExecuteCommandAsync();
  698. }
  699. }
  700. #endregion
  701. return Ok(JsonView(true, "操作成功!", diId));
  702. }
  703. catch (Exception ex)
  704. {
  705. Logs("[response]" + JsonConvert.SerializeObject(dto));
  706. Logs(ex.Message);
  707. return Ok(JsonView(false, ex.Message));
  708. }
  709. }
  710. /// <summary>
  711. /// 接团流程操作(增改)
  712. /// 安卓端使用 建团时添加客户名单
  713. /// </summary>
  714. /// <param name="dto"></param>
  715. /// <returns></returns>
  716. [HttpPost]
  717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  718. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  719. {
  720. try
  721. {
  722. #region 参数验证
  723. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  724. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  725. #region 页面操作权限验证
  726. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  727. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  728. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  729. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  730. #endregion
  731. #endregion
  732. _sqlSugar.BeginTran();
  733. decimal ffrPrice = 0.00M;
  734. DateTime? visitDt = null;
  735. if (dto.Status == 2)
  736. {
  737. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  738. if (groupInfo != null)
  739. {
  740. ffrPrice = groupInfo.PaymentMoney;
  741. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  742. }
  743. }
  744. var _dto = new GroupOperationDto();
  745. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  746. var groupData = await _groupRepository.GroupOperation(_dto);
  747. if (groupData.Code != 0)
  748. {
  749. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  750. }
  751. int diId = 0;
  752. //添加时 默认加入团组汇率
  753. if (dto.Status == 1) //添加
  754. {
  755. diId = groupData.Data;
  756. //添加默认币种
  757. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  758. //默认分配权限
  759. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  760. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  761. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  762. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  763. if (userIds.Count > 0)
  764. {
  765. userIds.Add(208);
  766. //创建团组管控
  767. GroupStepForDelegation.CreateWorkStep(diId);
  768. //发送消息
  769. string groupName = dto.TeamName;
  770. string createGroupUser = string.Empty;
  771. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  772. if (userInfo != null) createGroupUser = userInfo.CnName;
  773. string title = $"系统通知";
  774. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  775. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  776. }
  777. #region 应用推送
  778. try
  779. {
  780. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  781. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  782. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  783. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  784. {
  785. List<string> userList = new List<string>() { users.QiyeChatUserId };
  786. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  787. }
  788. }
  789. catch (Exception ex)
  790. {
  791. }
  792. #endregion
  793. //默认创建倒推表
  794. await _invertedListRep._Create(dto.UserId, diId);
  795. }
  796. if (dto.Status == 2)
  797. {
  798. diId = dto.Id;
  799. if (diId == 0)
  800. {
  801. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  802. }
  803. }
  804. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  805. if (viewData.Code != 0)
  806. {
  807. _sqlSugar.RollbackTran();
  808. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  809. }
  810. #region 团组操作默认添加/修改收款账单
  811. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  812. {
  813. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  814. .Where(x => x.IsDel == 0 &&
  815. x.Diid == diId &&
  816. x.Remark.Equals("预付款")
  817. )
  818. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  819. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  820. .FirstAsync();
  821. ffrInfo = new Fin_ForeignReceivables()
  822. {
  823. Diid = diId,
  824. PriceName = dto.ClientUnit,
  825. Price = dto.PaymentMoney,
  826. Count = 1,
  827. Unit = $"元",
  828. ItemSumPrice = dto.PaymentMoney,
  829. Rate = 1.0000M,
  830. Currency = 836,
  831. AddingWay = 0,
  832. CreateUserId = dto.UserId,
  833. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  834. Remark = $"预付款"
  835. };
  836. if (ffrInfo == null) //Add
  837. {
  838. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  839. }
  840. else //修改
  841. {
  842. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  843. .UpdateColumns(x => new
  844. {
  845. x.PriceName,
  846. x.Price,
  847. x.ItemSumPrice,
  848. x.CreateTime,
  849. x.CreateUserId
  850. })
  851. .WhereColumns(x => x.Id)
  852. .ExecuteCommandAsync();
  853. }
  854. }
  855. #endregion
  856. #region 签证人员团组时间通知
  857. #region 计算出访起止时间
  858. var startTime = new DateTime();
  859. var endTime = new DateTime();
  860. if (DateTime.TryParse(dto.VisitDate, out startTime))
  861. {
  862. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  863. }
  864. #endregion
  865. if (diId > 0)
  866. {
  867. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  868. }
  869. #endregion
  870. _sqlSugar.CommitTran();
  871. return Ok(JsonView(true, "添加成功"));
  872. }
  873. catch (Exception ex)
  874. {
  875. _sqlSugar.RollbackTran();
  876. return Ok(JsonView(false, ex.Message));
  877. }
  878. }
  879. /// <summary>
  880. /// 接团信息 操作(删除)
  881. /// </summary>
  882. /// <param name="dto"></param>
  883. /// <returns></returns>
  884. [HttpPost]
  885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  886. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  887. {
  888. var diId = dto.Id;
  889. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  890. #region 删除 验证 (费用录入、出入境费用、收款账单)
  891. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  892. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  893. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  894. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  895. #endregion
  896. var groupData = await _groupRepository.GroupDel(dto);
  897. if (groupData.Code != 0)
  898. {
  899. return Ok(JsonView(false, groupData.Msg));
  900. }
  901. return Ok(JsonView(true));
  902. }
  903. /// <summary>
  904. /// 获取团组销售报价号
  905. /// 团组添加时 使用
  906. /// </summary>
  907. /// <returns></returns>
  908. [HttpPost]
  909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  910. public async Task<IActionResult> GetGroupSalesQuoteNo()
  911. {
  912. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  913. if (groupData.Code != 0)
  914. {
  915. return Ok(JsonView(false, groupData.Msg));
  916. }
  917. object salesQuoteNo = new
  918. {
  919. SalesQuoteNo = groupData.Data
  920. };
  921. return Ok(JsonView(salesQuoteNo));
  922. }
  923. /// <summary>
  924. /// 设置确认出团
  925. /// </summary>
  926. /// <param name="dto"></param>
  927. /// <returns></returns>
  928. [HttpPost]
  929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  930. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  931. {
  932. var groupData = await _groupRepository.ConfirmationGroup(dto);
  933. if (groupData.Code != 0)
  934. {
  935. return Ok(JsonView(false, groupData.Msg));
  936. }
  937. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  938. #region OA消息推送
  939. try
  940. {
  941. string groupName = groupInfo.TeamName;
  942. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  943. string title = $"系统通知";
  944. string content = $"团组[{groupName}]已确认出团!";
  945. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  946. }
  947. catch (Exception ex)
  948. {
  949. }
  950. #endregion
  951. #region 应用推送
  952. try
  953. {
  954. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  955. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  956. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  957. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  958. {
  959. List<string> userList = new List<string>() { users.QiyeChatUserId };
  960. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  961. }
  962. }
  963. catch (Exception ex)
  964. {
  965. }
  966. #endregion
  967. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  968. return Ok(JsonView(true, "操作成功!", groupData.Data));
  969. }
  970. /// <summary>
  971. /// 获取团组名称data And 签证国别Data
  972. /// </summary>
  973. /// <param name="dto"></param>
  974. /// <returns></returns>
  975. [HttpPost]
  976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  977. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  978. {
  979. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  980. if (groupData.Code != 0)
  981. {
  982. return Ok(JsonView(false, groupData.Msg));
  983. }
  984. return Ok(JsonView(groupData.Data));
  985. }
  986. /// <summary>
  987. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  988. /// </summary>
  989. /// <returns></returns>
  990. [HttpPost]
  991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  992. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  993. {
  994. try
  995. {
  996. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  997. if (groupData.Code != 0)
  998. {
  999. return Ok(JsonView(false, groupData.Msg));
  1000. }
  1001. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1002. }
  1003. catch (Exception ex)
  1004. {
  1005. return Ok(JsonView(false, "程序错误!"));
  1006. throw;
  1007. }
  1008. }
  1009. /// <summary>
  1010. /// 团组清单 Excel
  1011. /// </summary>
  1012. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1013. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1014. /// <returns></returns>
  1015. [HttpGet]
  1016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1017. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1018. {
  1019. DateTime _beginDt, _endDt;
  1020. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1021. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1022. if (!beginBool && !endBool)
  1023. {
  1024. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1025. }
  1026. string sql = string.Format(@"
  1027. SELECT
  1028. ROW_NUMBER,
  1029. Id,
  1030. SalesQuoteNo,
  1031. TourCode,
  1032. TeamTypeId,
  1033. TeamType,
  1034. TeamLevId,
  1035. TeamLev,
  1036. TeamName,
  1037. ClientName,
  1038. ClientUnit,
  1039. VisitDate,
  1040. VisitDays,
  1041. VisitPNumber,
  1042. JietuanOperatorId,
  1043. JietuanOperator,
  1044. IsSure,
  1045. CreateTime,
  1046. IsBid
  1047. FROM
  1048. (
  1049. SELECT
  1050. ROW_NUMBER() OVER(
  1051. ORDER BY
  1052. gdi.CreateTime Desc
  1053. ) AS ROW_NUMBER,
  1054. gdi.Id,
  1055. SalesQuoteNo,
  1056. TourCode,
  1057. ssd.Id TeamTypeId,
  1058. ssd.Name TeamType,
  1059. ssd1.Id TeamLevId,
  1060. ssd1.Name TeamLev,
  1061. TeamName,
  1062. ClientName,
  1063. ClientUnit,
  1064. VisitDate,
  1065. VisitDays,
  1066. VisitPNumber,
  1067. JietuanOperator JietuanOperatorId,
  1068. su.CnName JietuanOperator,
  1069. IsSure,
  1070. gdi.CreateTime,
  1071. gdi.IsBid
  1072. FROM
  1073. Grp_DelegationInfo gdi
  1074. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1075. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1076. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1077. WHERE
  1078. gdi.IsDel = 0
  1079. AND gdi.IsBid = 0
  1080. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1081. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1082. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1083. #region 处理所属部门
  1084. /*
  1085. * 1.sq 和 gyy 等显示 市场部
  1086. * 2.王鸽和主管及张总还有管理员号统一国交部
  1087. * 2-1. 4 管理员 ,21 张海麟
  1088. */
  1089. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1090. List<int> userIds1 = new List<int>() { 4, 21 };
  1091. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1092. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1093. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1094. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1095. .ToListAsync();
  1096. foreach (var item in groupList)
  1097. {
  1098. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1099. }
  1100. #endregion
  1101. #region Excel
  1102. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1103. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1104. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1105. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1106. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1107. //载入模板
  1108. WorkbookDesigner designer = new WorkbookDesigner();
  1109. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1110. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1111. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1112. dt.TableName = "GroupList";
  1113. designer.SetDataSource(dt);
  1114. designer.Process();
  1115. if (!Directory.Exists(savePath))
  1116. {
  1117. Directory.CreateDirectory(savePath);
  1118. }
  1119. string serverPath = $"{savePath}{fileName}";
  1120. designer.Workbook.Save(serverPath);
  1121. string rst = $"{servicePath}{ftpPath}{fileName}";
  1122. #endregion
  1123. return Ok(JsonView(true, "操作成功!", rst));
  1124. }
  1125. #endregion
  1126. #region 团组&签证
  1127. /// <summary>
  1128. /// 根据团组Id获取签证客户信息List
  1129. /// </summary>
  1130. /// <param name="dto">请求dto</param>
  1131. /// <returns></returns>
  1132. [HttpPost]
  1133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1134. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1135. {
  1136. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1137. if (groupData.Code != 0)
  1138. {
  1139. return Ok(JsonView(false, groupData.Msg));
  1140. }
  1141. return Ok(JsonView(groupData.Data));
  1142. }
  1143. /// <summary>
  1144. /// IOS获取团组签证拍照上传进度01(团组列表)
  1145. /// </summary>
  1146. /// <param name="dto">请求dto</param>
  1147. /// <returns></returns>
  1148. [HttpPost]
  1149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1150. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1151. {
  1152. if (dto == null)
  1153. {
  1154. return Ok(JsonView(false, "参数为空"));
  1155. }
  1156. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1157. return Ok(JsonView(visaList));
  1158. }
  1159. /// <summary>
  1160. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1161. /// </summary>
  1162. /// <returns></returns>
  1163. [HttpPost]
  1164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1165. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1166. {
  1167. if (dto == null)
  1168. {
  1169. return Ok(JsonView(false, "请求错误:"));
  1170. }
  1171. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1172. return Ok(JsonView(list));
  1173. }
  1174. /// <summary>
  1175. /// IOS获取团组签证拍照上传进度03(相册)
  1176. /// </summary>
  1177. /// <returns></returns>
  1178. [HttpPost]
  1179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1180. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1181. {
  1182. if (dto == null)
  1183. {
  1184. return Ok(JsonView(false, "请求错误:"));
  1185. }
  1186. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1187. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1188. list.ForEach(s => s.url = url);
  1189. return Ok(JsonView(list));
  1190. }
  1191. /// <summary>
  1192. /// IOS获取团组签证拍照上传进度04(图片上传)
  1193. /// </summary>
  1194. /// <param name="dto"></param>
  1195. /// <returns></returns>
  1196. [HttpPost]
  1197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1198. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1199. {
  1200. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1201. //if (!string.IsNullOrEmpty(result))
  1202. //{
  1203. //}
  1204. //else {
  1205. // return Ok(JsonView(false, "上传失败"));
  1206. //}
  1207. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1208. int sucNum = 0;
  1209. try
  1210. {
  1211. foreach (var item in dto.base64DataList)
  1212. {
  1213. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1214. string result = decodeBase64ToImage(item, imageName);
  1215. if (!string.IsNullOrEmpty(result))
  1216. {
  1217. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1218. pic.CreateUserId = dto.CreateUserId;
  1219. pic.PicName = imageName;
  1220. pic.PicPath = result;
  1221. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1222. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1223. if (insertResult > 0)
  1224. {
  1225. sucNum++;
  1226. }
  1227. }
  1228. }
  1229. }
  1230. catch (Exception ex)
  1231. {
  1232. return Ok(JsonView(false, ex.Message));
  1233. }
  1234. string msg = string.Format(@"成功上传{0}张", sucNum);
  1235. return Ok(JsonView(true, msg));
  1236. }
  1237. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1238. {
  1239. string filename = "";//声明一个string类型的相对路径
  1240. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1241. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1242. try//会有异常抛出,try,catch一下
  1243. {
  1244. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1245. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1246. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1247. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1248. //文件名称
  1249. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1250. //上传的文件的路径
  1251. string filePath = "";
  1252. if (!Directory.Exists(fileDir))
  1253. {
  1254. Directory.CreateDirectory(fileDir);
  1255. }
  1256. //上传的文件的路径
  1257. filePath = fileDir + filename;
  1258. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1259. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1260. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1261. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1262. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1263. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1264. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1265. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1266. bitmap.Dispose();
  1267. }
  1268. catch (Exception e)
  1269. {
  1270. string massage = e.Message;
  1271. Logs("IOS图片上传Error:" + massage);
  1272. //filename = e.Message;
  1273. }
  1274. return filename;//返回相对路径
  1275. }
  1276. /// <summary>
  1277. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1278. /// </summary>
  1279. /// <param name="dto"></param>
  1280. /// <returns></returns>
  1281. [HttpPost]
  1282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1283. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1284. {
  1285. if (dto == null)
  1286. {
  1287. return Ok(JsonView(false, "请求错误:"));
  1288. }
  1289. string msg = "参数错误";
  1290. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1291. {
  1292. try
  1293. {
  1294. //_delegationVisaRep.BeginTran();
  1295. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1296. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1297. .Where(s => s.Id == dto.visaProgressCustomerId)
  1298. .ExecuteCommandAsync();
  1299. if (updCount > 0 && dto.publishCode == 1)
  1300. {
  1301. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1302. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1303. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1304. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1305. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1306. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1307. if (groupData == null)
  1308. {
  1309. _delegationVisaRep.RollbackTran();
  1310. }
  1311. string title = string.Format(@"[签证进度更新]");
  1312. string content = string.Format(@"测试文本");
  1313. bool rst = await _message.AddMsg(new MessageDto()
  1314. {
  1315. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1316. IssuerId = dto.publisher,
  1317. Title = title,
  1318. Content = content,
  1319. ReleaseTime = DateTime.Now,
  1320. UIdList = new List<int> {
  1321. 234
  1322. }
  1323. });
  1324. if (rst)
  1325. {
  1326. return Ok(JsonView(true, "发送通知成功"));
  1327. }
  1328. }
  1329. //_delegationVisaRep.CommitTran();
  1330. }
  1331. catch (Exception)
  1332. {
  1333. //_delegationVisaRep.RollbackTran();
  1334. }
  1335. }
  1336. return Ok(JsonView(true, msg));
  1337. }
  1338. #endregion
  1339. #region 团组任务分配
  1340. /// <summary>
  1341. /// 团组任务分配初始化
  1342. /// </summary>
  1343. /// <param name="dto"></param>
  1344. /// <returns></returns>
  1345. [HttpPost]
  1346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1347. public async Task<IActionResult> GetTaskAssignmen()
  1348. {
  1349. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1350. if (groupData.Code != 0)
  1351. {
  1352. return Ok(JsonView(false, groupData.Msg));
  1353. }
  1354. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1355. }
  1356. /// <summary>
  1357. /// 团组任务分配查询
  1358. /// </summary>
  1359. /// <param name="dto"></param>
  1360. /// <returns></returns>
  1361. [HttpPost]
  1362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1363. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1364. {
  1365. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1366. if (groupData.Code != 0)
  1367. {
  1368. return Ok(JsonView(false, groupData.Msg));
  1369. }
  1370. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1371. }
  1372. /// <summary>
  1373. /// 团组任务分配操作
  1374. /// </summary>
  1375. /// <param name="dto"></param>
  1376. /// <returns></returns>
  1377. [HttpPost]
  1378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1379. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1380. {
  1381. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1382. if (groupData.Code != 0)
  1383. {
  1384. return Ok(JsonView(false, groupData.Msg));
  1385. }
  1386. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1387. }
  1388. /// <summary>
  1389. /// 团组任务分配
  1390. /// 批量分配
  1391. /// 查询团组
  1392. /// </summary>
  1393. /// <param name="dto"></param>
  1394. /// <returns></returns>
  1395. [HttpPost]
  1396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1397. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1398. {
  1399. //参数验证
  1400. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1401. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1402. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1403. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1404. }
  1405. /// <summary>
  1406. /// 团组任务分配
  1407. /// 批量分配
  1408. /// </summary>
  1409. /// <param name="dto"></param>
  1410. /// <returns></returns>
  1411. [HttpPost]
  1412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1413. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1414. {
  1415. //参数验证
  1416. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1417. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1418. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1419. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1420. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1421. }
  1422. #endregion
  1423. #region 团组费用审核
  1424. /// <summary>
  1425. /// 费用审核
  1426. /// 团组列表 Page
  1427. /// </summary>
  1428. /// <param name="_dto">团组列表请求dto</param>
  1429. /// <returns></returns>
  1430. [HttpPost]
  1431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1432. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1433. {
  1434. #region 参数验证
  1435. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1436. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1437. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1438. #region 页面操作权限验证
  1439. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1440. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1441. #endregion
  1442. #endregion
  1443. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1444. {
  1445. string sqlWhere = string.Empty;
  1446. if (_dto.IsSure == 0) //未完成
  1447. {
  1448. sqlWhere += string.Format(@" And IsSure = 0");
  1449. }
  1450. else if (_dto.IsSure == 1) //已完成
  1451. {
  1452. sqlWhere += string.Format(@" And IsSure = 1");
  1453. }
  1454. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1455. {
  1456. string tj = _dto.SearchCriteria;
  1457. 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}%')",
  1458. tj, tj, tj, tj, tj);
  1459. }
  1460. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1461. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1462. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1463. From (
  1464. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1465. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1466. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1467. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1468. From Grp_DelegationInfo gdi
  1469. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1470. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1471. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1472. Where gdi.IsDel = 0 {0}
  1473. ) temp ", sqlWhere);
  1474. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1475. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1476. var _view = new
  1477. {
  1478. PageFuncAuth = pageFunAuthView,
  1479. Data = _DelegationList
  1480. };
  1481. return Ok(JsonView(true, "查询成功!", _view, total));
  1482. }
  1483. else
  1484. {
  1485. return Ok(JsonView(false, "查询失败"));
  1486. }
  1487. }
  1488. /// <summary>
  1489. /// 获取团组费用审核
  1490. /// </summary>
  1491. /// <param name="paras">参数Json字符串</param>
  1492. /// <returns></returns>
  1493. [HttpPost]
  1494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1495. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1496. {
  1497. try
  1498. {
  1499. #region 参数验证
  1500. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1501. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1502. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1503. #region 页面操作权限验证
  1504. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1505. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1506. #endregion
  1507. #endregion
  1508. var _view = new Grp_CreditCardPaymentView();
  1509. var clientNameList = getSimplClientList(_dto.DiId);
  1510. #region 费用清单
  1511. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1512. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1513. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1514. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1515. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1516. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1517. /*
  1518. * 76://酒店预订
  1519. */
  1520. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1521. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1522. /*
  1523. * 79://车/导游地接
  1524. */
  1525. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1526. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1527. /*
  1528. * 80: //签证
  1529. */
  1530. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1531. /*
  1532. *81: //邀请/公务活动
  1533. */
  1534. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1535. /*
  1536. * 82: //团组客户保险
  1537. */
  1538. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1539. /*
  1540. * Lable = 85 机票预订
  1541. */
  1542. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1543. /*
  1544. * 85 机票预定
  1545. */
  1546. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1547. /*
  1548. * 98 其他款项
  1549. */
  1550. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1551. /*
  1552. * 285:收款退还
  1553. */
  1554. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1555. /*
  1556. * 1015: //超支费用
  1557. */
  1558. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1559. /*
  1560. * 币种信息
  1561. */
  1562. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1563. /*
  1564. * 车/导游地接 费用类型
  1565. */
  1566. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1567. /*
  1568. * 车/导游地接 费用类型
  1569. */
  1570. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1571. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1572. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1573. /*
  1574. * 用户信息
  1575. */
  1576. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1577. /*
  1578. * 费用模块
  1579. */
  1580. var sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1581. string priceModule = string.Empty;
  1582. if (sdPriceName != null)
  1583. {
  1584. priceModule = sdPriceName.Name;
  1585. }
  1586. /*
  1587. * 成本信息
  1588. */
  1589. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1590. decimal _groupRate = 0.0000M;
  1591. string _groupCurrencyCode = "-";
  1592. if (groupCost != null)
  1593. {
  1594. _groupRate = groupCost.Rate;
  1595. if (int.TryParse(groupCost.Currency, out int _currency))
  1596. {
  1597. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1598. }
  1599. else _groupCurrencyCode = groupCost.Currency;
  1600. }
  1601. string costContentSql = $"Select * From Grp_GroupCost";
  1602. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1603. //处理日期为空的天数
  1604. for (int i = 0; i < groupCostDetails.Count; i++)
  1605. if (i != 0)
  1606. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1607. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1608. /*
  1609. * 处理详情数据
  1610. */
  1611. foreach (var entity in entityList)
  1612. {
  1613. var _detail = new Grp_CreditCardPaymentDetailView();
  1614. _detail.Id = entity.Id;
  1615. _detail.PriceName = priceModule;
  1616. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1617. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1618. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1619. //处理金额
  1620. if (entity.CTable == 1015)
  1621. {
  1622. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1623. if (czInfo != null)
  1624. {
  1625. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1626. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1627. }
  1628. }
  1629. /*
  1630. * 应付款金额
  1631. */
  1632. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1633. string PaymentCurrency_WaitPay = "Unknown";
  1634. string hotelCurrncyCode = "Unknown";
  1635. string hotelCurrncyName = "Unknown";
  1636. if (sdPaymentCurrency_WaitPay != null)
  1637. {
  1638. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1639. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1640. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1641. if (hotelCurrncyCode.Equals("CNY"))
  1642. {
  1643. entity.DayRate = 1.0000M;
  1644. }
  1645. }
  1646. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1647. /*
  1648. * 此次付款金额
  1649. */
  1650. decimal CurrPayStr = 0.00M,
  1651. OriginalCurrPay = 0.00M;
  1652. if (entity.PayPercentage == 0)
  1653. {
  1654. if (entity.PayThenMoney != 0)
  1655. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1656. }
  1657. else
  1658. {
  1659. if (entity.PayMoney != 0)
  1660. {
  1661. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1662. }
  1663. }
  1664. //if (_dto.Label == 79)
  1665. //{
  1666. // string original = string.Empty;
  1667. // if (hotelCurrncyCode.Equals("CNY"))
  1668. // {
  1669. // OriginalCurrPay = CurrPayStr;
  1670. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1671. // }
  1672. // else
  1673. // {
  1674. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1675. // //760 EUR(7600.00 CNY)
  1676. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1677. // }
  1678. //}
  1679. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1680. string original = string.Empty;
  1681. if (hotelCurrncyCode.Equals("CNY"))
  1682. {
  1683. OriginalCurrPay = CurrPayStr;
  1684. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1685. }
  1686. else
  1687. {
  1688. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1689. //760 EUR(7600.00 CNY)
  1690. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1691. }
  1692. /*
  1693. * 剩余尾款
  1694. */
  1695. decimal BalanceStr = 0;
  1696. if (CurrPayStr != 0)
  1697. {
  1698. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1699. BalanceStr = 0;
  1700. else
  1701. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1702. }
  1703. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1704. /*
  1705. * Bus名称
  1706. */
  1707. _detail.BusName = "待增加";
  1708. /*
  1709. *费用所属
  1710. */
  1711. switch (entity.CTable)
  1712. {
  1713. case 76://酒店预订
  1714. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1715. if (hotelReservations != null)
  1716. {
  1717. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1718. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1719. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1720. string roomFeeStr = "", roomFeestr1 = "";
  1721. //是否比较房型价格
  1722. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1723. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1724. roomFeeStr += $"<br/>";
  1725. var roomTotal = 0.00M;
  1726. if (hotelReservations.SingleRoomPrice > 0)
  1727. {
  1728. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1729. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1730. __isSingle = true;
  1731. roomTotal += fee;
  1732. }
  1733. if (hotelReservations.DoubleRoomPrice > 0)
  1734. {
  1735. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1736. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1737. __isDouble = true;
  1738. roomTotal += fee;
  1739. }
  1740. if (hotelReservations.SuiteRoomPrice > 0)
  1741. {
  1742. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1743. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1744. __isSuite = true;
  1745. roomTotal += fee;
  1746. }
  1747. if (hotelReservations.OtherRoomPrice > 0)
  1748. {
  1749. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1750. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1751. __isOther = true;
  1752. roomTotal += fee;
  1753. }
  1754. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  1755. else roomFeeStr += " 0.00 * 0";
  1756. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1757. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1758. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1759. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1760. /*
  1761. * 费用类型
  1762. * 1:房费
  1763. * 2:早餐
  1764. * 3:地税
  1765. * 4:城市税
  1766. * </summary>
  1767. */
  1768. //地税
  1769. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1770. if (governmentRentData != null)
  1771. {
  1772. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1773. governmentRentFee = governmentRentData.Price;
  1774. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1775. if (governmentRentCurrData != null)
  1776. {
  1777. governmentRentCode = governmentRentCurrData.Name;
  1778. governmentRentName = $"({governmentRentCurrData.Remark})";
  1779. }
  1780. }
  1781. //城市税
  1782. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1783. if (cityTaxData != null)
  1784. {
  1785. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1786. cityTaxFee = cityTaxData.Price;
  1787. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1788. if (cityTaxCurrData != null)
  1789. {
  1790. cityTaxCode = cityTaxCurrData.Name;
  1791. cityTaxName = $"({cityTaxCurrData.Remark})";
  1792. }
  1793. }
  1794. //酒店早餐
  1795. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1796. if (breakfastData != null)
  1797. {
  1798. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1799. breakfastFee = breakfastData.Price;
  1800. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1801. if (breakfastCurrData != null)
  1802. {
  1803. breakfastCode = breakfastCurrData.Name;
  1804. breakfastName = $"({breakfastCurrData.Remark})";
  1805. }
  1806. }
  1807. //房间费用
  1808. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1809. if (roomData != null)
  1810. {
  1811. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1812. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1813. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1814. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1815. roomFee = roomData.Price;
  1816. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1817. if (roomCurrData != null)
  1818. {
  1819. roomCode = roomCurrData.Name;
  1820. roomName = $"({roomCurrData.Remark})";
  1821. }
  1822. }
  1823. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1824. string hotelCostStr = "";
  1825. decimal hotelCsotTotal = 0.00M;
  1826. if (groupCost != null)
  1827. {
  1828. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1829. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1830. }
  1831. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1832. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1833. string hotelCost_day = "";
  1834. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1835. foreach (var item in hotelCostDetails1)
  1836. {
  1837. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1838. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1839. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1840. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1841. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1842. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1843. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1844. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1845. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1846. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1847. hotelCost_day += @$"<br/>";
  1848. }
  1849. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1850. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  1851. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  1852. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  1853. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1854. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1855. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1856. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1857. $"房间说明: {hotelReservations.Remark} <br/>" +
  1858. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  1859. $"{hotelBreakfastStr}" +
  1860. $"{hotelGovernmentRentStr}" +
  1861. $"{hotelCityTaxStr}";
  1862. _detail.PriceNameContent = hotelReservations.HotelName;
  1863. }
  1864. break;
  1865. case 79://车/导游地接
  1866. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1867. if (touristGuideGroundReservations != null)
  1868. {
  1869. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1870. {
  1871. _detail.BusName = touristGuideGroundReservations.BusName;
  1872. }
  1873. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1874. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1875. //if (isInt)
  1876. //{
  1877. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1878. // if (cityInfo != null)
  1879. // {
  1880. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1881. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1882. // if (carFeeItem != null)
  1883. // {
  1884. // nameContent += $@"({carFeeItem.Name})";
  1885. // }
  1886. // _detail.PriceNameContent = nameContent;
  1887. // }
  1888. //}
  1889. //else
  1890. //{
  1891. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1892. //}
  1893. var touristGuideGroundReservationsContents =
  1894. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1895. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1896. foreach (var item in touristGuideGroundReservationsContents)
  1897. {
  1898. string typeName = "Unknown";
  1899. string carCurrencyCode = "Unknown";
  1900. string carCurrencyName = "Unknown";
  1901. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1902. if (carTypeData != null) typeName = carTypeData.Name;
  1903. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1904. if (currencyData != null)
  1905. {
  1906. carCurrencyCode = currencyData.Name;
  1907. carCurrencyName = currencyData.Remark;
  1908. }
  1909. //op、成本 币种是否一致
  1910. bool IsCurrencyAgreement = false;
  1911. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1912. string opCostStr = string.Empty;
  1913. decimal opCostTypePrice = 0.00M;
  1914. #region 处理成本各项费用
  1915. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1916. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1917. if (opCost.Count > 0)
  1918. {
  1919. switch (item.SId)
  1920. {
  1921. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1922. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1923. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1924. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1925. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1926. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1927. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1928. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1929. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1930. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1931. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1932. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1933. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1934. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1935. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1936. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1937. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1938. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1939. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1940. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1941. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1942. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1943. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1944. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1945. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1946. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1947. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1948. }
  1949. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1950. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1951. }
  1952. #endregion
  1953. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1954. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1955. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1956. $"{opTypeStr} {opCostStr}<br/>" +
  1957. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1958. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1959. }
  1960. _detail.PriceMsgContent = priceMsg;
  1961. }
  1962. break;
  1963. case 80: //签证
  1964. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1965. if (visaInfo != null)
  1966. {
  1967. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1968. _detail.PriceNameContent = visaInfo.VisaDescription;
  1969. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1970. }
  1971. break;
  1972. case 81: //邀请/公务活动
  1973. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1974. if (_ioa != null)
  1975. {
  1976. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1977. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1978. sendCurrName = "Unknown", //快递费用币种 Name
  1979. sendCurrCode = "Unknown", //快递费用币种 Code
  1980. eventsCurrName = "Unknown", //公务活动费币种 Name
  1981. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1982. translateCurrName = "Unknown", //公务翻译费 Name
  1983. translateCurrCode = "Unknown"; //公务翻译费 Code
  1984. #region 处理费用币种
  1985. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1986. if (inviteCurrData != null)
  1987. {
  1988. inviteCurrName = inviteCurrData.Remark;
  1989. inviteCurrCode = inviteCurrData.Name;
  1990. }
  1991. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1992. if (sendCurrData != null)
  1993. {
  1994. sendCurrName = sendCurrData.Remark;
  1995. sendCurrCode = sendCurrData.Name;
  1996. }
  1997. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1998. if (eventsCurrData != null)
  1999. {
  2000. eventsCurrName = eventsCurrData.Remark;
  2001. eventsCurrCode = eventsCurrData.Name;
  2002. }
  2003. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2004. if (translateCurrData != null)
  2005. {
  2006. translateCurrName = translateCurrData.Remark;
  2007. translateCurrCode = translateCurrData.Name;
  2008. }
  2009. #endregion
  2010. _detail.PriceNameContent = _ioa.InviterArea;
  2011. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2012. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2013. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2014. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2015. $@"备注:" + _ioa.Remark + "<br/>";
  2016. }
  2017. break;
  2018. case 82: //团组客户保险
  2019. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2020. if (customers != null)
  2021. {
  2022. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2023. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2024. }
  2025. break;
  2026. case 85: //机票预订
  2027. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2028. if (jpRes != null)
  2029. {
  2030. string FlightsDescription = jpRes.FlightsDescription;
  2031. string PriceDescription = jpRes.PriceDescription;
  2032. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2033. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2034. }
  2035. break;
  2036. case 98://其他款项
  2037. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2038. if (gdpRes != null)
  2039. {
  2040. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2041. _detail.PriceNameContent = gdpRes.PriceName;
  2042. }
  2043. break;
  2044. case 285://收款退还
  2045. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2046. if (refundAndOtherMoney != null)
  2047. {
  2048. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2049. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2050. }
  2051. break;
  2052. case 751://酒店早餐
  2053. break;
  2054. case 1015://超支费用
  2055. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2056. if (groupExtraCost != null)
  2057. {
  2058. _detail.PriceNameContent = groupExtraCost.PriceName;
  2059. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2060. }
  2061. break;
  2062. default:
  2063. break;
  2064. }
  2065. /*
  2066. * 申请人
  2067. */
  2068. string operatorName = " - ";
  2069. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2070. if (_opUser != null)
  2071. {
  2072. operatorName = _opUser.CnName;
  2073. }
  2074. _detail.OperatorName = operatorName;
  2075. /*
  2076. * 审核人
  2077. */
  2078. string auditOperatorName = "Unknown";
  2079. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2080. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2081. else
  2082. {
  2083. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2084. if (_adUser != null)
  2085. {
  2086. auditOperatorName = _adUser.CnName;
  2087. }
  2088. }
  2089. _detail.AuditOperatorName = auditOperatorName;
  2090. /*
  2091. * 超预算比例
  2092. */
  2093. string overBudgetStr = "";
  2094. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2095. else if (entity.ExceedBudget == 0)
  2096. {
  2097. if (entity.CTable == 76 || entity.CTable == 79)
  2098. {
  2099. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2100. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2101. }
  2102. else
  2103. {
  2104. overBudgetStr = "未超预算";
  2105. }
  2106. }
  2107. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2108. _detail.OverBudget = overBudgetStr;
  2109. decimal auditFee = 0.00M; //已审核金额 人名币
  2110. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2111. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2112. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2113. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2114. {
  2115. auditedFeeOriginal = entity.PayMoney;
  2116. auditFee = CurrPayStr;
  2117. }
  2118. else if (entity.IsAuditGM == 0)
  2119. {
  2120. unAuditFeeCNY = CurrPayStr;
  2121. unAuditFeeOriginal = OriginalCurrPay;
  2122. OriginalCurrPay = 0.00M;
  2123. }
  2124. /*
  2125. * 费用总计
  2126. */
  2127. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2128. {
  2129. CurrencyId = entity.PaymentCurrency,
  2130. CurrencyName = PaymentCurrency_WaitPay,
  2131. AmountPayable = entity.PayMoney,
  2132. ThisPayment = OriginalCurrPay,
  2133. BalancePayment = BalanceStr,
  2134. AuditedFunds = auditFee,
  2135. AuditedFundsOriginal = auditedFeeOriginal,
  2136. UnAuditFundsCNY = unAuditFeeCNY,
  2137. UnAuditFundsOriginal = unAuditFeeOriginal
  2138. });
  2139. _detail.IsAuditGM = entity.IsAuditGM;
  2140. detailList.Add(_detail);
  2141. }
  2142. #endregion
  2143. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2144. /*
  2145. * 下方描述处理
  2146. */
  2147. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2148. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2149. if (ccpCurrencyPrice != null)
  2150. {
  2151. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2152. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2153. }
  2154. else
  2155. {
  2156. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2157. }
  2158. string amountPayableStr = string.Format(@"应付款总金额: ");
  2159. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2160. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2161. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2162. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2163. foreach (var item in nonDuplicat)
  2164. {
  2165. var currencyName = item.CurrencyName;
  2166. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2167. if (strs.Count > 0)
  2168. {
  2169. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2170. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2171. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2172. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2173. //单独处理此次付款金额
  2174. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2175. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2176. //单独处理已审核费用
  2177. //if (item.CurrencyId == 836) //人民币
  2178. //{
  2179. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2180. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2181. //}
  2182. //else
  2183. //{
  2184. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2185. //}
  2186. if (currencyName.Equals("CNY"))
  2187. {
  2188. //已审核费用
  2189. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AuditedFundsOriginal).ToString("#0.00"), currencyName);
  2190. //未审核费用
  2191. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2192. }
  2193. else
  2194. {
  2195. //已审核费用
  2196. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.AuditedFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2197. //未审核费用
  2198. 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"));
  2199. }
  2200. }
  2201. }
  2202. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2203. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2204. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2205. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2206. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2207. var _view1 = new
  2208. {
  2209. PageFuncAuth = pageFunAuthView,
  2210. Data = _view
  2211. };
  2212. return Ok(JsonView(_view1));
  2213. }
  2214. catch (Exception ex)
  2215. {
  2216. return Ok(JsonView(false, ex.Message));
  2217. }
  2218. }
  2219. /// <summary>
  2220. /// 费用审核
  2221. /// 修改团组费用审核状态
  2222. /// </summary>
  2223. /// <param name="_dto">参数Json字符串</param>
  2224. /// <returns></returns>
  2225. [HttpPost]
  2226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2227. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2228. {
  2229. #region 参数验证
  2230. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2231. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2232. #endregion
  2233. #region 页面操作权限验证
  2234. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2235. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2236. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2237. #endregion
  2238. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2239. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2240. DateTime dtNow = DateTime.Now;
  2241. _groupRepository.BeginTran();
  2242. int rst = 0;
  2243. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2244. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2245. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2246. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2247. List<dynamic> msgDatas = new List<dynamic>();
  2248. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2249. foreach (var item in idList)
  2250. {
  2251. int CreditId = int.Parse(item);
  2252. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2253. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2254. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2255. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2256. .Where(s => s.Id == CreditId)
  2257. .ExecuteCommandAsync();
  2258. if (result < 1)
  2259. {
  2260. rst = -1;
  2261. _groupRepository.RollbackTran();
  2262. return Ok(JsonView(false, "操作失败并回滚!"));
  2263. }
  2264. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2265. if (creditData != null)
  2266. {
  2267. #region 应用通知配置
  2268. try
  2269. {
  2270. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2271. }
  2272. catch (Exception ex)
  2273. {
  2274. }
  2275. #endregion
  2276. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2277. string groupNameStr = string.Empty;
  2278. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2279. if (groupData != null) groupNameStr = groupData.TeamName;
  2280. string creditTypeStr = string.Empty;
  2281. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2282. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2283. string creditCurrency = string.Empty;
  2284. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2285. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2286. if (creditCurrency.Equals("CNY"))
  2287. {
  2288. creditData.DayRate = 1.0000M;
  2289. }
  2290. if (creditData.PayPercentage == 0.00M)
  2291. {
  2292. creditData.PayPercentage = 100M;
  2293. }
  2294. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2295. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2296. string msgContent = "";
  2297. if (creditCurrency.Equals("CNY"))
  2298. {
  2299. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2300. }
  2301. else
  2302. {
  2303. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2304. }
  2305. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2306. }
  2307. }
  2308. if (rst == 0)
  2309. {
  2310. _groupRepository.CommitTran();
  2311. foreach (var item in msgDatas)
  2312. {
  2313. //发送消息
  2314. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2315. }
  2316. #region 应用推送
  2317. try
  2318. {
  2319. foreach (var ccpId in dic_ccp_user.Keys)
  2320. {
  2321. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2322. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2323. }
  2324. }
  2325. catch (Exception)
  2326. {
  2327. }
  2328. #endregion
  2329. return Ok(JsonView(true, "操作成功!"));
  2330. }
  2331. return Ok(JsonView(false, "操作失败!"));
  2332. }
  2333. #endregion
  2334. #region 机票费用录入
  2335. /// <summary>
  2336. /// 机票录入当前登录人可操作团组
  2337. /// </summary>
  2338. /// <param name="dto"></param>
  2339. /// <returns></returns>
  2340. [HttpPost]
  2341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2342. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2343. {
  2344. try
  2345. {
  2346. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2347. if (groupData.Code != 0)
  2348. {
  2349. return Ok(JsonView(false, groupData.Msg));
  2350. }
  2351. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2352. }
  2353. catch (Exception ex)
  2354. {
  2355. return Ok(JsonView(false, "程序错误!"));
  2356. throw;
  2357. }
  2358. }
  2359. /// <summary>
  2360. /// 机票费用录入列表
  2361. /// </summary>
  2362. /// <param name="dto"></param>
  2363. /// <returns></returns>
  2364. [HttpPost]
  2365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2366. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2367. {
  2368. try
  2369. {
  2370. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2371. if (groupData.Code != 0)
  2372. {
  2373. return Ok(JsonView(false, groupData.Msg));
  2374. }
  2375. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2376. }
  2377. catch (Exception ex)
  2378. {
  2379. return Ok(JsonView(false, ex.Message));
  2380. throw;
  2381. }
  2382. }
  2383. /// <summary>
  2384. /// 根据id查询费用录入信息
  2385. /// </summary>
  2386. /// <param name="dto"></param>
  2387. /// <returns></returns>
  2388. [HttpPost]
  2389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2390. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2391. {
  2392. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2393. if (groupData.Code != 0)
  2394. {
  2395. return Ok(JsonView(false, groupData.Msg));
  2396. }
  2397. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2398. }
  2399. /// <summary>
  2400. /// 机票费用录入操作(Status:1.新增,2.修改)
  2401. /// </summary>
  2402. /// <param name="dto"></param>
  2403. /// <returns></returns>
  2404. [HttpPost]
  2405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2406. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2407. {
  2408. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2409. if (groupData.Code != 0)
  2410. {
  2411. return Ok(JsonView(false, groupData.Msg));
  2412. }
  2413. #region 应用推送
  2414. try
  2415. {
  2416. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2417. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2418. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2419. //2024-10-21 新增LZ UID
  2420. var userIds = new List<int>() { 21 };
  2421. string title = $"系统通知";
  2422. string content = "";
  2423. var diId = dto.AirTicketResOpData.DiId;
  2424. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2425. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2426. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2427. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2428. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2429. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2430. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2431. }
  2432. catch (Exception ex)
  2433. {
  2434. }
  2435. #endregion
  2436. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2437. }
  2438. /// <summary>
  2439. /// 根据舱位类型查询接团客户名单信息
  2440. /// </summary>
  2441. /// <param name="dto"></param>
  2442. /// <returns></returns>
  2443. [HttpPost]
  2444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2445. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2446. {
  2447. try
  2448. {
  2449. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2450. if (crm_Groups.Count != 0)
  2451. {
  2452. List<dynamic> Customer = new List<dynamic>();
  2453. foreach (var item in crm_Groups)
  2454. {
  2455. var data = new
  2456. {
  2457. Id = item.Id,
  2458. Pinyin = item.Pinyin,
  2459. Name = item.LastName + item.FirstName
  2460. };
  2461. Customer.Add(data);
  2462. }
  2463. return Ok(JsonView(true, "查询成功!", Customer));
  2464. }
  2465. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2466. }
  2467. catch (Exception ex)
  2468. {
  2469. return Ok(JsonView(false, "程序错误!"));
  2470. throw;
  2471. }
  2472. }
  2473. /// <summary>
  2474. /// 根据团号获取客户信息
  2475. /// </summary>
  2476. /// <param name="dto"></param>
  2477. /// <returns></returns>
  2478. [HttpPost]
  2479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2480. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2481. {
  2482. var jw = JsonView(false);
  2483. if (dto.DIID < 1)
  2484. {
  2485. jw.Msg += "请输入正确的diid";
  2486. return Ok(jw);
  2487. }
  2488. var arr = getSimplClientList(dto.DIID);
  2489. jw = JsonView(true, "获取成功!", arr);
  2490. return Ok(jw);
  2491. }
  2492. private List<SimplClientInfo> getSimplClientList(int diId)
  2493. {
  2494. 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);
  2495. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2496. foreach (var item in arr)
  2497. {
  2498. EncryptionProcessor.DecryptProperties(item);
  2499. }
  2500. return arr;
  2501. }
  2502. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2503. {
  2504. string result = origin;
  2505. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2506. {
  2507. string[] temparr = origin.Split(',');
  2508. string fistrStr = temparr[0];
  2509. int count = temparr.Count();
  2510. int tempId;
  2511. bool success = int.TryParse(fistrStr, out tempId);
  2512. if (success)
  2513. {
  2514. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2515. if (tempInfo != null)
  2516. {
  2517. if (count > 1)
  2518. {
  2519. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2520. }
  2521. else
  2522. {
  2523. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2524. }
  2525. }
  2526. }
  2527. }
  2528. return result;
  2529. }
  2530. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2531. {
  2532. string result = origin;
  2533. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2534. {
  2535. string[] temparr = origin.Split(',');
  2536. result = "";
  2537. foreach (var item in temparr)
  2538. {
  2539. int tempId;
  2540. bool success = int.TryParse(item, out tempId);
  2541. if (success)
  2542. {
  2543. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2544. if (tempInfo != null)
  2545. {
  2546. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2547. }
  2548. }
  2549. }
  2550. }
  2551. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2552. return result;
  2553. }
  2554. /// <summary>
  2555. /// 机票费用录入,删除
  2556. /// </summary>
  2557. /// <param name="dto"></param>
  2558. /// <returns></returns>
  2559. [HttpPost]
  2560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2561. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2562. {
  2563. try
  2564. {
  2565. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2566. if (res)
  2567. {
  2568. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2569. {
  2570. IsDel = 1,
  2571. DeleteUserId = dto.DeleteUserId,
  2572. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2573. }).ExecuteCommandAsync();
  2574. return Ok(JsonView(true, "删除成功!"));
  2575. }
  2576. return Ok(JsonView(false, "删除失败!"));
  2577. }
  2578. catch (Exception ex)
  2579. {
  2580. return Ok(JsonView(false, "程序错误!"));
  2581. throw;
  2582. }
  2583. }
  2584. /// <summary>
  2585. /// 导出机票录入报表
  2586. /// </summary>
  2587. /// <param name="dto"></param>
  2588. /// <returns></returns>
  2589. [HttpPost]
  2590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2591. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2592. {
  2593. try
  2594. {
  2595. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2596. if (groupData.Code != 0)
  2597. {
  2598. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2599. }
  2600. else
  2601. {
  2602. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2603. if (AirTicketReservations.Count != 0)
  2604. {
  2605. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2606. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2607. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2608. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2609. WorkbookDesigner designer = new WorkbookDesigner();
  2610. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2611. decimal countCost = 0;
  2612. foreach (var item in AirTicketReservations)
  2613. {
  2614. #region 处理客人姓名
  2615. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2616. item.ClientName = clientNames;
  2617. #endregion
  2618. if (item.BankType == "其他")
  2619. {
  2620. item.BankNo = "--";
  2621. }
  2622. else
  2623. {
  2624. if (!string.IsNullOrEmpty(item.BankType))
  2625. {
  2626. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2627. }
  2628. }
  2629. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2630. item.Price = System.Decimal.Round(item.Price, 2);
  2631. countCost += Convert.ToDecimal(item.Price);
  2632. }
  2633. designer.SetDataSource("Export", AirTicketReservations);
  2634. designer.SetDataSource("ExportDiCode", diCode);
  2635. designer.SetDataSource("ExportDiName", diName);
  2636. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2637. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2638. designer.Process();
  2639. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2640. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2641. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2642. return Ok(JsonView(true, "成功", url = rst));
  2643. }
  2644. else
  2645. {
  2646. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2647. }
  2648. }
  2649. }
  2650. catch (Exception ex)
  2651. {
  2652. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2653. throw;
  2654. }
  2655. }
  2656. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2657. /// <summary>
  2658. /// 行程单导出
  2659. /// </summary>
  2660. /// <param name="dto"></param>
  2661. /// <returns></returns>
  2662. [HttpPost]
  2663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2664. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2665. {
  2666. try
  2667. {
  2668. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2669. if (groupData.Code != 0)
  2670. {
  2671. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2672. }
  2673. else
  2674. {
  2675. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2676. if (dto.Language == "CN")
  2677. {
  2678. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2679. DocumentBuilder builder = new DocumentBuilder(doc);
  2680. int tableIndex = 0;//表格索引
  2681. //得到文档中的第一个表格
  2682. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2683. foreach (var item in _AirTicketReservations)
  2684. {
  2685. #region 处理固定数据
  2686. string[] FlightsCode = item.FlightsCode.Split('/');
  2687. if (FlightsCode.Length != 0)
  2688. {
  2689. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2690. if (_AirCompany != null)
  2691. {
  2692. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2693. }
  2694. else
  2695. {
  2696. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2697. }
  2698. }
  2699. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2700. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2701. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2702. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2703. string name = "";
  2704. foreach (string clientName in nameArray)
  2705. {
  2706. if (!name.Contains(clientName))
  2707. {
  2708. name += clientName + ",";
  2709. }
  2710. }
  2711. if (!string.IsNullOrWhiteSpace(name))
  2712. {
  2713. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2714. }
  2715. else
  2716. {
  2717. table.Range.Bookmarks["ClientName"].Text = "--";
  2718. }
  2719. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2720. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2721. table.Range.Bookmarks["JointTicket"].Text = "--";
  2722. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2723. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2724. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2725. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2726. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2727. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2728. #endregion
  2729. #region 循环数据处理
  2730. List<AirInfo> airs = new List<AirInfo>();
  2731. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2732. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2733. for (int i = 0; i < FlightsCode.Length; i++)
  2734. {
  2735. AirInfo air = new AirInfo();
  2736. string[] tempstr = DayArray[i]
  2737. .Replace("\r\n", string.Empty)
  2738. .Replace("\\r\\n", string.Empty)
  2739. .TrimStart().TrimEnd()
  2740. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2741. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2742. string starCity = "";
  2743. if (star_Three != null)
  2744. {
  2745. starCity = star_Three.AirPort;
  2746. }
  2747. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2748. string EndCity = "";
  2749. if (End_Three != null)
  2750. {
  2751. EndCity = End_Three.AirPort;
  2752. }
  2753. air.Destination = starCity + "/" + EndCity;
  2754. air.Flight = FlightsCode[i];
  2755. air.SeatingClass = item.CTypeName;
  2756. string dateTime = tempstr[2];
  2757. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2758. air.FlightDate = DateTemp;
  2759. air.DepartureTime = tempstr[5];
  2760. air.LandingTime = tempstr[6];
  2761. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2762. air.TicketStatus = "--";
  2763. air.Luggage = "--";
  2764. air.DepartureTerminal = "--";
  2765. air.LandingTerminal = "--";
  2766. airs.Add(air);
  2767. }
  2768. int row = 13;
  2769. for (int i = 0; i < airs.Count; i++)
  2770. {
  2771. if (airs.Count > 2)
  2772. {
  2773. for (int j = 0; j < airs.Count - 2; j++)
  2774. {
  2775. var CopyRow = table.Rows[12].Clone(true);
  2776. table.Rows.Add(CopyRow);
  2777. }
  2778. }
  2779. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2780. int index = 0;
  2781. foreach (PropertyInfo property in properties)
  2782. {
  2783. string value = property.GetValue(airs[i]).ToString();
  2784. Cell ishcel0 = table.Rows[row].Cells[index];
  2785. Paragraph p = new Paragraph(doc);
  2786. string s = value;
  2787. p.AppendChild(new Run(doc, s));
  2788. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2789. ishcel0.AppendChild(p);
  2790. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2791. index++;
  2792. }
  2793. row++;
  2794. }
  2795. #endregion
  2796. Paragraph lastParagraph = new Paragraph(doc);
  2797. //第一个表格末尾加段落
  2798. table.ParentNode.InsertAfter(lastParagraph, table);
  2799. //复制第一个表格
  2800. Table cloneTable = (Table)table.Clone(true);
  2801. //在文档末尾段落后面加入复制的表格
  2802. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2803. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2804. {
  2805. int rownewsIndex = 13;
  2806. for (int i = 0; i < 2; i++)
  2807. {
  2808. var CopyRow = table.Rows[12].Clone(true);
  2809. table.Rows.RemoveAt(13);
  2810. table.Rows.Add(CopyRow);
  2811. rownewsIndex++;
  2812. }
  2813. }
  2814. else
  2815. {
  2816. table.Rows.RemoveAt(12);
  2817. }
  2818. cloneTable.Rows.RemoveAt(12);
  2819. }
  2820. if (_AirTicketReservations.Count != 0)
  2821. {
  2822. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2823. if (FlightsCode.Length != 0)
  2824. {
  2825. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2826. if (_AirCompany != null)
  2827. {
  2828. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2829. }
  2830. else
  2831. {
  2832. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2833. }
  2834. }
  2835. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2836. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2837. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2838. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2839. string name = "";
  2840. foreach (string clientName in nameArray)
  2841. {
  2842. if (!name.Contains(clientName))
  2843. {
  2844. name += clientName + ",";
  2845. }
  2846. }
  2847. if (!string.IsNullOrWhiteSpace(name))
  2848. {
  2849. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2850. }
  2851. else
  2852. {
  2853. table.Range.Bookmarks["ClientName"].Text = "--";
  2854. }
  2855. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2856. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2857. table.Range.Bookmarks["JointTicket"].Text = "--";
  2858. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2859. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2860. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2861. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2862. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2863. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2864. }
  2865. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2866. //保存合并后的文档
  2867. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2868. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2869. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2870. return Ok(JsonView(true, "成功!", rst));
  2871. }
  2872. else
  2873. {
  2874. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2875. DocumentBuilder builder = new DocumentBuilder(doc);
  2876. int tableIndex = 0;//表格索引
  2877. //得到文档中的第一个表格
  2878. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2879. List<string> texts = new List<string>();
  2880. foreach (var item in _AirTicketReservations)
  2881. {
  2882. string[] FlightsCode = item.FlightsCode.Split('/');
  2883. if (FlightsCode.Length != 0)
  2884. {
  2885. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2886. if (_AirCompany != null)
  2887. {
  2888. if (!transDic.ContainsKey(_AirCompany.CnName))
  2889. {
  2890. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2891. }
  2892. }
  2893. else
  2894. {
  2895. if (!transDic.ContainsKey("--"))
  2896. {
  2897. transDic.Add("--", "--");
  2898. }
  2899. }
  2900. }
  2901. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2902. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2903. string name = "";
  2904. foreach (string clientName in nameArray)
  2905. {
  2906. name += clientName + ",";
  2907. }
  2908. if (!texts.Contains(name))
  2909. {
  2910. texts.Add(name);
  2911. }
  2912. List<AirInfo> airs = new List<AirInfo>();
  2913. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2914. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2915. for (int i = 0; i < FlightsCode.Length; i++)
  2916. {
  2917. AirInfo air = new AirInfo();
  2918. string[] tempstr = DayArray[i]
  2919. .Replace("\r\n", string.Empty)
  2920. .Replace("\\r\\n", string.Empty)
  2921. .TrimStart().TrimEnd()
  2922. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2923. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2924. if (star_Three != null)
  2925. {
  2926. if (!transDic.ContainsKey(star_Three.AirPort))
  2927. {
  2928. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2929. }
  2930. }
  2931. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2932. if (End_Three != null)
  2933. {
  2934. if (!transDic.ContainsKey(End_Three.AirPort))
  2935. {
  2936. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2937. }
  2938. }
  2939. if (!texts.Contains(item.CTypeName))
  2940. {
  2941. texts.Add(item.CTypeName);
  2942. }
  2943. }
  2944. }
  2945. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2946. if (transData.Count > 0)
  2947. {
  2948. foreach (TranslateResult item in transData)
  2949. {
  2950. if (!transDic.ContainsKey(item.Query))
  2951. {
  2952. transDic.Add(item.Query, item.Translation);
  2953. }
  2954. }
  2955. }
  2956. foreach (var item in _AirTicketReservations)
  2957. {
  2958. #region 处理固定数据
  2959. string[] FlightsCode = item.FlightsCode.Split('/');
  2960. if (FlightsCode.Length != 0)
  2961. {
  2962. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2963. if (_AirCompany != null)
  2964. {
  2965. string str = "--";
  2966. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2967. if (!string.IsNullOrEmpty(translateResult))
  2968. {
  2969. str = translateResult;
  2970. str = _airTicketResRep.Processing(str);
  2971. }
  2972. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2973. }
  2974. else
  2975. {
  2976. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2977. }
  2978. }
  2979. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2980. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2981. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2982. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2983. string names = "";
  2984. foreach (string clientName in nameArray)
  2985. {
  2986. names += clientName + ",";
  2987. }
  2988. if (!string.IsNullOrWhiteSpace(names))
  2989. {
  2990. string str = "--";
  2991. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2992. if (!string.IsNullOrEmpty(translateResult))
  2993. {
  2994. str = translateResult;
  2995. str = _airTicketResRep.Processing(str);
  2996. }
  2997. table.Range.Bookmarks["ClientName"].Text = str;
  2998. }
  2999. else
  3000. {
  3001. table.Range.Bookmarks["ClientName"].Text = "--";
  3002. }
  3003. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3004. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3005. table.Range.Bookmarks["JointTicket"].Text = "--";
  3006. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3007. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3008. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3009. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3010. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3011. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3012. #endregion
  3013. #region 循环数据处理
  3014. List<AirInfo> airs = new List<AirInfo>();
  3015. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3016. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3017. for (int i = 0; i < FlightsCode.Length; i++)
  3018. {
  3019. AirInfo air = new AirInfo();
  3020. string[] tempstr = DayArray[i]
  3021. .Replace("\r\n", string.Empty)
  3022. .Replace("\\r\\n", string.Empty)
  3023. .TrimStart().TrimEnd()
  3024. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3025. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3026. string starCity = "";
  3027. if (star_Three != null)
  3028. {
  3029. string str2 = "--";
  3030. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3031. if (!string.IsNullOrEmpty(translateResult2))
  3032. {
  3033. str2 = translateResult2;
  3034. str2 = _airTicketResRep.Processing(str2);
  3035. }
  3036. starCity = str2;
  3037. }
  3038. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3039. string EndCity = "";
  3040. if (End_Three != null)
  3041. {
  3042. string str1 = "--";
  3043. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3044. if (!string.IsNullOrEmpty(translateResult1))
  3045. {
  3046. str1 = translateResult1;
  3047. str1 = _airTicketResRep.Processing(str1);
  3048. }
  3049. EndCity = str1;
  3050. }
  3051. air.Destination = starCity + "/" + EndCity;
  3052. air.Flight = FlightsCode[i];
  3053. string str = "--";
  3054. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3055. if (!string.IsNullOrEmpty(translateResult))
  3056. {
  3057. str = translateResult;
  3058. str = _airTicketResRep.Processing(str);
  3059. }
  3060. air.SeatingClass = str;
  3061. string dateTime = tempstr[2];
  3062. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3063. air.FlightDate = DateTemp;
  3064. air.DepartureTime = tempstr[5];
  3065. air.LandingTime = tempstr[6];
  3066. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3067. air.TicketStatus = "--";
  3068. air.Luggage = "--";
  3069. air.DepartureTerminal = "--";
  3070. air.LandingTerminal = "--";
  3071. airs.Add(air);
  3072. }
  3073. int row = 13;
  3074. for (int i = 0; i < airs.Count; i++)
  3075. {
  3076. if (airs.Count > 2)
  3077. {
  3078. for (int j = 0; j < airs.Count - 2; j++)
  3079. {
  3080. var CopyRow = table.Rows[12].Clone(true);
  3081. table.Rows.Add(CopyRow);
  3082. }
  3083. }
  3084. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3085. int index = 0;
  3086. foreach (PropertyInfo property in properties)
  3087. {
  3088. string value = property.GetValue(airs[i]).ToString();
  3089. Cell ishcel0 = table.Rows[row].Cells[index];
  3090. Paragraph p = new Paragraph(doc);
  3091. string s = value;
  3092. p.AppendChild(new Run(doc, s));
  3093. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3094. ishcel0.AppendChild(p);
  3095. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3096. //ishcel0.CellFormat.VerticalAlignment=
  3097. index++;
  3098. }
  3099. row++;
  3100. }
  3101. #endregion
  3102. Paragraph lastParagraph = new Paragraph(doc);
  3103. //第一个表格末尾加段落
  3104. table.ParentNode.InsertAfter(lastParagraph, table);
  3105. //复制第一个表格
  3106. Table cloneTable = (Table)table.Clone(true);
  3107. //在文档末尾段落后面加入复制的表格
  3108. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3109. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3110. {
  3111. int rownewsIndex = 13;
  3112. for (int i = 0; i < 2; i++)
  3113. {
  3114. var CopyRow = table.Rows[12].Clone(true);
  3115. table.Rows.RemoveAt(13);
  3116. table.Rows.Add(CopyRow);
  3117. rownewsIndex++;
  3118. }
  3119. }
  3120. else
  3121. {
  3122. table.Rows.RemoveAt(12);
  3123. }
  3124. cloneTable.Rows.RemoveAt(12);
  3125. }
  3126. if (_AirTicketReservations.Count != 0)
  3127. {
  3128. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3129. if (FlightsCode.Length != 0)
  3130. {
  3131. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3132. if (_AirCompany != null)
  3133. {
  3134. string str = "--";
  3135. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3136. if (!string.IsNullOrEmpty(translateResult))
  3137. {
  3138. str = translateResult;
  3139. str = _airTicketResRep.Processing(str);
  3140. }
  3141. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3142. }
  3143. else
  3144. {
  3145. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3146. }
  3147. }
  3148. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3149. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3150. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3151. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3152. string names = "";
  3153. foreach (string clientName in nameArray)
  3154. {
  3155. names += clientName + ",";
  3156. }
  3157. if (!string.IsNullOrWhiteSpace(names))
  3158. {
  3159. string str = "--";
  3160. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3161. if (!string.IsNullOrEmpty(translateResult))
  3162. {
  3163. str = translateResult;
  3164. str = _airTicketResRep.Processing(str);
  3165. }
  3166. table.Range.Bookmarks["ClientName"].Text = str;
  3167. }
  3168. else
  3169. {
  3170. table.Range.Bookmarks["ClientName"].Text = "--";
  3171. }
  3172. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3173. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3174. table.Range.Bookmarks["JointTicket"].Text = "--";
  3175. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3176. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3177. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3178. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3179. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3180. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3181. }
  3182. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3183. //保存合并后的文档
  3184. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3185. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3186. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3187. return Ok(JsonView(true, "成功!", rst));
  3188. }
  3189. }
  3190. }
  3191. catch (Exception ex)
  3192. {
  3193. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3194. throw;
  3195. }
  3196. }
  3197. #endregion
  3198. #region 团组增减款项 --> 其他款项
  3199. /// <summary>
  3200. /// 团组增减款项下拉框绑定
  3201. /// </summary>
  3202. /// <param name="dto"></param>
  3203. /// <returns></returns>
  3204. [HttpPost]
  3205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3206. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3207. {
  3208. #region 参数验证
  3209. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3210. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3211. #endregion
  3212. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3213. }
  3214. /// <summary>
  3215. /// 根据团组Id查询团组增减款项
  3216. /// </summary>
  3217. /// <param name="dto"></param>
  3218. /// <returns></returns>
  3219. [HttpPost]
  3220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3221. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3222. {
  3223. #region 参数验证
  3224. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3225. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3226. #endregion
  3227. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3228. }
  3229. /// <summary>
  3230. /// 团组增减款项操作(Status:1.新增,2.修改)
  3231. /// </summary>
  3232. /// <param name="dto"></param>
  3233. /// <returns></returns>
  3234. [HttpPost]
  3235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3236. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3237. {
  3238. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3239. if (groupData.Code != 200)
  3240. {
  3241. return Ok(JsonView(false, groupData.Msg));
  3242. }
  3243. #region 应用推送
  3244. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3245. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3246. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3247. //自动审核
  3248. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3249. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3250. //2024-10-21 新增LZ UID
  3251. var userIds = new List<int>() { 21 };
  3252. string title = $"系统通知";
  3253. string content = "";
  3254. var diId = dto.DiId;
  3255. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3256. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3257. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3258. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3259. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3260. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3261. #endregion
  3262. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3263. }
  3264. /// <summary>
  3265. /// 团组增减款项操作 删除
  3266. /// </summary>
  3267. /// <param name="dto"></param>
  3268. /// <returns></returns>
  3269. [HttpPost]
  3270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3271. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3272. {
  3273. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3274. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3275. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3276. if (res.Code == 0)
  3277. {
  3278. return Ok(JsonView(true, "删除成功!"));
  3279. }
  3280. return Ok(JsonView(false, "删除失败!"));
  3281. }
  3282. /// <summary>
  3283. /// 根据团组增减款项Id查询
  3284. /// </summary>
  3285. /// <param name="dto"></param>
  3286. /// <returns></returns>
  3287. [HttpPost]
  3288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3289. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3290. {
  3291. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3292. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3293. }
  3294. /// <summary>
  3295. /// 查询供应商名称
  3296. /// </summary>
  3297. /// <param name="dto"></param>
  3298. /// <returns></returns>
  3299. [HttpPost]
  3300. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3301. {
  3302. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3303. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3304. ?? new List<Grp_DecreasePayments>();
  3305. dbResult = dbResult.Distinct(new
  3306. ProductComparer()).ToList();
  3307. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3308. {
  3309. x.Id,
  3310. x.SupplierAddress,
  3311. x.SupplierArea,
  3312. x.SupplierContact,
  3313. x.SupplierContactNumber,
  3314. x.SupplierEmail,
  3315. x.SupplierName,
  3316. x.SupplierSocialAccount,
  3317. x.SupplierTypeId,
  3318. }).ToList());
  3319. return Ok(jw);
  3320. }
  3321. /// <summary>
  3322. /// 团组增减款项 OTA匹配
  3323. /// </summary>
  3324. /// <param name="file"></param>
  3325. /// <returns></returns>
  3326. [HttpPost]
  3327. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3328. {
  3329. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3330. string fileName = file.FileName;
  3331. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3332. {
  3333. return Ok(JsonView(false, "请上传Excel文件!"));
  3334. }
  3335. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3336. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3337. if (!Directory.Exists(path))
  3338. {
  3339. Directory.CreateDirectory(path);
  3340. }
  3341. var filePath = @$"{path}/{fileName}";
  3342. //保存文件
  3343. using (FileStream fs = System.IO.File.Create(filePath))
  3344. {
  3345. file.CopyTo(fs);
  3346. fs.Flush();
  3347. }
  3348. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3349. //读取ExcelFile
  3350. DataTable dt = ConvertExcelToDataTable(filePath);
  3351. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3352. dt.TableName = "TB";
  3353. //修改table列名
  3354. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3355. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3356. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3357. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3358. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3359. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3360. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3361. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3362. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3363. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3364. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3365. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3366. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3367. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3368. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3369. var otaOrderNos = new List<string>();
  3370. foreach (DataRow item in dt.Rows)
  3371. {
  3372. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3373. }
  3374. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3375. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3376. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3377. .Select((dp, di) => new
  3378. {
  3379. dp.PriceName,
  3380. dp.OTAOrderNo,
  3381. dp.FeeTotal,
  3382. di.TeamName,
  3383. })
  3384. .ToListAsync();
  3385. foreach (DataRow item in dt.Rows)
  3386. {
  3387. var otaOrderNo = item["OTAOrderNo"].ToString();
  3388. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3389. if (oaData == null) continue;
  3390. item["GroupName"] = oaData.TeamName;
  3391. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3392. }
  3393. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3394. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3395. List<DataTable> datas = new List<DataTable>();
  3396. datas.Add(dt);
  3397. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3398. return Ok(JsonView(true, "操作成功", new { url = url }));
  3399. }
  3400. #region
  3401. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3402. {
  3403. // 创建Workbook对象
  3404. Workbook workbook = new Workbook(excelFilePath);
  3405. // 获取第一个工作表
  3406. Worksheet worksheet = workbook.Worksheets[0];
  3407. // 将工作表转换为DataTable
  3408. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3409. return dataTable;
  3410. }
  3411. #endregion
  3412. #endregion
  3413. #region 文件上传、删除
  3414. /// <summary>
  3415. /// region 文件上传 可以带参数
  3416. /// </summary>
  3417. /// <param name="file"></param>
  3418. /// <returns></returns>
  3419. [HttpPost]
  3420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3421. public async Task<IActionResult> UploadProject(IFormFile file)
  3422. {
  3423. //var TypeName = Request.Headers["TypeName"].ToString();
  3424. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3425. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3426. ////文件名称
  3427. //string projectFileName = file.FileName;
  3428. ////上传的文件的路径
  3429. //string filePath = $"{fileDir}/{projectFileName}";
  3430. //if (TypeName == "A")//A代表团组增减款项
  3431. //{
  3432. // filePath = fileDir + $@"\团组增减款项相关文件";
  3433. // if (!Directory.Exists(filePath))
  3434. // {
  3435. // Directory.CreateDirectory(filePath);
  3436. // }
  3437. // //上传的文件的路径
  3438. // filePath += $@"\{projectFileName}";
  3439. //}
  3440. //else if (TypeName == "B")//B代表商邀相关文件
  3441. //{
  3442. // //上传的文件的路径
  3443. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3444. // if (!Directory.Exists(filePath))
  3445. // {
  3446. // Directory.CreateDirectory(filePath);
  3447. // }
  3448. // //上传的文件的路径
  3449. // filePath = $@"\{projectFileName}";
  3450. //}
  3451. //try
  3452. //{
  3453. // using (FileStream fs = System.IO.File.Create(filePath))
  3454. // {
  3455. // file.CopyTo(fs);
  3456. // fs.Flush();
  3457. // }
  3458. //}
  3459. //catch (Exception ex)
  3460. //{
  3461. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3462. //}
  3463. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3464. try
  3465. {
  3466. var TypeName = Request.Headers["TypeName"].ToString();
  3467. if (file != null)
  3468. {
  3469. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3470. //文件名称
  3471. string projectFileName = file.FileName;
  3472. //上传的文件的路径
  3473. string filePath = $"{fileDir}/{projectFileName}";
  3474. if (TypeName == "A")//A代表团组增减款项
  3475. {
  3476. if (!Directory.Exists(fileDir))
  3477. {
  3478. Directory.CreateDirectory(fileDir);
  3479. }
  3480. //上传的文件的路径
  3481. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3482. }
  3483. else if (TypeName == "B")//B代表商邀相关文件
  3484. {
  3485. if (!Directory.Exists(fileDir))
  3486. {
  3487. Directory.CreateDirectory(fileDir);
  3488. }
  3489. //上传的文件的路径
  3490. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3491. }
  3492. using (FileStream fs = System.IO.File.Create(filePath))
  3493. {
  3494. file.CopyTo(fs);
  3495. fs.Flush();
  3496. }
  3497. return Ok(JsonView(true, "上传成功!", projectFileName));
  3498. }
  3499. else
  3500. {
  3501. return Ok(JsonView(false, "上传失败!"));
  3502. }
  3503. }
  3504. catch (Exception ex)
  3505. {
  3506. return Ok(JsonView(false, "程序错误!"));
  3507. }
  3508. }
  3509. /// <summary>
  3510. /// 删除指定文件
  3511. /// </summary>
  3512. /// <param name="dto"></param>
  3513. /// <returns></returns>
  3514. [HttpPost]
  3515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3516. public async Task<IActionResult> DelFile(DelFileDto dto)
  3517. {
  3518. try
  3519. {
  3520. var TypeName = Request.Headers["TypeName"].ToString();
  3521. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3522. string filePath = "";
  3523. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3524. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3525. int id = 0;
  3526. if (TypeName == "A")
  3527. {
  3528. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3529. // 删除该文件
  3530. System.IO.File.Delete(filePath);
  3531. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3532. .Where(a => a.Id == dto.Id)
  3533. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3534. .ExecuteCommandAsync();
  3535. }
  3536. else if (TypeName == "B")
  3537. {
  3538. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3539. // 删除该文件
  3540. System.IO.File.Delete(filePath);
  3541. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3542. if (info != null)
  3543. {
  3544. string[] files = new string[] { };
  3545. if (!string.IsNullOrEmpty(info.Attachment))
  3546. {
  3547. try
  3548. {
  3549. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3550. }
  3551. catch (Exception)
  3552. {
  3553. files = new List<string>() { info.Attachment }.ToArray();
  3554. }
  3555. }
  3556. if (files.Length > 0)
  3557. {
  3558. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3559. string filePath2 = string.Empty;
  3560. if (files1.Length > 0)
  3561. {
  3562. filePath2 = JsonConvert.SerializeObject(files1);
  3563. }
  3564. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3565. .Where(a => a.Id == dto.Id)
  3566. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3567. .ExecuteCommandAsync();
  3568. }
  3569. }
  3570. }
  3571. if (id != 0)
  3572. {
  3573. return Ok(JsonView(true, "成功!"));
  3574. }
  3575. else
  3576. {
  3577. return Ok(JsonView(false, "失败!"));
  3578. }
  3579. }
  3580. catch (Exception ex)
  3581. {
  3582. return Ok(JsonView(false, "程序错误!"));
  3583. throw;
  3584. }
  3585. }
  3586. /// <summary>
  3587. /// 文件上传多个文件 可以带参数
  3588. /// </summary>
  3589. /// <param name="file"></param>
  3590. /// <returns></returns>
  3591. [HttpPost]
  3592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3593. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3594. {
  3595. try
  3596. {
  3597. var TypeName = Request.Headers["TypeName"].ToString();
  3598. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3599. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3600. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3601. var filePahts = new List<string>();
  3602. foreach (var file in files)
  3603. {
  3604. //文件名称
  3605. string projectFileName = file.FileName;
  3606. //上传的文件的路径
  3607. string filePath = $"{fileDir}/{projectFileName}";
  3608. if (TypeName == "A")//A代表团组增减款项
  3609. {
  3610. if (!Directory.Exists(fileDir))
  3611. {
  3612. Directory.CreateDirectory(fileDir);
  3613. }
  3614. //上传的文件的路径
  3615. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3616. }
  3617. else if (TypeName == "B")//B代表商邀相关文件
  3618. {
  3619. if (!Directory.Exists(fileDir))
  3620. {
  3621. Directory.CreateDirectory(fileDir);
  3622. }
  3623. //上传的文件的路径
  3624. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3625. }
  3626. using (FileStream fs = System.IO.File.Create(filePath))
  3627. {
  3628. file.CopyTo(fs);
  3629. fs.Flush();
  3630. }
  3631. filePahts.Add(projectFileName);
  3632. }
  3633. return Ok(JsonView(true, "上传成功!", filePahts));
  3634. }
  3635. catch (Exception ex)
  3636. {
  3637. return Ok(JsonView(false, "程序错误!"));
  3638. }
  3639. }
  3640. #endregion
  3641. #region 商邀费用录入
  3642. /// <summary>
  3643. /// 根据团组Id查询商邀费用列表
  3644. /// </summary>
  3645. /// <param name="dto"></param>
  3646. /// <returns></returns>
  3647. [HttpPost]
  3648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3649. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3650. {
  3651. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3652. if (groupData.Code != 0)
  3653. {
  3654. return Ok(JsonView(false, groupData.Msg));
  3655. }
  3656. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3657. }
  3658. /// <summary>
  3659. /// 商邀费用列表
  3660. /// 下载文件
  3661. /// </summary>
  3662. /// <param name="dto"></param>
  3663. /// <returns></returns>
  3664. [HttpGet("{id}")]
  3665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3666. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3667. {
  3668. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3669. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3670. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3671. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3672. var filePaths = new List<string>();
  3673. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3674. try
  3675. {
  3676. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3677. }
  3678. catch (Exception ex)
  3679. {
  3680. filePaths.Add(info.Attachment);
  3681. }
  3682. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3683. for (int i = 0; i < filePaths.Count; i++)
  3684. {
  3685. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3686. }
  3687. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3688. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3689. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3690. {
  3691. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3692. {
  3693. foreach (string filePath in filePaths)
  3694. {
  3695. if (System.IO.File.Exists(filePath))
  3696. {
  3697. // 获取文件名
  3698. string fileName = Path.GetFileName(filePath);
  3699. // 将文件添加到ZIP归档中
  3700. zipArchive.CreateEntryFromFile(filePath, fileName);
  3701. }
  3702. }
  3703. }
  3704. }
  3705. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3706. }
  3707. /// <summary>
  3708. /// 商邀费用 Info Page 基础数据源
  3709. /// </summary>
  3710. /// <param name="dto"></param>
  3711. /// <returns></returns>
  3712. [HttpPost]
  3713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3714. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3715. {
  3716. try
  3717. {
  3718. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3719. if (groupData.Code != 0)
  3720. {
  3721. return Ok(JsonView(false, groupData.Msg));
  3722. }
  3723. return Ok(JsonView(true, "操作成功", groupData.Data));
  3724. }
  3725. catch (Exception ex)
  3726. {
  3727. return Ok(JsonView(false, ex.Message));
  3728. throw;
  3729. }
  3730. }
  3731. /// <summary>
  3732. /// 根据商邀费用ID查询C表和商邀费用数据
  3733. /// </summary>
  3734. /// <param name="dto"></param>
  3735. /// <returns></returns>
  3736. [HttpPost]
  3737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3738. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3739. {
  3740. try
  3741. {
  3742. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3743. if (groupData.Code != 0)
  3744. {
  3745. return Ok(JsonView(false, groupData.Msg));
  3746. }
  3747. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3748. }
  3749. catch (Exception ex)
  3750. {
  3751. return Ok(JsonView(false, ex.Message));
  3752. throw;
  3753. }
  3754. }
  3755. /// <summary>
  3756. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3757. /// </summary>
  3758. /// <param name="dto"></param>
  3759. /// <returns></returns>
  3760. [HttpPost]
  3761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3762. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3763. {
  3764. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3765. if (groupData.Code != 0)
  3766. {
  3767. return Ok(JsonView(false, groupData.Msg));
  3768. }
  3769. #region 应用推送
  3770. try
  3771. {
  3772. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3773. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3774. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3775. //2024-10-21 新增LZ UID
  3776. var userIds = new List<int>() { 21 };
  3777. string title = $"系统通知";
  3778. string content = "";
  3779. var diId = dto.DiId;
  3780. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3781. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3782. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3783. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3784. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3785. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3786. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3787. }
  3788. catch (Exception ex)
  3789. {
  3790. }
  3791. #endregion
  3792. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3793. }
  3794. /// <summary>
  3795. /// 商邀删除
  3796. /// </summary>
  3797. /// <param name="dto"></param>
  3798. /// <returns></returns>
  3799. [HttpPost]
  3800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3801. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3802. {
  3803. try
  3804. {
  3805. _sqlSugar.BeginTran();
  3806. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3807. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3808. {
  3809. IsDel = 1,
  3810. DeleteUserId = dto.DeleteUserId,
  3811. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3812. })
  3813. .Where(it => it.Id == dto.Id)
  3814. .ExecuteCommand();
  3815. if (res1 > 0)
  3816. {
  3817. int _diId = 0;
  3818. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3819. if (_ioaInfo != null)
  3820. {
  3821. _diId = _ioaInfo.DiId;
  3822. }
  3823. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3824. .SetColumns(a => new Grp_CreditCardPayment()
  3825. {
  3826. IsDel = 1,
  3827. DeleteUserId = dto.DeleteUserId,
  3828. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3829. })
  3830. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3831. .ExecuteCommand();
  3832. if (res2 > 0)
  3833. {
  3834. _sqlSugar.CommitTran();
  3835. return Ok(JsonView(true, "删除成功!"));
  3836. }
  3837. }
  3838. _sqlSugar.RollbackTran();
  3839. return Ok(JsonView(false, "删除失败"));
  3840. }
  3841. catch (Exception ex)
  3842. {
  3843. _sqlSugar.RollbackTran();
  3844. return Ok(JsonView(false, ex.Message));
  3845. }
  3846. }
  3847. /// <summary>
  3848. /// 团组模块文件上传
  3849. /// </summary>
  3850. /// <param name="dto"></param>
  3851. /// <returns></returns>
  3852. [HttpPost]
  3853. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3854. {
  3855. var jw = JsonView(false);
  3856. long M = 1024 * 1024;
  3857. if (dto.Files == null || dto.Files.Count == 0)
  3858. {
  3859. jw.Msg = "无文件信息!";
  3860. return Ok(jw);
  3861. }
  3862. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3863. {
  3864. jw.Msg = "文件大小超过20M!";
  3865. return Ok(jw);
  3866. }
  3867. //var nameSp = dto.File.FileName.Split(".");
  3868. //if (nameSp.Length < 2)
  3869. //{
  3870. // jw.Msg = "拓展名称有误!";
  3871. // return Ok(jw);
  3872. //}
  3873. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3874. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3875. //{
  3876. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3877. // return Ok(jw);
  3878. //}
  3879. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3880. if (Ctable == null)
  3881. {
  3882. jw.Msg = "Ctable指向有误!";
  3883. return Ok(jw);
  3884. }
  3885. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3886. if (groupInfo == null)
  3887. {
  3888. jw.Msg = "团组信息不存在!";
  3889. return Ok(jw);
  3890. }
  3891. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3892. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3893. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3894. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3895. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3896. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3897. try
  3898. {
  3899. if (!Directory.Exists(fileBase))
  3900. {
  3901. Directory.CreateDirectory(fileBase);
  3902. }
  3903. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3904. foreach (var fileStream in dto.Files)
  3905. {
  3906. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3907. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3908. {
  3909. Cid = dto.Cid,
  3910. CreateTime = DateTime.Now,
  3911. CreateUserId = dto.Userid,
  3912. Ctable = dto.Ctable,
  3913. Diid = dto.Diid,
  3914. IsDel = 0,
  3915. FilePath = saveFilePath,
  3916. FileName = fileStream.FileName
  3917. };
  3918. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3919. {
  3920. fileStream.CopyTo(fs);
  3921. fs.Flush();
  3922. }
  3923. saveArr.Add(file);
  3924. }
  3925. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3926. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3927. jw = JsonView(true, "保存成功!", new
  3928. {
  3929. count = addResult,
  3930. filesName = saveArr.Select(x => x.FileName)
  3931. });
  3932. }
  3933. catch (Exception ex)
  3934. {
  3935. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3936. {
  3937. count = 0,
  3938. filesName = new string[0],
  3939. });
  3940. }
  3941. return Ok(jw);
  3942. }
  3943. /// <summary>
  3944. /// 查询各模块已保存文件
  3945. /// </summary>
  3946. /// <param name="dto"></param>
  3947. /// <returns></returns>
  3948. [HttpPost]
  3949. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3950. {
  3951. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3952. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3953. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3954. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3955. {
  3956. expression = Expressionable.Create<Grp_GroupModelFile>()
  3957. .And(x => visaIds.Contains(x.CreateUserId));
  3958. }
  3959. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3960. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3961. .Where(expression.ToExpression())
  3962. .ToList();
  3963. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3964. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3965. {
  3966. x.FileName,
  3967. x.Id,
  3968. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3969. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3970. })));
  3971. }
  3972. /// <summary>
  3973. /// 下载该团组下的所有文件
  3974. /// </summary>
  3975. /// <param name="dto"></param>
  3976. /// <returns></returns>
  3977. [HttpPost]
  3978. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3979. {
  3980. var jw = JsonView(false);
  3981. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3982. if (groupInfo == null)
  3983. {
  3984. jw.Msg = "团组信息不存在!";
  3985. return Ok(jw);
  3986. }
  3987. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3988. var isModule = Convert.ToBoolean(dto.isModule);
  3989. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3990. IOOperatorHelper io = new IOOperatorHelper();
  3991. if (isModule)
  3992. {
  3993. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3994. foreach (var moduleArr in moduleGroup)
  3995. {
  3996. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3997. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3998. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3999. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4000. foreach (var item in moduleArr)
  4001. {
  4002. if (System.IO.File.Exists(item.FilePath))
  4003. {
  4004. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4005. {
  4006. byte[] bytes = new byte[fileStream.Length];
  4007. fileStream.Read(bytes, 0, bytes.Length);
  4008. fileStream.Close();
  4009. Stream stream = new MemoryStream(bytes);
  4010. chiZips.Add(item.FileName, stream);
  4011. }
  4012. }
  4013. }
  4014. if (chiZips.Count > 0)
  4015. {
  4016. var byts = io.ConvertZipStream(chiZips);
  4017. Stream stream = new MemoryStream(byts);
  4018. Zips.Add(key.Name + "_.zip", stream);
  4019. }
  4020. }
  4021. }
  4022. else
  4023. {
  4024. foreach (var item in dbQuery)
  4025. {
  4026. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4027. {
  4028. byte[] bytes = new byte[fileStream.Length];
  4029. fileStream.Read(bytes, 0, bytes.Length);
  4030. fileStream.Close();
  4031. Stream stream = new MemoryStream(bytes);
  4032. while (Zips.Keys.Contains(item.FileName))
  4033. {
  4034. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4035. }
  4036. Zips.Add(item.FileName, stream);
  4037. }
  4038. }
  4039. }
  4040. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4041. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4042. if (Zips.Count > 0)
  4043. {
  4044. var byts = io.ConvertZipStream(Zips);
  4045. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4046. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4047. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4048. }
  4049. else
  4050. {
  4051. jw.Msg = "暂无生成文件!";
  4052. }
  4053. return Ok(jw);
  4054. }
  4055. /// <summary>
  4056. /// 下载该团组下此模块的所有文件
  4057. /// </summary>
  4058. /// <param name="dto"></param>
  4059. /// <returns></returns>
  4060. [HttpPost]
  4061. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4062. {
  4063. var jw = JsonView(false);
  4064. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4065. if (groupInfo == null)
  4066. {
  4067. jw.Msg = "团组信息不存在!";
  4068. return Ok(jw);
  4069. }
  4070. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4071. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4072. && x.IsDel == 0);
  4073. if (key == null)
  4074. {
  4075. jw.Msg = "Ctable指向错误!";
  4076. return Ok(jw);
  4077. }
  4078. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4079. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4080. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4081. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4082. IOOperatorHelper io = new IOOperatorHelper();
  4083. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4084. foreach (var item in dbQuery)
  4085. {
  4086. if (System.IO.File.Exists(item.FilePath))
  4087. {
  4088. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4089. {
  4090. byte[] bytes = new byte[fileStream.Length];
  4091. fileStream.Read(bytes, 0, bytes.Length);
  4092. fileStream.Close();
  4093. Stream stream = new MemoryStream(bytes);
  4094. while (Zips.Keys.Contains(item.FileName))
  4095. {
  4096. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4097. }
  4098. Zips.Add(item.FileName, stream);
  4099. }
  4100. }
  4101. }
  4102. if (Zips.Count > 0)
  4103. {
  4104. var byts = io.ConvertZipStream(Zips);
  4105. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4106. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4107. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4108. }
  4109. else
  4110. {
  4111. jw.Msg = "暂无生成文件!";
  4112. }
  4113. return Ok(jw);
  4114. }
  4115. /// <summary>
  4116. /// 删除该团组下的指定文件
  4117. /// </summary>
  4118. /// <param name="dto"></param>
  4119. /// <returns></returns>
  4120. [HttpPost]
  4121. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4122. {
  4123. var jw = JsonView(false);
  4124. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4125. if (sing == null)
  4126. {
  4127. jw.Msg = "暂无";
  4128. return Ok(jw);
  4129. }
  4130. if (System.IO.File.Exists(sing.FilePath))
  4131. {
  4132. try
  4133. {
  4134. System.IO.File.Delete(sing.FilePath);
  4135. }
  4136. catch (Exception ex)
  4137. {
  4138. jw.Msg = "删除失败!" + ex.Message;
  4139. return Ok(jw);
  4140. }
  4141. }
  4142. sing.IsDel = 1;
  4143. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4144. sing.DeleteUserId = dto.UserId;
  4145. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4146. jw = JsonView(true, "删除成功!");
  4147. return Ok(jw);
  4148. }
  4149. #endregion
  4150. #region 团组英文资料
  4151. /// <summary>
  4152. /// 查询团组英文所有资料
  4153. /// </summary>
  4154. /// <param name="dto"></param>
  4155. /// <returns></returns>
  4156. [HttpPost]
  4157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4158. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4159. {
  4160. try
  4161. {
  4162. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4163. if (groupData.Code != 0)
  4164. {
  4165. return Ok(JsonView(false, groupData.Msg));
  4166. }
  4167. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4168. }
  4169. catch (Exception ex)
  4170. {
  4171. return Ok(JsonView(false, "程序错误!"));
  4172. throw;
  4173. }
  4174. }
  4175. /// <summary>
  4176. /// 团组英文资料操作(Status:1.新增,2.修改)
  4177. /// </summary>
  4178. /// <param name="dto"></param>
  4179. /// <returns></returns>
  4180. [HttpPost]
  4181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4182. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4183. {
  4184. try
  4185. {
  4186. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4187. if (groupData.Code != 0)
  4188. {
  4189. return Ok(JsonView(false, groupData.Msg));
  4190. }
  4191. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4192. }
  4193. catch (Exception ex)
  4194. {
  4195. return Ok(JsonView(false, "程序错误!"));
  4196. throw;
  4197. }
  4198. }
  4199. /// <summary>
  4200. /// 团组英文资料Id查询数据
  4201. /// </summary>
  4202. /// <param name="dto"></param>
  4203. /// <returns></returns>
  4204. [HttpPost]
  4205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4206. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4207. {
  4208. try
  4209. {
  4210. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4211. if (_DelegationEnData != null)
  4212. {
  4213. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4214. }
  4215. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4216. }
  4217. catch (Exception ex)
  4218. {
  4219. return Ok(JsonView(false, "程序错误!"));
  4220. throw;
  4221. }
  4222. }
  4223. /// <summary>
  4224. /// 团组英文资料删除
  4225. /// </summary>
  4226. /// <param name="dto"></param>
  4227. /// <returns></returns>
  4228. [HttpPost]
  4229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4230. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4231. {
  4232. try
  4233. {
  4234. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4235. if (!res)
  4236. {
  4237. return Ok(JsonView(false, "删除失败"));
  4238. }
  4239. return Ok(JsonView(true, "删除成功!"));
  4240. }
  4241. catch (Exception ex)
  4242. {
  4243. return Ok(JsonView(false, "程序错误!"));
  4244. throw;
  4245. }
  4246. }
  4247. #endregion
  4248. #region 导出邀请函
  4249. /// <summary>
  4250. /// 导出邀请函页面初始化
  4251. /// </summary>
  4252. /// <param name="dto"></param>
  4253. /// <returns></returns>
  4254. [HttpPost]
  4255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4256. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4257. {
  4258. try
  4259. {
  4260. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4261. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4262. if (dto.DiId == 0)
  4263. {
  4264. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4265. }
  4266. else
  4267. {
  4268. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4269. }
  4270. return Ok(JsonView(true, "查询成功!", new
  4271. {
  4272. deleClient = crm_Deles,
  4273. delegations = grp_Delegations
  4274. }));
  4275. }
  4276. catch (Exception ex)
  4277. {
  4278. return Ok(JsonView(false, "程序错误!"));
  4279. throw;
  4280. }
  4281. }
  4282. /// <summary>
  4283. /// 导出邀请函
  4284. /// </summary>
  4285. /// <param name="dto"></param>
  4286. /// <returns></returns>
  4287. [HttpPost]
  4288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4289. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4290. {
  4291. #region 参数验证
  4292. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4293. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4294. #endregion
  4295. try
  4296. {
  4297. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4298. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4299. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4300. From Grp_TourClientList tcl
  4301. Left Join
  4302. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4303. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4304. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4305. From Crm_DeleClient dc
  4306. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4307. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4308. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4309. Where dc.IsDel = 0) temp
  4310. On temp.DcId =tcl.ClientId
  4311. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4312. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4313. List<string> texts = new List<string>();
  4314. if (datas.Count != 0)
  4315. {
  4316. foreach (TourClientListDetailsView item in datas)
  4317. {
  4318. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4319. {
  4320. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4321. }
  4322. else
  4323. {
  4324. string name = item.LastName + item.FirstName;
  4325. texts.Add(name);
  4326. }
  4327. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4328. {
  4329. if (!transDic.ContainsKey(item.Job))
  4330. {
  4331. texts.Add(item.Job);
  4332. }
  4333. }
  4334. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4335. {
  4336. texts.Add(item.CompanyFullName);
  4337. }
  4338. }
  4339. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4340. if (transData.Count > 0)
  4341. {
  4342. foreach (TranslateResult item in transData)
  4343. {
  4344. if (!transDic.ContainsKey(item.Query))
  4345. {
  4346. transDic.Add(item.Query, item.Translation);
  4347. }
  4348. }
  4349. }
  4350. List<GuestList> list = new List<GuestList>();
  4351. foreach (TourClientListDetailsView dele in datas)
  4352. {
  4353. GuestList guestList = new GuestList();
  4354. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4355. {
  4356. guestList.Name = dele.Pinyin;
  4357. }
  4358. else
  4359. {
  4360. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4361. guestList.Name = Name;
  4362. }
  4363. if (dele.Sex == 0)
  4364. {
  4365. guestList.Sex = "Male";
  4366. }
  4367. else if (dele.Sex == 1)
  4368. {
  4369. guestList.Sex = "Female";
  4370. }
  4371. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4372. if (!string.IsNullOrEmpty(dele.Job))
  4373. {
  4374. guestList.Job = dele.Job;
  4375. }
  4376. list.Add(guestList);
  4377. }
  4378. //载入模板
  4379. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4380. DocumentBuilder builder = new DocumentBuilder(doc);
  4381. //获取word里所有表格
  4382. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4383. //获取所填表格的序数
  4384. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4385. var rowStart = tableOne.Rows[0]; //获取第1行
  4386. //循环赋值
  4387. for (int i = 0; i < list.Count; i++)
  4388. {
  4389. builder.MoveToCell(0, i + 1, 0, 0);
  4390. builder.Write(list[i].Name.ToString());
  4391. builder.MoveToCell(0, i + 1, 1, 0);
  4392. builder.Write(list[i].Sex.ToString());
  4393. builder.MoveToCell(0, i + 1, 2, 0);
  4394. builder.Write(list[i].DOB.ToString());
  4395. builder.MoveToCell(0, i + 1, 3, 0);
  4396. builder.Write(list[i].Job.ToString());
  4397. }
  4398. //删除多余行
  4399. while (tableOne.Rows.Count > list.Count + 1)
  4400. {
  4401. tableOne.Rows.RemoveAt(list.Count + 1);
  4402. }
  4403. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4404. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4405. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4406. doc.Save(filePath);
  4407. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4408. return Ok(JsonView(true, "操作成功!", Url));
  4409. }
  4410. else
  4411. {
  4412. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4413. }
  4414. }
  4415. catch (Exception ex)
  4416. {
  4417. return Ok(JsonView(false, ex.Message));
  4418. throw;
  4419. }
  4420. }
  4421. #endregion
  4422. #region 团组经理模块 出入境费用
  4423. /// <summary>
  4424. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4425. /// </summary>
  4426. /// <returns></returns>
  4427. [HttpPost]
  4428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4429. public async Task<IActionResult> SetDayAndCostAreaChange()
  4430. {
  4431. try
  4432. {
  4433. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4434. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4435. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4436. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4437. foreach (var item in unite) //处理交集数据
  4438. {
  4439. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4440. }
  4441. foreach (var item in merge) //处理差集数据
  4442. {
  4443. int nationalTravelFeeId = 0;
  4444. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4445. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4446. else
  4447. {
  4448. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4449. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4450. }
  4451. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4452. }
  4453. //只更新dayAndCost 的 nationalTravelFeeId;
  4454. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4455. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4456. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4457. }
  4458. catch (Exception ex)
  4459. {
  4460. return Ok(JsonView(false, ex.Message));
  4461. throw;
  4462. }
  4463. }
  4464. /// <summary>
  4465. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4466. /// </summary>
  4467. /// <returns></returns>
  4468. [HttpPost]
  4469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4470. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4471. {
  4472. try
  4473. {
  4474. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4475. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4476. //SetDataInfoView
  4477. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4478. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4479. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4480. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4481. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4482. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4483. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4484. //默认币种显示
  4485. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4486. {
  4487. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4488. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4489. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4490. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4491. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4492. };
  4493. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4494. if (_currencyRate.Count > 0)
  4495. {
  4496. foreach (var item in _currencyInfos)
  4497. {
  4498. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4499. if (rateInfo != null)
  4500. {
  4501. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4502. rate1 *= 1.035M;
  4503. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4504. }
  4505. }
  4506. }
  4507. return Ok(JsonView(true, "查询成功!", new
  4508. {
  4509. GroupNameData = groupNameData.Data,
  4510. CurrencyData = _CurrencyData,
  4511. WordTypeData = _WordTypeData,
  4512. ExcelTypeData = _ExcelTypeData,
  4513. CurrencyInit = _currencyInfos
  4514. }));
  4515. }
  4516. catch (Exception ex)
  4517. {
  4518. return Ok(JsonView(false, ex.Message));
  4519. throw;
  4520. }
  4521. }
  4522. /// <summary>
  4523. /// 团组模块 - 出入境费用
  4524. /// 实时汇率 tips
  4525. /// 签证费用 tips
  4526. /// 机票费用 tips
  4527. /// </summary>
  4528. /// <returns></returns>
  4529. [HttpPost]
  4530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4531. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4532. {
  4533. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4534. //默认币种显示
  4535. var _currencyInfos = _currencyInit;
  4536. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4537. List<dynamic> reteInfos = new List<dynamic>();
  4538. if (_currencyRate.Count > 0)
  4539. {
  4540. foreach (var item in _currencyInfos)
  4541. {
  4542. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4543. if (rateInfo != null)
  4544. {
  4545. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4546. decimal rate1 = item.Rate;
  4547. rate1 *= 1.03M;
  4548. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4549. reteInfos.Add(new
  4550. {
  4551. currCode = item.CurrencyCode,
  4552. currName = item.CurrencyName,
  4553. rate = rate2,
  4554. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4555. });
  4556. }
  4557. }
  4558. }
  4559. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4560. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4561. return Ok(JsonView(true, "查询成功!", new
  4562. {
  4563. //GroupNameData = groupNameData.Data,
  4564. visaData = visaData.Data,
  4565. airData = airData.Data,
  4566. reteInfos = reteInfos
  4567. }));
  4568. }
  4569. /// <summary>
  4570. /// 团组模块 - 出入境费用 - Info
  4571. /// </summary>
  4572. /// <returns></returns>
  4573. [HttpPost]
  4574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4575. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4576. {
  4577. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4578. }
  4579. /// <summary>
  4580. /// 团组模块 - 出入境费用 - Add And Update
  4581. /// </summary>
  4582. /// <returns></returns>
  4583. [HttpPost]
  4584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4585. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4586. {
  4587. try
  4588. {
  4589. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4590. if (dto.DayOtherPriceData.Any())
  4591. {
  4592. var inserList = dto.DayOtherPriceData
  4593. .Where(x => x.Id == 0)
  4594. .Select(x => new Grp_DayOtherPrice
  4595. {
  4596. Cost = x.Cost,
  4597. Id = x.Id,
  4598. CreateTime = DateTime.Now,
  4599. CreateUserId = dto.UserId,
  4600. Currency = x.Currency,
  4601. Diid = x.DiId,
  4602. Index = x.Index,
  4603. IsDel = 0,
  4604. SetDataId = x.SetDataId,
  4605. SubTotal = x.SubTotal,
  4606. Remark = x.Remark
  4607. })
  4608. .ToList();
  4609. var updateList = dto.DayOtherPriceData
  4610. .Where(x => x.Id != 0)
  4611. .Select(x => new Grp_DayOtherPrice
  4612. {
  4613. Cost = x.Cost,
  4614. Id = x.Id,
  4615. CreateTime = DateTime.Now,
  4616. CreateUserId = dto.UserId,
  4617. Currency = x.Currency,
  4618. Diid = x.DiId,
  4619. Index = x.Index,
  4620. IsDel = 0,
  4621. SetDataId = x.SetDataId,
  4622. SubTotal = x.SubTotal,
  4623. Remark = x.Remark
  4624. })
  4625. .ToList();
  4626. //添加
  4627. _sqlSugar.BeginTran();
  4628. if (inserList.Any())
  4629. {
  4630. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4631. }
  4632. if (updateList.Any())
  4633. {
  4634. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4635. }
  4636. _sqlSugar.CommitTran();
  4637. }
  4638. if (data.Code != 0)
  4639. {
  4640. return Ok(JsonView(false, data.Msg));
  4641. }
  4642. //生成默认文件pdf并且通知人员
  4643. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4644. {
  4645. DiId = dto.DiId,
  4646. ExportType = 1,
  4647. SubTypeId = 1005
  4648. }, "pdf");
  4649. //发送通知
  4650. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4651. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4652. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4653. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4654. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4655. //汇率信息记录
  4656. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4657. return Ok(JsonView(true, data.Msg, data.Data));
  4658. }
  4659. catch (Exception ex)
  4660. {
  4661. return Ok(JsonView(false, ex.Message));
  4662. }
  4663. }
  4664. /// <summary>
  4665. /// 团组模块 - 出入境费用 - Confirm 费用
  4666. /// </summary>
  4667. /// <returns></returns>
  4668. [HttpPost]
  4669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4670. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4671. {
  4672. //TODO:测试完毕需把对应的用户ID更改
  4673. //1、数据表添加字段
  4674. //2、更改字段接口()
  4675. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4676. //3、确认成功 给财务发送消息
  4677. if (_view.Code == 200)
  4678. {
  4679. if (dto.Type == 1)
  4680. {
  4681. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4682. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4683. }
  4684. }
  4685. return Ok(_view);
  4686. }
  4687. /// <summary>
  4688. /// 团组模块 - 出入境费用 - File downlaod
  4689. /// </summary>
  4690. /// <param name="dto"></param>
  4691. /// <returns></returns>
  4692. [HttpPost]
  4693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4694. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4695. {
  4696. try
  4697. {
  4698. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4699. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4700. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4701. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4702. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4703. 3 团组成员名单 1 团组成员名单", ""));
  4704. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4705. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4706. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4707. //数据源
  4708. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4709. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4710. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4711. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4712. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4713. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4714. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4715. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4716. .Select((x, a, b) => new
  4717. {
  4718. x.Index,
  4719. itemName = a.Name,
  4720. CurrencyStr = b.Name,
  4721. x.Cost,
  4722. x.SubTotal,
  4723. x.Remark
  4724. })
  4725. .OrderBy((x) => x.Index)
  4726. .ToList(); //其他款项费用
  4727. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4728. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4729. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4730. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4731. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4732. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4733. .Select((tcl, dc, cc) => new ClientInfo
  4734. {
  4735. LastName = dc.LastName,
  4736. FirstName = dc.FirstName,
  4737. Sex = dc.Sex,
  4738. Birthday = dc.BirthDay,
  4739. Company = cc.CompanyFullName,
  4740. Job = dc.Job
  4741. })
  4742. .ToList();
  4743. foreach (var item in DeleClientList)
  4744. {
  4745. EncryptionProcessor.DecryptProperties(item);
  4746. }
  4747. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4748. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4749. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4750. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4751. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4752. if (dto.ExportType == 1) //明细表
  4753. {
  4754. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4755. {
  4756. //获取模板
  4757. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4758. //载入模板
  4759. Document doc = new Document(tempPath);
  4760. DocumentBuilder builder = new DocumentBuilder(doc);
  4761. //利用键值对存放数据
  4762. Dictionary<string, string> dic = new Dictionary<string, string>();
  4763. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4764. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4765. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4766. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4767. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4768. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4769. //境内费用(其他费用)
  4770. if (_EnterExitCosts.ChoiceOne == 1)
  4771. {
  4772. string row1_1 = "";
  4773. if (_EnterExitCosts.Visa > 0)
  4774. {
  4775. //insidePayTotal += _EnterExitCosts.Visa;
  4776. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4777. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4778. {
  4779. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4780. }
  4781. }
  4782. string row1_2 = "";
  4783. if (_EnterExitCosts.YiMiao > 0)
  4784. {
  4785. //insidePayTotal += _EnterExitCosts.YiMiao;
  4786. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4787. }
  4788. if (_EnterExitCosts.HeSuan > 0)
  4789. {
  4790. //insidePayTotal += _EnterExitCosts.HeSuan;
  4791. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4792. }
  4793. if (_EnterExitCosts.Service > 0)
  4794. {
  4795. //insidePayTotal += _EnterExitCosts.Service;
  4796. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4797. }
  4798. string row1_3 = "";
  4799. if (_EnterExitCosts.Safe > 0)
  4800. {
  4801. //insidePayTotal += _EnterExitCosts.Safe;
  4802. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4803. }
  4804. if (_EnterExitCosts.Ticket > 0)
  4805. {
  4806. //insidePayTotal += _EnterExitCosts.Ticket;
  4807. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4808. }
  4809. string row1 = "";
  4810. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4811. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4812. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4813. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4814. dic.Add("Row1Str", row1);
  4815. }
  4816. string airTotalStr = string.Empty,
  4817. airPriceStr = string.Empty;
  4818. //经济舱
  4819. if (_EnterExitCosts.SumJJC == 1)
  4820. {
  4821. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4822. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4823. }
  4824. //公务舱
  4825. if (_EnterExitCosts.SumGWC == 1)
  4826. {
  4827. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4828. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4829. }
  4830. //头等舱
  4831. if (_EnterExitCosts.SumTDC == 1)
  4832. {
  4833. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4834. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4835. }
  4836. dic.Add("AirTotalStr", airTotalStr);
  4837. dic.Add("AirPriceStr", airPriceStr);
  4838. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4839. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4840. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4841. int table1Row = 0,
  4842. table2Row = 0,
  4843. table3Row = 0,
  4844. table4Row = 0,
  4845. table5Row = 0;
  4846. //住宿费
  4847. if (_EnterExitCosts.ChoiceThree == 1)
  4848. {
  4849. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4850. table1Row = dac1.Count;
  4851. #region 填充word表格内容
  4852. for (int i = 0; i < dac1.Count; i++)
  4853. {
  4854. Grp_DayAndCost dac = dac1[i];
  4855. if (dac == null) continue;
  4856. builder.MoveToCell(0, i, 0, 0);
  4857. builder.Write("第" + dac.Days.ToString() + "晚:");
  4858. builder.MoveToCell(0, i, 1, 0);
  4859. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4860. //builder.Write(dac.Place == null ? "" : dac.Place);
  4861. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4862. builder.MoveToCell(0, i, 2, 0);
  4863. builder.Write("费用标准:");
  4864. string curr = "";
  4865. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4866. if (currData != null)
  4867. {
  4868. curr = currData.Name;
  4869. }
  4870. builder.MoveToCell(0, i, 3, 0);
  4871. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4872. builder.MoveToCell(0, i, 4, 0);
  4873. builder.Write("费用小计:");
  4874. builder.MoveToCell(0, i, 5, 0);
  4875. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4876. }
  4877. #endregion
  4878. }
  4879. else dic.Add("SubZS", "0.00");
  4880. //删除多余行
  4881. while (table1.Rows.Count > table1Row)
  4882. {
  4883. table1.Rows.RemoveAt(table1Row);
  4884. }
  4885. //伙食费
  4886. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4887. if (_EnterExitCosts.ChoiceFour == 1)
  4888. {
  4889. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4890. table2Row = dac2.Count;
  4891. #region 填充word表格内容
  4892. for (int i = 0; i < dac2.Count; i++)
  4893. {
  4894. Grp_DayAndCost dac = dac2[i];
  4895. if (dac == null) continue;
  4896. builder.MoveToCell(1, i, 0, 0);
  4897. builder.Write("第" + dac.Days.ToString() + "天:");
  4898. builder.MoveToCell(1, i, 1, 0);
  4899. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4900. builder.MoveToCell(1, i, 2, 0);
  4901. builder.Write("费用标准:");
  4902. string curr = "";
  4903. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4904. if (currData != null)
  4905. {
  4906. curr = currData.Name;
  4907. }
  4908. builder.MoveToCell(1, i, 3, 0);
  4909. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4910. builder.MoveToCell(1, i, 4, 0);
  4911. builder.Write("费用小计:");
  4912. builder.MoveToCell(1, i, 5, 0);
  4913. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4914. }
  4915. #endregion
  4916. }
  4917. else dic.Add("SubHS", "0.00");
  4918. //删除多余行
  4919. while (table2.Rows.Count > table2Row)
  4920. {
  4921. table2.Rows.RemoveAt(table2Row);
  4922. }
  4923. //公杂费
  4924. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4925. if (_EnterExitCosts.ChoiceFive == 1)
  4926. {
  4927. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4928. table3Row = dac3.Count;
  4929. #region 填充word表格内容
  4930. for (int i = 0; i < dac3.Count; i++)
  4931. {
  4932. Grp_DayAndCost dac = dac3[i];
  4933. if (dac == null) continue;
  4934. builder.MoveToCell(2, i, 0, 0);
  4935. builder.Write("第" + dac.Days.ToString() + "天:");
  4936. builder.MoveToCell(2, i, 1, 0);
  4937. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4938. builder.MoveToCell(2, i, 2, 0);
  4939. builder.Write("费用标准:");
  4940. string curr = "";
  4941. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4942. if (currData != null)
  4943. {
  4944. curr = currData.Name;
  4945. }
  4946. builder.MoveToCell(2, i, 3, 0);
  4947. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4948. builder.MoveToCell(2, i, 4, 0);
  4949. builder.Write("费用小计:");
  4950. builder.MoveToCell(2, i, 5, 0);
  4951. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4952. }
  4953. //删除多余行
  4954. while (table3.Rows.Count > table3Row)
  4955. {
  4956. table3.Rows.RemoveAt(table3Row);
  4957. }
  4958. #endregion
  4959. }
  4960. else dic.Add("SubGZF", "0.00");
  4961. //删除多余行
  4962. while (table3.Rows.Count > table3Row)
  4963. {
  4964. table3.Rows.RemoveAt(table3Row);
  4965. }
  4966. //培训费
  4967. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4968. if (_EnterExitCosts.ChoiceSix == 1)
  4969. {
  4970. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4971. dic.Add("SubPX", pxStr);
  4972. table4Row = dac4.Count;
  4973. #region 填充word表格内容
  4974. for (int i = 0; i < dac4.Count; i++)
  4975. {
  4976. Grp_DayAndCost dac = dac4[i];
  4977. if (dac == null) continue;
  4978. builder.MoveToCell(3, i, 0, 0);
  4979. builder.Write("第" + dac.Days.ToString() + "天:");
  4980. builder.MoveToCell(3, i, 1, 0);
  4981. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4982. builder.MoveToCell(3, i, 2, 0);
  4983. builder.Write("费用标准:");
  4984. string curr = "";
  4985. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4986. if (currData != null)
  4987. {
  4988. curr = currData.Name;
  4989. }
  4990. builder.MoveToCell(3, i, 3, 0);
  4991. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4992. builder.MoveToCell(3, i, 4, 0);
  4993. builder.Write("费用小计:");
  4994. builder.MoveToCell(3, i, 5, 0);
  4995. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4996. }
  4997. #endregion
  4998. }
  4999. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5000. //删除多余行
  5001. while (table4.Rows.Count > table4Row)
  5002. {
  5003. table4.Rows.RemoveAt(table4Row);
  5004. }
  5005. //其他费用
  5006. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5007. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5008. {
  5009. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5010. dic.Add("titleQi", qtStr);
  5011. table5Row = dac5.Count;
  5012. #region 填充word表格内容
  5013. for (int i = 0; i < dac5.Count; i++)
  5014. {
  5015. var dac = dac5[i];
  5016. if (dac == null) continue;
  5017. builder.MoveToCell(4, i, 0, 0);
  5018. builder.Write("第" + dac.Index.ToString() + "项:");
  5019. builder.MoveToCell(4, i, 1, 0);
  5020. builder.Write(dac.itemName);
  5021. builder.MoveToCell(4, i, 2, 0);
  5022. builder.Write("费用标准:");
  5023. builder.MoveToCell(4, i, 3, 0);
  5024. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5025. builder.MoveToCell(4, i, 4, 0);
  5026. builder.Write("费用小计:");
  5027. builder.MoveToCell(4, i, 5, 0);
  5028. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5029. builder.MoveToCell(4, i, 6, 0);
  5030. builder.Write("备注:");
  5031. builder.MoveToCell(4, i, 7, 0);
  5032. builder.Write(dac.Remark);
  5033. }
  5034. #endregion
  5035. }
  5036. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5037. //删除多余行
  5038. while (table5.Rows.Count > table5Row)
  5039. {
  5040. table5.Rows.RemoveAt(table5Row);
  5041. }
  5042. //加上其他费用
  5043. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5044. decimal subJJC = 0.00M,
  5045. subGWC = 0.00M,
  5046. subTDC = 0.00M;
  5047. //经济舱
  5048. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5049. //公务舱
  5050. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5051. //头等舱
  5052. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5053. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5054. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5055. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5056. #region 填充word模板书签内容
  5057. foreach (var key in dic.Keys)
  5058. {
  5059. Bookmark bookmark = doc.Range.Bookmarks[key];
  5060. if (bookmark != null)
  5061. {
  5062. builder.MoveToBookmark(key);
  5063. builder.Write(dic[key]);
  5064. }
  5065. }
  5066. #endregion
  5067. //文件名
  5068. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5069. AsposeHelper.removewatermark_v2180();
  5070. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5071. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5072. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5073. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5074. }
  5075. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5076. {
  5077. //获取模板
  5078. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5079. //载入模板
  5080. Document doc = new Document(tempPath);
  5081. DocumentBuilder builder = new DocumentBuilder(doc);
  5082. Dictionary<string, string> dic = new Dictionary<string, string>();
  5083. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5084. {
  5085. List<string> list = new List<string>();
  5086. try
  5087. {
  5088. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5089. foreach (var item in spilitArr)
  5090. {
  5091. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5092. var depCode = spDotandEmpty[2].Substring(0, 3);
  5093. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5094. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5095. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5096. list.Add(depName);
  5097. list.Add(arrName);
  5098. }
  5099. list = list.Distinct().ToList();
  5100. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5101. }
  5102. catch (Exception)
  5103. {
  5104. dic.Add("ReturnCode", "行程录入不正确!");
  5105. }
  5106. }
  5107. else
  5108. {
  5109. dic.Add("ReturnCode", "未录入行程!");
  5110. }
  5111. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5112. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5113. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5114. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5115. {
  5116. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5117. dic.Add("Day", sp.Days.ToString());
  5118. }
  5119. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5120. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5121. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5122. //dic.Add("Names", Names);
  5123. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5124. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5125. decimal dac1totalPrice = 0.00M;
  5126. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5127. foreach (var dac in dac1)
  5128. {
  5129. if (dac.SubTotal == 0.00M)
  5130. {
  5131. continue;
  5132. }
  5133. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5134. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5135. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5136. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5137. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5138. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5139. builder.Write(currency);//币种
  5140. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5141. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5142. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5143. builder.Write("");//人数
  5144. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5145. builder.Write("");//天数
  5146. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5147. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5148. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5149. decimal rate = 0.00M;
  5150. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5151. builder.Write(rate.ToString("#0.0000"));//汇率
  5152. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5153. decimal rbmPrice = dac.SubTotal;
  5154. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5155. accommodationStartIndex++;
  5156. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5157. }
  5158. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5159. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5160. {
  5161. table1.Rows.RemoveAt(i - 1);
  5162. foodandotherStartIndex--;
  5163. }
  5164. if (dac2.Count == dac3.Count)//国家 币种 金额
  5165. {
  5166. for (int i = 0; i < dac2.Count; i++)
  5167. {
  5168. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5169. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5170. }
  5171. }
  5172. decimal dac2totalPrice = 0.00M;
  5173. foreach (var dac in dac2)
  5174. {
  5175. if (dac.SubTotal == 0)
  5176. {
  5177. continue;
  5178. }
  5179. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5180. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5181. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5182. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5183. builder.Write(currency);//币种
  5184. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5185. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5186. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5187. builder.Write("");//人数
  5188. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5189. builder.Write("");//天数
  5190. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5191. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5192. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5193. decimal rate = 0.00M;
  5194. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5195. builder.Write(rate.ToString("#0.0000"));//汇率
  5196. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5197. decimal rbmPrice = dac.SubTotal;
  5198. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5199. foodandotherStartIndex++;
  5200. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5201. }
  5202. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5203. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5204. {
  5205. table1.Rows.RemoveAt(i - 1);
  5206. }
  5207. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5208. string otherFeeStr = "";
  5209. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5210. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5211. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5212. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5213. foreach (var otherInfo in dac5)
  5214. {
  5215. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5216. }
  5217. #endregion
  5218. if (otherFeeStr.Length > 0)
  5219. {
  5220. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5221. otherFeeStr = $"({otherFeeStr})";
  5222. dic.Add("OtherFeeStr", otherFeeStr);
  5223. }
  5224. //总计
  5225. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5226. //国际旅费
  5227. string outsideAir = string.Empty;
  5228. string allPriceAir = string.Empty;
  5229. if (_EnterExitCosts.SumJJC == 1)
  5230. {
  5231. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5232. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5233. }
  5234. if (_EnterExitCosts.SumGWC == 1)
  5235. {
  5236. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5237. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5238. }
  5239. if (_EnterExitCosts.SumTDC == 1)
  5240. {
  5241. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5242. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5243. }
  5244. dic.Add("InTravelPrice", $"({outsideAir})");
  5245. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5246. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5247. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5248. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5249. foreach (var key in dic.Keys)
  5250. {
  5251. builder.MoveToBookmark(key);
  5252. builder.Write(dic[key]);
  5253. }
  5254. //模板文件名
  5255. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5256. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5257. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5258. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5259. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5260. }
  5261. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5262. {
  5263. //获取模板
  5264. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5265. //载入模板
  5266. WorkbookDesigner designer = new WorkbookDesigner();
  5267. designer.Workbook = new Workbook(tempPath);
  5268. Dictionary<string, string> dic = new Dictionary<string, string>();
  5269. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5270. {
  5271. List<string> list = new List<string>();
  5272. try
  5273. {
  5274. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5275. foreach (var item in spilitArr)
  5276. {
  5277. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5278. var depCode = spDotandEmpty[2].Substring(0, 3);
  5279. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5280. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5281. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5282. list.Add(depName);
  5283. list.Add(arrName);
  5284. }
  5285. list = list.Distinct().ToList();
  5286. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5287. }
  5288. catch (Exception)
  5289. {
  5290. dic.Add("ReturnCode", "行程录入不正确!");
  5291. }
  5292. }
  5293. else
  5294. {
  5295. dic.Add("ReturnCode", "未录入行程!");
  5296. }
  5297. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5298. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5299. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5300. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5301. {
  5302. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5303. dic.Add("Day", sp.Days.ToString());
  5304. }
  5305. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5306. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5307. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5308. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5309. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5310. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5311. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5312. designer.SetDataSource("Name", Names);
  5313. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5314. designer.SetDataSource("Day", dic["Day"] + "天");
  5315. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5316. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5317. int startIndex = 10;
  5318. const int startIndexcopy = 10;
  5319. if (dac2.Count == dac3.Count)//国家 币种 金额
  5320. {
  5321. for (int i = 0; i < dac2.Count; i++)
  5322. {
  5323. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5324. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5325. }
  5326. }
  5327. DataTable dtdac1 = new DataTable();
  5328. List<string> place = new List<string>();
  5329. dtdac1.Columns.AddRange(new DataColumn[] {
  5330. new DataColumn(){ ColumnName = "city"},
  5331. new DataColumn(){ ColumnName = "curr"},
  5332. new DataColumn(){ ColumnName = "criterion"},
  5333. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5334. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5335. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5336. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5337. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5338. });
  5339. DataTable dtdac2 = new DataTable();
  5340. dtdac2.Columns.AddRange(new DataColumn[] {
  5341. new DataColumn(){ ColumnName = "city"},
  5342. new DataColumn(){ ColumnName = "curr"},
  5343. new DataColumn(){ ColumnName = "criterion"},
  5344. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5345. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5346. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5347. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5348. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5349. });
  5350. dtdac1.TableName = "tb1";
  5351. dtdac2.TableName = "tb2";
  5352. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5353. foreach (var item in dac1)
  5354. {
  5355. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5356. if (place.Contains(item.Place))
  5357. {
  5358. continue;
  5359. }
  5360. DataRow row = dtdac1.NewRow();
  5361. row["city"] = item.Place;
  5362. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5363. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5364. row["curr"] = currency;
  5365. row["rate"] = rate.ToString("#0.0000");
  5366. row["criterion"] = item.Cost.ToString("#0.00");
  5367. row["number"] = 1;
  5368. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5369. //row["costRMB"] = rbmPrice;
  5370. dtdac1.Rows.Add(row);
  5371. place.Add(item.Place);
  5372. }
  5373. place = new List<string>();
  5374. foreach (var item in dac2)
  5375. {
  5376. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5377. if (place.Contains(item.Place))
  5378. {
  5379. continue;
  5380. }
  5381. DataRow row = dtdac2.NewRow();
  5382. row["city"] = item.Place;
  5383. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5384. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5385. row["curr"] = currency;
  5386. row["rate"] = rate.ToString("#0.0000");
  5387. row["criterion"] = item.Cost.ToString("#0.00");
  5388. row["number"] = 1;
  5389. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5390. //row["cost"] = item.SubTotal;
  5391. //row["costRMB"] = rbmPrice;
  5392. dtdac2.Rows.Add(row);
  5393. place.Add(item.Place);
  5394. //dac2totalPrice += rbmPrice;
  5395. }
  5396. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5397. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5398. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5399. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5400. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5401. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5402. string cell4Str1 = string.Empty;
  5403. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5404. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5405. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5406. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5407. string cellStr = $" 5.其他费用(";
  5408. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5409. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5410. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5411. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5412. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5413. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5414. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5415. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5416. foreach (var otherInfo in dac5)
  5417. {
  5418. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5419. }
  5420. #endregion
  5421. if (cellStr.Length > 8)
  5422. {
  5423. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5424. }
  5425. cellStr += ")";
  5426. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5427. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5428. decimal pxFee = dac4.Sum(it => it.Cost);
  5429. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5430. string celllastStr1 = "";
  5431. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5432. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5433. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5434. celllastStr1 += $",国际旅费 元";
  5435. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5436. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5437. designer.SetDataSource("cell4Str", cell4Str);
  5438. designer.SetDataSource("cellStr", cellStr);
  5439. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5440. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5441. designer.SetDataSource("celllastStr", celllastStr);
  5442. Workbook wb = designer.Workbook;
  5443. var sheet = wb.Worksheets[0];
  5444. //绑定datatable数据集
  5445. designer.SetDataSource(dtdac1);
  5446. designer.SetDataSource(dtdac2);
  5447. designer.Process();
  5448. var rowStart = dtdac1.Rows.Count;
  5449. while (rowStart > 0)
  5450. {
  5451. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5452. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5453. startIndex++;
  5454. rowStart--;
  5455. }
  5456. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5457. startIndex += 1; //总计行
  5458. rowStart = dtdac2.Rows.Count;
  5459. while (rowStart > 0)
  5460. {
  5461. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5462. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5463. startIndex++;
  5464. rowStart--;
  5465. }
  5466. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5467. wb.CalculateFormula(true);
  5468. //模板文件名
  5469. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5470. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5471. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5472. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5473. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5474. }
  5475. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5476. {
  5477. //获取模板
  5478. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5479. //载入模板
  5480. Document doc = new Document(tempPath);
  5481. DocumentBuilder builder = new DocumentBuilder(doc);
  5482. Dictionary<string, string> dic = new Dictionary<string, string>();
  5483. dic.Add("GroupName", _DelegationInfo.TeamName);
  5484. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5485. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5486. string missionLeaderJob = "";//负责人job
  5487. int groupNumber = 0; //团人数
  5488. if (DeleClientList.Count > 0)
  5489. {
  5490. missionLeader = DeleClientList[0]?.Name ?? "";
  5491. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5492. }
  5493. dic.Add("MissionLeader", missionLeader); //团负责人
  5494. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5495. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5496. #region MyRegion
  5497. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5498. //{
  5499. // List<string> list = new List<string>();
  5500. // try
  5501. // {
  5502. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5503. // foreach (var item in spilitArr)
  5504. // {
  5505. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5506. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5507. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5508. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5509. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5510. // list.Add(depName);
  5511. // list.Add(arrName);
  5512. // }
  5513. // list = list.Distinct().ToList();
  5514. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5515. // }
  5516. // catch (Exception)
  5517. // {
  5518. // dic.Add("ReturnCode", "行程录入不正确!");
  5519. // }
  5520. //}
  5521. //else
  5522. //{
  5523. // dic.Add("ReturnCode", "未录入行程!");
  5524. //}
  5525. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5526. dic.Add("ReturnCode", string.Join("、", countrys));
  5527. #endregion
  5528. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5529. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5530. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5531. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5532. //{
  5533. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5534. // dic.Add("Day", sp.Days.ToString());
  5535. //}
  5536. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5537. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5538. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5539. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5540. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5541. //培训人员名单
  5542. int cultivateRowIndex = 7;
  5543. foreach (var item in DeleClientList)
  5544. {
  5545. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5546. builder.Write(item.Name);
  5547. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5548. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5549. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5550. string birthDay = "";
  5551. if (item.Birthday != null)
  5552. {
  5553. DateTime dt = Convert.ToDateTime(item.Birthday);
  5554. birthDay = $"{dt.Year}.{dt.Month}";
  5555. }
  5556. builder.Write(birthDay);
  5557. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5558. builder.Write(item.Company);
  5559. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5560. builder.Write(item.Job);
  5561. cultivateRowIndex++;
  5562. }
  5563. //删除多余行
  5564. //cultivateRowIndex -= 2;
  5565. int delRows = 10 + 7 - cultivateRowIndex;
  5566. if (delRows > 0)
  5567. {
  5568. for (int i = 0; i < delRows; i++)
  5569. {
  5570. table1.Rows.RemoveAt(cultivateRowIndex);
  5571. //cultivateRowIndex++;
  5572. }
  5573. }
  5574. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5575. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5576. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5577. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5578. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5579. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5580. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5581. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5582. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5583. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5584. //其他费用
  5585. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5586. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5587. //其他费用合计
  5588. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5589. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5590. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5591. //公务舱合计
  5592. //国际旅费
  5593. string outsideJJ = "";
  5594. string allPriceJJ = "";
  5595. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5596. {
  5597. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5598. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5599. }
  5600. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5601. {
  5602. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5603. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5604. }
  5605. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5606. {
  5607. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5608. dic.Add("AirFeeTotal", airFeeTotalStr);
  5609. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5610. dic.Add("FeeTotal", feeTotalStr);
  5611. }
  5612. foreach (var key in dic.Keys)
  5613. {
  5614. builder.MoveToBookmark(key);
  5615. builder.Write(dic[key]);
  5616. }
  5617. //模板文件名
  5618. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5619. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5620. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5621. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5622. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5623. }
  5624. }
  5625. else if (dto.ExportType == 2) //表格
  5626. {
  5627. //利用键值对存放数据
  5628. Dictionary<string, string> dic = new Dictionary<string, string>();
  5629. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5630. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5631. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5632. dic.Add("Day", sp.Days.ToString());
  5633. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5634. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5635. {
  5636. //获取模板
  5637. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5638. //载入模板
  5639. Document doc = new Document(tempPath);
  5640. DocumentBuilder builder = new DocumentBuilder(doc);
  5641. dic.Add("TeamName", _DelegationInfo.TeamName);
  5642. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5643. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5644. string missionLeaderName = "",
  5645. missionLeaderJob = "";
  5646. if (DeleClientList.Count > 0)
  5647. {
  5648. missionLeaderName = DeleClientList[0].Name;
  5649. missionLeaderJob = DeleClientList[0].Job;
  5650. }
  5651. dic.Add("MissionLeaderName", missionLeaderName);
  5652. dic.Add("MissionLeaderJob", missionLeaderJob);
  5653. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5654. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5655. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5656. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5657. int rowCount = 10;//总人数行
  5658. int startRowIndex = 7; //起始行
  5659. for (int i = 0; i < DeleClientList.Count; i++)
  5660. {
  5661. builder.MoveToCell(0, startRowIndex, 0, 0);
  5662. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5663. builder.MoveToCell(0, startRowIndex, 1, 0);
  5664. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5665. builder.Write(sex);//性别
  5666. builder.MoveToCell(0, startRowIndex, 2, 0);
  5667. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5668. builder.MoveToCell(0, startRowIndex, 3, 0);
  5669. builder.Write(DeleClientList[i].Company);//工作单位
  5670. builder.MoveToCell(0, startRowIndex, 4, 0);
  5671. builder.Write(DeleClientList[i].Job);//职务及级别
  5672. builder.MoveToCell(0, startRowIndex, 5, 0);
  5673. builder.Write("");//人员属性
  5674. builder.MoveToCell(0, startRowIndex, 6, 0);
  5675. builder.Write("");//上次出国时间
  5676. startRowIndex++;
  5677. }
  5678. int nullRow = rowCount - DeleClientList.Count;//空行
  5679. for (int i = 0; i < nullRow; i++)
  5680. {
  5681. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5682. }
  5683. foreach (var key in dic.Keys)
  5684. {
  5685. builder.MoveToBookmark(key);
  5686. builder.Write(dic[key]);
  5687. }
  5688. //模板文件名
  5689. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5690. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5691. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5692. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5693. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5694. }
  5695. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5696. {
  5697. //获取模板
  5698. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5699. //载入模板
  5700. Document doc = new Document(tempPath);
  5701. DocumentBuilder builder = new DocumentBuilder(doc);
  5702. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5703. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5704. dic.Add("Names", Names);
  5705. int accommodationRows = 12, foodandotherRows = 12;
  5706. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5707. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5708. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5709. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5710. int accommodationStartIndex = 6;
  5711. decimal dac1totalPrice = 0.00M;
  5712. foreach (var dac in dac1)
  5713. {
  5714. if (dac.SubTotal == 0)
  5715. {
  5716. continue;
  5717. }
  5718. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5719. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5720. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5721. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5722. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5723. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5724. builder.Write(currency);//币种
  5725. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5726. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5727. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5728. builder.Write("");//人数
  5729. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5730. builder.Write("");//天数
  5731. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5732. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5733. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5734. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5735. builder.Write(rate.ToString("#0.0000"));//汇率
  5736. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5737. decimal rbmPrice = rate * dac.SubTotal;
  5738. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5739. accommodationStartIndex++;
  5740. dac1totalPrice += rbmPrice;
  5741. }
  5742. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5743. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5744. builder.Write("小计");
  5745. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5746. builder.Write(dac1totalPrice.ToString("#0.00"));
  5747. accommodationStartIndex++;
  5748. int nullRow = accommodationRows - dac1.Count;
  5749. //删除空行
  5750. //if (nullRow > 0)
  5751. //{
  5752. // int rowIndex = accommodationStartIndex;
  5753. // for (int i = 0; i < nullRow; i++)
  5754. // {
  5755. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5756. // row.Remove();
  5757. // rowIndex++;
  5758. // }
  5759. //}
  5760. if (dac2.Count == dac3.Count)//国家 币种 金额
  5761. {
  5762. for (int i = 0; i < dac2.Count; i++)
  5763. {
  5764. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5765. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5766. }
  5767. }
  5768. int foodandotherStartIndex = 19;//
  5769. decimal dac2totalPrice = 0.00M;
  5770. foreach (var dac in dac2)
  5771. {
  5772. if (dac.SubTotal == 0)
  5773. {
  5774. continue;
  5775. }
  5776. //foodandotherStartIndex = 12;
  5777. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5778. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5779. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5780. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5781. builder.Write(currency);//币种
  5782. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5783. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5784. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5785. builder.Write("");//人数
  5786. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5787. builder.Write("");//天数
  5788. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5789. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5790. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5791. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5792. builder.Write(rate.ToString("#0.0000"));//汇率
  5793. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5794. decimal rbmPrice = rate * dac.SubTotal;
  5795. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5796. foodandotherStartIndex++;
  5797. dac2totalPrice += rbmPrice;
  5798. }
  5799. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5800. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5801. //删除空行
  5802. //if (dac2.Count < foodandotherRows)
  5803. //{
  5804. // while (table2.Rows.Count > dac2.Count)
  5805. // {
  5806. // table2.Rows.RemoveAt(dac2.Count);
  5807. // }
  5808. //}
  5809. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5810. string otherFeeStr = "";
  5811. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5812. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5813. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5814. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5815. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5816. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5817. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5818. foreach (var otherInfo in dac5)
  5819. {
  5820. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5821. }
  5822. #endregion
  5823. if (otherFeeStr.Length > 0)
  5824. {
  5825. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5826. otherFeeStr = $"({otherFeeStr})";
  5827. dic.Add("OtherFeeStr", otherFeeStr);
  5828. }
  5829. foreach (var key in dic.Keys)
  5830. {
  5831. builder.MoveToBookmark(key);
  5832. builder.Write(dic[key]);
  5833. }
  5834. //模板文件名
  5835. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5836. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5837. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5838. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5839. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5840. }
  5841. }
  5842. else if (dto.ExportType == 3)
  5843. {
  5844. if (dto.SubTypeId == 1) //团组成员名单
  5845. {
  5846. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  5847. //获取模板
  5848. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5849. //载入模板
  5850. Document doc = new Document(tempPath);
  5851. DocumentBuilder builder = new DocumentBuilder(doc);
  5852. //获取word里所有表格
  5853. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5854. //获取所填表格的序数
  5855. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5856. var rowStart = tableOne.Rows[0]; //获取第1行
  5857. //循环赋值
  5858. for (int i = 0; i < DeleClientList.Count; i++)
  5859. {
  5860. builder.MoveToCell(0, i + 1, 0, 0);
  5861. builder.Write(DeleClientList[i].Name);
  5862. builder.MoveToCell(0, i + 1, 1, 0);
  5863. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5864. builder.Write(sex);
  5865. builder.MoveToCell(0, i + 1, 2, 0);
  5866. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5867. builder.MoveToCell(0, i + 1, 3, 0);
  5868. builder.Write(DeleClientList[i].Company);
  5869. builder.MoveToCell(0, i + 1, 4, 0);
  5870. builder.Write(DeleClientList[i].Job);
  5871. }
  5872. //删除多余行
  5873. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5874. {
  5875. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5876. }
  5877. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5878. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5879. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5880. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5881. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5882. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5883. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5884. }
  5885. }
  5886. return Ok(JsonView(400, "操作失败!", ""));
  5887. }
  5888. catch (Exception ex)
  5889. {
  5890. return Ok(JsonView(400, ex.Message, ""));
  5891. }
  5892. }
  5893. /// <summary>
  5894. /// 获取三公费用标准city
  5895. /// </summary>
  5896. /// <param name="placeData"></param>
  5897. /// <param name="nationalTravelFeeId"></param>
  5898. /// <returns></returns>
  5899. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5900. {
  5901. string _city = string.Empty;
  5902. if (placeData.Count < 1) return _city;
  5903. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5904. if (data == null) return _city;
  5905. string country = data.Country;
  5906. string city = data.City;
  5907. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5908. else _city = city;
  5909. return _city;
  5910. }
  5911. /// <summary>
  5912. /// 团组模块 - 出入境费用 - 明细表导出
  5913. /// </summary>
  5914. /// <returns></returns>
  5915. [HttpPost]
  5916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5917. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5918. {
  5919. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5920. if (data.Code != 0)
  5921. {
  5922. return Ok(JsonView(false, data.Msg));
  5923. }
  5924. return Ok(JsonView(true, data.Msg, data.Data));
  5925. }
  5926. /// <summary>
  5927. /// 团组模块 - 出入境费用 - 一键清空
  5928. /// </summary>
  5929. /// <returns></returns>
  5930. [HttpPost]
  5931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5932. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5933. {
  5934. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5935. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5936. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5937. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5938. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5939. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5940. .SetColumns(x => new Grp_DayOtherPrice
  5941. {
  5942. IsDel = 1,
  5943. DeleteUserId = dto.UserId,
  5944. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5945. })
  5946. .ExecuteCommandAsync();
  5947. if (_view.Code == 0)
  5948. {
  5949. return Ok(JsonView(true, "操作成功"));
  5950. }
  5951. return Ok(JsonView(false, "操作失败"));
  5952. }
  5953. /// <summary>
  5954. /// 团组模块 - 出入境费用 - 子项删除
  5955. /// </summary>
  5956. /// <returns></returns>
  5957. [HttpPost]
  5958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5959. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5960. {
  5961. try
  5962. {
  5963. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5964. if (data.Code != 0)
  5965. {
  5966. return Ok(JsonView(false, data.Msg));
  5967. }
  5968. return Ok(JsonView(true, "操作成功!", data.Data));
  5969. }
  5970. catch (Exception ex)
  5971. {
  5972. return Ok(JsonView(false, ex.Message));
  5973. }
  5974. }
  5975. /// <summary>
  5976. /// 删除三公其他费用
  5977. /// </summary>
  5978. /// <param name="dto"></param>
  5979. /// <returns></returns>
  5980. [HttpPost]
  5981. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  5982. {
  5983. var jw = JsonView(false,"删除失败!");
  5984. var data = new Grp_DayOtherPrice()
  5985. {
  5986. Id = dto.Id,
  5987. IsDel = 1,
  5988. DeleteUserId = dto.DeleteUserId,
  5989. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  5990. };
  5991. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  5992. if (del > 0)
  5993. {
  5994. jw.Code = 200;
  5995. jw.Msg = "删除成功!";
  5996. }
  5997. return Ok(jw);
  5998. }
  5999. /// <summary>
  6000. /// 团组模块 - 出入境国家费用标准 List
  6001. /// </summary>
  6002. /// <returns></returns>
  6003. [HttpPost]
  6004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6005. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6006. {
  6007. try
  6008. {
  6009. Stopwatch sw = new Stopwatch();
  6010. sw.Start();
  6011. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6012. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6013. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6014. Where gntf.Isdel = 0");
  6015. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6016. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6017. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6018. //foreach (var item in nationalTravel)
  6019. //{
  6020. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6021. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6022. // if (otherData != null)
  6023. // {
  6024. // cityData.Remove(otherData);
  6025. // cityData.Add(otherData);
  6026. // }
  6027. // nationalTravelFeeData1.Add(new
  6028. // {
  6029. // Country = item.Country,
  6030. // CityData = cityData
  6031. // });
  6032. //}
  6033. sw.Stop();
  6034. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6035. }
  6036. catch (Exception ex)
  6037. {
  6038. return Ok(JsonView(false, ex.Message));
  6039. throw;
  6040. }
  6041. }
  6042. /// <summary>
  6043. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6044. /// </summary>
  6045. /// <returns></returns>
  6046. [HttpPost]
  6047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6048. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6049. {
  6050. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6051. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6052. List<string> countryData = new List<string>();
  6053. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6054. countryData = countryData.Distinct().ToList();
  6055. List<dynamic> dataSource = new List<dynamic>();
  6056. foreach (var item in countryData)
  6057. {
  6058. List<string> cityData1 = new List<string>();
  6059. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6060. var countryData2 = new
  6061. {
  6062. CountryName = item,
  6063. CityData = cityData1
  6064. };
  6065. dataSource.Add(countryData2);
  6066. }
  6067. return Ok(JsonView(true, "查询成功!", dataSource));
  6068. }
  6069. /// <summary>
  6070. /// 团组模块 - 出入境国家费用标准 Page List
  6071. /// </summary>
  6072. /// <returns></returns>
  6073. [HttpPost]
  6074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6075. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6076. {
  6077. int portId = dto.PortType;
  6078. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6079. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6080. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6081. string whereSql = string.Empty;
  6082. if (!string.IsNullOrEmpty(dto.Country))
  6083. {
  6084. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6085. }
  6086. if (!string.IsNullOrEmpty(dto.City))
  6087. {
  6088. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6089. }
  6090. string pageSql = string.Format(@"Select * From (
  6091. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6092. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6093. From Grp_NationalTravelFee gntf
  6094. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6095. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6096. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6097. RefAsync<int> total = 0;
  6098. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6099. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6100. }
  6101. /// <summary>
  6102. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6103. /// </summary>
  6104. /// <returns></returns>
  6105. [HttpPost]
  6106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6107. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6108. {
  6109. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6110. int portId = dto.PortType;
  6111. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6112. string whereSql = string.Empty;
  6113. if (!string.IsNullOrEmpty(dto.Country))
  6114. {
  6115. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6116. }
  6117. if (!string.IsNullOrEmpty(dto.City))
  6118. {
  6119. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6120. }
  6121. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6122. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6123. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6124. From Grp_NationalTravelFee gntf
  6125. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6126. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6127. Where gntf.Isdel = 0 {0} ", whereSql);
  6128. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6129. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6130. }
  6131. /// <summary>
  6132. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6133. /// </summary>
  6134. /// <returns></returns>
  6135. [HttpPost]
  6136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6137. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6138. {
  6139. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6140. if (data.Code != 0)
  6141. {
  6142. return Ok(JsonView(false, data.Msg));
  6143. }
  6144. return Ok(JsonView(true, "操作成功!", data.Data));
  6145. }
  6146. /// <summary>
  6147. /// 团组模块 - 出入境国家费用标准 - Del
  6148. /// </summary>
  6149. /// <returns></returns>
  6150. [HttpPost]
  6151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6152. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6153. {
  6154. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6155. {
  6156. Id = dto.Id,
  6157. DeleteUserId = dto.DeleteUserId,
  6158. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6159. IsDel = 1
  6160. };
  6161. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6162. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6163. .WhereColumns(it => new { it.Id })
  6164. .ExecuteCommandAsync();
  6165. if (delStatus <= 0)
  6166. {
  6167. return Ok(JsonView(false, "删除失败!"));
  6168. }
  6169. return Ok(JsonView(true, "操作成功!"));
  6170. }
  6171. /// <summary>
  6172. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6173. /// 注:Get 请求Headers 加 Token
  6174. /// </summary>
  6175. /// <param name="groupId"></param>
  6176. /// <returns></returns>
  6177. [HttpGet("{groupId}")]
  6178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6179. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6180. {
  6181. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6182. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6183. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6184. data.ForEach(x =>
  6185. {
  6186. x.CreateUserId = _currUserInfo.UserId;
  6187. });
  6188. if (data.Any())
  6189. {
  6190. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6191. if (add > 0)
  6192. {
  6193. return Ok(JsonView(true, "操作成功!"));
  6194. }
  6195. }
  6196. return Ok(JsonView(false, "未操作!"));
  6197. }
  6198. #endregion
  6199. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6200. /// <summary>
  6201. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6202. /// </summary>
  6203. /// <returns></returns>
  6204. [HttpPost]
  6205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6206. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  6207. {
  6208. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6209. //SetDataInfoView
  6210. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6211. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6212. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6213. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6214. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6215. //默认币种显示
  6216. var _currencyInfos = _currencyInit;
  6217. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6218. if (_currencyRate.Count > 0)
  6219. {
  6220. foreach (var item in _currencyInfos)
  6221. {
  6222. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6223. if (rateInfo != null)
  6224. {
  6225. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6226. rate1 *= 1.035M;
  6227. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6228. }
  6229. }
  6230. }
  6231. return Ok(JsonView(true, "查询成功!", new
  6232. {
  6233. WordTypeData = _WordTypeData,
  6234. ExcelTypeData = _ExcelTypeData,
  6235. CurrencyInit = _currencyInfos
  6236. }));
  6237. }
  6238. /// <summary>
  6239. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6240. /// </summary>
  6241. /// <returns></returns>
  6242. [HttpPost]
  6243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6244. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6245. {
  6246. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6247. RefAsync<int> total = 0;
  6248. int diId = 0;
  6249. var status = int.TryParse(dto.GroupName, out diId);
  6250. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6251. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6252. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  6253. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  6254. .Select(x => new
  6255. {
  6256. Id = x.Id,
  6257. GroupName = x.TeamName
  6258. })
  6259. .OrderByDescending(x => x.Id)
  6260. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6261. return Ok(JsonView(true, "查询成功!", data, total));
  6262. }
  6263. /// <summary>
  6264. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6265. /// </summary>
  6266. /// <returns></returns>
  6267. [HttpPost]
  6268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6269. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6270. {
  6271. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6272. RefAsync<int> total = 0;
  6273. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6274. .Where(x => x.IsDel == 0 && x.STid == 66)
  6275. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6276. .Select(x => new
  6277. {
  6278. id = x.Id,
  6279. name = x.Name,
  6280. remark = x.Remark,
  6281. })
  6282. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6283. return Ok(JsonView(true, "查询成功!", data, total));
  6284. }
  6285. /// <summary>
  6286. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  6287. /// </summary>
  6288. /// <returns></returns>
  6289. [HttpPost]
  6290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6291. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  6292. {
  6293. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6294. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6295. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  6296. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  6297. var groupOtherRateData = groupRateData.TeamRates;
  6298. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6299. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  6300. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  6301. groupOtherRateData = groupOtherRateData
  6302. .Select(x => new TeamRateDescAddCurrencyIdView {
  6303. CurrencyId = x.CurrencyId,
  6304. CurrencyName = x.CurrencyName,
  6305. CurrencyCode = x.CurrencyCode,
  6306. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  6307. }).ToList();
  6308. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  6309. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  6310. }
  6311. /// <summary>
  6312. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6313. /// </summary>
  6314. /// <returns></returns>
  6315. [HttpPost]
  6316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6317. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6318. {
  6319. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6320. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6321. var tipsData = new List<int>() {1,2,3 };
  6322. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6323. if (dto.TipsType == 1)
  6324. {
  6325. //默认币种显示
  6326. var _currencyInfos = _currencyInit;
  6327. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6328. List<dynamic> reteInfos = new List<dynamic>();
  6329. if (_currencyRate.Count > 0)
  6330. {
  6331. foreach (var item in _currencyInfos)
  6332. {
  6333. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6334. if (rateInfo != null)
  6335. {
  6336. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6337. decimal rate1 = item.Rate;
  6338. rate1 *= 1.03M;
  6339. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6340. reteInfos.Add(new
  6341. {
  6342. currCode = item.CurrencyCode,
  6343. currName = item.CurrencyName,
  6344. rate = rate2,
  6345. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6346. });
  6347. }
  6348. }
  6349. }
  6350. return Ok(JsonView(true, "查询成功!", reteInfos));
  6351. }
  6352. else if (dto.TipsType == 2)
  6353. {
  6354. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6355. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6356. }
  6357. else if (dto.TipsType == 3)
  6358. {
  6359. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6360. return Ok(JsonView(true, "查询成功!", airData.Data));
  6361. }
  6362. return Ok(JsonView(false));
  6363. }
  6364. /// <summary>
  6365. /// 团组模块 - 出入境国家费用标准-移动端 List
  6366. /// </summary>
  6367. /// <returns></returns>
  6368. [HttpPost]
  6369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6370. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6371. {
  6372. Stopwatch sw = new Stopwatch();
  6373. sw.Start();
  6374. RefAsync<int> total = 0;
  6375. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6376. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6377. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6378. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6379. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6380. .Select((ntf, sd, u) => new
  6381. {
  6382. Id = ntf.Id,
  6383. Area = $"{ntf.Country}-{ntf.City}",
  6384. Currency = ntf.Currency,
  6385. CurrencyCode = sd.Name,
  6386. CurrencyName = sd.Remark,
  6387. RoomCost = ntf.RoomCost,
  6388. FoodCost = ntf.FoodCost,
  6389. PublicCost = ntf.PublicCost,
  6390. LastUpdateUserId = ntf.LastUpdateUserId,
  6391. LastUpdateUserName = u.CnName,
  6392. LastUpdateTime = ntf.LastUpdateTime,
  6393. })
  6394. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6395. sw.Stop();
  6396. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6397. }
  6398. /// <summary>
  6399. /// 团组模块 - 出入境费用-移动端 - Info
  6400. /// </summary>
  6401. /// <returns></returns>
  6402. [HttpPost]
  6403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6404. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  6405. {
  6406. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6407. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6408. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  6409. return Ok(data);
  6410. }
  6411. /// <summary>
  6412. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  6413. /// </summary>
  6414. /// <returns></returns>
  6415. [HttpPost]
  6416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6417. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  6418. {
  6419. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6420. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6421. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6422. var mobileInfo = new EnterExitCostMobileParentInfoView();
  6423. mobileInfo.DiId = dto.DiId;
  6424. if (eecInfo == null) return Ok(mobileInfo);
  6425. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  6426. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  6427. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6428. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6429. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6430. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6431. {
  6432. SubId = dac.Id,
  6433. DiId = dac.DiId,
  6434. Type = dac.Type,
  6435. Days = dac.Days,
  6436. NationalTravelFeeId = dac.NationalTravelFeeId,
  6437. Arae = $"{ntf.Country}-{ntf.City}",
  6438. Cost = dac.Cost,
  6439. Currency = dac.Currency,
  6440. CurrencyName = sd.Name,
  6441. SubTotal = dac.SubTotal,
  6442. })
  6443. .ToList();
  6444. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  6445. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  6446. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  6447. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  6448. mobileInfo.Currencys = CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
  6449. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  6450. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  6451. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  6452. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  6453. //其他款项
  6454. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6455. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6456. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6457. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6458. .OrderBy((dop, sd1, sd2) => dop.Index)
  6459. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6460. {
  6461. SubId = dop.Id,
  6462. DiId = dop.Diid,
  6463. Index = dop.Index,
  6464. SetDataId = dop.SetDataId,
  6465. SetDataName = sd1.Name,
  6466. Cost = dop.Cost,
  6467. Currency = dop.Currency,
  6468. CurrencyName = sd2.Remark,
  6469. SubTotal = dop.SubTotal,
  6470. Remark = dop.Remark,
  6471. })
  6472. .ToArray();
  6473. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  6474. return Ok(mobileInfo);
  6475. }
  6476. /// <summary>
  6477. /// 团组模块 - 出入境费用-移动端 - SubInfo
  6478. /// </summary>
  6479. /// <returns></returns>
  6480. [HttpPost]
  6481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6482. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  6483. {
  6484. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6485. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6486. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  6487. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  6488. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6489. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  6490. var subType = dto.SubType;
  6491. if (subType == 1) //1:境内费用
  6492. {
  6493. var oneData = new ChoiceOneMobileSubInfoView()
  6494. {
  6495. Id = eecInfo.Id,
  6496. ChoiceOne = eecInfo.ChoiceOne,
  6497. ChoiceOneTotalCost = eecInfo.InsidePay,
  6498. Visa = eecInfo.Visa,
  6499. VisaRemark = eecInfo.VisaRemark,
  6500. YiMiao = eecInfo.YiMiao,
  6501. HeSuan = eecInfo.HeSuan,
  6502. Service = eecInfo.Service,
  6503. Ticket = eecInfo.Ticket,
  6504. Safe = eecInfo.Safe,
  6505. };
  6506. return Ok(JsonView(oneData));
  6507. }
  6508. else if (subType == 2) //2:国际旅费
  6509. {
  6510. var twoData = new ChoiceTwoMobileSubInfoView() {
  6511. Id = eecInfo.Id,
  6512. ChoiceTwoJJ = eecInfo.SumJJC,
  6513. OutsideJJPay = eecInfo.OutsideJJPay,
  6514. ChoiceTwoGW = eecInfo.SumGWC,
  6515. OutsideGWPay = eecInfo.OutsideGWPay,
  6516. ChoiceTwoTD = eecInfo.SumTDC,
  6517. OutsideTDPay = eecInfo.OutsideTDPay,
  6518. AirJJ = eecInfo.AirJJ,
  6519. AirGW = eecInfo.AirGW,
  6520. AirTD = eecInfo.AirTD,
  6521. CityTranffic = eecInfo.CityTranffic
  6522. };
  6523. return Ok(JsonView(twoData));
  6524. }
  6525. else if (subType == 3) //3:住宿费
  6526. {
  6527. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6528. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6529. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6530. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  6531. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6532. {
  6533. SubId = dac.Id,
  6534. DiId = dac.DiId,
  6535. Type = dac.Type,
  6536. Days = dac.Days,
  6537. NationalTravelFeeId = dac.NationalTravelFeeId,
  6538. Arae = $"{ntf.Country}-{ntf.City}",
  6539. Cost = dac.Cost,
  6540. Currency = dac.Currency,
  6541. CurrencyName = sd.Name,
  6542. SubTotal = dac.SubTotal,
  6543. })
  6544. .ToArray();
  6545. var data = new ChoiceMobileSubInfo3To6View() {
  6546. ParentId = eecInfo.Id,
  6547. Choice = eecInfo.ChoiceThree,
  6548. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6549. Details = dayAndCostDatas
  6550. };
  6551. return Ok(JsonView(data));
  6552. }
  6553. else if (subType == 4) //4:伙食费
  6554. {
  6555. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6556. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6557. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6558. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  6559. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6560. {
  6561. SubId = dac.Id,
  6562. DiId = dac.DiId,
  6563. Type = dac.Type,
  6564. Days = dac.Days,
  6565. NationalTravelFeeId = dac.NationalTravelFeeId,
  6566. Arae = $"{ntf.Country}-{ntf.City}",
  6567. Cost = dac.Cost,
  6568. Currency = dac.Currency,
  6569. CurrencyName = sd.Name,
  6570. SubTotal = dac.SubTotal,
  6571. })
  6572. .ToArray();
  6573. var data = new ChoiceMobileSubInfo3To6View()
  6574. {
  6575. ParentId = eecInfo.Id,
  6576. Choice = eecInfo.ChoiceFour,
  6577. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6578. Details = dayAndCostDatas
  6579. };
  6580. return Ok(JsonView(data));
  6581. }
  6582. else if (subType == 5) //5:公杂费
  6583. {
  6584. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6585. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6586. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6587. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  6588. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6589. {
  6590. SubId = dac.Id,
  6591. DiId = dac.DiId,
  6592. Type = dac.Type,
  6593. Days = dac.Days,
  6594. NationalTravelFeeId = dac.NationalTravelFeeId,
  6595. Arae = $"{ntf.Country}-{ntf.City}",
  6596. Cost = dac.Cost,
  6597. Currency = dac.Currency,
  6598. CurrencyName = sd.Name,
  6599. SubTotal = dac.SubTotal,
  6600. })
  6601. .ToArray();
  6602. var data = new ChoiceMobileSubInfo3To6View()
  6603. {
  6604. ParentId = eecInfo.Id,
  6605. Choice = eecInfo.ChoiceFive,
  6606. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6607. Details = dayAndCostDatas
  6608. };
  6609. return Ok(JsonView(data));
  6610. }
  6611. else if (subType == 6) //6:培训费
  6612. {
  6613. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6614. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6615. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6616. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  6617. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6618. {
  6619. SubId = dac.Id,
  6620. DiId = dac.DiId,
  6621. Type = dac.Type,
  6622. Days = dac.Days,
  6623. NationalTravelFeeId = dac.NationalTravelFeeId,
  6624. Arae = $"{ntf.Country}-{ntf.City}",
  6625. Cost = dac.Cost,
  6626. Currency = dac.Currency,
  6627. CurrencyName = sd.Name,
  6628. SubTotal = dac.SubTotal,
  6629. })
  6630. .ToArray();
  6631. var data = new ChoiceMobileSubInfo3To6View()
  6632. {
  6633. ParentId = eecInfo.Id,
  6634. Choice = eecInfo.ChoiceSix,
  6635. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6636. Details = dayAndCostDatas
  6637. };
  6638. return Ok(JsonView(data));
  6639. }
  6640. else if (subType == 7) //7:其他
  6641. {
  6642. //其他款项
  6643. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6644. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6645. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6646. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6647. .OrderBy((dop, sd1, sd2) => dop.Index)
  6648. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6649. {
  6650. SubId = dop.Id,
  6651. DiId = dop.Diid,
  6652. Index = dop.Index,
  6653. SetDataId = dop.SetDataId,
  6654. SetDataName = sd1.Name,
  6655. Cost = dop.Cost,
  6656. Currency = dop.Currency,
  6657. CurrencyName = sd2.Name,
  6658. SubTotal = dop.SubTotal,
  6659. Remark = dop.Remark,
  6660. })
  6661. .ToArray();
  6662. var data = new ChoiceSevenMobileSubInfoView()
  6663. {
  6664. ParentId = eecInfo.Id,
  6665. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  6666. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  6667. Details = otherData
  6668. };
  6669. return Ok(JsonView(data));
  6670. }
  6671. return Ok(JsonView(false));
  6672. }
  6673. #region op
  6674. /// <summary>
  6675. /// 移动端更新费用消息通知
  6676. /// </summary>
  6677. /// <param name="diid"></param>
  6678. /// <param name="id"></param>
  6679. /// <param name="currUserId"></param>
  6680. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  6681. {
  6682. try
  6683. {
  6684. ////生成默认文件pdf并且通知人员
  6685. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6686. //{
  6687. // DiId = diid,
  6688. // ExportType = 1,
  6689. // SubTypeId = 1005
  6690. //}, "pdf");
  6691. ////发送通知
  6692. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6693. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  6694. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  6695. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  6696. ////汇率信息记录
  6697. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  6698. }
  6699. catch (Exception ex)
  6700. {
  6701. //记录日志
  6702. throw;
  6703. }
  6704. }
  6705. /// <summary>
  6706. /// 验证出入境费用数据是否存在
  6707. /// 不存在添加
  6708. /// </summary>
  6709. /// <param name="diId"></param>
  6710. /// <param name="currUserId"></param>
  6711. /// <returns></returns>
  6712. /// <exception cref="CustomException"></exception>
  6713. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  6714. {
  6715. var parentId = 0;
  6716. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  6717. if (info != null) parentId = info.Id;
  6718. else
  6719. {
  6720. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId }).ExecuteReturnIdentityAsync();
  6721. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  6722. parentId = addId;
  6723. }
  6724. return parentId;
  6725. }
  6726. /// <summary>
  6727. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  6728. /// </summary>
  6729. /// <returns></returns>
  6730. [HttpPost]
  6731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6732. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  6733. {
  6734. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6735. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6736. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6737. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  6738. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  6739. int id = dto.Id;
  6740. if (id <= 0) //add
  6741. {
  6742. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  6743. if (add < 1) return Ok(JsonView(false));
  6744. id = add;
  6745. }
  6746. else //update
  6747. {
  6748. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  6749. if (upd < 1) return Ok(JsonView(false));
  6750. }
  6751. #region 汇率变更时更改币种相关费用
  6752. var opDayCosts = new List<Grp_DayAndCost>();
  6753. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  6754. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  6755. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  6756. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  6757. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6758. .Select((dac, sd) => new {
  6759. dac.Id,
  6760. dac.DiId,
  6761. CurrencyCode = sd.Name,
  6762. dac.Cost
  6763. })
  6764. .ToList();
  6765. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6766. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  6767. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6768. .Select((dop, sd) => new {
  6769. dop.Id,
  6770. dop.Diid,
  6771. CurrencyCode = sd.Name,
  6772. dop.Cost
  6773. })
  6774. .ToList();
  6775. if (dayCosts.Count > 0)
  6776. {
  6777. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6778. foreach (var dc in new_dayCosts)
  6779. {
  6780. var thisCurrency = dc.Key.ToUpper();
  6781. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6782. if (thisRate == 0.00M) continue;
  6783. foreach (var dcSub in dc)
  6784. {
  6785. opDayCosts.Add(new Grp_DayAndCost() {
  6786. Id = dcSub.Id,
  6787. DiId = dcSub.DiId,
  6788. Cost = dcSub.Cost,
  6789. SubTotal = dcSub.Cost * thisRate,
  6790. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6791. });
  6792. }
  6793. }
  6794. if (opDayCosts.Count > 0)
  6795. {
  6796. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6797. }
  6798. }
  6799. if (dayOtherCosts.Count > 0)
  6800. {
  6801. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6802. foreach (var dc in new_dayOtherCosts)
  6803. {
  6804. var thisCurrency = dc.Key.ToUpper();
  6805. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6806. if (thisRate == 0.00M) continue;
  6807. foreach (var dcSub in dc)
  6808. {
  6809. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  6810. {
  6811. Id = dcSub.Id,
  6812. Diid = dcSub.Diid,
  6813. Cost = dcSub.Cost,
  6814. SubTotal = dcSub.Cost * thisRate,
  6815. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6816. });
  6817. }
  6818. }
  6819. if (opDayOtherCosts.Count > 0)
  6820. {
  6821. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6822. }
  6823. }
  6824. #endregion
  6825. //消息通知
  6826. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  6827. //汇率信息记录
  6828. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  6829. return Ok(JsonView(new { parentId = id }));
  6830. }
  6831. /// <summary>
  6832. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  6833. /// </summary>
  6834. /// <returns></returns>
  6835. [HttpPost]
  6836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6837. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  6838. {
  6839. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6840. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6841. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6842. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  6843. int id = dto.Id;
  6844. if (id <= 0) //add
  6845. {
  6846. checkboxInfo.CreateUserId = dto.CurrUserId;
  6847. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6848. if (add < 1) return Ok(JsonView(false));
  6849. }
  6850. else //update
  6851. {
  6852. var upd = await _sqlSugar.Updateable(checkboxInfo)
  6853. .UpdateColumns(x => new {
  6854. x.ChoiceOne,
  6855. x.ChoiceTwo,
  6856. x.SumJJC,
  6857. x.SumGWC,
  6858. x.SumTDC,
  6859. x.ChoiceThree,
  6860. x.ChoiceFour,
  6861. x.ChoiceFive,
  6862. x.ChoiceSix,
  6863. x.OtherExpenses_Checked
  6864. })
  6865. .Where(x => x.Id == id)
  6866. .ExecuteCommandAsync();
  6867. if (upd < 1) return Ok(JsonView(false));
  6868. }
  6869. return Ok(JsonView(new { parentId = id }));
  6870. }
  6871. /// <summary>
  6872. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  6873. /// </summary>
  6874. /// <returns></returns>
  6875. [HttpPost]
  6876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6877. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  6878. {
  6879. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  6880. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  6881. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6882. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6883. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6884. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  6885. var checkboxInfo = new Grp_EnterExitCost() {
  6886. Id = id,
  6887. DiId = diId,
  6888. CreateUserId = currUserId
  6889. };
  6890. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  6891. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  6892. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  6893. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  6894. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  6895. if (id <= 0) //add
  6896. {
  6897. checkboxInfo.CreateUserId = dto.CurrUserId;
  6898. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6899. if (add < 1) return Ok(JsonView(false));
  6900. }
  6901. else //update
  6902. {
  6903. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  6904. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  6905. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  6906. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  6907. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  6908. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  6909. .Where(x => x.Id == id)
  6910. .ExecuteCommandAsync();
  6911. if (upd < 1) return Ok(JsonView(false));
  6912. }
  6913. return Ok(JsonView(new { parentId = id }));
  6914. }
  6915. /// <summary>
  6916. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  6917. /// </summary>
  6918. /// <returns></returns>
  6919. [HttpPost]
  6920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6921. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  6922. {
  6923. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6924. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6925. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6926. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6927. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  6928. int id = dto.Id;
  6929. if (id <= 0) //add
  6930. {
  6931. info.CreateUserId = dto.CurrUserId;
  6932. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  6933. if (add < 1) return Ok(JsonView(false));
  6934. id = add;
  6935. }
  6936. else //update
  6937. {
  6938. var upd = await _sqlSugar.Updateable(info)
  6939. .UpdateColumns(x => new {
  6940. x.ChoiceOne,
  6941. x.InsidePay,
  6942. x.VisaRemark,
  6943. x.Visa,
  6944. x.Service,
  6945. x.Safe,
  6946. x.Ticket,
  6947. x.HeSuan,
  6948. x.YiMiao,
  6949. })
  6950. .Where(x => x.Id == id)
  6951. .ExecuteCommandAsync();
  6952. if (upd < 1) return Ok(JsonView(false));
  6953. }
  6954. //消息通知
  6955. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6956. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  6957. }
  6958. /// <summary>
  6959. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  6960. /// </summary>
  6961. /// <returns></returns>
  6962. [HttpPost]
  6963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6964. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  6965. {
  6966. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6967. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6968. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6969. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6970. info.OutsideJJPay = dto.OutsideJJPay;
  6971. info.OutsideGWPay = dto.OutsideGWPay;
  6972. info.OutsideTDPay = dto.OutsideTDPay;
  6973. info.AirJJ = dto.AirJJ;
  6974. info.AirGW = dto.AirGW;
  6975. info.AirTD = dto.AirTD;
  6976. info.CityTranffic = dto.CityTranffic;
  6977. info.SumJJC = dto.ChoiceTwoJJ;
  6978. info.SumGWC = dto.ChoiceTwoGW;
  6979. info.SumTDC = dto.ChoiceTwoTD;
  6980. int id = dto.Id;
  6981. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  6982. if (id <= 0) //add
  6983. {
  6984. info.CreateUserId = dto.CurrUserId;
  6985. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  6986. if (addId <= 0) return Ok(JsonView(false));
  6987. id = addId;
  6988. }
  6989. else //update
  6990. {
  6991. var upd = await _sqlSugar.Updateable(info)
  6992. .UpdateColumns(x => new {
  6993. x.SumJJC,
  6994. x.OutsideJJPay,
  6995. x.SumGWC,
  6996. x.OutsideGWPay,
  6997. x.SumTDC,
  6998. x.OutsideTDPay,
  6999. x.AirJJ,
  7000. x.AirGW,
  7001. x.AirTD,
  7002. x.CityTranffic
  7003. })
  7004. .Where(x => x.Id == id)
  7005. .ExecuteCommandAsync();
  7006. if (upd <1) return Ok(JsonView(false));
  7007. }
  7008. jjcItemTotal = info.AirJJ + info.CityTranffic;
  7009. gwcItemTotal = info.AirGW + info.CityTranffic;
  7010. tdcItemTotal = info.AirTD + info.CityTranffic;
  7011. //消息通知
  7012. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7013. return Ok(JsonView(new
  7014. {
  7015. parentId = id,
  7016. choiceTwoJJ = dto.ChoiceTwoJJ,
  7017. jjcItemTotal = jjcItemTotal,
  7018. choiceTwoGW = dto.ChoiceTwoGW,
  7019. gwcItemTotal = gwcItemTotal,
  7020. choiceTwoTD = dto.ChoiceTwoTD,
  7021. tdcItemTotal = tdcItemTotal
  7022. }));
  7023. }
  7024. /// <summary>
  7025. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  7026. /// </summary>
  7027. /// <returns></returns>
  7028. [HttpPost]
  7029. [ApiExplorerSettings(IgnoreApi = true)]
  7030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7031. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  7032. {
  7033. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7034. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7035. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7036. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  7037. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  7038. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7039. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  7040. var infos = infos1.Select(x => new Grp_DayAndCost
  7041. {
  7042. Id = x.Id,
  7043. DiId = dto.DiId,
  7044. Type = dto.FeeType,
  7045. Days = x.Days,
  7046. NationalTravelFeeId = x.NationalTravelFeeId,
  7047. Cost = x.Cost,
  7048. Currency = x.Currency,
  7049. SubTotal = x.SubTotal,
  7050. CreateUserId = dto.CurrUserId
  7051. })
  7052. .ToList();
  7053. var adds = infos.Where(x => x.Id <= 0).ToList();
  7054. var upds = infos.Where(x => x.Id > 0).ToList();
  7055. if (adds.Count > 0)
  7056. {
  7057. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7058. if (add < 1) return Ok(JsonView(false));
  7059. }
  7060. if (upds.Count > 0)
  7061. {
  7062. var upd = await _sqlSugar.Updateable(adds)
  7063. .UpdateColumns(x => new
  7064. {
  7065. x.Days,
  7066. x.NationalTravelFeeId,
  7067. x.Cost,
  7068. x.Currency,
  7069. x.SubTotal
  7070. })
  7071. .WhereColumns(x => new { x.Id })
  7072. .ExecuteCommandAsync();
  7073. if (upd < 1) return Ok(JsonView(false));
  7074. }
  7075. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7076. //消息通知
  7077. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7078. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7079. return Ok(JsonView(new { itemTotal = itemTotal }));
  7080. }
  7081. /// <summary>
  7082. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  7083. /// </summary>
  7084. /// <returns></returns>
  7085. [HttpPost]
  7086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7087. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  7088. {
  7089. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  7090. int subId = dto.SubId, feeType = dto.FeeType;
  7091. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7092. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7093. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7094. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7095. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  7096. subInfo.Id = subId;
  7097. subInfo.DiId = dto.DiId;
  7098. if (feeType == 3) subInfo.Type = 1;
  7099. else if (feeType == 4) subInfo.Type = 2;
  7100. else if (feeType == 5) subInfo.Type = 3;
  7101. else if (feeType == 6) subInfo.Type = 4;
  7102. subInfo.CreateUserId = dto.CurrUserId;
  7103. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  7104. if (parentId < 1) return Ok(JsonView(false));
  7105. //子表op
  7106. if (subId < 1)
  7107. {
  7108. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7109. if (subAdd < 1) return Ok(JsonView(false));
  7110. }
  7111. else
  7112. {
  7113. var subUpd = await _sqlSugar.Updateable(subInfo)
  7114. .UpdateColumns(x => new
  7115. {
  7116. x.Days,
  7117. x.NationalTravelFeeId,
  7118. x.Cost,
  7119. x.Currency,
  7120. x.SubTotal
  7121. })
  7122. .WhereColumns(x => new { x.Id })
  7123. .ExecuteCommandAsync();
  7124. if (subUpd < 1) return Ok(JsonView(false));
  7125. }
  7126. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  7127. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7128. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  7129. }
  7130. /// <summary>
  7131. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7132. /// </summary>
  7133. /// <returns></returns>
  7134. [HttpPost]
  7135. [ApiExplorerSettings(IgnoreApi = true)]
  7136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7137. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  7138. {
  7139. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7140. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7141. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7142. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  7143. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  7144. {
  7145. Id = x.Id,
  7146. Diid = dto.DiId,
  7147. SetDataId = x.SetDataId,
  7148. Index = x.Index,
  7149. Cost = x.Cost,
  7150. Currency = x.Currency,
  7151. SubTotal = x.SubTotal,
  7152. CreateUserId = dto.CurrUserId,
  7153. Remark = x.Remark
  7154. }).ToList();
  7155. var adds = infos.Where(x => x.Id <= 0).ToList();
  7156. var upds = infos.Where(x => x.Id > 0).ToList();
  7157. if (adds.Count > 0)
  7158. {
  7159. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7160. if (add < 1) return Ok(JsonView(false));
  7161. }
  7162. if (upds.Count > 0)
  7163. {
  7164. var upd = await _sqlSugar.Updateable(adds)
  7165. .UpdateColumns(x => new
  7166. {
  7167. x.Index,
  7168. x.SetDataId,
  7169. x.Cost,
  7170. x.Currency,
  7171. x.SubTotal,
  7172. x.Remark
  7173. })
  7174. .WhereColumns(x => new { x.Id })
  7175. .ExecuteCommandAsync();
  7176. if (upd < 1) return Ok(JsonView(false));
  7177. }
  7178. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7179. //消息通知
  7180. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7181. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7182. return Ok(JsonView(new { itemTotal = itemTotal }));
  7183. }
  7184. /// <summary>
  7185. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  7186. /// </summary>
  7187. /// <returns></returns>
  7188. [HttpPost]
  7189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7190. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  7191. {
  7192. int subId = dto.SubId;
  7193. int diId = dto.Diid;
  7194. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7195. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7196. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7197. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  7198. subInfo.Id = subId;
  7199. subInfo.Diid = dto.Diid;
  7200. subInfo.CreateUserId = dto.CurrUserId;
  7201. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  7202. if (parentId < 1) return Ok(JsonView(false));
  7203. #region 子表op
  7204. if (subId < 1)//add
  7205. {
  7206. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7207. if (subAdd < 1) return Ok(JsonView(false));
  7208. }
  7209. else //upd
  7210. {
  7211. var subUpd = await _sqlSugar.Updateable(subInfo)
  7212. .UpdateColumns(x => new
  7213. {
  7214. x.Index,
  7215. x.SetDataId,
  7216. x.Cost,
  7217. x.Currency,
  7218. x.SubTotal,
  7219. x.Remark
  7220. })
  7221. .WhereColumns(x => new { x.Id })
  7222. .ExecuteCommandAsync();
  7223. if (subUpd < 1) return Ok(JsonView(false));
  7224. }
  7225. #endregion
  7226. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  7227. //消息通知
  7228. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  7229. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  7230. }
  7231. /// <summary>
  7232. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  7233. /// </summary>
  7234. /// <returns></returns>
  7235. [HttpPost]
  7236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7237. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  7238. {
  7239. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7240. if (data.Code != 0)
  7241. {
  7242. return Ok(JsonView(false, data.Msg));
  7243. }
  7244. return Ok(JsonView(true, "操作成功!", data.Data));
  7245. }
  7246. /// <summary>
  7247. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  7248. /// </summary>
  7249. /// <param name="dto"></param>
  7250. /// <returns></returns>
  7251. [HttpPost]
  7252. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  7253. {
  7254. var data = new Grp_DayOtherPrice()
  7255. {
  7256. Id = dto.Id,
  7257. IsDel = 1,
  7258. DeleteUserId = dto.DeleteUserId,
  7259. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7260. };
  7261. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7262. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  7263. return Ok(JsonView(false,"删除失败!"));
  7264. }
  7265. #endregion
  7266. #endregion
  7267. #region 签证费用录入
  7268. /// <summary>
  7269. /// 根据diid查询签证费用列表
  7270. /// </summary>
  7271. /// <param name="dto"></param>
  7272. /// <returns></returns>
  7273. [HttpPost]
  7274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7275. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  7276. {
  7277. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  7278. if (groupData.Code != 0)
  7279. {
  7280. return Ok(JsonView(false, groupData.Msg));
  7281. }
  7282. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7283. }
  7284. /// <summary>
  7285. /// 根据签证费用Id查询单条数据及c表数据
  7286. /// </summary>
  7287. /// <param name="dto"></param>
  7288. /// <returns></returns>
  7289. [HttpPost]
  7290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7291. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  7292. {
  7293. Result groupData = await _visaPriceRep.PostVisaById(dto);
  7294. if (groupData.Code != 0)
  7295. {
  7296. return Ok(JsonView(false, groupData.Msg));
  7297. }
  7298. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7299. }
  7300. /// <summary>
  7301. /// 签证费用删除
  7302. /// </summary>
  7303. /// <param name="dto"></param>
  7304. /// <returns></returns>
  7305. [HttpPost]
  7306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7307. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  7308. {
  7309. _sqlSugar.BeginTran();
  7310. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  7311. if (!res)
  7312. {
  7313. _sqlSugar.RollbackTran();
  7314. return Ok(JsonView(false, "删除失败"));
  7315. }
  7316. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  7317. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  7318. .SetColumns(a => new Grp_CreditCardPayment()
  7319. {
  7320. IsDel = 1,
  7321. DeleteUserId = dto.DeleteUserId,
  7322. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7323. })
  7324. .ExecuteCommand();
  7325. if (resSub < 1)
  7326. {
  7327. _sqlSugar.RollbackTran();
  7328. return Ok(JsonView(false, "删除失败"));
  7329. }
  7330. _sqlSugar.CommitTran();
  7331. return Ok(JsonView(true, "删除成功!"));
  7332. }
  7333. /// <summary>
  7334. /// 签证费用录入下拉框初始化
  7335. /// </summary>
  7336. /// <returns></returns>
  7337. [HttpPost]
  7338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7339. public async Task<IActionResult> VisaPriceAddSelect()
  7340. {
  7341. //支付方式
  7342. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  7343. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  7344. //币种
  7345. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  7346. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  7347. //乘客类型
  7348. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  7349. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  7350. //卡类型
  7351. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  7352. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  7353. //代办费类型
  7354. var agencyFeeTypeData = new List<dynamic>() {
  7355. new { id = 0 , Text = "未选择" },
  7356. new { id = 1 , Text = "小公务" },
  7357. new { id = 2 , Text = "大公务" },
  7358. };
  7359. //签证费用标准国家Data
  7360. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  7361. var data = new
  7362. {
  7363. Payment = _Payment,
  7364. CurrencyList = _CurrencyList,
  7365. PassengerType = _PassengerType,
  7366. BankCard = _BankCard,
  7367. AgencyFeeType = agencyFeeTypeData,
  7368. CountryFeeData = visaCountryFeeData
  7369. };
  7370. return Ok(JsonView(true, "查询成功!", data));
  7371. }
  7372. /// <summary>
  7373. /// 签证费用录入操作(Status:1.新增,2.修改)
  7374. /// </summary>
  7375. /// <param name="dto"></param>
  7376. /// <returns></returns>
  7377. [HttpPost]
  7378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7379. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  7380. {
  7381. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  7382. if (groupData.Code != 0)
  7383. {
  7384. return Ok(JsonView(false, groupData.Msg));
  7385. }
  7386. #region 应用推送
  7387. try
  7388. {
  7389. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7390. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7391. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7392. //2024-10-21 新增LZ UID
  7393. var userIds = new List<int>() { 21 };
  7394. string title = $"系统通知";
  7395. string content = "";
  7396. var diId = dto.DiId;
  7397. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7398. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7399. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7400. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7401. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7402. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7403. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7404. }
  7405. catch (Exception ex)
  7406. {
  7407. }
  7408. #endregion
  7409. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7410. }
  7411. #endregion
  7412. #region 签证提成录入
  7413. /// <summary>
  7414. /// 签证提成录入
  7415. /// 基础数据
  7416. /// </summary>
  7417. /// <param name="_dto"></param>
  7418. /// <returns></returns>
  7419. [HttpGet]
  7420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7421. public async Task<IActionResult> VisaCommissionInit()
  7422. {
  7423. return Ok(await _visaCommissionRep.Init());
  7424. }
  7425. /// <summary>
  7426. /// 签证提成录入
  7427. /// Item
  7428. /// </summary>
  7429. /// <param name="_dto"></param>
  7430. /// <returns></returns>
  7431. [HttpPost]
  7432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7433. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  7434. {
  7435. var validator = new VisaCommissionItemDtoValidator();
  7436. var validatorRes = await validator.ValidateAsync(_dto);
  7437. if (!validatorRes.IsValid)
  7438. {
  7439. StringBuilder sb = new StringBuilder();
  7440. foreach (var item in validatorRes.Errors)
  7441. {
  7442. sb.AppendLine(item.ErrorMessage);
  7443. }
  7444. return Ok(JsonView(false, sb.ToString()));
  7445. }
  7446. return Ok(await _visaCommissionRep.Item(_dto));
  7447. }
  7448. /// <summary>
  7449. /// 签证提成录入
  7450. /// Save
  7451. /// </summary>
  7452. /// <param name="_dto"></param>
  7453. /// <returns></returns>
  7454. [HttpPost]
  7455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7456. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  7457. {
  7458. //参数验证
  7459. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  7460. foreach (var item in _dto.Items)
  7461. {
  7462. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  7463. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  7464. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  7465. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  7466. }
  7467. return Ok(await _visaCommissionRep.Save(_dto));
  7468. }
  7469. /// <summary>
  7470. /// 签证提成录入
  7471. /// Create
  7472. /// </summary>
  7473. /// <param name="_dto"></param>
  7474. /// <returns></returns>
  7475. [HttpPost]
  7476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7477. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  7478. {
  7479. var validator = new VisaCommissionCreateDtoValidator();
  7480. var validatorRes = await validator.ValidateAsync(_dto);
  7481. if (!validatorRes.IsValid)
  7482. {
  7483. StringBuilder sb = new StringBuilder();
  7484. foreach (var item in validatorRes.Errors)
  7485. {
  7486. sb.AppendLine(item.ErrorMessage);
  7487. }
  7488. return Ok(JsonView(false, sb.ToString()));
  7489. }
  7490. return Ok(await _visaCommissionRep.Create(_dto));
  7491. }
  7492. /// <summary>
  7493. /// 签证提成录入
  7494. /// Put(编辑)
  7495. /// </summary>
  7496. /// <param name="id"></param>
  7497. /// <param name="_dto"></param>
  7498. /// <returns></returns>
  7499. [HttpPut]
  7500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7501. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  7502. {
  7503. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7504. var validator = new VisaCommissionCreateDtoValidator();
  7505. var validatorRes = await validator.ValidateAsync(_dto);
  7506. if (!validatorRes.IsValid)
  7507. {
  7508. StringBuilder sb = new StringBuilder();
  7509. foreach (var item in validatorRes.Errors)
  7510. {
  7511. sb.AppendLine(item.ErrorMessage);
  7512. }
  7513. return Ok(JsonView(false, sb.ToString()));
  7514. }
  7515. return Ok(await _visaCommissionRep.Edit(id, _dto));
  7516. }
  7517. /// <summary>
  7518. /// 签证提成录入
  7519. /// Del
  7520. /// </summary>
  7521. /// <param name="id"></param>
  7522. /// <param name="currUserId"></param>
  7523. /// <returns></returns>
  7524. [HttpPost]
  7525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7526. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  7527. {
  7528. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7529. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  7530. return Ok(await _visaCommissionRep.Del(id, currUserId));
  7531. }
  7532. #endregion
  7533. #region op费用录入
  7534. /// <summary>
  7535. /// 根据diid查询op费用列表
  7536. /// </summary>
  7537. /// <param name="dto"></param>
  7538. /// <returns></returns>
  7539. [HttpPost]
  7540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7541. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  7542. {
  7543. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  7544. if (groupData.Code != 0)
  7545. {
  7546. return Ok(JsonView(false, groupData.Msg));
  7547. }
  7548. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7549. }
  7550. /// <summary>
  7551. /// 根据op费用Id查询单条数据及c表数据
  7552. /// </summary>
  7553. /// <param name="dto"></param>
  7554. /// <returns></returns>
  7555. [HttpPost]
  7556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7557. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  7558. {
  7559. try
  7560. {
  7561. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  7562. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  7563. var data = new
  7564. {
  7565. CarTouristGuideGround = _groupData,
  7566. CreditCardPayment = _creditCardPayment
  7567. };
  7568. return Ok(JsonView(true, "查询成功!", data));
  7569. }
  7570. catch (Exception ex)
  7571. {
  7572. return Ok(JsonView(false, "程序错误!"));
  7573. }
  7574. }
  7575. /// <summary>
  7576. /// op费用删除
  7577. /// </summary>
  7578. /// <param name="dto"></param>
  7579. /// <returns></returns>
  7580. [HttpPost]
  7581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7582. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  7583. {
  7584. try
  7585. {
  7586. _sqlSugar.BeginTran();
  7587. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7588. if (!res)
  7589. {
  7590. return Ok(JsonView(false, "删除失败"));
  7591. }
  7592. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  7593. {
  7594. IsDel = 1,
  7595. DeleteUserId = dto.DeleteUserId,
  7596. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7597. }).ExecuteCommandAsync();
  7598. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  7599. {
  7600. IsDel = 1,
  7601. DeleteUserId = dto.DeleteUserId,
  7602. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7603. }).ExecuteCommandAsync();
  7604. #region 删除超支相关数据
  7605. //删除导入的超支数据
  7606. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  7607. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  7608. {
  7609. IsDel = 1,
  7610. DeleteUserId = dto.DeleteUserId,
  7611. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7612. }).ExecuteCommand();
  7613. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  7614. {
  7615. IsDel = 1,
  7616. DeleteUserId = dto.DeleteUserId,
  7617. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7618. }).ExecuteCommand();
  7619. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  7620. {
  7621. IsDel = 1,
  7622. DeleteUserId = dto.DeleteUserId,
  7623. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7624. }).ExecuteCommand();
  7625. #endregion
  7626. _sqlSugar.CommitTran();
  7627. return Ok(JsonView(true, "删除成功!"));
  7628. }
  7629. catch (Exception ex)
  7630. {
  7631. _sqlSugar.RollbackTran();
  7632. return Ok(JsonView(false, "程序错误!" + ex.Message));
  7633. }
  7634. }
  7635. /// <summary>
  7636. /// op费用录入操作(Status:1.新增,2.修改)
  7637. /// </summary>
  7638. /// <param name="dto"></param>
  7639. /// <returns></returns>
  7640. [HttpPost]
  7641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7642. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  7643. {
  7644. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  7645. if (groupData.Code != 0)
  7646. {
  7647. return Ok(JsonView(false, groupData.Msg));
  7648. }
  7649. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7650. }
  7651. /// <summary>
  7652. /// 填写费用详细页面初始化绑定
  7653. /// </summary>
  7654. /// <param name="dto"></param>
  7655. /// <returns></returns>
  7656. [HttpPost]
  7657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7658. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  7659. {
  7660. try
  7661. {
  7662. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  7663. if (groupData.Code != 0)
  7664. {
  7665. return Ok(JsonView(false, groupData.Msg));
  7666. }
  7667. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7668. }
  7669. catch (Exception ex)
  7670. {
  7671. return Ok(JsonView(false, ex.Message));
  7672. }
  7673. }
  7674. /// <summary>
  7675. /// 根据op费用Id查询详细数据
  7676. /// </summary>
  7677. /// <param name="dto"></param>
  7678. /// <returns></returns>
  7679. [HttpPost]
  7680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7681. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  7682. {
  7683. try
  7684. {
  7685. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  7686. if (groupData.Code != 0)
  7687. {
  7688. return Ok(JsonView(false, groupData.Msg));
  7689. }
  7690. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7691. }
  7692. catch (Exception ex)
  7693. {
  7694. return Ok(JsonView(false, ex.Message));
  7695. }
  7696. }
  7697. /// <summary>
  7698. /// OP费用录入填写详情
  7699. /// </summary>
  7700. /// <param name="dto"></param>
  7701. /// <returns></returns>
  7702. [HttpPost]
  7703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7704. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  7705. {
  7706. try
  7707. {
  7708. #region 参数校验
  7709. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  7710. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  7711. if (di == null) return Ok(JsonView(false, "团组错误!"));
  7712. #endregion
  7713. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  7714. if (groupData.Code != 0)
  7715. {
  7716. return Ok(JsonView(false, groupData.Msg));
  7717. }
  7718. //自动审核
  7719. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  7720. #region 应用推送
  7721. try
  7722. {
  7723. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7724. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7725. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7726. //2024-10-21 新增LZ UID
  7727. var userIds = new List<int>() { 21 };
  7728. string title = $"系统通知";
  7729. var diId = dto.DiId;
  7730. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7731. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7732. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  7733. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7734. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7735. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7736. }
  7737. catch (Exception ex)
  7738. {
  7739. }
  7740. #endregion
  7741. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7742. }
  7743. catch (Exception ex)
  7744. {
  7745. return Ok(JsonView(false, ex.Message));
  7746. }
  7747. }
  7748. /// <summary>
  7749. /// 获取三公详细所有城市
  7750. /// </summary>
  7751. /// <returns></returns>
  7752. [HttpGet]
  7753. public IActionResult OpCarCityResult()
  7754. {
  7755. var jw = JsonView(false);
  7756. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  7757. {
  7758. x.Id,
  7759. x.Country,
  7760. x.City,
  7761. }).ToList();
  7762. if (data.Count > 0)
  7763. {
  7764. jw = JsonView(true, "获取成功!", data);
  7765. }
  7766. else
  7767. {
  7768. jw.Msg = "城市数据为空!";
  7769. jw.Data = new string[0];
  7770. }
  7771. return Ok(jw);
  7772. }
  7773. /// <summary>
  7774. /// 导出地接费用明细
  7775. /// </summary>
  7776. /// <param name="dto"></param>
  7777. /// <returns></returns>
  7778. [HttpPost]
  7779. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  7780. {
  7781. var jw = JsonView(false);
  7782. if (dto.Diid < 1)
  7783. {
  7784. jw.Msg = "请输入正确的diid!";
  7785. return Ok(jw);
  7786. }
  7787. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  7788. if (group == null)
  7789. {
  7790. jw.Msg = "未找到团组信息!";
  7791. return Ok(jw);
  7792. }
  7793. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  7794. if (localGuideArr.Count == 0)
  7795. {
  7796. jw.Msg = "该团组暂无地接信息!";
  7797. return Ok(jw);
  7798. }
  7799. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  7800. var overspendSoure = new Dictionary<int, int>
  7801. {
  7802. { 91, 982 }, //车
  7803. { 92 , 1059} ,//导游
  7804. { 994 , 1073}, //翻译
  7805. { 988 , 1074 }, //早餐
  7806. { 93 , 1075 }, //午餐
  7807. { 989 , 1076 }, //晚餐
  7808. };
  7809. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  7810. foreach (var groupArr in localGroup)
  7811. {
  7812. var keyValue = groupArr.Key;
  7813. if (int.TryParse(keyValue, out int cityid))
  7814. {
  7815. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  7816. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  7817. }
  7818. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  7819. foreach (var item in groupArr)
  7820. {
  7821. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  7822. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  7823. new Grp_CarTouristGuideGroundReservationsContentExtend
  7824. {
  7825. Count = a.Count,
  7826. CreateTime = a.CreateTime,
  7827. CreateUserId = a.CreateUserId,
  7828. CTGGRId = a.CTGGRId,
  7829. Currency = a.Currency,
  7830. DatePrice = a.DatePrice,
  7831. DeleteTime = a.DeleteTime,
  7832. DeleteUserId = a.DeleteUserId,
  7833. DiId = a.DiId,
  7834. Id = a.Id,
  7835. IsDel = a.IsDel,
  7836. Price = a.Price,
  7837. PriceContent = a.PriceContent,
  7838. Remark = a.Remark,
  7839. SId = a.SId,
  7840. SidName = b.Name,
  7841. Units = a.Units,
  7842. }
  7843. ).ToList();
  7844. if (content.Count > 0)
  7845. {
  7846. contentArr.Add(content);
  7847. }
  7848. }
  7849. //open excel
  7850. //set excel
  7851. //save excel
  7852. try
  7853. {
  7854. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  7855. IWorkbook workbook;
  7856. if (Path.GetExtension(filePath).ToLower() == ".xls")
  7857. {
  7858. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7859. }
  7860. else
  7861. {
  7862. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7863. }
  7864. ISheet sheet = workbook.GetSheetAt(0);
  7865. var rowStartIndex = 2;
  7866. var clounmCount = 10;
  7867. var initStyleRow = sheet.GetRow(2);
  7868. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7869. //var overspendArrDetail =
  7870. var existsId = new List<CarCompare>();
  7871. var lastElem = arr.Last();
  7872. var thisSid = -1;
  7873. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7874. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7875. {
  7876. Name = "未知币种!",
  7877. Remark = "未知币种!",
  7878. };
  7879. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7880. Action cloneRowFn = () =>
  7881. {
  7882. rowStartIndex++;
  7883. var cloneRow = sheet.CreateRow(rowStartIndex);
  7884. // 复制样式
  7885. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7886. {
  7887. ICell sourceCell = initStyleRow.GetCell(i);
  7888. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7889. // 确保单元格存在样式
  7890. if (sourceCell.CellStyle != null)
  7891. {
  7892. targetCell.CellStyle = sourceCell.CellStyle;
  7893. }
  7894. }
  7895. };
  7896. var mergeRow = () =>
  7897. {
  7898. for (int i = 2; i < sheet.LastRowNum; i++)
  7899. {
  7900. var row = sheet.GetRow(i);
  7901. var cellFirst = row.GetCell(0);
  7902. var thisIndex = i + 1;
  7903. while (thisIndex < sheet.LastRowNum)
  7904. {
  7905. var nextRow = sheet.GetRow(thisIndex);
  7906. var nextCellFirst = nextRow.GetCell(0);
  7907. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7908. {
  7909. thisIndex++;
  7910. }
  7911. else
  7912. {
  7913. break;
  7914. }
  7915. }
  7916. thisIndex--;
  7917. if (thisIndex != i)
  7918. {
  7919. //合并row
  7920. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7921. i, // 起始行索引(0-based)
  7922. thisIndex, // 结束行索引(0-based)
  7923. 0, // 起始列索引(0-based)
  7924. 0 // 结束列索引(0-based)
  7925. );
  7926. sheet.AddMergedRegion(cellRangeAddress);
  7927. i = thisIndex;
  7928. }
  7929. }
  7930. };
  7931. var chaoshiNumber = 0;
  7932. var totalNumber = 0.00M;
  7933. string lastStr = "";
  7934. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7935. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7936. {
  7937. b.IsAuditGM,
  7938. x.Id,
  7939. x.Area,
  7940. b.PayPercentage,
  7941. b.PayMoney,
  7942. }).ToList();
  7943. string yesPayment = "", noPayment = "";
  7944. foreach (var item in queryCarArrByCityAndDiid)
  7945. {
  7946. if (item.IsAuditGM == 1)
  7947. {
  7948. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7949. }
  7950. else
  7951. {
  7952. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7953. }
  7954. }
  7955. lastStr = yesPayment + noPayment;
  7956. foreach (var item in arr)
  7957. {
  7958. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  7959. {
  7960. if (thisSid != item.SId)
  7961. {
  7962. if (thisSid == -1)
  7963. {
  7964. thisSid = item.SId;
  7965. }
  7966. else
  7967. {
  7968. //合并小计行
  7969. //创建合并区域的实例
  7970. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7971. rowStartIndex, // 起始行索引(0-based)
  7972. rowStartIndex, // 结束行索引(0-based)
  7973. 0, // 起始列索引(0-based)
  7974. 3 // 结束列索引(0-based)
  7975. );
  7976. sheet.AddMergedRegion(cellRangeAddress);
  7977. var CellStyle = workbook.CreateCellStyle();
  7978. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7979. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7980. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7981. for (int i = 0; i <= clounmCount; i++)
  7982. {
  7983. if (i > 6)
  7984. {
  7985. var CellStyle1 = workbook.CreateCellStyle();
  7986. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7987. IFont Font = workbook.CreateFont(); // 创建字体
  7988. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7989. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7990. CellStyle1.SetFont(Font);
  7991. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7992. }
  7993. else
  7994. {
  7995. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7996. }
  7997. }
  7998. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7999. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8000. //超时合计
  8001. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8002. //超时数
  8003. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8004. //超时合计费用
  8005. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8006. thisSid = item.SId;
  8007. cloneRowFn();
  8008. chaoshiNumber = 0;
  8009. totalNumber = 0;
  8010. }
  8011. }
  8012. IRow row = sheet.GetRow(rowStartIndex);
  8013. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8014. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  8015. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  8016. if (isOpenOverspendSoure)
  8017. {
  8018. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8019. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  8020. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  8021. }
  8022. for (int i = 0; i <= clounmCount; i++)
  8023. {
  8024. var cell = row.GetCell(i);
  8025. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  8026. if (cell == null)
  8027. {
  8028. cell = row.CreateCell(i);
  8029. }
  8030. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  8031. fontRed.CloneStyleFrom(cell.CellStyle);
  8032. IFont Font = workbook.CreateFont(); // 创建字体
  8033. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  8034. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8035. fontRed.SetFont(Font);
  8036. byte[] rgb = new byte[3] { 255, 242, 204 };
  8037. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  8038. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  8039. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  8040. if (workbook is XSSFWorkbook)
  8041. {
  8042. BackgroundColor255_242_204.FillForegroundColor = 0;
  8043. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  8044. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  8045. }
  8046. else
  8047. {
  8048. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  8049. }
  8050. if (i == 1 || i > 6)
  8051. {
  8052. if (i > 6)
  8053. {
  8054. fontRed.FillForegroundColor = 0;
  8055. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  8056. fontRed.FillPattern = FillPattern.SolidForeground;
  8057. }
  8058. cell.CellStyle = fontRed;
  8059. }
  8060. if (i > 2 && i < 7)
  8061. {
  8062. cell.CellStyle = BackgroundColor255_242_204;
  8063. }
  8064. cell.SetCellValue(setCellValue); //写入单元格
  8065. }
  8066. if (overspendSoure.ContainsKey(thisSid))
  8067. {
  8068. var overspendId = overspendSoure[thisSid];
  8069. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8070. }
  8071. cloneRowFn();
  8072. existsId.Add(new CarCompare
  8073. {
  8074. DataPrice = item.DatePrice.ObjToDate(),
  8075. Sid = item.SId
  8076. });
  8077. }
  8078. if (item.Equals(lastElem))
  8079. {
  8080. //合并小计行
  8081. //创建合并区域的实例
  8082. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8083. rowStartIndex, // 起始行索引(0-based)
  8084. rowStartIndex, // 结束行索引(0-based)
  8085. 0, // 起始列索引(0-based)
  8086. 3 // 结束列索引(0-based)
  8087. );
  8088. sheet.AddMergedRegion(cellRangeAddress);
  8089. var CellStyle = workbook.CreateCellStyle();
  8090. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8091. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8092. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8093. for (int i = 0; i <= clounmCount; i++)
  8094. {
  8095. if (i > 6)
  8096. {
  8097. var CellStyle1 = workbook.CreateCellStyle();
  8098. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8099. IFont Font = workbook.CreateFont(); // 创建字体
  8100. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8101. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8102. CellStyle1.SetFont(Font);
  8103. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8104. }
  8105. else
  8106. {
  8107. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8108. }
  8109. }
  8110. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8111. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8112. //超时合计
  8113. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8114. //超时数
  8115. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8116. //超时合计费用
  8117. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8118. cloneRowFn();
  8119. // 创建合并区域的实例
  8120. cellRangeAddress = new CellRangeAddress(
  8121. rowStartIndex, // 起始行索引(0-based)
  8122. rowStartIndex, // 结束行索引(0-based)
  8123. 0, // 起始列索引(0-based)
  8124. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  8125. );
  8126. // 添加合并区域
  8127. sheet.AddMergedRegion(cellRangeAddress);
  8128. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  8129. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  8130. }
  8131. }
  8132. mergeRow();
  8133. // 保存修改后的Excel文件到新文件
  8134. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  8135. // new FileStream(newFilePath, FileMode.CreateNew)
  8136. using (var stream = new MemoryStream())
  8137. {
  8138. workbook.Write(stream, true);
  8139. stream.Flush();
  8140. stream.Seek(0, SeekOrigin.Begin);
  8141. MemoryStream memoryStream = new MemoryStream();
  8142. stream.CopyTo(memoryStream);
  8143. memoryStream.Seek(0, SeekOrigin.Begin);
  8144. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  8145. }
  8146. workbook.Close();
  8147. workbook.Dispose();
  8148. }
  8149. catch (Exception ex)
  8150. {
  8151. jw.Msg = "出现异常!" + ex.Message;
  8152. return Ok(jw);
  8153. }
  8154. }
  8155. if (Zips.Count > 0)
  8156. {
  8157. IOOperatorHelper io = new IOOperatorHelper();
  8158. var byts = io.ConvertZipStream(Zips);
  8159. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  8160. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  8161. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  8162. }
  8163. else
  8164. {
  8165. jw.Msg = "暂无生成文件!";
  8166. }
  8167. return Ok(jw);
  8168. }
  8169. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  8170. {
  8171. string outStr = string.Empty;
  8172. switch (i)
  8173. {
  8174. case 0:
  8175. outStr = arr[0].SidName;
  8176. break;
  8177. case 1:
  8178. outStr = arr[0].DataPriceStr;
  8179. break;
  8180. case 2:
  8181. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  8182. break;
  8183. case 4:
  8184. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  8185. break;
  8186. case 7:
  8187. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8188. {
  8189. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  8190. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  8191. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  8192. }
  8193. break;
  8194. case 8:
  8195. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8196. {
  8197. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  8198. }
  8199. break;
  8200. case 9:
  8201. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8202. {
  8203. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  8204. }
  8205. break;
  8206. case 10:
  8207. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8208. {
  8209. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  8210. }
  8211. break;
  8212. }
  8213. return outStr;
  8214. }
  8215. #region OP行程单
  8216. /// <summary>
  8217. /// OP行程单初始化
  8218. /// </summary>
  8219. /// <param name="dto"></param>
  8220. /// <returns></returns>
  8221. [HttpPost]
  8222. public IActionResult InitOpTravel(InitOpTravelDto dto)
  8223. {
  8224. var jw = JsonView(false);
  8225. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  8226. var group = groupList.First();
  8227. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  8228. if (group == null)
  8229. {
  8230. jw.Msg = "暂无团组!";
  8231. return Ok(jw);
  8232. }
  8233. group = groupList.Find(x => x.Id == diid);
  8234. if (group == null)
  8235. {
  8236. jw.Msg = "请输入正确的团组ID!";
  8237. return Ok(jw);
  8238. }
  8239. string city = string.Empty;
  8240. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  8241. if (blackCode.Count > 0)
  8242. {
  8243. var black = blackCode.First();
  8244. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  8245. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  8246. if (blackSp.Length > 0)
  8247. {
  8248. try
  8249. {
  8250. var cityArrCode = new List<string>(20);
  8251. foreach (var item in blackSp)
  8252. {
  8253. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  8254. var IndexSelect = itemSp[2];
  8255. var cityArrCodeLength = cityArrCode.Count - 1;
  8256. var startCity = IndexSelect.Substring(0, 3);
  8257. if (cityArrCodeLength > 0)
  8258. {
  8259. var arrEndCity = cityArrCode[cityArrCodeLength];
  8260. if (arrEndCity != startCity)
  8261. {
  8262. cityArrCode.Add(startCity.ToUpper());
  8263. }
  8264. }
  8265. else
  8266. {
  8267. cityArrCode.Add(startCity.ToUpper());
  8268. }
  8269. var endCity = IndexSelect.Substring(3, 3);
  8270. cityArrCode.Add(endCity.ToUpper());
  8271. }
  8272. var cityThree = string.Empty;
  8273. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  8274. cityThree = cityThree.TrimEnd(',');
  8275. if (string.IsNullOrWhiteSpace(cityThree))
  8276. {
  8277. throw new
  8278. Exception("error");
  8279. }
  8280. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  8281. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  8282. foreach (var item in cityArrCode)
  8283. {
  8284. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  8285. if (find != null)
  8286. {
  8287. city += find.City + "/";
  8288. }
  8289. else
  8290. {
  8291. city += item + "三字码未收入/";
  8292. }
  8293. }
  8294. city = city.TrimEnd('/');
  8295. }
  8296. catch (Exception e)
  8297. {
  8298. city = "黑屏代码格式不正确!";
  8299. }
  8300. }
  8301. }
  8302. else
  8303. {
  8304. city = "未录入黑屏代码";
  8305. }
  8306. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  8307. {
  8308. Date = x.Date,
  8309. Days = x.Days,
  8310. Diffgroup = x.Diffgroup,
  8311. Diid = x.Diid,
  8312. Traffic_First = x.Traffic_First,
  8313. Traffic_Second = x.Traffic_Second,
  8314. Trip = x.Trip,
  8315. WeekDay = x.WeekDay,
  8316. Id = x.Id
  8317. }).ToList();
  8318. jw.Data = new
  8319. {
  8320. groupList = groupList.Select(x => new
  8321. {
  8322. x.Id,
  8323. x.TeamName,
  8324. x.TourCode
  8325. }).ToList(),
  8326. groupInfo = new
  8327. {
  8328. group.VisitDays,
  8329. group.TourCode,
  8330. group.VisitPNumber,
  8331. group.TeamName,
  8332. city
  8333. },
  8334. OpTravelList
  8335. };
  8336. jw.Code = 200;
  8337. jw.Msg = "操作成功!";
  8338. return Ok(jw);
  8339. }
  8340. /// <summary>
  8341. /// 删除团组行程单
  8342. /// </summary>
  8343. /// <returns></returns>
  8344. [HttpPost]
  8345. public IActionResult DelTravel(DelOpTravelDto dto)
  8346. {
  8347. var jw = JsonView(false);
  8348. if (dto.UserId <= 0 || dto.Diid <= 0)
  8349. {
  8350. jw.Msg = "请输入正确的参数!";
  8351. return Ok(jw);
  8352. }
  8353. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  8354. .SetColumns(x => new Grp_TravelList
  8355. {
  8356. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8357. DeleteUserId = dto.UserId,
  8358. IsDel = 1,
  8359. }).ExecuteCommand();
  8360. jw = JsonView(true);
  8361. return Ok(jw);
  8362. }
  8363. /// <summary>
  8364. /// 行程单保存
  8365. /// </summary>
  8366. /// <returns></returns>
  8367. [HttpPost]
  8368. public IActionResult TravelSave(TravelSaveDto dto)
  8369. {
  8370. var jw = JsonView(false);
  8371. if (dto.Arr.Count > 0)
  8372. {
  8373. try
  8374. {
  8375. _sqlSugar.BeginTran();
  8376. foreach (var item in dto.Arr)
  8377. {
  8378. if (item.Id == 0)
  8379. {
  8380. throw new Exception("请传入正确的Id");
  8381. }
  8382. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  8383. .SetColumns(x => new Grp_TravelList
  8384. {
  8385. Trip = item.Trip
  8386. }).ExecuteCommand();
  8387. }
  8388. _sqlSugar.CommitTran();
  8389. jw = JsonView(true);
  8390. }
  8391. catch (Exception ex)
  8392. {
  8393. _sqlSugar.RollbackTran();
  8394. jw.Msg = "程序异常!" + ex.Message;
  8395. }
  8396. }
  8397. else
  8398. {
  8399. jw.Msg = "请传入正确的参数!";
  8400. }
  8401. return Ok(jw);
  8402. }
  8403. /// <summary>
  8404. /// 导出行程单
  8405. /// </summary>
  8406. /// <param name="dto"></param>
  8407. /// <returns></returns>
  8408. [HttpPost]
  8409. public IActionResult ExportTravel(ExportTravelDto dto)
  8410. {
  8411. var jw = JsonView(false);
  8412. jw.Data = "";
  8413. int diid = 0;
  8414. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  8415. if (Find == null)
  8416. {
  8417. jw.Msg = "请选择正确的团组!";
  8418. return Ok(jw);
  8419. }
  8420. else
  8421. {
  8422. diid = Find.Id;
  8423. }
  8424. //数据源
  8425. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  8426. DataTable dtBlack = null;
  8427. try
  8428. {
  8429. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  8430. }
  8431. catch (Exception)
  8432. {
  8433. jw.Msg = "机票黑屏代码有误!";
  8434. return Ok(jw);
  8435. }
  8436. string CityStr = string.Empty;
  8437. if (dtBlack.Rows.Count == 0)
  8438. {
  8439. jw.Msg = "机票黑屏代码有误!";
  8440. return Ok(jw);
  8441. }
  8442. else
  8443. {
  8444. foreach (DataRow row in dtBlack.Rows)
  8445. {
  8446. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  8447. {
  8448. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  8449. return Ok(jw);
  8450. }
  8451. }
  8452. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  8453. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  8454. }
  8455. //创建数据源Table
  8456. DataTable dtSource = new DataTable();
  8457. dtSource.Columns.Add("Days", typeof(string));
  8458. dtSource.Columns.Add("Date", typeof(string));
  8459. dtSource.Columns.Add("Week", typeof(string));
  8460. dtSource.Columns.Add("Traffic", typeof(string));
  8461. dtSource.Columns.Add("Trip", typeof(string));
  8462. //获取数据,放到datatable
  8463. foreach (var item in _travelList)
  8464. {
  8465. DataRow dr = dtSource.NewRow();
  8466. dr["Days"] = item.Days;
  8467. dr["Date"] = item.Date;
  8468. dr["Week"] = item.WeekDay;
  8469. dr["Traffic"] = item.Traffic_First
  8470. + "\r\n"
  8471. + item.Traffic_Second;
  8472. dr["Trip"] = item.Trip;
  8473. dtSource.Rows.Add(dr);
  8474. }
  8475. Dictionary<string, string> dic = new Dictionary<string, string>();
  8476. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  8477. dic.Add("City", CityStr);
  8478. dic.Add("Days", Find.VisitDays.ToString());
  8479. dic.Add("DeleCode", Find.TourCode);
  8480. dic.Add("Pnum", Find.VisitPNumber.ToString());
  8481. //模板路径
  8482. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  8483. //载入模板
  8484. Document doc = null;
  8485. DocumentBuilder builder = null;
  8486. try
  8487. {
  8488. //载入模板
  8489. doc = new Document(tempPath);
  8490. builder = new DocumentBuilder(doc);
  8491. }
  8492. catch (Exception)
  8493. {
  8494. jw.Msg = "模板位置不存在!";
  8495. return Ok(jw);
  8496. }
  8497. foreach (var key in dic.Keys)
  8498. {
  8499. Bookmark bookmark = doc.Range.Bookmarks[key];
  8500. if (bookmark != null)
  8501. {
  8502. builder.MoveToBookmark(key);
  8503. builder.Write(dic[key]);
  8504. }
  8505. }
  8506. //获取word里所有表格
  8507. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8508. //获取所填表格的序数
  8509. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8510. try
  8511. {
  8512. //循环赋值
  8513. for (int i = 0; i < dtSource.Rows.Count; i++)
  8514. {
  8515. builder.MoveToCell(0, i + 1, 0, 0);
  8516. builder.Write(dtSource.Rows[i]["Days"].ToString());
  8517. builder.MoveToCell(0, i + 1, 1, 0);
  8518. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  8519. builder.MoveToCell(0, i + 1, 2, 0);
  8520. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  8521. var trip = dtSource.Rows[i]["Trip"].ToString();
  8522. builder.MoveToCell(0, i + 1, 3, 0);
  8523. builder.Write(trip);
  8524. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  8525. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8526. // 获取特定索引的段落
  8527. Paragraph paragraph = (Paragraph)paragraphs[0];
  8528. Run run = paragraph.Runs[0];
  8529. Aspose.Words.Font font = run.Font;
  8530. font.Name = "黑体";
  8531. //设置双休红色
  8532. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  8533. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8534. paragraph = (Paragraph)paragraphs[1];
  8535. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  8536. {
  8537. run = paragraph.Runs[0];
  8538. font = run.Font;
  8539. font.Color = Color.Red;
  8540. }
  8541. }
  8542. }
  8543. catch (Exception ex)
  8544. {
  8545. }
  8546. //删除多余行
  8547. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  8548. {
  8549. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  8550. }
  8551. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  8552. if (!Directory.Exists(savePath))
  8553. {
  8554. try
  8555. {
  8556. Directory.CreateDirectory(savePath);
  8557. }
  8558. catch
  8559. {
  8560. }
  8561. }
  8562. string path = savePath + Find.TeamName + "出访日程";
  8563. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  8564. try
  8565. {
  8566. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  8567. string postfix = ".docx";
  8568. if (dto.IsPDF == 1)
  8569. {
  8570. saveFormat = Aspose.Words.SaveFormat.Pdf;
  8571. postfix = ".pdf";
  8572. }
  8573. doc.Save(path + postfix, saveFormat);
  8574. jw = JsonView(true, "导出成功", ftpPath + postfix);
  8575. }
  8576. catch (Exception)
  8577. {
  8578. jw = JsonView(false);
  8579. }
  8580. return Ok(jw);
  8581. }
  8582. /// <summary>
  8583. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  8584. /// </summary>
  8585. /// <param name="num"></param>
  8586. /// <returns></returns>
  8587. string GetNum(string num)
  8588. {
  8589. string str = "";
  8590. switch (num)
  8591. {
  8592. case "1":
  8593. str = "一";
  8594. break;
  8595. case "2":
  8596. str = "二";
  8597. break;
  8598. case "3":
  8599. str = "三";
  8600. break;
  8601. case "4":
  8602. str = "四";
  8603. break;
  8604. case "5":
  8605. str = "五";
  8606. break;
  8607. case "6":
  8608. str = "六";
  8609. break;
  8610. case "7":
  8611. str = "七";
  8612. break;
  8613. case "8":
  8614. str = "八";
  8615. break;
  8616. case "9":
  8617. str = "九";
  8618. break;
  8619. case "10":
  8620. str = "十";
  8621. break;
  8622. case "11":
  8623. str = "十一";
  8624. break;
  8625. case "12":
  8626. str = "十二";
  8627. break;
  8628. case "一":
  8629. str = "1";
  8630. break;
  8631. case "二":
  8632. str = "2";
  8633. break;
  8634. case "三":
  8635. str = "3";
  8636. break;
  8637. case "四":
  8638. str = "4";
  8639. break;
  8640. case "五":
  8641. str = "5";
  8642. break;
  8643. case "六":
  8644. str = "6";
  8645. break;
  8646. case "七":
  8647. str = "7";
  8648. break;
  8649. case "八":
  8650. str = "8";
  8651. break;
  8652. case "九":
  8653. str = "9";
  8654. break;
  8655. case "十":
  8656. str = "10";
  8657. break;
  8658. case "十一":
  8659. str = "11";
  8660. break;
  8661. case "十二":
  8662. str = "12";
  8663. break;
  8664. }
  8665. return str;
  8666. }
  8667. #endregion
  8668. #endregion
  8669. #region 团组成本
  8670. /// <summary>
  8671. /// 团组成本数据初始化
  8672. /// </summary>
  8673. /// <param name="dto"></param>
  8674. /// <returns></returns>
  8675. [HttpPost]
  8676. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  8677. {
  8678. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  8679. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  8680. WHEN COUNT(*) >= 0 THEN 'True'
  8681. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  8682. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  8683. ").ToList(); //团组列表
  8684. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  8685. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  8686. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  8687. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  8688. if (groupinfoValue != null)
  8689. {
  8690. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  8691. var spArr = new string[1] { countryArr };
  8692. if (countryArr.Contains("|"))
  8693. {
  8694. spArr = countryArr.Split("|");
  8695. }
  8696. else if (countryArr.Contains("、"))
  8697. {
  8698. spArr = countryArr.Split("、");
  8699. }
  8700. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  8701. {
  8702. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  8703. if (dbQueryCountry != null)
  8704. {
  8705. visaCountryInfoArr.Add(dbQueryCountry);
  8706. }
  8707. }
  8708. }
  8709. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  8710. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  8711. var create = _GroupCostRepository.
  8712. CreateGroupCostByBlackCode(dto.Diid);
  8713. if (groupCost.Count == 0 && create.Code == 0)
  8714. {
  8715. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  8716. }
  8717. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  8718. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  8719. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  8720. groupCostMap = groupCostMap.Select(x =>
  8721. {
  8722. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  8723. {
  8724. x.Date = dataForamt.ToString("yyyy-MM-dd");
  8725. }
  8726. return x;
  8727. }).ToList();
  8728. //GroupCostParameter.Add(new
  8729. // Grp_GroupCostParameter());
  8730. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  8731. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  8732. return Ok(JsonView(new
  8733. {
  8734. groupList,
  8735. groupInfo,
  8736. groupChecks,
  8737. groupCost = groupCostMap,
  8738. hotelNumber,
  8739. GroupCostParameter = GroupCostParameterMap,
  8740. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  8741. {
  8742. x.VisaCountry,
  8743. x.VisaPrice,
  8744. x.Id,
  8745. }).ToList(),
  8746. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  8747. blackCodeIsTrue = create.Code == 0 ? true : false,
  8748. hotelIsTrue = hotelIsTrue,
  8749. }));
  8750. }
  8751. /// <summary>
  8752. /// 团组成本信息保存
  8753. /// </summary>
  8754. /// <param name="dto"></param>
  8755. /// <returns></returns>
  8756. [HttpPost]
  8757. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  8758. {
  8759. if (dto.Diid <= 0 || dto.Userid <= 0)
  8760. {
  8761. return Ok(JsonView(false));
  8762. }
  8763. JsonView jw = null;
  8764. bool isTrue = false;
  8765. #region 复制团组成本
  8766. //if (dto.Diid == 2581)
  8767. //{
  8768. // dto.Diid = 2599;
  8769. // dto.CheckBoxs.ForEach(x =>
  8770. // {
  8771. // x.Diid = 2599;
  8772. // });
  8773. // dto.GroupCosts.ForEach(x =>
  8774. // {
  8775. // x.Diid = 2599;
  8776. // });
  8777. // dto.CostTypeHotelNumbers.ForEach(x =>
  8778. // {
  8779. // x.Diid = 2599;
  8780. // });
  8781. // dto.GroupCostParameters.ForEach(x =>
  8782. // {
  8783. // x.DiId = 2599;
  8784. // });
  8785. //}
  8786. #endregion
  8787. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  8788. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  8789. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  8790. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  8791. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  8792. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  8793. try
  8794. {
  8795. _sqlSugar.BeginTran();
  8796. isTrue = await _GroupCostRepository.
  8797. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  8798. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  8799. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  8800. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  8801. _sqlSugar.CommitTran();
  8802. jw = JsonView(true, "保存成功!", isTrue);
  8803. }
  8804. catch (Exception)
  8805. {
  8806. _sqlSugar.RollbackTran();
  8807. jw = JsonView(false);
  8808. }
  8809. return Ok(jw);
  8810. }
  8811. /// <summary>
  8812. /// 司兼导数据
  8813. /// </summary>
  8814. /// <param name="dto"></param>
  8815. /// <returns></returns>
  8816. [HttpPost]
  8817. public IActionResult GetCarGuides(CarGuidesDto dto)
  8818. {
  8819. JsonView jw = null;
  8820. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  8821. jw = JsonView(true, "获取成功!", Data);
  8822. return Ok(jw);
  8823. }
  8824. /// <summary>
  8825. /// 导游数据
  8826. /// </summary>
  8827. /// <param name="dto"></param>
  8828. /// <returns></returns>
  8829. [HttpPost]
  8830. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  8831. {
  8832. JsonView jw = null;
  8833. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  8834. // 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
  8835. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  8836. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  8837. jw = JsonView(true, "获取成功!", Data);
  8838. return Ok(jw);
  8839. }
  8840. /// <summary>
  8841. /// 成本车数据
  8842. /// </summary>
  8843. /// <param name="dto"></param>
  8844. /// <returns></returns>
  8845. [HttpPost]
  8846. public IActionResult GetCarInfo(CarGuidesDto dto)
  8847. {
  8848. JsonView jw = null;
  8849. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  8850. jw = JsonView(true, "获取成功!", Data);
  8851. return Ok(jw);
  8852. }
  8853. /// <summary>
  8854. /// 景点数据
  8855. /// </summary>
  8856. /// <param name="dto"></param>
  8857. /// <returns></returns>
  8858. [HttpPost]
  8859. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  8860. {
  8861. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  8862. return Ok(JsonView(true, "获取成功!", Data));
  8863. }
  8864. /// <summary>
  8865. /// 成本通知
  8866. /// </summary>
  8867. /// <param name="dto"></param>
  8868. /// <returns></returns>
  8869. [HttpPost]
  8870. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8871. {
  8872. if (dto.Diid < 0)
  8873. {
  8874. return Ok(JsonView(false));
  8875. }
  8876. JsonView jw = null;
  8877. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8878. if (GroupCostParameter != null)
  8879. {
  8880. int IsShare = 0;
  8881. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8882. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8883. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8884. string msg = string.Empty;
  8885. if (isTrue)
  8886. {
  8887. if (IsShare == 0)
  8888. {
  8889. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8890. }
  8891. else
  8892. {
  8893. #region 企微通知对应岗位用户
  8894. try
  8895. {
  8896. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8897. }
  8898. catch (Exception ex)
  8899. {
  8900. }
  8901. #endregion
  8902. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8903. }
  8904. jw = JsonView(isTrue, msg, new { IsShare });
  8905. }
  8906. else
  8907. {
  8908. msg = "修改失败!";
  8909. jw = JsonView(isTrue, msg);
  8910. }
  8911. }
  8912. else
  8913. {
  8914. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8915. }
  8916. return Ok(jw);
  8917. }
  8918. /// <summary>
  8919. /// 导出报价单
  8920. /// </summary>
  8921. /// <param name="dto"></param>
  8922. /// <returns></returns>
  8923. [HttpPost]
  8924. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8925. {
  8926. if (dto.Diid == 0)
  8927. {
  8928. return Ok(JsonView(false, "请传递团组id"));
  8929. }
  8930. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8931. if (deleInfo.Code != 0)
  8932. {
  8933. return Ok(JsonView(false, "团组信息查询失败!"));
  8934. }
  8935. var di = deleInfo.Data as DelegationInfoWebView;
  8936. if (di != null)
  8937. {
  8938. di.TeamName = di.TeamName.Replace("|", "、");
  8939. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8940. //文件名
  8941. string strFileName = di.TeamName + "-收款账单.doc";
  8942. //获取模板
  8943. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  8944. //载入模板
  8945. Document doc = new Document(tmppath);
  8946. decimal TotalPrice = 0.00M;
  8947. string itemStr = string.Empty;
  8948. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  8949. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8950. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8951. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  8952. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  8953. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  8954. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  8955. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  8956. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  8957. foreach (var cost in groupCostType)
  8958. {
  8959. var List = cost.ToList();
  8960. if (cost.Key == "A")
  8961. {
  8962. foreach (var ListItem in List)
  8963. {
  8964. if (ListItem.number > 0)
  8965. {
  8966. if (ListItem.code.Contains("TBR"))
  8967. {
  8968. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8969. }
  8970. else
  8971. {
  8972. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8973. }
  8974. TotalPrice += (ListItem.number * ListItem.price);
  8975. }
  8976. }
  8977. }
  8978. else
  8979. {
  8980. itemStr = itemStr.Insert(0, "A段\r\n");
  8981. itemStr += "B段\r\n";
  8982. foreach (var ListItem in List)
  8983. {
  8984. if (ListItem.number > 0)
  8985. {
  8986. if (ListItem.code.Contains("TBR"))
  8987. {
  8988. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8989. }
  8990. else
  8991. {
  8992. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8993. }
  8994. TotalPrice += (ListItem.number * ListItem.price);
  8995. }
  8996. }
  8997. }
  8998. }
  8999. #region 替换Word模板书签内容
  9000. Dictionary<string, string> marks = new Dictionary<string, string>();
  9001. marks.Add("To", di.ClientUnit);//付款方
  9002. marks.Add("ToTel", di.TellPhone);//付款方电话
  9003. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  9004. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  9005. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  9006. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  9007. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  9008. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  9009. marks.Add("PayItemContent", itemStr);//详细信息
  9010. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  9011. #endregion
  9012. ////注
  9013. //if (doc.Range.Bookmarks["Attention"] != null)
  9014. //{
  9015. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  9016. // mark.Text = frList[0].Attention;
  9017. //}
  9018. foreach (var item in marks.Keys)
  9019. {
  9020. if (doc.Range.Bookmarks[item] != null)
  9021. {
  9022. Bookmark mark = doc.Range.Bookmarks[item];
  9023. mark.Text = marks[item];
  9024. }
  9025. }
  9026. byte[] bytes = null;
  9027. using (MemoryStream stream = new MemoryStream())
  9028. {
  9029. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9030. bytes = stream.ToArray();
  9031. }
  9032. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  9033. return Ok(JsonView(true, "", new
  9034. {
  9035. Data = bytes,
  9036. strFileName,
  9037. }));
  9038. }
  9039. else
  9040. {
  9041. return Ok(JsonView(false, "团组信息不存在!"));
  9042. }
  9043. }
  9044. /// <summary>
  9045. /// 导出团组成本
  9046. /// </summary>
  9047. /// <param name="dto"></param>
  9048. /// <returns></returns>
  9049. [HttpPost]
  9050. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  9051. {
  9052. var jw = JsonView(false);
  9053. if (dto.Diid == 0)
  9054. {
  9055. return Ok(JsonView(false, "请传递团组id"));
  9056. }
  9057. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9058. if (deleInfo.Code != 0)
  9059. {
  9060. return Ok(JsonView(false, "团组信息查询失败!"));
  9061. }
  9062. var di = deleInfo.Data as DelegationInfoWebView;
  9063. if (di == null)
  9064. {
  9065. return Ok(JsonView(false, "团组信息查询失败!"));
  9066. }
  9067. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  9068. WorkbookDesigner designer = new WorkbookDesigner();
  9069. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  9070. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  9071. for (int i = 0; i < List_GC.Count; i++)
  9072. {
  9073. GroupCost_Excel gc = new GroupCost_Excel();
  9074. gc.Id = List_GC[i].Id;
  9075. gc.Diid = List_GC[i].Diid.ToString();
  9076. gc.DAY = List_GC[i].DAY;
  9077. string week = "";
  9078. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  9079. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  9080. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  9081. gc.ITIN = List_GC[i].ITIN;
  9082. gc.CarType = List_GC[i].CarType;
  9083. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  9084. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  9085. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  9086. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  9087. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  9088. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  9089. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  9090. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  9091. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  9092. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  9093. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  9094. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  9095. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9096. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9097. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  9098. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  9099. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  9100. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  9101. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  9102. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  9103. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  9104. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  9105. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  9106. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  9107. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  9108. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  9109. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  9110. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  9111. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  9112. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  9113. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  9114. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  9115. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  9116. List_GC1.Add(gc);
  9117. }
  9118. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  9119. dt.TableName = "TB";
  9120. //报表标题等不用dt的值
  9121. designer.SetDataSource("TeamName", dto.title.TeamName);
  9122. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  9123. designer.SetDataSource("Tax", dto.title.Tax);
  9124. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  9125. designer.SetDataSource("Currency", dto.title.Currency);
  9126. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  9127. designer.SetDataSource("Rate", dto.title.Rate);
  9128. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  9129. var Aparams = hotels.Find(x => x.Type == "Default");
  9130. if (Aparams == null)
  9131. {
  9132. return Ok(jw);
  9133. }
  9134. //酒店数量
  9135. var txtSGRNumber = Aparams.SGR.ToString();
  9136. var txtTBRNumber = Aparams.TBR.ToString();
  9137. var txtJSESNumber = Aparams.JSES.ToString();
  9138. var txtSUITENumbe = Aparams.SUITE.ToString();
  9139. if (dto.costType == "B")
  9140. {
  9141. Aparams = hotels.Find(x => x.Type == "A");
  9142. var Bparams = hotels.Find(x => x.Type == "B");
  9143. if (Aparams == null || Bparams == null)
  9144. {
  9145. return Ok(jw);
  9146. }
  9147. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  9148. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  9149. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  9150. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  9151. }
  9152. designer.SetDataSource("SGRNumber", txtSGRNumber);
  9153. designer.SetDataSource("TBRNumber", txtTBRNumber);
  9154. designer.SetDataSource("JSESNumber", txtJSESNumber);
  9155. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  9156. var ws = designer.Workbook.Worksheets[0];
  9157. int Row = List_GC.Count;
  9158. int startIndex = 11;
  9159. int HideRows = 0;
  9160. List<int> hideRowsList = new List<int>();
  9161. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  9162. #region A段left数据
  9163. var left = dto.leftInfo.Find(x => x.Type == "A");
  9164. if (left == null)
  9165. {
  9166. return Ok(jw);
  9167. }
  9168. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  9169. if (leftBindData != null)
  9170. {
  9171. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  9172. designer.SetDataSource("VisaRS", leftBindData.rs);
  9173. designer.SetDataSource("VisaXS", leftBindData.xs);
  9174. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9175. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9176. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9177. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9178. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9179. }
  9180. else
  9181. {
  9182. hideRowsList.Add(Row + startIndex + HideRows);
  9183. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9184. }
  9185. HideRows += 2;
  9186. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  9187. if (leftBindData != null)
  9188. {
  9189. designer.SetDataSource("BXDRCB", leftBindData.cb);
  9190. designer.SetDataSource("BXRS", leftBindData.rs);
  9191. designer.SetDataSource("BXXS", leftBindData.xs);
  9192. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9193. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9194. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9195. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9196. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9197. }
  9198. else
  9199. {
  9200. hideRowsList.Add(Row + startIndex + HideRows);
  9201. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9202. }
  9203. HideRows += 2;
  9204. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9205. if (leftBindData != null)
  9206. {
  9207. designer.SetDataSource("HSDRCB", leftBindData.cb);
  9208. designer.SetDataSource("HSRS", leftBindData.rs);
  9209. designer.SetDataSource("HSXS", leftBindData.xs);
  9210. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9211. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9212. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9213. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9214. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9215. }
  9216. else
  9217. {
  9218. hideRowsList.Add(Row + startIndex + HideRows);
  9219. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9220. }
  9221. HideRows += 2;
  9222. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9223. if (leftBindData != null)
  9224. {
  9225. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  9226. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  9227. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  9228. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9229. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9230. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9231. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9232. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9233. }
  9234. else
  9235. {
  9236. hideRowsList.Add(Row + startIndex + HideRows);
  9237. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9238. }
  9239. HideRows += 2;
  9240. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9241. if (leftBindData != null)
  9242. {
  9243. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  9244. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  9245. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  9246. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9247. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9248. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9249. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9250. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9251. }
  9252. else
  9253. {
  9254. hideRowsList.Add(Row + startIndex + HideRows);
  9255. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9256. }
  9257. HideRows += 2;
  9258. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9259. if (leftBindData != null)
  9260. {
  9261. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  9262. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  9263. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  9264. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9265. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9266. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9267. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9268. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9269. }
  9270. else
  9271. {
  9272. hideRowsList.Add(Row + startIndex + HideRows);
  9273. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9274. }
  9275. HideRows += 2;
  9276. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9277. if (leftBindData != null)
  9278. {
  9279. ////TBR
  9280. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  9281. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  9282. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  9283. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9284. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9285. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9286. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9287. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9288. }
  9289. else
  9290. {
  9291. hideRowsList.Add(Row + startIndex + HideRows);
  9292. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9293. }
  9294. HideRows += 2;
  9295. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9296. if (leftBindData != null)
  9297. {
  9298. ////SGR
  9299. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  9300. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  9301. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  9302. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9303. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9304. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9305. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9306. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9307. }
  9308. else
  9309. {
  9310. hideRowsList.Add(Row + startIndex + HideRows);
  9311. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9312. }
  9313. HideRows += 2;
  9314. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9315. if (leftBindData != null)
  9316. {
  9317. ////JS/ES
  9318. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  9319. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  9320. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  9321. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9322. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9323. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9324. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9325. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9326. }
  9327. else
  9328. {
  9329. hideRowsList.Add(Row + startIndex + HideRows);
  9330. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9331. }
  9332. HideRows += 2;
  9333. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9334. if (leftBindData != null)
  9335. {
  9336. ////SUITE
  9337. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  9338. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  9339. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  9340. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9341. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9342. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9343. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9344. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9345. }
  9346. else
  9347. {
  9348. hideRowsList.Add(Row + startIndex + HideRows);
  9349. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9350. }
  9351. HideRows += 2;
  9352. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9353. if (leftBindData != null)
  9354. {
  9355. designer.SetDataSource("DJDRCB", leftBindData.cb);
  9356. designer.SetDataSource("DJRS", leftBindData.rs);
  9357. designer.SetDataSource("DJXS", leftBindData.xs);
  9358. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9359. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9360. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9361. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9362. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9363. }
  9364. else
  9365. {
  9366. hideRowsList.Add(Row + startIndex + HideRows);
  9367. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9368. }
  9369. HideRows += 2;
  9370. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9371. if (leftBindData != null)
  9372. {
  9373. designer.SetDataSource("HCPCB", leftBindData.cb);
  9374. designer.SetDataSource("HCPRS", leftBindData.rs);
  9375. designer.SetDataSource("HCPXS", leftBindData.xs);
  9376. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9377. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9378. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9379. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9380. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9381. }
  9382. else
  9383. {
  9384. hideRowsList.Add(Row + startIndex + HideRows);
  9385. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9386. }
  9387. HideRows += 2;
  9388. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9389. if (leftBindData != null)
  9390. {
  9391. designer.SetDataSource("CPCB", leftBindData.cb);
  9392. designer.SetDataSource("CPRS", leftBindData.rs);
  9393. designer.SetDataSource("CPXS", leftBindData.xs);
  9394. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9395. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9396. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9397. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9398. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9399. }
  9400. else
  9401. {
  9402. hideRowsList.Add(Row + startIndex + HideRows);
  9403. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9404. }
  9405. HideRows += 2;
  9406. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9407. if (leftBindData != null)
  9408. {
  9409. designer.SetDataSource("GWDRCD", leftBindData.cb);
  9410. designer.SetDataSource("GWRS", leftBindData.rs);
  9411. designer.SetDataSource("GWXS", leftBindData.xs);
  9412. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9413. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9414. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9415. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9416. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9417. }
  9418. else
  9419. {
  9420. hideRowsList.Add(Row + startIndex + HideRows);
  9421. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9422. }
  9423. HideRows += 2;
  9424. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9425. if (leftBindData != null)
  9426. {
  9427. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  9428. designer.SetDataSource("LYJRS", leftBindData.rs);
  9429. designer.SetDataSource("LYJXS", leftBindData.xs);
  9430. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9431. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9432. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9433. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9434. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9435. }
  9436. else
  9437. {
  9438. hideRowsList.Add(Row + startIndex + HideRows);
  9439. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9440. }
  9441. #endregion
  9442. #region A段Right信息
  9443. var right = dto.rightInfo.Find(x => x.Type == "A");
  9444. if (right == null)
  9445. {
  9446. return Ok(jw);
  9447. }
  9448. HideRows += 4;
  9449. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9450. if (rightBindData != null)
  9451. {
  9452. //经济舱 + 双人间 TBR
  9453. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  9454. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  9455. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9456. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  9457. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9458. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9459. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9460. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9461. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9462. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9463. }
  9464. else
  9465. {
  9466. hideRowsList.Add(Row + startIndex + HideRows);
  9467. }
  9468. HideRows += 2;
  9469. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9470. if (rightBindData != null)
  9471. {
  9472. //经济舱 + 单人间 SGR
  9473. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  9474. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  9475. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9476. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  9477. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9478. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9479. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9480. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9481. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9482. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9483. }
  9484. else
  9485. {
  9486. hideRowsList.Add(Row + startIndex + HideRows);
  9487. }
  9488. HideRows += 2;
  9489. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9490. if (rightBindData != null)
  9491. {
  9492. //公务舱 + 单人间 SGR
  9493. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  9494. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  9495. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9496. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  9497. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9498. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9499. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9500. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9501. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9502. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9503. }
  9504. else
  9505. {
  9506. hideRowsList.Add(Row + startIndex + HideRows);
  9507. }
  9508. HideRows += 2;
  9509. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9510. if (rightBindData != null)
  9511. {
  9512. //公务舱 + 小套房 JSES
  9513. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  9514. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  9515. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9516. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  9517. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9518. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9519. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9520. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9521. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9522. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9523. }
  9524. else
  9525. {
  9526. hideRowsList.Add(Row + startIndex + HideRows);
  9527. }
  9528. HideRows += 2;
  9529. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9530. if (rightBindData != null)
  9531. {
  9532. //公务舱 + 小套房 JSES
  9533. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  9534. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  9535. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9536. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  9537. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9538. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9539. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9540. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9541. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9542. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9543. }
  9544. else
  9545. {
  9546. hideRowsList.Add(Row + startIndex + HideRows);
  9547. }
  9548. HideRows += 2;
  9549. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9550. if (rightBindData != null)
  9551. {
  9552. //经济舱 + 大套房
  9553. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  9554. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  9555. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9556. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  9557. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9558. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9559. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9560. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9561. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9562. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9563. }
  9564. else
  9565. {
  9566. hideRowsList.Add(Row + startIndex + HideRows);
  9567. }
  9568. HideRows += 2;
  9569. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9570. if (rightBindData != null)
  9571. {
  9572. //头等舱 + 小套房 JSES
  9573. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  9574. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  9575. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9576. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  9577. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9578. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9579. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9580. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9581. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9582. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9583. }
  9584. else
  9585. {
  9586. hideRowsList.Add(Row + startIndex + HideRows);
  9587. }
  9588. HideRows += 2;
  9589. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9590. if (rightBindData != null)
  9591. {
  9592. //头等舱 + 大套房
  9593. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  9594. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  9595. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9596. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  9597. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9598. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9599. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9600. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9601. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9602. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9603. }
  9604. else
  9605. {
  9606. hideRowsList.Add(Row + startIndex + HideRows);
  9607. }
  9608. #endregion
  9609. #region B段标题清空
  9610. designer.SetDataSource("CostBDRCB", "");
  9611. designer.SetDataSource("CostBRS", "");
  9612. designer.SetDataSource("CostBXS", "");
  9613. designer.SetDataSource("CostBZCB", "");
  9614. designer.SetDataSource("CostBDRBJ", "");
  9615. designer.SetDataSource("CostBZBJ", "");
  9616. designer.SetDataSource("CostBDRLR", "");
  9617. designer.SetDataSource("CostBZLR", "");
  9618. designer.SetDataSource("CostBDRCBOM", "");
  9619. designer.SetDataSource("CostBRSOM", "");
  9620. designer.SetDataSource("CostBZCBOM", "");
  9621. designer.SetDataSource("CostBDRBJOM", "");
  9622. designer.SetDataSource("CostBZBJOM", "");
  9623. designer.SetDataSource("CostBDRLROM", "");
  9624. designer.SetDataSource("CostBZLROM", "");
  9625. #endregion
  9626. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  9627. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  9628. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  9629. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  9630. designer.SetDataSource("DJName", "地接(CNY)");
  9631. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  9632. designer.SetDataSource("CPName", "地接-船票(CNY)");
  9633. designer.SetDataSource("GWName", "公务(CNY)");
  9634. designer.SetDataSource("YQHName", "邀请函(CNY)");
  9635. designer.SetDataSource("LYJName", "零用金(CNY)");
  9636. designer.SetDataSource("HSName", "核酸检测(CNY)");
  9637. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  9638. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  9639. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  9640. designer.SetDataSource("BXName", "保险(CNY)");
  9641. designer.SetDataSource("VisaName", "签证(CNY)");
  9642. #region B段基本数据
  9643. if (dto.costType == "B")
  9644. {
  9645. left = dto.leftInfo.Find(x => x.Type == "B");
  9646. if (left == null)
  9647. {
  9648. return Ok(jw);
  9649. }
  9650. #region B段left数据
  9651. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9652. if (leftBindData != null)
  9653. {
  9654. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  9655. designer.SetDataSource("BHSRS", leftBindData.rs);
  9656. designer.SetDataSource("BHSXS", leftBindData.xs);
  9657. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9658. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9659. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9660. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9661. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9662. }
  9663. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9664. if (leftBindData != null)
  9665. {
  9666. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  9667. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  9668. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  9669. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9670. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9671. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9672. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9673. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9674. }
  9675. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9676. if (leftBindData != null)
  9677. {
  9678. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  9679. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  9680. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  9681. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9682. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9683. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9684. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9685. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9686. }
  9687. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9688. if (leftBindData != null)
  9689. {
  9690. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  9691. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  9692. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  9693. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9694. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9695. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9696. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9697. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9698. }
  9699. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9700. if (leftBindData != null)
  9701. {
  9702. designer.SetDataSource("BHCPCB", leftBindData.cb);
  9703. designer.SetDataSource("BHCPRS", leftBindData.rs);
  9704. designer.SetDataSource("BHCPXS", leftBindData.xs);
  9705. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9706. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9707. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9708. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9709. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9710. }
  9711. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9712. if (leftBindData != null)
  9713. {
  9714. designer.SetDataSource("BCPCB", leftBindData.cb);
  9715. designer.SetDataSource("BCPRS", leftBindData.rs);
  9716. designer.SetDataSource("BCPXS", leftBindData.xs);
  9717. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9718. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9719. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9720. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9721. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9722. }
  9723. //TBR
  9724. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9725. if (leftBindData != null)
  9726. {
  9727. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  9728. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  9729. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  9730. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9731. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9732. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9733. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9734. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9735. }
  9736. //SGR
  9737. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9738. if (leftBindData != null)
  9739. {
  9740. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  9741. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  9742. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  9743. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9744. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9745. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9746. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9747. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9748. }
  9749. //JS/ES
  9750. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9751. if (leftBindData != null)
  9752. {
  9753. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  9754. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  9755. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  9756. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9757. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9758. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9759. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9760. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9761. }
  9762. //SUITE
  9763. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9764. if (leftBindData != null)
  9765. {
  9766. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  9767. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  9768. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  9769. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9770. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9771. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9772. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9773. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9774. }
  9775. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9776. if (leftBindData != null)
  9777. {
  9778. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  9779. designer.SetDataSource("BDJRS", leftBindData.rs);
  9780. designer.SetDataSource("BDJXS", leftBindData.xs);
  9781. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9782. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9783. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9784. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9785. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9786. }
  9787. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9788. if (leftBindData != null)
  9789. {
  9790. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  9791. designer.SetDataSource("BGWRS", leftBindData.rs);
  9792. designer.SetDataSource("BGWXS", leftBindData.xs);
  9793. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9794. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9795. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9796. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9797. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9798. }
  9799. #region 优化方案
  9800. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  9801. //excelBind.Add("零用金", new {
  9802. //cb="",
  9803. //rs="",
  9804. //xs ="",
  9805. //zcb = "",
  9806. //});
  9807. #endregion
  9808. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9809. if (leftBindData != null)
  9810. {
  9811. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  9812. designer.SetDataSource("BLYJRS", leftBindData.rs);
  9813. designer.SetDataSource("BLYJXS", leftBindData.xs);
  9814. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9815. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9816. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9817. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9818. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9819. }
  9820. #endregion
  9821. #region B段Right信息
  9822. right = dto.rightInfo.Find(x => x.Type == "B");
  9823. if (right == null)
  9824. {
  9825. return Ok(jw);
  9826. }
  9827. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9828. if (rightBindData != null)
  9829. {
  9830. //经济舱 + 双人间 TBR
  9831. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  9832. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  9833. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9834. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  9835. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9836. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9837. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9838. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9839. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9840. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9841. }
  9842. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9843. if (rightBindData != null)
  9844. {
  9845. //经济舱 + 单人间 SGR
  9846. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  9847. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  9848. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9849. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  9850. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9851. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9852. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9853. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9854. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9855. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9856. }
  9857. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9858. if (rightBindData != null)
  9859. {
  9860. //公务舱 + 单人间 SGR
  9861. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  9862. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  9863. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9864. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  9865. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9866. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9867. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9868. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9869. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9870. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9871. }
  9872. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9873. if (rightBindData != null)
  9874. {
  9875. //公务舱 + 小套房 JSES
  9876. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9877. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9878. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9879. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9880. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9881. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9882. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9883. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9884. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9885. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9886. }
  9887. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9888. if (rightBindData != null)
  9889. {
  9890. //公务舱 + 小套房 JSES
  9891. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9892. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9893. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9894. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9895. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9896. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9897. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9898. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9899. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9900. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9901. }
  9902. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9903. if (rightBindData != null)
  9904. {
  9905. //经济舱 + 大套房
  9906. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9907. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9908. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9909. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9910. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9911. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9912. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9913. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9914. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9915. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9916. }
  9917. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9918. if (rightBindData != null)
  9919. {
  9920. //头等舱 + 小套房 JSES
  9921. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9922. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9923. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9924. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9925. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9926. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9927. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9928. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9929. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9930. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9931. }
  9932. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9933. if (rightBindData != null)
  9934. {
  9935. //头等舱 + 大套房
  9936. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9937. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9938. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9939. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9940. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9941. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9942. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9943. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9944. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9945. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9946. }
  9947. #endregion
  9948. #region 标题
  9949. designer.SetDataSource("CostBDRCB", "单人成本");
  9950. designer.SetDataSource("CostBRS", "人数");
  9951. designer.SetDataSource("CostBXS", "系数");
  9952. designer.SetDataSource("CostBZCB", "总成本");
  9953. designer.SetDataSource("CostBDRBJ", "单人报价");
  9954. designer.SetDataSource("CostBZBJ", "总报价");
  9955. designer.SetDataSource("CostBDRLR", "单人利润");
  9956. designer.SetDataSource("CostBZLR", "总利润");
  9957. designer.SetDataSource("CostBDRCBOM", "单人成本");
  9958. designer.SetDataSource("CostBRSOM", "人数");
  9959. designer.SetDataSource("CostBZCBOM", "总成本");
  9960. designer.SetDataSource("CostBDRBJOM", "单人报价");
  9961. designer.SetDataSource("CostBZBJOM", "总报价");
  9962. designer.SetDataSource("CostBDRLROM", "单人利润");
  9963. designer.SetDataSource("CostBZLROM", "总利润");
  9964. #endregion
  9965. }
  9966. #endregion
  9967. designer.SetDataSource("TzZCB2", TzZCB2);
  9968. designer.SetDataSource("TzZBJ2", TzZBJ2);
  9969. designer.SetDataSource("TzZLR2", TzZLR2);
  9970. string[] dataSourceKeys = new string[]
  9971. {
  9972. "VF",
  9973. "TGS",
  9974. "TGOF",
  9975. "TGM",
  9976. "TGA",
  9977. "TGTF",
  9978. "TGEF",
  9979. "CFM",
  9980. "CFOF",
  9981. "B",
  9982. "L",
  9983. "D",
  9984. "TBR",
  9985. "SGR",
  9986. "JSES",
  9987. "Suite",
  9988. "TV",
  9989. "1L",
  9990. "IF",
  9991. "EF",
  9992. "BRF",
  9993. "TE",
  9994. "TGT",
  9995. "DRVT",
  9996. "PC",
  9997. "TLF",
  9998. "ECT"
  9999. };
  10000. foreach (var item in dataSourceKeys)
  10001. {
  10002. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  10003. if (find != null)
  10004. {
  10005. designer.SetDataSource(item, find.text);
  10006. }
  10007. else
  10008. {
  10009. designer.SetDataSource(item, 0);
  10010. }
  10011. }
  10012. designer.SetDataSource(dt);
  10013. //根据数据源处理生成报表内容
  10014. designer.Process();
  10015. designer.Workbook.Worksheets[0].Name = "清单";
  10016. Worksheet sheet = designer.Workbook.Worksheets[0];
  10017. foreach (var Rowindex in hideRowsList)
  10018. {
  10019. ws.Cells.HideRows(Rowindex, 2);
  10020. }
  10021. byte[] bytes = null;
  10022. string strFileName = di.TeamName + "-团组-成本.xls";
  10023. using (MemoryStream stream = new MemoryStream())
  10024. {
  10025. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  10026. bytes = stream.ToArray();
  10027. }
  10028. return Ok(JsonView(true, "", new
  10029. {
  10030. Data = bytes,
  10031. strFileName,
  10032. }));
  10033. }
  10034. /// <summary>
  10035. /// 导出客户报表
  10036. /// </summary>
  10037. /// <returns></returns>
  10038. [HttpPost]
  10039. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  10040. {
  10041. var jw = JsonView(false);
  10042. if (dto.Diid == 0)
  10043. {
  10044. return Ok(JsonView(false, "请传递团组id"));
  10045. }
  10046. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10047. if (deleInfo.Code != 0)
  10048. {
  10049. return Ok(JsonView(false, "团组信息查询失败!"));
  10050. }
  10051. var di = deleInfo.Data as DelegationInfoWebView;
  10052. if (di == null)
  10053. {
  10054. return Ok(JsonView(false, "团组信息查询失败!"));
  10055. }
  10056. //文件名
  10057. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  10058. //获取模板
  10059. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  10060. //载入模板
  10061. Document doc = new Document(tmppath);
  10062. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  10063. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  10064. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  10065. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  10066. var AParameter = ParameterList.Find(x => x.CostType == "A");
  10067. var BParameter = ParameterList.Find(x => x.CostType == "B");
  10068. if (AParameter == null)
  10069. {
  10070. return Ok(JsonView(false, "系数不存在!"));
  10071. }
  10072. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  10073. , TzAirDesc, TzZCost;
  10074. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  10075. = TzAirDesc = TzZCost = string.Empty;
  10076. TzNumber = AParameter.CostTypenumber.ToString();
  10077. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  10078. CarGuides1 = dto.CarGuides1;
  10079. Meal = dto.Meal;
  10080. SubsidizedMeals = dto.SubsidizedMeals;
  10081. NightRepair = dto.NightRepair;
  10082. AttractionsTickets = dto.AttractionsTickets;
  10083. MiscellaneousFees = dto.MiscellaneousFees;
  10084. ATip = dto.ATip;
  10085. TzHotelDesc = "";
  10086. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  10087. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  10088. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  10089. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  10090. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  10091. TzAirDesc = "";
  10092. TzZCost = dto.TzZCost;
  10093. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  10094. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  10095. var index = 1;
  10096. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  10097. foreach (var item in TzHotelDescArr)
  10098. {
  10099. if (AinfoArr != null)
  10100. {
  10101. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10102. if (Ainfo != null)
  10103. {
  10104. if (int.Parse(Ainfo.rs) <= 0)
  10105. {
  10106. continue;
  10107. }
  10108. var hotelText = string.Empty;
  10109. switch (item)
  10110. {
  10111. case "SGR":
  10112. hotelText = "单人间";
  10113. break;
  10114. case "JSES":
  10115. hotelText = "小套房";
  10116. break;
  10117. case "SUITE":
  10118. hotelText = "套房";
  10119. break;
  10120. case "TBR":
  10121. hotelText = "双人间";
  10122. break;
  10123. }
  10124. if (item != "TBR")
  10125. {
  10126. 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";
  10127. }
  10128. else
  10129. {
  10130. 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";
  10131. }
  10132. index++;
  10133. }
  10134. }
  10135. }
  10136. index = 1;
  10137. foreach (var item in TzAirDescArr)
  10138. {
  10139. if (AinfoArr != null)
  10140. {
  10141. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10142. if (Ainfo != null)
  10143. {
  10144. if (int.Parse(Ainfo.rs) <= 0)
  10145. {
  10146. continue;
  10147. }
  10148. 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";
  10149. index++;
  10150. }
  10151. }
  10152. }
  10153. if (dto.costType == "B")
  10154. {
  10155. if (BParameter == null)
  10156. {
  10157. return Ok(JsonView(false, "B段系数不存在!"));
  10158. }
  10159. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  10160. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  10161. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  10162. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  10163. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  10164. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  10165. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  10166. foreach (var item in TzHotelDescArr)
  10167. {
  10168. if (AinfoArr != null)
  10169. {
  10170. TzHotelDesc += "B段信息 \r\n";
  10171. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10172. if (Ainfo != null)
  10173. {
  10174. if (int.Parse(Ainfo.rs) <= 0)
  10175. {
  10176. continue;
  10177. }
  10178. var hotelText = string.Empty;
  10179. switch (item)
  10180. {
  10181. case "SGR":
  10182. hotelText = "单人间";
  10183. break;
  10184. case "JSES":
  10185. hotelText = "小套房";
  10186. break;
  10187. case "SUITE":
  10188. hotelText = "套房";
  10189. break;
  10190. case "TBR":
  10191. hotelText = "双人间";
  10192. break;
  10193. }
  10194. if (item != "TBR")
  10195. {
  10196. 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";
  10197. }
  10198. else
  10199. {
  10200. 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";
  10201. }
  10202. index++;
  10203. }
  10204. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  10205. }
  10206. }
  10207. index = 1;
  10208. foreach (var item in TzAirDescArr)
  10209. {
  10210. if (AinfoArr != null)
  10211. {
  10212. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10213. if (Ainfo != null)
  10214. {
  10215. if (int.Parse(Ainfo.rs) <= 0)
  10216. {
  10217. continue;
  10218. }
  10219. 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";
  10220. index++;
  10221. }
  10222. }
  10223. }
  10224. }
  10225. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  10226. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  10227. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  10228. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  10229. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  10230. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  10231. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  10232. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  10233. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  10234. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  10235. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  10236. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  10237. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  10238. DickeyValue.Add("Visa", Visa); // 签证单人报价
  10239. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  10240. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  10241. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  10242. DickeyValue.Add("TzZCost", TzZCost);
  10243. foreach (var key in DickeyValue.Keys)
  10244. {
  10245. if (doc.Range.Bookmarks[key] != null)
  10246. {
  10247. Bookmark mark = doc.Range.Bookmarks[key];
  10248. mark.Text = DickeyValue[key];
  10249. }
  10250. }
  10251. byte[] bytes = null;
  10252. string strFileName = di.TeamName + "-客户报价.doc";
  10253. using (MemoryStream stream = new MemoryStream())
  10254. {
  10255. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10256. bytes = stream.ToArray();
  10257. }
  10258. return Ok(JsonView(true, "", new
  10259. {
  10260. Data = bytes,
  10261. strFileName,
  10262. }));
  10263. }
  10264. /// <summary>
  10265. /// 团组成本 各模块(酒店,地接,机票)成本提示
  10266. /// </summary>
  10267. /// <param name="dto"></param>
  10268. /// <returns></returns>
  10269. [HttpPost]
  10270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10271. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  10272. {
  10273. try
  10274. {
  10275. #region 参数验证
  10276. if (dto.DiId < 0)
  10277. {
  10278. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  10279. }
  10280. List<int> cTableIds = new List<int>() {
  10281. 76 ,//酒店预订
  10282. 77 ,//行程
  10283. 79 ,//车/导游地接
  10284. 80 ,//签证
  10285. 81 ,//邀请/公务活
  10286. 82 ,//团组客户保险
  10287. 85 ,//机票预订
  10288. 98 ,//其他款项
  10289. 285 ,//收款退还
  10290. 751 ,//酒店早餐
  10291. 1015 // 超支费用
  10292. };
  10293. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  10294. {
  10295. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  10296. }
  10297. #endregion
  10298. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  10299. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  10300. if (_GroupCostParameters.Count <= 0)
  10301. {
  10302. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  10303. }
  10304. if (_GroupCostParameters[0].IsShare == 0)
  10305. {
  10306. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  10307. }
  10308. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10309. //处理date为空问题
  10310. if (_GroupCosts.Count > 0)
  10311. {
  10312. for (int i = 0; i < _GroupCosts.Count; i++)
  10313. {
  10314. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  10315. {
  10316. if (i > 0)
  10317. {
  10318. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  10319. }
  10320. }
  10321. }
  10322. }
  10323. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  10324. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  10325. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  10326. string currCode = "";
  10327. #region currCode 验证
  10328. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  10329. if (isInt)
  10330. {
  10331. var currData = currDatas.Find(it => it.Id == intCurrency);
  10332. if (currData != null)
  10333. {
  10334. currCode = currData.Name;
  10335. }
  10336. }
  10337. else
  10338. {
  10339. currCode = _GroupCostParameters[0].Currency.Trim();
  10340. }
  10341. #endregion
  10342. //op,酒店单段模式存储
  10343. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  10344. {
  10345. CurrencyCode = currCode,
  10346. Rate = _GroupCostParameters[0].Rate,
  10347. CostType = _GroupCostParameters[0].CostType,
  10348. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  10349. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  10350. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  10351. };
  10352. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  10353. if (_GroupCostParameters.Count == 2)
  10354. {
  10355. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  10356. }
  10357. foreach (var item in _GroupCostParameters)
  10358. {
  10359. decimal _rate = 1;
  10360. decimal _rate1 = item.Rate;
  10361. decimal _scale = 1;
  10362. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  10363. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  10364. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  10365. //if (userInfo != null)
  10366. //{
  10367. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  10368. // {
  10369. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  10370. // {
  10371. // _scale = 1.00M;
  10372. // }
  10373. // }
  10374. //}
  10375. #endregion
  10376. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  10377. {
  10378. CurrencyCode = currCode,
  10379. Rate = _rate1,
  10380. CostType = item.CostType,
  10381. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  10382. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  10383. CostTypeNumber = item.CostTypenumber
  10384. };
  10385. if (_GroupCostParameters.Count > 1)
  10386. {
  10387. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  10388. }
  10389. else
  10390. {
  10391. modulePromptInfo.CostTypeNumber = item.LYJRS;
  10392. }
  10393. if (dto.CTable == 79)//
  10394. {
  10395. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  10396. modulePromptInfo.TotalCost = item.DJCB;
  10397. }
  10398. List<string> costTypes = new List<string>() { "A", "B" };
  10399. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  10400. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  10401. if (_GroupCostsDuplicates.Count() == 1)
  10402. {
  10403. _GroupCostsTypeData = _GroupCosts;
  10404. }
  10405. else
  10406. {
  10407. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  10408. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  10409. }
  10410. /*
  10411. * 76 酒店预订
  10412. * 77 行程
  10413. * 79 车/导游地接
  10414. * 80 签证
  10415. * 81 邀请/公务活动
  10416. * 82 团组客户保险
  10417. * 85 机票预订
  10418. * 98 其他款项
  10419. * 285 收款退还
  10420. * 751 酒店早餐
  10421. * 1015 超支费用
  10422. */
  10423. switch (dto.CTable)
  10424. {
  10425. case 76: // 酒店预订
  10426. _ModuleSubPromptInfo.AddRange(
  10427. _GroupCostsTypeData.Select(it => new
  10428. {
  10429. it.DAY,
  10430. it.Date,
  10431. it.ACCON,
  10432. it.ITIN,
  10433. it.SGR,
  10434. it.TBR,
  10435. it.JS_ES,
  10436. it.Suite
  10437. })
  10438. );
  10439. break;
  10440. case 79: // 车/导游地接
  10441. _ModuleSubPromptInfo.AddRange(
  10442. _GroupCostsTypeData.Select(it => new
  10443. {
  10444. Date = it.Date, //日期
  10445. CarFee = it.CarCost * _rate * _scale, //车费用
  10446. CarType = it.CarType, //车型
  10447. DriverFee = it.CFS * _rate * _scale, //司机工资
  10448. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  10449. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  10450. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  10451. GuideFee = it.TGS * _rate * _scale, //导游费用
  10452. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  10453. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  10454. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  10455. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  10456. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  10457. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  10458. Breakfast = it.B * _rate * _scale, //早餐费
  10459. Lunch = it.L * _rate * _scale, //午餐费
  10460. Dinner = it.D * _rate * _scale, //晚餐费
  10461. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  10462. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  10463. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  10464. TicketFee = it.EF * _rate * _scale, //门票费
  10465. TicketRemark = it.EFR, //门票费描述
  10466. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  10467. TravelSupplies = it.TE * _rate * _scale, //出行物资
  10468. SpentCash = it.PC * _rate * _scale, //零用金
  10469. LeadersFee = it.TLF * _rate * _scale, //领队费
  10470. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  10471. })
  10472. );
  10473. break;
  10474. case 85: // 机票
  10475. List<dynamic> datas = new List<dynamic>();
  10476. datas.Add(
  10477. new
  10478. {
  10479. AirType = "经济舱",
  10480. AirNum = item.JJCRS,
  10481. AirDRCB = item.JJCCB,
  10482. AirZCB = (item.JJCRS * item.JJCCB)
  10483. }
  10484. );
  10485. datas.Add(
  10486. new
  10487. {
  10488. AirType = "公务舱",
  10489. AirNum = item.GWCRS,
  10490. AirDRCB = item.GWCCB,
  10491. AirZCB = (item.GWCRS * item.GWCCB)
  10492. }
  10493. );
  10494. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10495. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  10496. modulePromptInfo.Data = new
  10497. {
  10498. airFeeData = datas,
  10499. airInitData = initDatas
  10500. };
  10501. _ModulePromptInfos.Add(modulePromptInfo);
  10502. break;
  10503. default:
  10504. break;
  10505. }
  10506. }
  10507. if (dto.CTable != 85)
  10508. {
  10509. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  10510. _ModulePromptInfos.Add(_ModulePromptInfo);
  10511. }
  10512. _view.ModulePromptInfos = _ModulePromptInfos;
  10513. return Ok(JsonView(true, "操作成功!", _view));
  10514. }
  10515. catch (Exception ex)
  10516. {
  10517. return Ok(JsonView(false, ex.Message));
  10518. }
  10519. }
  10520. /// <summary>
  10521. /// 根据黑屏代码重新生成行程
  10522. /// </summary>
  10523. /// <param name="dto"></param>
  10524. /// <returns></returns>
  10525. [HttpPost]
  10526. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  10527. {
  10528. var jw = JsonView(false);
  10529. var Create = _GroupCostRepository.
  10530. CreateGroupCostByBlackCode(dto.Diid);
  10531. jw.Msg = Create.Msg;
  10532. if (Create.Code == 0)
  10533. {
  10534. jw.Code = 200;
  10535. jw.Data = new
  10536. {
  10537. groupCost = Create.Data,
  10538. blackCodeIsTrue = true
  10539. };
  10540. }
  10541. else
  10542. {
  10543. jw.Code = 400;
  10544. jw.Data = new
  10545. {
  10546. groupCost = Create.Data,
  10547. blackCodeIsTrue = false,
  10548. };
  10549. }
  10550. return Ok(jw);
  10551. }
  10552. /// <summary>
  10553. /// 成本获取OP历史车费用
  10554. /// </summary>
  10555. /// <param name="dto"></param>
  10556. /// <returns></returns>
  10557. [HttpPost]
  10558. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  10559. {
  10560. var jw = JsonView(false);
  10561. try
  10562. {
  10563. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  10564. //获取现有所有车的数据
  10565. if (!dto.Param.IsNullOrWhiteSpace())
  10566. {
  10567. string sql = $@"
  10568. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  10569. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  10570. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  10571. 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
  10572. AND gctggr.ServiceEndTime is not NULL
  10573. ORDER by gctggrc.id DESC
  10574. ";
  10575. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  10576. var numeberResult = await Task.Run(() =>
  10577. {
  10578. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  10579. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  10580. return numberArr;
  10581. });
  10582. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  10583. foreach (var item in numeberResult)
  10584. {
  10585. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  10586. {
  10587. Country = "数据异常!",
  10588. City = string.Empty,
  10589. };
  10590. item.Area = find.Country + " " + find.City;
  10591. }
  10592. dbResult.AddRange(numeberResult);
  10593. if (dto.Param.Contains("、"))
  10594. {
  10595. var sp = dto.Param.Split("、");
  10596. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10597. .Where(x =>
  10598. {
  10599. return System.Array.Exists(sp, e =>
  10600. {
  10601. bool where = false;
  10602. if (x.Area != null)
  10603. {
  10604. where = x.Area.Contains(e);
  10605. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10606. {
  10607. return false;
  10608. }
  10609. }
  10610. if (x.PriceName != null && !where)
  10611. {
  10612. where = x.PriceName.Contains(e);
  10613. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10614. {
  10615. return false;
  10616. }
  10617. }
  10618. return where;
  10619. });
  10620. }).ToList();
  10621. }
  10622. else
  10623. {
  10624. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10625. .Where(x =>
  10626. {
  10627. bool where = false;
  10628. if (x.Area != null)
  10629. {
  10630. where = x.Area.Contains(dto.Param);
  10631. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10632. {
  10633. return false;
  10634. }
  10635. }
  10636. if (x.PriceName != null && !where)
  10637. {
  10638. where = x.PriceName.Contains(dto.Param);
  10639. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10640. {
  10641. return false;
  10642. }
  10643. }
  10644. return where;
  10645. }
  10646. )
  10647. .ToList();
  10648. }
  10649. }
  10650. var view = dbResult.Select(x =>
  10651. {
  10652. decimal dp = 0.00M;
  10653. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  10654. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  10655. if (string.IsNullOrWhiteSpace(x.DatePrice))
  10656. {
  10657. if (startB && endB)
  10658. {
  10659. var timesp = endD.Subtract(startD);
  10660. if ((timesp.Days + 1) != 0)
  10661. {
  10662. dp = x.Price / (timesp.Days + 1);
  10663. }
  10664. }
  10665. }
  10666. else
  10667. {
  10668. dp = x.Price;
  10669. }
  10670. return new
  10671. {
  10672. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  10673. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  10674. x.Area,
  10675. x.id,
  10676. price = x.Price.ToString("F2"),
  10677. x.PriceName,
  10678. x.PriceContent,
  10679. x.TeamName,
  10680. x.DatePrice,
  10681. dayPrice = dp.ToString("F2"),
  10682. };
  10683. }).OrderByDescending(x => x.id).ToList();
  10684. jw = JsonView(true, "获取成功!", view);
  10685. }
  10686. catch (Exception e)
  10687. {
  10688. jw = JsonView(false, e.Message);
  10689. }
  10690. return Ok(jw);
  10691. }
  10692. #endregion
  10693. #region 酒店预订 新 雷怡 2023-12-28 17:45
  10694. /// <summary>
  10695. /// 酒店预订
  10696. /// 酒店费用列表 根据团组Id查询
  10697. /// </summary>
  10698. /// <param name="_dto"></param>
  10699. /// <returns></returns>
  10700. [HttpPost]
  10701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10702. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  10703. {
  10704. #region 参数验证
  10705. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10706. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10707. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10708. #region 团组操作权限验证 76 酒店预定模块
  10709. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10710. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10711. #endregion
  10712. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10713. #region 页面操作权限验证
  10714. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10715. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10716. #endregion
  10717. #endregion
  10718. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  10719. }
  10720. /// <summary>
  10721. /// 酒店预订
  10722. /// 基础数据
  10723. /// </summary>
  10724. /// <param name="_dto"></param>
  10725. /// <returns></returns>
  10726. [HttpPost]
  10727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10728. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  10729. {
  10730. #region 参数验证
  10731. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10732. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10733. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10734. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10735. #region 页面操作权限验证
  10736. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10737. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10738. #endregion
  10739. #region 团组操作权限验证 76 酒店预定模块
  10740. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10741. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10742. #endregion
  10743. #endregion
  10744. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  10745. }
  10746. /// <summary>
  10747. /// 酒店预订
  10748. /// 创建 入住卷号码
  10749. /// </summary>
  10750. /// <param name="_dto"></param>
  10751. /// <returns></returns>
  10752. [HttpPost]
  10753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10754. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  10755. {
  10756. #region 参数验证
  10757. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10758. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10759. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10760. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10761. #region 页面操作权限验证
  10762. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10763. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10764. #endregion
  10765. #region 团组操作权限验证 76 酒店预定模块
  10766. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10767. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10768. #endregion
  10769. #endregion
  10770. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  10771. if (data.Code != 0)
  10772. {
  10773. return Ok(JsonView(false, data.Msg));
  10774. }
  10775. return Ok(JsonView(true, data.Msg, data.Data));
  10776. }
  10777. /// <summary>
  10778. /// 酒店预订
  10779. /// 详情
  10780. /// </summary>
  10781. /// <param name="_dto"></param>
  10782. /// <returns></returns>
  10783. [HttpPost]
  10784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10785. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  10786. {
  10787. #region 参数验证
  10788. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  10789. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10790. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  10791. #region 团组操作权限验证 76 酒店预定模块
  10792. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10793. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10794. #endregion
  10795. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10796. #region 页面操作权限验证
  10797. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10798. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10799. #endregion
  10800. #endregion
  10801. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  10802. }
  10803. /// <summary>
  10804. /// 酒店预订
  10805. /// Add Or Edit
  10806. /// </summary>
  10807. /// <param name="_dto"></param>
  10808. /// <returns></returns>
  10809. [HttpPost]
  10810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10811. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  10812. {
  10813. #region 参数验证
  10814. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10815. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10816. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10817. #region 团组操作权限验证 76 酒店预定模块
  10818. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10819. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10820. #endregion
  10821. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10822. #region 页面操作权限验证
  10823. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10824. if (_dto.Id == 0) // Add
  10825. {
  10826. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10827. }
  10828. else if (_dto.Id > 1) // Edit
  10829. {
  10830. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10831. }
  10832. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  10833. #endregion
  10834. #endregion
  10835. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  10836. if (_view.Code != 200)
  10837. {
  10838. return Ok(_view);
  10839. }
  10840. #region 成本无酒店价格数据进入超支
  10841. _sqlSugar.BeginTran();
  10842. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  10843. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  10844. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  10845. for (int i = 0; i < groupCost.Count; i++)
  10846. {
  10847. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  10848. {
  10849. groupCost[i].Date = groupCost[i - 1].Date;
  10850. }
  10851. }
  10852. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  10853. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  10854. List<Fin_GroupExtraCostDto_OP>();
  10855. if (start_Bool && end_Bool)
  10856. {
  10857. while (start_Time < end_Time)
  10858. {
  10859. foreach (var item in groupCost_Grp)
  10860. {
  10861. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  10862. {
  10863. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  10864. {
  10865. extraCostList.Add(new
  10866. Fin_GroupExtraCostDto_OP
  10867. {
  10868. Area = _dto.AreaId,
  10869. coefficient = 1.5M,
  10870. createUser = _dto.UserId,
  10871. currency = _dto.CardPriceCurrency,
  10872. diId = _dto.DiId,
  10873. ManagerConfirm = 0,
  10874. SupervisorConfirm = 0,
  10875. SYsupervisorConfirm = 0,
  10876. editType = 1,
  10877. PortType = 1,
  10878. price = _dto.CardPrice,
  10879. PriceCount = 1,
  10880. priceType = 1027,
  10881. priceDetailType = 1044,
  10882. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  10883. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  10884. });
  10885. }
  10886. }
  10887. }
  10888. start_Time = start_Time.AddDays(1);
  10889. }
  10890. }
  10891. if (extraCostList.Any())
  10892. {
  10893. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  10894. }
  10895. _sqlSugar.CommitTran();
  10896. #endregion
  10897. #region 应用推送
  10898. try
  10899. {
  10900. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10901. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10902. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10903. var diId = _dto.DiId;
  10904. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10905. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10906. #region 操作记录
  10907. var opInfo = new Crm_TableOperationRecord() {
  10908. TableName = "Grp_HotelReservations",
  10909. PortType = _dto.PortType,
  10910. DataId = hotelId,
  10911. CreateUserId = _dto.UserId
  10912. };
  10913. var opStatus = OperationEnum.NoOperation;
  10914. if (_dto.Id<1) //添加操作
  10915. {
  10916. opInfo.OperationItem = OperationEnum.Add;
  10917. }
  10918. else if (_dto.Id > 0)
  10919. {
  10920. opInfo.OperationItem = OperationEnum.Edit;
  10921. }
  10922. string opRemark = string.Empty;
  10923. if (ccpInfo != null)
  10924. {
  10925. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  10926. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  10927. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  10928. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  10929. }
  10930. opInfo.Remark = opRemark;
  10931. await _tableorRep.AddAsync(opInfo);
  10932. #endregion
  10933. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  10934. //2024-10-21 新增LZ UID
  10935. var userIds = new List<int>() { 21 };
  10936. string title = $"费用审核";
  10937. string content = "";
  10938. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10939. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10940. try
  10941. {
  10942. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10943. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  10944. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  10945. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  10946. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  10947. }
  10948. catch (Exception ex )
  10949. {
  10950. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  10951. }
  10952. }
  10953. catch (Exception ex)
  10954. {
  10955. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  10956. }
  10957. try
  10958. {
  10959. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10960. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10961. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10962. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10963. //自动审核
  10964. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  10965. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  10966. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  10967. //2024-10-21 新增LZ UID
  10968. var userIds = new List<int>() { 21 };
  10969. string title = $"系统通知";
  10970. var diId = _dto.DiId;
  10971. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10972. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10973. string content = "";
  10974. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10975. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10976. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10977. }
  10978. catch (Exception ex)
  10979. {
  10980. }
  10981. #endregion
  10982. return Ok(_view);
  10983. }
  10984. /// <summary>
  10985. /// 酒店自动审核测试
  10986. /// Add Or Edit
  10987. /// </summary>
  10988. /// <param name="_dto"></param>
  10989. /// <returns></returns>
  10990. [HttpPost]
  10991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10992. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  10993. {
  10994. #region 应用推送
  10995. try
  10996. {
  10997. //自动审核
  10998. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  10999. }
  11000. catch (Exception ex)
  11001. {
  11002. return Ok(JsonView(false, "操作失败"));
  11003. }
  11004. #endregion
  11005. return Ok(JsonView(false, "操作成功"));
  11006. }
  11007. /// <summary>
  11008. /// 酒店预订
  11009. /// Del
  11010. /// </summary>
  11011. /// <param name="_dto"></param>
  11012. /// <returns></returns>
  11013. [HttpPost]
  11014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11015. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  11016. {
  11017. #region 参数验证
  11018. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11019. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11020. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11021. #region 团组操作权限验证 76 酒店预定模块
  11022. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11023. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11024. #endregion
  11025. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11026. #region 页面操作权限验证
  11027. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11028. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11029. #endregion
  11030. #endregion
  11031. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  11032. #region 操作记录
  11033. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  11034. {
  11035. TableName = "Grp_HotelReservations",
  11036. PortType = _dto.PortType,
  11037. OperationItem = OperationEnum.Del,
  11038. DataId = _dto.Id,
  11039. CreateUserId = _dto.UserId
  11040. });
  11041. #endregion
  11042. return Ok(data);
  11043. }
  11044. /// <summary>
  11045. /// 酒店预订
  11046. /// 生成VOUCHER
  11047. /// 2024.05.06 之前版本
  11048. /// </summary>
  11049. /// <param name="_dto"></param>
  11050. /// <returns></returns>
  11051. [HttpPost]
  11052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11053. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  11054. {
  11055. try
  11056. {
  11057. #region 参数验证
  11058. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11059. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11060. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11061. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  11062. #region 团组操作权限验证 76 酒店预定模块
  11063. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11064. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11065. #endregion
  11066. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11067. #region 页面操作权限验证
  11068. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11069. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11070. #endregion
  11071. #endregion
  11072. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  11073. //判断数据是否完整
  11074. if (hr != null)
  11075. {
  11076. if (!string.IsNullOrEmpty(hr.DetermineNo))
  11077. {
  11078. string strFileName = "HotelStatement/";
  11079. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11080. if (dele != null)
  11081. strFileName += dele.TourCode;
  11082. //载入模板
  11083. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  11084. Document doc = new Document(sss);
  11085. DocumentBuilder builder = new DocumentBuilder(doc);
  11086. #region 替换Word模板书签内容
  11087. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  11088. //入住卷预定号码
  11089. if (doc.Range.Bookmarks["VNO"] != null)
  11090. {
  11091. Bookmark mark = doc.Range.Bookmarks["VNO"];
  11092. mark.Text = hr.CheckNumber;
  11093. }
  11094. //酒店时间
  11095. if (doc.Range.Bookmarks["Date"] != null)
  11096. {
  11097. Bookmark mark = doc.Range.Bookmarks["Date"];
  11098. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11099. }
  11100. //团号
  11101. if (doc.Range.Bookmarks["TNo"] != null)
  11102. {
  11103. Bookmark mark = doc.Range.Bookmarks["TNo"];
  11104. mark.Text = dele.TourCode;
  11105. }
  11106. //预定号码
  11107. if (doc.Range.Bookmarks["BookingId"] != null)
  11108. {
  11109. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  11110. mark.Text = hr.ReservationsNo;
  11111. }
  11112. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  11113. {
  11114. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  11115. mark.Text = hr.DetermineNo;
  11116. }
  11117. //酒店城市
  11118. if (doc.Range.Bookmarks["City"] != null)
  11119. {
  11120. Bookmark mark = doc.Range.Bookmarks["City"];
  11121. mark.Text = hr.City;
  11122. }
  11123. //酒店名称
  11124. if (doc.Range.Bookmarks["HName"] != null)
  11125. {
  11126. Bookmark mark = doc.Range.Bookmarks["HName"];
  11127. mark.Text = hr.HotelName;
  11128. }
  11129. //酒店地址
  11130. if (doc.Range.Bookmarks["Address"] != null)
  11131. {
  11132. Bookmark mark = doc.Range.Bookmarks["Address"];
  11133. mark.Text = hr.HotelAddress;
  11134. }
  11135. //酒店电话
  11136. if (doc.Range.Bookmarks["Tel"] != null)
  11137. {
  11138. Bookmark mark = doc.Range.Bookmarks["Tel"];
  11139. mark.Text = hr.HotelTel;
  11140. }
  11141. //酒店传真
  11142. if (doc.Range.Bookmarks["Fax"] != null)
  11143. {
  11144. Bookmark mark = doc.Range.Bookmarks["Fax"];
  11145. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  11146. {
  11147. mark.Text = hr.HotelFax;
  11148. }
  11149. }
  11150. //入住时间
  11151. if (doc.Range.Bookmarks["CIn"] != null)
  11152. {
  11153. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11154. Bookmark mark = doc.Range.Bookmarks["CIn"];
  11155. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  11156. }
  11157. //退房时间
  11158. if (doc.Range.Bookmarks["COut"] != null)
  11159. {
  11160. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11161. Bookmark mark = doc.Range.Bookmarks["COut"];
  11162. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11163. }
  11164. //客户名称
  11165. if (doc.Range.Bookmarks["GName"] != null)
  11166. {
  11167. string guestName = "";
  11168. string[] clients = new string[] { };
  11169. if (hr.GuestName.Contains(","))
  11170. {
  11171. clients = hr.GuestName.Split(",");
  11172. }
  11173. else
  11174. {
  11175. clients = new string[] { hr.GuestName };
  11176. }
  11177. List<int> clientIds_int = new List<int>();
  11178. if (clients.Length > 0)
  11179. {
  11180. foreach (var item in clients)
  11181. {
  11182. if (item.IsNumeric())
  11183. {
  11184. clientIds_int.Add(int.Parse(item));
  11185. }
  11186. }
  11187. }
  11188. if (clientIds_int.Count > 0)
  11189. {
  11190. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  11191. foreach (var client in _clientDatas)
  11192. {
  11193. //男
  11194. if (client.Sex == 0) guestName += $"Mr.";
  11195. //女
  11196. else if (client.Sex == 1) guestName += $"Ms.";
  11197. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  11198. {
  11199. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  11200. }
  11201. //guestName += $"{client.Pinyin},";
  11202. }
  11203. if (guestName.Length > 0)
  11204. {
  11205. guestName = guestName.Substring(0, guestName.Length - 1);
  11206. }
  11207. }
  11208. else
  11209. {
  11210. guestName = hr.GuestName;
  11211. }
  11212. Bookmark mark = doc.Range.Bookmarks["GName"];
  11213. mark.Text = guestName;
  11214. }
  11215. //房间介绍
  11216. if (doc.Range.Bookmarks["ROOM"] != null)
  11217. {
  11218. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  11219. mark.Text = hr.RoomExplanation;
  11220. }
  11221. //报价描述
  11222. if (doc.Range.Bookmarks["NOTE"] != null)
  11223. {
  11224. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  11225. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  11226. if (ss != null)
  11227. mark.Text = ss.Name;
  11228. }
  11229. //入住时间
  11230. if (doc.Range.Bookmarks["CheckIn"] != null)
  11231. {
  11232. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11233. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  11234. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11235. }
  11236. //退房时间
  11237. if (doc.Range.Bookmarks["CheckOut"] != null)
  11238. {
  11239. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11240. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  11241. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11242. }
  11243. //日期
  11244. if (doc.Range.Bookmarks["DT"] != null)
  11245. {
  11246. Bookmark mark = doc.Range.Bookmarks["DT"];
  11247. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11248. }
  11249. //名称
  11250. if (doc.Range.Bookmarks["VName"] != null)
  11251. {
  11252. Bookmark mark = doc.Range.Bookmarks["VName"];
  11253. mark.Text = hr.HotelName;
  11254. }
  11255. //号码
  11256. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  11257. {
  11258. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  11259. mark.Text = hr.CheckNumber;
  11260. }
  11261. #endregion
  11262. strFileName += "VOUCHER.doc";
  11263. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11264. doc.Save(fileDir);
  11265. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11266. return Ok(JsonView(true, "操作成功!", Url));
  11267. }
  11268. else
  11269. {
  11270. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  11271. }
  11272. }
  11273. else
  11274. {
  11275. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  11276. }
  11277. }
  11278. catch (Exception ex)
  11279. {
  11280. return Ok(JsonView(false, ex.Message));
  11281. }
  11282. }
  11283. /// <summary>
  11284. /// 酒店预订
  11285. /// 生成VOUCHER
  11286. /// 2024.05.06 之后版本
  11287. /// </summary>
  11288. /// <param name="_dto"></param>
  11289. /// <returns></returns>
  11290. [HttpPost]
  11291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11292. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  11293. {
  11294. #region 参数验证
  11295. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11296. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11297. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11298. #region 团组操作权限验证 76 酒店预定模块
  11299. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11300. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11301. #endregion
  11302. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11303. #region 页面操作权限验证
  11304. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11305. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11306. #endregion
  11307. #endregion
  11308. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  11309. //判断数据是否完整
  11310. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11311. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11312. string strFileName = "HotelStatement/";
  11313. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11314. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  11315. #region 数据处理
  11316. List<int> guestIds = new List<int>();
  11317. int index = 0;
  11318. foreach (var item in hrDtas)
  11319. {
  11320. if (item.GuestName.Contains(","))
  11321. {
  11322. string[] guestIdArr = item.GuestName.Split(',');
  11323. foreach (var guestIdStr in guestIdArr)
  11324. {
  11325. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  11326. if (guestBool)
  11327. {
  11328. guestIds.Add(guestId);
  11329. }
  11330. }
  11331. }
  11332. else guestNames += item.GuestName;
  11333. var voucherInfo = new HotelVoucherInfoView()
  11334. {
  11335. HotelName = item.HotelName,
  11336. CheckInDate = item.CheckInDate,
  11337. CheckOutDate = item.CheckOutDate,
  11338. ConfirmationNumber = item.DetermineNo.Trim(),
  11339. RoomType = item.RoomExplanation
  11340. };
  11341. vouchers.Add(voucherInfo);
  11342. }
  11343. if (guestIds.Count > 0)
  11344. {
  11345. guestIds = guestIds.Distinct().ToList();
  11346. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  11347. if (guestDatas.Count > 0)
  11348. {
  11349. guestNames = "";
  11350. foreach (var guest in guestDatas)
  11351. {
  11352. string guestName = "";
  11353. if (guest.Sex == 0) guestName += @"MR.";
  11354. else if (guest.Sex == 1) guestName += @"MS.";
  11355. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11356. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11357. guestNames += @$"{guestName.Trim()}、";
  11358. }
  11359. if (guestNames.Length > 0)
  11360. {
  11361. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11362. }
  11363. }
  11364. }
  11365. #endregion
  11366. //载入模板
  11367. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  11368. Document doc = new Document(sss);
  11369. DocumentBuilder builder = new DocumentBuilder(doc);
  11370. if (doc.Range.Bookmarks["GuestName"] != null)
  11371. {
  11372. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  11373. mark.Text = guestNames;
  11374. }
  11375. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11376. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  11377. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  11378. for (int i = 1; i <= vouchers.Count; i++)
  11379. {
  11380. HotelVoucherInfoView hviv = vouchers[i - 1];
  11381. builder.MoveToCell(0, i, 0, 0);
  11382. builder.Write(hviv.HotelName);
  11383. builder.MoveToCell(0, i, 1, 0);
  11384. builder.Write(hviv.CheckInDate);
  11385. builder.MoveToCell(0, i, 2, 0);
  11386. builder.Write(hviv.CheckOutDate);
  11387. builder.MoveToCell(0, i, 3, 0);
  11388. builder.Write(hviv.RoomType);
  11389. builder.MoveToCell(0, i, 4, 0);
  11390. builder.Write(hviv.ConfirmationNumber);
  11391. }
  11392. //删除多余行
  11393. int currRowIndex = vouchers.Count + 1;
  11394. int delRows = 21 - currRowIndex;
  11395. if (delRows > 0)
  11396. {
  11397. for (int i = 0; i < delRows; i++)
  11398. {
  11399. table.Rows.RemoveAt(currRowIndex);
  11400. //cultivateRowIndex++;
  11401. }
  11402. }
  11403. strFileName += "VOUCHER.docx";
  11404. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11405. doc.Save(fileDir);
  11406. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11407. return Ok(JsonView(true, "操作成功!", Url));
  11408. }
  11409. /// <summary>
  11410. /// 酒店预订
  11411. /// 生成VOUCHER 批量生成
  11412. /// New
  11413. /// </summary>
  11414. /// <param name="_dto"></param>
  11415. /// <returns></returns>
  11416. [HttpPost]
  11417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11418. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  11419. {
  11420. #region 参数验证
  11421. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11422. if (_dto.PageId < 1) _dto.PageId = 28;
  11423. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11424. #region 团组操作权限验证 76 酒店预定模块
  11425. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11426. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11427. #endregion
  11428. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11429. #region 页面操作权限验证
  11430. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11431. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11432. #endregion
  11433. #endregion
  11434. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  11435. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  11436. .OrderBy(x => x.CheckInDate)
  11437. .ToListAsync();
  11438. //判断数据是否完整
  11439. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11440. string strFileName = "HotelStatement/";
  11441. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11442. if (dele != null)
  11443. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  11444. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  11445. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  11446. .Where(it => it.IsDel == 0)
  11447. .ToListAsync();
  11448. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  11449. for (int i = 0; i < hrDtas.Count; i++)
  11450. {
  11451. string guestNames = string.Empty;
  11452. List<int> guestIds = new List<int>();
  11453. var item = hrDtas[i];
  11454. //处理客户姓名
  11455. if (item.GuestName.Contains(","))
  11456. {
  11457. string[] guestIdArr = item.GuestName.Split(',');
  11458. foreach (var guestIdStr in guestIdArr)
  11459. if (int.TryParse(guestIdStr, out int guestId))
  11460. guestIds.Add(guestId);
  11461. }
  11462. else
  11463. {
  11464. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  11465. if (guestIdBool)
  11466. {
  11467. guestIds.Add(guestId);
  11468. }
  11469. //NaN
  11470. if (item.GuestName.Contains("NaN"))
  11471. {
  11472. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  11473. }
  11474. }
  11475. if (guestIds.Count > 0)
  11476. {
  11477. guestIds = guestIds.Distinct().ToList();
  11478. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  11479. if (guestDatas1.Count > 0)
  11480. {
  11481. guestNames = "";
  11482. foreach (var guest in guestDatas1)
  11483. {
  11484. string guestName = "";
  11485. if (guest.Sex == 0) guestName += @"MR.";
  11486. else if (guest.Sex == 1) guestName += @"MS.";
  11487. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11488. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11489. guestNames += @$"{guestName.Trim()}、";
  11490. }
  11491. if (guestNames.Length > 0)
  11492. {
  11493. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11494. }
  11495. }
  11496. }
  11497. //if (!string.IsNullOrEmpty(guestNames))
  11498. //{
  11499. hrDtas[i].GuestName = guestNames;
  11500. //}
  11501. }
  11502. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11503. Document doc = new Document();
  11504. DocumentBuilder builder = new DocumentBuilder(doc);
  11505. try
  11506. {
  11507. builder.MoveToDocumentStart();
  11508. foreach (var item in hrDtas)
  11509. {
  11510. //标题
  11511. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11512. builder.ParagraphFormat.LineSpacing = 1;
  11513. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11514. builder.ParagraphFormat.Style.Font.Size = 9;
  11515. builder.ParagraphFormat.Style.Font.Bold = true;
  11516. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11517. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  11518. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11519. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11520. builder.ParagraphFormat.LineSpacing = 1;
  11521. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11522. builder.ParagraphFormat.Style.Font.Size = 9;
  11523. builder.ParagraphFormat.Style.Font.Bold = true;
  11524. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  11525. builder.StartTable();
  11526. // 设置边框颜色
  11527. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  11528. //设置边框样式
  11529. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  11530. //表格
  11531. #region 第一行
  11532. builder.InsertCell();
  11533. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11534. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11535. //builder.CellFormat.AllowAutoFit = false;
  11536. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11537. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11538. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11539. builder.CellFormat.WrapText = true; //自动换行
  11540. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11541. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  11542. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11543. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11544. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11545. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11546. builder.Write("TOUR NO:");
  11547. builder.InsertCell();
  11548. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11549. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11550. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11551. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11552. builder.ParagraphFormat.Style.Font.Bold = false;
  11553. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11554. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11555. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11556. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11557. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11558. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11559. builder.Write($"{dele?.TourCode ?? "-"}");
  11560. builder.InsertCell();
  11561. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11562. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11563. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11564. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11565. builder.ParagraphFormat.Style.Font.Bold = false;
  11566. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11567. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11568. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11569. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11570. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11571. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11572. builder.Write($"CITY:");
  11573. builder.InsertCell();
  11574. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11575. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11576. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11577. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11578. builder.ParagraphFormat.Style.Font.Bold = false;
  11579. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11580. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11581. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11582. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11583. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11584. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11585. builder.Write($"{item.City}");
  11586. builder.EndRow();
  11587. #endregion
  11588. #region 第二行
  11589. builder.InsertCell();
  11590. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11591. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11592. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11593. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11594. builder.ParagraphFormat.Style.Font.Bold = false;
  11595. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11596. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11597. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11598. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11599. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11600. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11601. builder.Write("CONFIRMATION NO:");
  11602. builder.InsertCell();
  11603. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11604. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11605. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11606. builder.ParagraphFormat.Style.Font.Bold = false;
  11607. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11608. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11609. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11610. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11611. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11612. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11613. builder.CellFormat.VerticalMerge = CellMerge.None;
  11614. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11615. builder.Write($"{item.DetermineNo}");
  11616. builder.InsertCell();
  11617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11618. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11619. builder.InsertCell();
  11620. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11621. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11622. builder.EndRow();
  11623. #endregion
  11624. #region 第三行
  11625. builder.InsertCell();
  11626. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11627. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11628. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11629. builder.ParagraphFormat.Style.Font.Bold = false;
  11630. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11631. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11632. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11633. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11634. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11635. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11636. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11637. builder.Write($"HOTEL NAME:");
  11638. builder.InsertCell();
  11639. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11640. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11641. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11642. builder.ParagraphFormat.Style.Font.Bold = false;
  11643. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11644. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11645. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11646. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11647. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11648. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11649. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11650. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11651. builder.Write($"{item.HotelName}");
  11652. builder.InsertCell();
  11653. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11654. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11655. builder.InsertCell();
  11656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11657. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11658. builder.EndRow();
  11659. #endregion
  11660. #region 第四行
  11661. builder.InsertCell();
  11662. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11663. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11664. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11665. builder.ParagraphFormat.Style.Font.Bold = false;
  11666. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11667. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11668. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11669. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11670. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11671. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11672. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11673. builder.Write($"HOTEL ADDRESS:");
  11674. builder.InsertCell();
  11675. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11676. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11677. builder.ParagraphFormat.Style.Font.Size = 8;
  11678. builder.ParagraphFormat.Style.Font.Bold = false;
  11679. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11680. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11681. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11682. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11683. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11684. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11685. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11686. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11687. builder.Write($"{item.HotelAddress}");
  11688. builder.InsertCell();
  11689. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11690. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11691. builder.InsertCell();
  11692. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11693. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11694. builder.EndRow();
  11695. #endregion
  11696. #region 第五行
  11697. builder.InsertCell();
  11698. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11699. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11700. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11701. builder.ParagraphFormat.Style.Font.Bold = false;
  11702. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11703. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11704. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11705. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11706. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11707. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11708. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11709. builder.Write("TEL:");
  11710. builder.InsertCell();
  11711. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11712. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11713. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11714. builder.ParagraphFormat.Style.Font.Bold = false;
  11715. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11716. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11717. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11718. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11719. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11720. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11721. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11722. builder.Write($"{item.HotelTel}");
  11723. builder.InsertCell();
  11724. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11725. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11726. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11727. builder.ParagraphFormat.Style.Font.Bold = false;
  11728. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11729. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11730. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11731. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11732. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11733. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11734. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11735. builder.Write($"FAX:");
  11736. builder.InsertCell();
  11737. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11738. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11739. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11740. builder.ParagraphFormat.Style.Font.Bold = false;
  11741. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11742. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11743. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11744. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11745. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11746. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11747. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11748. builder.Write($"{item.HotelFax}");
  11749. builder.EndRow();
  11750. #endregion
  11751. #region 第六行
  11752. builder.InsertCell();
  11753. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11754. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11755. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11756. builder.ParagraphFormat.Style.Font.Bold = false;
  11757. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11758. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11759. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11760. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11761. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11762. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11763. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11764. builder.Write("CHECK IN:");
  11765. builder.InsertCell();
  11766. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11767. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11768. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11769. builder.ParagraphFormat.Style.Font.Bold = false;
  11770. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11771. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11772. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11773. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11774. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11775. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11776. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11777. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  11778. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11779. builder.Write($"{checkInStr}");
  11780. builder.InsertCell();
  11781. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11782. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11783. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11784. builder.ParagraphFormat.Style.Font.Bold = false;
  11785. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11786. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11787. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11788. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11789. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11790. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11791. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11792. builder.Write($"CHECK OUT:");
  11793. builder.InsertCell();
  11794. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11795. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11796. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11797. builder.ParagraphFormat.Style.Font.Bold = false;
  11798. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11799. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11800. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11801. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11802. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11803. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11804. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11805. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  11806. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  11807. builder.Write($"{checkOutStr}");
  11808. builder.EndRow();
  11809. #endregion
  11810. #region 第七行
  11811. builder.InsertCell();
  11812. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11813. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11814. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11815. builder.ParagraphFormat.Style.Font.Bold = false;
  11816. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11817. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11818. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11819. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11820. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11821. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11822. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11823. builder.Write($"GUEST NAME:");
  11824. builder.InsertCell();
  11825. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11826. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11827. builder.ParagraphFormat.Style.Font.Size = 8;
  11828. builder.ParagraphFormat.Style.Font.Bold = false;
  11829. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11830. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11831. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11832. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11833. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11834. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11835. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11836. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11837. builder.Write($"{item.GuestName}");
  11838. builder.InsertCell();
  11839. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11840. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11841. builder.InsertCell();
  11842. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11843. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11844. builder.EndRow();
  11845. #endregion
  11846. #region 第八行
  11847. builder.InsertCell();
  11848. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11849. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11850. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11851. builder.ParagraphFormat.Style.Font.Bold = false;
  11852. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11853. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11854. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11855. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11856. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11857. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11858. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11859. builder.Write($"ROOM TYPE:");
  11860. builder.InsertCell();
  11861. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11862. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11863. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11864. builder.ParagraphFormat.Style.Font.Bold = false;
  11865. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11866. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11867. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11868. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11869. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11870. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11871. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11872. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11873. builder.Write($"{item.RoomExplanation}");
  11874. builder.InsertCell();
  11875. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11876. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11877. builder.InsertCell();
  11878. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11879. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11880. builder.EndRow();
  11881. #endregion
  11882. #region 第九行
  11883. builder.InsertCell();
  11884. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11885. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11886. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11887. builder.ParagraphFormat.Style.Font.Bold = false;
  11888. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11889. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11890. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11891. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11892. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11893. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11894. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11895. builder.Write($"NOTE:");
  11896. builder.InsertCell();
  11897. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11898. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11899. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11900. builder.ParagraphFormat.Style.Font.Bold = false;
  11901. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11902. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11903. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11904. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11905. 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.");
  11906. builder.InsertCell();
  11907. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11908. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11909. builder.InsertCell();
  11910. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11911. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11912. builder.EndRow();
  11913. #endregion
  11914. builder.EndTable();
  11915. //换行
  11916. builder.Writeln("");
  11917. builder.Writeln("");
  11918. }
  11919. #region 获取文档中的所有表格 设置文字自适应
  11920. // 获取文档中的所有表格。
  11921. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11922. {
  11923. // 遍历表格中的所有行。
  11924. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11925. {
  11926. foreach (Cell cell in row.Cells)
  11927. {
  11928. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  11929. cellFormat.Width = 0;
  11930. }
  11931. }
  11932. }
  11933. #endregion
  11934. #region 设置页眉
  11935. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  11936. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  11937. if (System.IO.File.Exists(voucherHeaderPath))
  11938. {
  11939. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  11940. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  11941. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  11942. Shape shape = builder.InsertImage(imageBytes);
  11943. // 调整图片位置
  11944. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  11945. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  11946. shape.Top = 50; // 将图片距离页眉上边缘的距离
  11947. shape.Left = 0; // 将图片距离页面左边缘的距离
  11948. shape.Width = 81; // 设置图片宽度
  11949. shape.Height = 36; // 设置图片高度
  11950. }
  11951. //靠右
  11952. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  11953. //// 设置页脚上下边距
  11954. //builder.PageSetup.HeaderDistance = 42;
  11955. // 添加页眉线
  11956. Aspose.Words.Border borderHeader = null;
  11957. try
  11958. {
  11959. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  11960. }
  11961. catch (Exception e)
  11962. {
  11963. // TODO Auto-generated catch block
  11964. //e.printStackTrace();
  11965. }
  11966. borderHeader.Shadow = true;
  11967. borderHeader.DistanceFromText = 2;
  11968. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  11969. #endregion
  11970. }
  11971. catch (Exception ex)
  11972. {
  11973. }
  11974. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11975. doc.Save(fileDir);
  11976. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11977. return Ok(JsonView(true, "操作成功!", Url));
  11978. }
  11979. /// <summary>
  11980. /// 酒店预订
  11981. /// 生成 预定成本 Excel
  11982. /// </summary>
  11983. /// <param name="_dto"></param>
  11984. /// <returns></returns>
  11985. [HttpPost]
  11986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11987. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  11988. {
  11989. #region 参数验证
  11990. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  11991. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  11992. if (!vadalitorRes.IsValid)
  11993. {
  11994. var errors = new StringBuilder();
  11995. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  11996. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  11997. }
  11998. #region 团组操作权限验证 76 酒店预定模块
  11999. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12000. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12001. #endregion
  12002. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12003. #region 页面操作权限验证
  12004. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12005. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12006. #endregion
  12007. #endregion
  12008. decimal _rate = 1.00M;
  12009. string _currency = string.Empty;
  12010. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  12011. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  12012. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  12013. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  12014. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  12015. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  12016. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  12017. if (_GroupCostParameter == null)
  12018. {
  12019. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  12020. bool isIntType = int.TryParse(_currency, out int currId);
  12021. if (isIntType)
  12022. {
  12023. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12024. }
  12025. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12026. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12027. if (currInfo == null)
  12028. {
  12029. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12030. }
  12031. else _rate = currInfo.Rate;
  12032. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  12033. {
  12034. _rate = _GroupCostParameter.Rate;
  12035. }
  12036. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12037. string strFileName = "HotelStatement/";
  12038. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12039. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12040. var rateDatas = new List<dynamic>();
  12041. #region 数据处理
  12042. foreach (var item in hrDtas)
  12043. {
  12044. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12045. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12046. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12047. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12048. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12049. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  12050. {
  12051. continue;
  12052. }
  12053. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12054. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  12055. string singleRoomFeeStr = string.Empty,
  12056. doubleRoomFeeStr = string.Empty,
  12057. suiteRoomFeeStr = string.Empty,
  12058. otherRoomFeeStr = string.Empty,
  12059. payMoneyStr = string.Empty,
  12060. cardPriceStr = string.Empty;
  12061. if (roomCurr.Equals("CNY"))
  12062. {
  12063. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  12064. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12065. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12066. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12067. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12068. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  12069. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  12070. }
  12071. else
  12072. {
  12073. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12074. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12075. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12076. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12077. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12078. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12079. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12080. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12081. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12082. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12083. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  12084. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  12085. if (ccpPaymentCurrency.Equals("CNY"))
  12086. {
  12087. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  12088. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12089. }
  12090. else
  12091. {
  12092. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  12093. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  12094. }
  12095. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  12096. if (hotelcardPriceCurrency.Equals("CNY"))
  12097. {
  12098. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12099. }
  12100. else
  12101. {
  12102. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  12103. }
  12104. }
  12105. string breakfastPriceStr = string.Empty,
  12106. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12107. governmentRentStr = string.Empty,
  12108. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12109. cityTaxStr = string.Empty,
  12110. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12111. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  12112. if (!string.IsNullOrEmpty(breakfastCurrency1))
  12113. {
  12114. if (breakfastCurrency1.Equals("CNY"))
  12115. {
  12116. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12117. }
  12118. else
  12119. {
  12120. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  12121. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  12122. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  12123. }
  12124. }
  12125. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12126. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  12127. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  12128. {
  12129. if (governmentRentCurrency.Equals("CNY"))
  12130. {
  12131. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12132. }
  12133. else
  12134. {
  12135. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  12136. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  12137. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  12138. }
  12139. }
  12140. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12141. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  12142. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  12143. {
  12144. if (cityTaxStrCurrency1.Equals("CNY"))
  12145. {
  12146. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12147. }
  12148. else
  12149. {
  12150. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  12151. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  12152. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  12153. }
  12154. }
  12155. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12156. int payDId = roomInfo?.PayDId ?? 0;
  12157. pcfds.Add(new HotelReservations_PCFD_View()
  12158. {
  12159. City = item.City,
  12160. HotelName = item.HotelName,
  12161. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12162. // SingleRoomCount = item.SingleRoomCount,
  12163. SingleRoomPrice = singleRoomFeeStr,
  12164. // DoubleRoomCount = item.DoubleRoomCount,
  12165. DoubleRoomPrice = doubleRoomFeeStr,
  12166. //SuiteRoomCount = item.SuiteRoomCount,
  12167. SuiteRoomPrice = suiteRoomFeeStr,
  12168. OtherRoomPrice = otherRoomFeeStr,
  12169. //OtherRoomCount = item.OtherRoomCount,
  12170. BreakfastPrice = breakfastPriceStr,
  12171. GovernmentRent = governmentRentStr,
  12172. CityTax = cityTaxStr,
  12173. RoomExplanation = item.RoomExplanation,
  12174. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12175. PayTime = roomInfo?.ConsumptionDate,
  12176. BankNo = roomInfo?.BankNo,
  12177. PayMoney = payMoneyStr,
  12178. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12179. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12180. CardPrice = cardPriceStr,
  12181. Remark = ccpInfo.Remark
  12182. });
  12183. }
  12184. #endregion
  12185. //载入模板
  12186. WorkbookDesigner designer = new WorkbookDesigner();
  12187. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12188. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12189. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12190. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12191. var rateDatas1 = rateDatas.Distinct();
  12192. var rateStr = string.Empty;
  12193. foreach (var item in rateDatas1)
  12194. {
  12195. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  12196. }
  12197. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  12198. designer.SetDataSource("Opertor", userInfo.CnName);
  12199. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12200. dt.TableName = "ViewMyHotelReservations";
  12201. designer.SetDataSource(dt);
  12202. designer.Process();
  12203. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12204. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12205. designer.Workbook.Save(serverPath);
  12206. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12207. #region 删除指定行
  12208. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12209. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12210. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12211. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12212. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12213. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12214. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12215. cssIndex = dt.Columns["CityTax"].Ordinal,
  12216. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12217. remarkIndex = dt.Columns["Remark"].Ordinal;
  12218. //删除指定列
  12219. foreach (DataRow item in dt.Rows)
  12220. {
  12221. string singleStr = item["SingleRoomPrice"].ToString();
  12222. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12223. if (containsDigitButNotZero1) singleDel = false;
  12224. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12225. string doubleStr = item["DoubleRoomPrice"].ToString();
  12226. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12227. if (containsDigitButNotZero2) doubleDel = false;
  12228. string suiteStr = item["SuiteRoomPrice"].ToString();
  12229. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12230. if (containsDigitButNotZero3) suiteDel = false;
  12231. string otherStr = item["OtherRoomPrice"].ToString();
  12232. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12233. if (containsDigitButNotZero4) otherDel = false;
  12234. string zcStr = item["BreakfastPrice"].ToString();
  12235. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12236. if (containsDigitButNotZero5) zcDel = false;
  12237. string dsStr = item["GovernmentRent"].ToString();
  12238. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12239. if (containsDigitButNotZero6) dsDel = false;
  12240. string cssStr = item["CityTax"].ToString();
  12241. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12242. if (containsDigitButNotZero7) cssDel = false;
  12243. string cpStr = item["ConsumptionPatterns"].ToString();
  12244. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12245. string remarkStr = item["Remark"].ToString();
  12246. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12247. }
  12248. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12249. DeleteColumn(serverPath, cpIndex, cpDel);
  12250. DeleteColumn(serverPath, dsIndex, dsDel);
  12251. DeleteColumn(serverPath, cssIndex, cssDel);
  12252. DeleteColumn(serverPath, zcIndex, zcDel);
  12253. DeleteColumn(serverPath, otherIndex, otherDel);
  12254. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12255. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12256. DeleteColumn(serverPath, singleIndex, singleDel);
  12257. #endregion
  12258. //只保留第一个表格
  12259. DeleteSheet(serverPath);
  12260. return Ok(JsonView(true, "操作成功", url = rst));
  12261. }
  12262. else
  12263. {
  12264. _currency = _GroupCostParameter.Currency;
  12265. bool isIntType = int.TryParse(_currency, out int currId);
  12266. if (isIntType)
  12267. {
  12268. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12269. }
  12270. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12271. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12272. if (currInfo == null)
  12273. {
  12274. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12275. }
  12276. if (!_currency.ToUpper().Equals("CNY"))
  12277. {
  12278. _rate = _GroupCostParameter.Rate;
  12279. }
  12280. _rate = currInfo.Rate;
  12281. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12282. string strFileName = "HotelStatement/";
  12283. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12284. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12285. #region 数据处理
  12286. foreach (var item in hrDtas)
  12287. {
  12288. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12289. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12290. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12291. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12292. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12293. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12294. string singleRoomFeeStr = string.Empty,
  12295. doubleRoomFeeStr = string.Empty,
  12296. suiteRoomFeeStr = string.Empty,
  12297. otherRoomFeeStr = string.Empty,
  12298. payMoneyStr = string.Empty,
  12299. cardPriceStr = string.Empty;
  12300. if (roomCurr.Equals(_currency))
  12301. {
  12302. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  12303. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  12304. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  12305. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  12306. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  12307. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  12308. }
  12309. else
  12310. {
  12311. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12312. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12313. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12314. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12315. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12316. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12317. }
  12318. string breakfastPriceStr = string.Empty,
  12319. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12320. governmentRentStr = string.Empty,
  12321. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12322. cityTaxStrStr = string.Empty,
  12323. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12324. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  12325. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  12326. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  12327. int payDId = roomInfo?.PayDId ?? 0;
  12328. pcfds.Add(new HotelReservations_PCFD_View()
  12329. {
  12330. City = item.City,
  12331. HotelName = item.HotelName,
  12332. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12333. // SingleRoomCount = item.SingleRoomCount,
  12334. SingleRoomPrice = singleRoomFeeStr,
  12335. // DoubleRoomCount = item.DoubleRoomCount,
  12336. DoubleRoomPrice = doubleRoomFeeStr,
  12337. //SuiteRoomCount = item.SuiteRoomCount,
  12338. SuiteRoomPrice = suiteRoomFeeStr,
  12339. OtherRoomPrice = otherRoomFeeStr,
  12340. //OtherRoomCount = item.OtherRoomCount,
  12341. BreakfastPrice = breakfastPriceStr,
  12342. GovernmentRent = governmentRentStr,
  12343. CityTax = cityTaxStrStr,
  12344. RoomExplanation = item.RoomExplanation,
  12345. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12346. PayTime = roomInfo?.ConsumptionDate,
  12347. BankNo = roomInfo?.BankNo,
  12348. PayMoney = payMoneyStr,
  12349. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12350. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12351. CardPrice = cardPriceStr,
  12352. Remark = ccpInfo.Remark
  12353. });
  12354. }
  12355. #endregion
  12356. //载入模板
  12357. WorkbookDesigner designer = new WorkbookDesigner();
  12358. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12359. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12360. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12361. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12362. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  12363. designer.SetDataSource("Opertor", userInfo.CnName);
  12364. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12365. dt.TableName = "ViewMyHotelReservations";
  12366. designer.SetDataSource(dt);
  12367. designer.Process();
  12368. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12369. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12370. designer.Workbook.Save(serverPath);
  12371. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12372. #region 删除指定行
  12373. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12374. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12375. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12376. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12377. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12378. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12379. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12380. cssIndex = dt.Columns["CityTax"].Ordinal,
  12381. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12382. remarkIndex = dt.Columns["Remark"].Ordinal;
  12383. //删除指定列
  12384. foreach (DataRow item in dt.Rows)
  12385. {
  12386. string singleStr = item["SingleRoomPrice"].ToString();
  12387. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12388. if (containsDigitButNotZero1) singleDel = false;
  12389. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12390. string doubleStr = item["DoubleRoomPrice"].ToString();
  12391. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12392. if (containsDigitButNotZero2) doubleDel = false;
  12393. string suiteStr = item["SuiteRoomPrice"].ToString();
  12394. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12395. if (containsDigitButNotZero3) suiteDel = false;
  12396. string otherStr = item["OtherRoomPrice"].ToString();
  12397. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12398. if (containsDigitButNotZero4) otherDel = false;
  12399. string zcStr = item["BreakfastPrice"].ToString();
  12400. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12401. if (containsDigitButNotZero5) zcDel = false;
  12402. string dsStr = item["GovernmentRent"].ToString();
  12403. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12404. if (containsDigitButNotZero6) dsDel = false;
  12405. string cssStr = item["CityTax"].ToString();
  12406. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12407. if (containsDigitButNotZero7) cssDel = false;
  12408. string cpStr = item["ConsumptionPatterns"].ToString();
  12409. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12410. string remarkStr = item["Remark"].ToString();
  12411. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12412. }
  12413. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12414. DeleteColumn(serverPath, cpIndex, cpDel);
  12415. DeleteColumn(serverPath, dsIndex, dsDel);
  12416. DeleteColumn(serverPath, cssIndex, cssDel);
  12417. DeleteColumn(serverPath, zcIndex, zcDel);
  12418. DeleteColumn(serverPath, otherIndex, otherDel);
  12419. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12420. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12421. DeleteColumn(serverPath, singleIndex, singleDel);
  12422. #endregion
  12423. //只保留第一个表格
  12424. DeleteSheet(serverPath);
  12425. return Ok(JsonView(true, "操作成功", url = rst));
  12426. }
  12427. return Ok(JsonView(false));
  12428. }
  12429. /// <summary>
  12430. /// 删除指定列
  12431. /// </summary>
  12432. /// <param name="file"></param>
  12433. /// <param name="columnIndex"></param>
  12434. /// <param name="isDel"></param>
  12435. private void DeleteColumn(string file, int columnIndex, bool isDel)
  12436. {
  12437. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12438. //wb.Save(file);
  12439. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  12440. if (sheet1 != null)
  12441. {
  12442. if (isDel)
  12443. {
  12444. Cells cells = sheet1.Cells;
  12445. cells.DeleteColumn(columnIndex);
  12446. }
  12447. }
  12448. wb.Save(file);
  12449. }
  12450. /// <summary>
  12451. /// 删除sheet
  12452. /// </summary>
  12453. /// <param name="file"></param>
  12454. /// <param name="sheetName"></param>
  12455. private void DeleteSheet(string file, string sheetName = "")
  12456. {
  12457. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12458. //wb.Save(file);
  12459. List<string> sheets = new List<string>();
  12460. foreach (var item in wb.Worksheets)
  12461. {
  12462. sheets.Add(item.Name);
  12463. }
  12464. if (sheets.Count > 0)
  12465. {
  12466. sheets.RemoveAt(0);//不删除第一个sheet
  12467. foreach (var item in sheets)
  12468. {
  12469. wb.Worksheets.RemoveAt(item);
  12470. }
  12471. }
  12472. wb.Save(file);
  12473. }
  12474. /// <summary>
  12475. /// 酒店预订
  12476. /// 确认单
  12477. /// </summary>
  12478. /// <param name="_dto"></param>
  12479. /// <returns></returns>
  12480. [HttpPost]
  12481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12482. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  12483. {
  12484. try
  12485. {
  12486. #region 参数验证
  12487. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12488. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12489. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12490. #region 团组操作权限验证 76 酒店预定模块
  12491. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12492. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12493. #endregion
  12494. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12495. #region 页面操作权限验证
  12496. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12497. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12498. #endregion
  12499. #endregion
  12500. //团组信息
  12501. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  12502. //酒店数据
  12503. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  12504. if (listhoteldata.Count < 0)
  12505. {
  12506. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  12507. }
  12508. //利datatable存储
  12509. DataTable dt = new DataTable();
  12510. dt.Columns.Add("CheckInDate", typeof(string));
  12511. dt.Columns.Add("City", typeof(string));
  12512. dt.Columns.Add("Hotel", typeof(string));
  12513. dt.Columns.Add("Room", typeof(string));
  12514. for (int i = 0; i < listhoteldata.Count; i++)
  12515. {
  12516. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  12517. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  12518. while (dayStart < dayEnd)
  12519. {
  12520. string temp = "";
  12521. DataRow row = dt.NewRow();
  12522. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  12523. row["City"] = listhoteldata[i].City;
  12524. row["Hotel"] = listhoteldata[i].HotelName;
  12525. if (listhoteldata[i].SingleRoomCount > 0)
  12526. {
  12527. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  12528. }
  12529. if (listhoteldata[i].DoubleRoomCount > 0)
  12530. {
  12531. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  12532. }
  12533. if (listhoteldata[i].SuiteRoomCount > 0)
  12534. {
  12535. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  12536. }
  12537. if (listhoteldata[i].OtherRoomCount > 0)
  12538. {
  12539. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  12540. }
  12541. row["Room"] = temp;
  12542. dt.Rows.Add(row);
  12543. dayStart = dayStart.AddDays(1);
  12544. }
  12545. }
  12546. Dictionary<string, string> dic = new Dictionary<string, string>();
  12547. dic.Add("Dele", di.TeamName);
  12548. dic.Add("City", di.VisitCountry);
  12549. //模板路径
  12550. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  12551. //载入模板
  12552. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  12553. DocumentBuilder builder = new DocumentBuilder(doc);
  12554. foreach (var key in dic.Keys)
  12555. {
  12556. builder.MoveToBookmark(key);
  12557. builder.Write(dic[key]);
  12558. }
  12559. //获取word里所有表格
  12560. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12561. //获取所填表格的序数
  12562. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12563. var rowStart = tableOne.Rows[0]; //获取第1行
  12564. //循环赋值
  12565. for (int i = 0; i < dt.Rows.Count; i++)
  12566. {
  12567. builder.MoveToCell(0, i + 1, 0, 0);
  12568. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  12569. builder.MoveToCell(0, i + 1, 1, 0);
  12570. builder.Write(dt.Rows[i]["City"].ToString());
  12571. builder.MoveToCell(0, i + 1, 2, 0);
  12572. builder.Write(dt.Rows[i]["Hotel"].ToString());
  12573. builder.MoveToCell(0, i + 1, 3, 0);
  12574. builder.Write(dt.Rows[i]["Room"].ToString());
  12575. }
  12576. //删除多余行
  12577. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  12578. {
  12579. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  12580. }
  12581. string strFileName = di.TeamName + "酒店确认单.doc";
  12582. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  12583. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  12584. return Ok(JsonView(true, "成功", url));
  12585. }
  12586. catch (Exception ex)
  12587. {
  12588. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  12589. }
  12590. }
  12591. #endregion
  12592. #region 团组状态
  12593. /// <summary>
  12594. /// 团组状态列表 Page
  12595. /// </summary>
  12596. /// <param name="dto">团组列表请求dto</param>
  12597. /// <returns></returns>
  12598. [HttpPost]
  12599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12600. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  12601. {
  12602. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12603. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  12604. {
  12605. string sqlWhere = string.Empty;
  12606. if (dto.IsSure == 0) //未完成
  12607. {
  12608. sqlWhere += string.Format(@" And IsSure = 0");
  12609. }
  12610. else if (dto.IsSure == 1) //已完成
  12611. {
  12612. sqlWhere += string.Format(@" And IsSure = 1");
  12613. }
  12614. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  12615. {
  12616. string tj = dto.SearchCriteria;
  12617. 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}%')",
  12618. tj, tj, tj, tj, tj);
  12619. }
  12620. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  12621. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  12622. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  12623. From (
  12624. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  12625. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  12626. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  12627. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  12628. From Grp_DelegationInfo gdi
  12629. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  12630. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  12631. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  12632. Where gdi.IsDel = 0 {0}
  12633. ) temp ", sqlWhere);
  12634. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  12635. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  12636. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  12637. }
  12638. else
  12639. {
  12640. return Ok(JsonView(false, "查询失败"));
  12641. }
  12642. }
  12643. /// <summary>
  12644. /// 团组状态
  12645. /// 设置操作完成
  12646. /// </summary>
  12647. /// <param name="dto">团组列表请求dto</param>
  12648. /// <returns></returns>
  12649. [HttpPost]
  12650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12651. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  12652. {
  12653. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12654. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  12655. {
  12656. Id = dto.Id,
  12657. IsSure = 1
  12658. };
  12659. var result = await _sqlSugar.Updateable(_DelegationInfo)
  12660. .UpdateColumns(it => new { it.IsSure })
  12661. .WhereColumns(it => new { it.Id })
  12662. .ExecuteCommandAsync();
  12663. if (result > 0)
  12664. {
  12665. return Ok(JsonView(true, "操作完成!"));
  12666. }
  12667. return Ok(JsonView(false, "操作失败!"));
  12668. }
  12669. #endregion
  12670. #region 保险费用录入
  12671. /// <summary>
  12672. /// 根据团组Id查询保险费用列表
  12673. /// </summary>
  12674. /// <param name="dto"></param>
  12675. /// <returns></returns>
  12676. [HttpPost]
  12677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12678. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  12679. {
  12680. Result groupData = await _customersRep.CustomersByDiId(dto);
  12681. if (groupData.Code != 0)
  12682. {
  12683. return Ok(JsonView(false, groupData.Msg));
  12684. }
  12685. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12686. }
  12687. /// <summary>
  12688. /// 根据保险费用Id查询保险费用详细
  12689. /// </summary>
  12690. /// <param name="dto"></param>
  12691. /// <returns></returns>
  12692. [HttpPost]
  12693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12694. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  12695. {
  12696. try
  12697. {
  12698. Result groupData = await _customersRep.CustomersById(dto);
  12699. if (groupData.Code != 0)
  12700. {
  12701. return Ok(JsonView(false, groupData.Msg));
  12702. }
  12703. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12704. }
  12705. catch (Exception ex)
  12706. {
  12707. return Ok(JsonView(false, ex.Message));
  12708. }
  12709. }
  12710. /// <summary>
  12711. /// 保险费用录入页面初始化绑定
  12712. /// </summary>
  12713. /// <param name="dto"></param>
  12714. /// <returns></returns>
  12715. [HttpPost]
  12716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12717. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  12718. {
  12719. try
  12720. {
  12721. Result groupData = await _customersRep.CustomersInitialize(dto);
  12722. if (groupData.Code != 0)
  12723. {
  12724. return Ok(JsonView(false, groupData.Msg));
  12725. }
  12726. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12727. }
  12728. catch (Exception ex)
  12729. {
  12730. return Ok(JsonView(false, ex.Message));
  12731. }
  12732. }
  12733. /// <summary>
  12734. /// 保险费用操作(Status:1.新增,2.修改)
  12735. /// </summary>
  12736. /// <param name="dto"></param>
  12737. /// <returns></returns>
  12738. [HttpPost]
  12739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12740. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  12741. {
  12742. Result groupData = await _customersRep.OpCustomers(dto);
  12743. if (groupData.Code != 0)
  12744. {
  12745. return Ok(JsonView(false, groupData.Msg));
  12746. }
  12747. #region 应用推送
  12748. try
  12749. {
  12750. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12751. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12752. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  12753. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12754. //自动审核
  12755. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  12756. //2024-10-21 新增LZ UID
  12757. var userIds = new List<int>() { 21 };
  12758. string title = $"系统通知";
  12759. var diId = dto.DiId;
  12760. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12761. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12762. string content = "";
  12763. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12764. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12765. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12766. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12767. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12768. }
  12769. catch (Exception ex)
  12770. {
  12771. }
  12772. #endregion
  12773. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12774. }
  12775. /// <summary>
  12776. /// 保险文件上传
  12777. /// </summary>
  12778. /// <param name="file"></param>
  12779. /// <returns></returns>
  12780. [HttpPost]
  12781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12782. public async Task<IActionResult> UploadCus(IFormFile file)
  12783. {
  12784. try
  12785. {
  12786. if (file != null)
  12787. {
  12788. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12789. //文件名称
  12790. string projectFileName = file.FileName;
  12791. //上传的文件的路径
  12792. string filePath = "";
  12793. if (!Directory.Exists(fileDir))
  12794. {
  12795. Directory.CreateDirectory(fileDir);
  12796. }
  12797. //上传的文件的路径
  12798. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  12799. using (FileStream fs = System.IO.File.Create(filePath))
  12800. {
  12801. file.CopyTo(fs);
  12802. fs.Flush();
  12803. }
  12804. return Ok(JsonView(true, "上传成功!", projectFileName));
  12805. }
  12806. else
  12807. {
  12808. return Ok(JsonView(false, "上传失败!"));
  12809. }
  12810. }
  12811. catch (Exception ex)
  12812. {
  12813. return Ok(JsonView(false, "程序错误!"));
  12814. throw;
  12815. }
  12816. }
  12817. /// <summary>
  12818. /// 保险删除指定文件
  12819. /// </summary>
  12820. /// <param name="dto"></param>
  12821. /// <returns></returns>
  12822. [HttpPost]
  12823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12824. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  12825. {
  12826. try
  12827. {
  12828. string filePath = "";
  12829. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12830. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  12831. //int id = 0;
  12832. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  12833. // 删除该文件
  12834. try
  12835. {
  12836. System.IO.File.Delete(filePath);
  12837. 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()
  12838. {
  12839. Attachment = "",
  12840. }).ExecuteCommandAsync();
  12841. if (result != 0)
  12842. {
  12843. return Ok(JsonView(true, "成功!"));
  12844. }
  12845. else
  12846. {
  12847. return Ok(JsonView(false, "失败!"));
  12848. }
  12849. }
  12850. catch (Exception)
  12851. {
  12852. 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()
  12853. {
  12854. Attachment = "",
  12855. }).ExecuteCommandAsync();
  12856. if (result != 0)
  12857. {
  12858. return Ok(JsonView(true, "成功!"));
  12859. }
  12860. else
  12861. {
  12862. return Ok(JsonView(false, "失败!"));
  12863. }
  12864. }
  12865. }
  12866. catch (Exception ex)
  12867. {
  12868. return Ok(JsonView(false, "程序错误!"));
  12869. throw;
  12870. }
  12871. }
  12872. /// <summary>
  12873. /// 保险费用操作(删除)
  12874. /// </summary>
  12875. /// <param name="dto"></param>
  12876. /// <returns></returns>
  12877. [HttpPost]
  12878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12879. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  12880. {
  12881. try
  12882. {
  12883. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  12884. if (!res)
  12885. {
  12886. return Ok(JsonView(false, "删除失败"));
  12887. }
  12888. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  12889. {
  12890. IsDel = 1,
  12891. DeleteUserId = dto.DeleteUserId,
  12892. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12893. }).ExecuteCommandAsync();
  12894. return Ok(JsonView(true, "删除成功!"));
  12895. }
  12896. catch (Exception ex)
  12897. {
  12898. return Ok(JsonView(false, "程序错误!"));
  12899. throw;
  12900. }
  12901. }
  12902. #endregion
  12903. #region 接团客户名单 PageId 104
  12904. /// <summary>
  12905. /// 接团客户名单
  12906. /// 迁移数据(慎用!)
  12907. /// </summary>
  12908. /// <param name="dto"></param>
  12909. /// <returns></returns>
  12910. [HttpPost]
  12911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12912. public async Task<IActionResult> PostTourClientListChange()
  12913. {
  12914. try
  12915. {
  12916. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  12917. //var groupClinetData1
  12918. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  12919. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  12920. int updateCount = 0;
  12921. if (oldOAClientList.Count > 0)
  12922. {
  12923. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  12924. _sqlSugar.BeginTran();
  12925. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  12926. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  12927. foreach (var item in oldOAClientList)
  12928. {
  12929. int comId = 0;
  12930. string format = "yyyy-MM-dd HH:mm:ss";
  12931. string data11 = "1990-01-01 00:00";
  12932. var data1 = IsValidDate(item.OPdate, format);
  12933. if (data1) data11 = item.OPdate;
  12934. //客户公司验证
  12935. if (!string.IsNullOrEmpty(item.Company))
  12936. {
  12937. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  12938. if (clientComInfo == null) // add
  12939. {
  12940. var addInfo = new Crm_CustomerCompany()
  12941. {
  12942. CompanyAbbreviation = "",
  12943. CompanyFullName = item.Company,
  12944. Address = "",
  12945. PostCodes = "",
  12946. LastedOpUserId = item.OPer,
  12947. LastedOpDt = Convert.ToDateTime(data11),
  12948. CreateUserId = item.OPer,
  12949. CreateTime = Convert.ToDateTime(data11),
  12950. IsDel = 0
  12951. };
  12952. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  12953. if (comId1 > 0) comId = comId1;
  12954. }
  12955. else comId = clientComInfo.Id;
  12956. }
  12957. //客户人员验证
  12958. int clientId = 0;
  12959. string name = item.LastName + item.Name;
  12960. if (!string.IsNullOrEmpty(name))
  12961. {
  12962. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  12963. if (clientInfo == null)
  12964. {
  12965. DateTime? dateTime = null;
  12966. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  12967. if (isDt) dateTime = birthDayDt;
  12968. var addInfo1 = new Crm_DeleClient()
  12969. {
  12970. CrmCompanyId = comId,
  12971. DiId = -1,
  12972. LastName = item.LastName,
  12973. FirstName = item.Name,
  12974. OldName = "",
  12975. Pinyin = item.Pinyin,
  12976. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  12977. Marriage = 0,
  12978. Phone = item.Phone,
  12979. Job = item.Job,
  12980. BirthDay = dateTime
  12981. };
  12982. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  12983. if (clientId1 > 0) clientId = clientId1;
  12984. }
  12985. else clientId = clientInfo.Id;
  12986. }
  12987. if (clientId < 1)
  12988. {
  12989. continue;
  12990. }
  12991. int airType = 0;
  12992. if (item.AirType == "超经舱") airType = 459;
  12993. else if (item.AirType == "公务舱") airType = 458;
  12994. else if (item.AirType == "经济舱") airType = 460;
  12995. else if (item.AirType == "其他") airType = 565;
  12996. else if (item.AirType == "头等舱") airType = 457;
  12997. var _TourClientListEntity = new Grp_TourClientList()
  12998. {
  12999. DiId = item.Diid,
  13000. ClientId = clientId,
  13001. CreateUserId = item.OPer,
  13002. CreateTime = Convert.ToDateTime(data11),
  13003. Remark = item.Remark,
  13004. IsDel = item.Isdel,
  13005. ShippingSpaceTypeId = airType,
  13006. ShippingSpaceSpecialNeeds = item.AirRemark,
  13007. HotelSpecialNeeds = item.RoomType
  13008. };
  13009. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  13010. if (_TourClientList > 0)
  13011. {
  13012. updateCount++;
  13013. }
  13014. }
  13015. _sqlSugar.CommitTran();
  13016. }
  13017. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  13018. }
  13019. catch (Exception ex)
  13020. {
  13021. _sqlSugar.RollbackTran();
  13022. return Ok(JsonView(false, ex.Message));
  13023. }
  13024. return Ok(JsonView(true));
  13025. }
  13026. private bool IsValidDate(string dateString, string format)
  13027. {
  13028. DateTime dateValue;
  13029. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  13030. return valid;
  13031. }
  13032. /// <summary>
  13033. /// 接团客户名单
  13034. /// 根据团组Id查询List
  13035. /// </summary>
  13036. /// <param name="dto"></param>
  13037. /// <returns></returns>
  13038. [HttpPost]
  13039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13040. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  13041. {
  13042. #region 参数验证
  13043. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  13044. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  13045. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  13046. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13047. #region 页面操作权限验证
  13048. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13049. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13050. #endregion
  13051. #endregion
  13052. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  13053. if (viewData.Code != 0)
  13054. {
  13055. return Ok(JsonView(false, viewData.Msg));
  13056. }
  13057. return Ok(JsonView(viewData.Data));
  13058. }
  13059. /// <summary>
  13060. /// 接团客户名单
  13061. /// 基础数据 Init
  13062. /// </summary>
  13063. /// <param name="_dto"></param>
  13064. /// <returns></returns>
  13065. [HttpPost]
  13066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13067. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  13068. {
  13069. #region 参数验证
  13070. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13071. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13072. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13073. #region 页面操作权限验证
  13074. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13075. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13076. #endregion
  13077. #endregion
  13078. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  13079. }
  13080. /// <summary>
  13081. /// 接团客户名单
  13082. /// 根据 Id查询 Details
  13083. /// </summary>
  13084. /// <param name="_dto"></param>
  13085. /// <returns></returns>
  13086. [HttpPost]
  13087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13088. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  13089. {
  13090. #region 参数验证
  13091. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13092. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13093. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13094. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13095. #region 页面操作权限验证
  13096. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13097. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13098. #endregion
  13099. #endregion
  13100. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  13101. if (viewData.Code != 0)
  13102. {
  13103. return Ok(JsonView(false, viewData.Msg));
  13104. }
  13105. return Ok(JsonView(viewData.Data));
  13106. }
  13107. /// <summary>
  13108. /// 接团客户名单
  13109. /// Add Or Edit
  13110. /// </summary>
  13111. /// <param name="_dto"></param>
  13112. /// <returns></returns>
  13113. [HttpPost]
  13114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13115. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  13116. {
  13117. #region 参数验证
  13118. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13119. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13120. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13121. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13122. #region 页面操作权限验证
  13123. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13124. if (_dto.Id == 0) //添加
  13125. {
  13126. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13127. }
  13128. else if (_dto.Id >= 0) //修改
  13129. {
  13130. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13131. }
  13132. #endregion
  13133. #endregion
  13134. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  13135. if (viewData.Code != 0)
  13136. {
  13137. return Ok(JsonView(false, viewData.Msg));
  13138. }
  13139. return Ok(JsonView(true));
  13140. }
  13141. /// <summary>
  13142. /// 接团客户名单
  13143. /// AddMultiple(添加多个)
  13144. /// </summary>
  13145. /// <param name="_dto"></param>
  13146. /// <returns></returns>
  13147. [HttpPost]
  13148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13149. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  13150. {
  13151. #region 参数验证
  13152. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13153. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13154. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13155. #region 页面操作权限验证
  13156. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13157. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13158. #endregion
  13159. #endregion
  13160. var viewData = await _tourClientListRep._AddMultiple(_dto);
  13161. if (viewData.Code != 0)
  13162. {
  13163. return Ok(JsonView(false, viewData.Msg));
  13164. }
  13165. return Ok(JsonView(true));
  13166. }
  13167. /// <summary>
  13168. /// 接团客户名单
  13169. /// Del
  13170. /// </summary>
  13171. /// <param name="_dto"></param>
  13172. /// <returns></returns>
  13173. [HttpPost]
  13174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13175. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  13176. {
  13177. #region 参数验证
  13178. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13179. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13180. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13181. #region 页面操作权限验证
  13182. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13183. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13184. #endregion
  13185. #endregion
  13186. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  13187. if (viewData.Code != 0)
  13188. {
  13189. return Ok(JsonView(false, viewData.Msg));
  13190. }
  13191. return Ok(JsonView(true));
  13192. }
  13193. /// <summary>
  13194. /// 接团客户名单
  13195. /// 文件下载 客户名单
  13196. /// </summary>
  13197. /// <param name="_dto"></param>
  13198. /// <returns></returns>
  13199. [HttpPost]
  13200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13201. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  13202. {
  13203. #region 参数验证
  13204. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13205. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13206. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  13207. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13208. #region 页面操作权限验证
  13209. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13210. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13211. #endregion
  13212. #endregion
  13213. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  13214. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  13215. From Grp_TourClientList tcl
  13216. Left Join
  13217. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  13218. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  13219. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  13220. From Crm_DeleClient dc
  13221. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  13222. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  13223. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  13224. Where dc.IsDel = 0) temp
  13225. On temp.DcId =tcl.ClientId
  13226. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  13227. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  13228. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  13229. //载入模板
  13230. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  13231. if (_dto.Language == 1)
  13232. {
  13233. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  13234. }
  13235. //载入模板
  13236. var doc = new Document(tempPath);
  13237. DocumentBuilder builder = new DocumentBuilder(doc);
  13238. //获取word里所有表格
  13239. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13240. //获取所填表格的序数
  13241. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13242. var rowStart = tableOne.Rows[0]; //获取第1行
  13243. if (_dto.Language == 0)
  13244. {
  13245. //循环赋值
  13246. for (int i = 0; i < DcList.Count; i++)
  13247. {
  13248. EncryptionProcessor.DecryptProperties(DcList[i]);
  13249. builder.MoveToCell(0, i + 1, 0, 0);
  13250. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  13251. builder.MoveToCell(0, i + 1, 1, 0);
  13252. int sex = DcList[i].Sex;
  13253. string sexStr = string.Empty;
  13254. if (sex == 0) sexStr = "男";
  13255. else if (sex == 1) sexStr = "女";
  13256. else sexStr = "未设置";
  13257. builder.Write(sexStr);
  13258. builder.MoveToCell(0, i + 1, 2, 0);
  13259. string birthDay = DcList[i].BirthDay;
  13260. string birthDayStr = string.Empty;
  13261. if (!string.IsNullOrEmpty(birthDay))
  13262. {
  13263. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  13264. }
  13265. builder.Write(birthDayStr);
  13266. builder.MoveToCell(0, i + 1, 3, 0);
  13267. string company = "";
  13268. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13269. {
  13270. company = DcList[i].CompanyFullName.ToString();
  13271. }
  13272. builder.Write(company);
  13273. builder.MoveToCell(0, i + 1, 4, 0);
  13274. builder.Write(DcList[i].Job);
  13275. }
  13276. }
  13277. else if (_dto.Language == 1)
  13278. {
  13279. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  13280. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  13281. List<string> transArrayStr = new List<string>();
  13282. string transStrRes1 = "";
  13283. for (int i = 0; i < DcList.Count; i++)
  13284. {
  13285. var dc = DcList[i];
  13286. EncryptionProcessor.DecryptProperties(dc);
  13287. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  13288. if (dc.Job.Equals("暂无")) dc.Job = "-";
  13289. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  13290. if (DcList.Count - 1 == i) transStrRes1 += str1;
  13291. else transStrRes1 += $"{str1}|";
  13292. }
  13293. //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";
  13294. string transStrRes = "";
  13295. if (transStrRes1.Length > 0)
  13296. {
  13297. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  13298. }
  13299. //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
  13300. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  13301. //List<string> transArray = new List<string> { };
  13302. List<TranslateInfo> transArray = new List<TranslateInfo>();
  13303. if (transStrRes.Contains("|"))
  13304. {
  13305. string[] transArray1 = transStrRes.Split('|');
  13306. if (transArray1.Length > 0)
  13307. {
  13308. foreach (var item in transArray1)
  13309. {
  13310. if (item.Contains("&"))
  13311. {
  13312. string[] transArray2 = item.Split('&');
  13313. int index = 0;
  13314. string companyName = "", job = "";
  13315. if (transArray2.Length > 0)
  13316. {
  13317. bool success = int.TryParse(transArray2[0].Trim(), out index);
  13318. if (1 < transArray2.Length) companyName = transArray2[1];
  13319. if (2 < transArray2.Length) job = transArray2[2];
  13320. }
  13321. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  13322. }
  13323. }
  13324. }
  13325. }
  13326. //循环赋值
  13327. for (int i = 0; i < DcList.Count; i++)
  13328. {
  13329. string PYName = "";
  13330. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  13331. {
  13332. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  13333. string PY_First = DcList[i].Pinyin.Split('/')[1];
  13334. PYName = PY_First + " " + PY_Last;
  13335. }
  13336. else
  13337. {
  13338. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  13339. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  13340. PYName = PY_First + " " + PY_Last;
  13341. }
  13342. builder.MoveToCell(0, i + 1, 0, 0);
  13343. builder.Write(PYName);
  13344. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  13345. builder.MoveToCell(0, i + 1, 1, 0);
  13346. builder.Write(sex);
  13347. DateTime birthDt;
  13348. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  13349. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  13350. builder.MoveToCell(0, i + 1, 2, 0);
  13351. builder.Write(birthday);
  13352. string company = string.Empty, job = string.Empty;
  13353. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  13354. if (dcTransInfo != null)
  13355. {
  13356. company = dcTransInfo.CompanyName;
  13357. job = dcTransInfo.Job;
  13358. }
  13359. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13360. {
  13361. //查询对照表
  13362. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  13363. if (tempCec != null)
  13364. {
  13365. company = tempCec.enName;
  13366. }
  13367. //翻译
  13368. else
  13369. {
  13370. }
  13371. }
  13372. builder.MoveToCell(0, i + 1, 3, 0);
  13373. builder.Write(company);
  13374. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  13375. {
  13376. //查询对照表
  13377. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  13378. if (tempPec != null)
  13379. {
  13380. job = tempPec.enName;
  13381. }
  13382. //翻译
  13383. else
  13384. {
  13385. }
  13386. }
  13387. builder.MoveToCell(0, i + 1, 4, 0);
  13388. builder.Write(job);
  13389. }
  13390. }
  13391. //删除多余行
  13392. while (tableOne.Rows.Count > DcList.Count + 1)
  13393. {
  13394. tableOne.Rows.RemoveAt(DcList.Count + 1);
  13395. }
  13396. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  13397. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  13398. doc.Save(fileDir);
  13399. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  13400. return Ok(JsonView(true, "操作成功!", Url));
  13401. }
  13402. private class TranslateInfo
  13403. {
  13404. public int Index { get; set; }
  13405. public string CompanyName { get; set; }
  13406. public string Job { get; set; }
  13407. }
  13408. #endregion
  13409. #region 团组倒推表
  13410. /// <summary>
  13411. /// 倒推表基础数据
  13412. /// Init
  13413. /// </summary>
  13414. /// <param name="dto"></param>
  13415. /// <returns></returns>
  13416. [HttpPost]
  13417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13418. public async Task<IActionResult> PostInvertedListInit()
  13419. {
  13420. var viewData = await _invertedListRep._Init();
  13421. if (viewData.Code != 0)
  13422. {
  13423. return Ok(JsonView(false, viewData.Msg));
  13424. }
  13425. return Ok(JsonView(viewData.Data));
  13426. }
  13427. /// <summary>
  13428. /// 倒推表
  13429. /// Info
  13430. /// </summary>
  13431. /// <param name="dto"></param>
  13432. /// <returns></returns>
  13433. [HttpPost]
  13434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13435. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  13436. {
  13437. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  13438. if (viewData.Code != 0)
  13439. {
  13440. return Ok(JsonView(false, viewData.Msg));
  13441. }
  13442. return Ok(JsonView(viewData.Data));
  13443. }
  13444. /// <summary>
  13445. /// 倒推表
  13446. /// Create
  13447. /// </summary>
  13448. /// <param name="dto"></param>
  13449. /// <returns></returns>
  13450. [HttpPost]
  13451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13452. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  13453. {
  13454. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  13455. if (viewData.Code != 0)
  13456. {
  13457. return Ok(JsonView(false, viewData.Msg));
  13458. }
  13459. return Ok(JsonView(viewData.Data));
  13460. }
  13461. /// <summary>
  13462. /// 倒推表
  13463. /// Update
  13464. /// </summary>
  13465. /// <param name="dto"></param>
  13466. /// <returns></returns>
  13467. [HttpPost]
  13468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13469. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  13470. {
  13471. var viewData = await _invertedListRep._Update(dto);
  13472. if (viewData.Code != 0)
  13473. {
  13474. return Ok(JsonView(false, viewData.Msg));
  13475. }
  13476. return Ok(JsonView(viewData.Data));
  13477. }
  13478. /// <summary>
  13479. /// 倒推表
  13480. /// File Download
  13481. /// </summary>
  13482. /// <param name="dto"></param>
  13483. /// <returns></returns>
  13484. [HttpPost]
  13485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13486. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  13487. {
  13488. var info2 = await _invertedListRep._Info(1, dto.DiId);
  13489. if (info2.Code != 0)
  13490. {
  13491. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  13492. }
  13493. var info1 = info2.Data as InvertedListInfoView;
  13494. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  13495. string teamName = "";
  13496. if (info != null) teamName = info.TeamName;
  13497. //载入模板
  13498. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  13499. DocumentBuilder builder = new DocumentBuilder(doc);
  13500. //利用键值对存放数据
  13501. Dictionary<string, string> dic = new Dictionary<string, string>();
  13502. dic.Add("TeamName", teamName);
  13503. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  13504. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  13505. dic.Add("BPRemark", info1.ApprovalDataRemark);
  13506. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  13507. dic.Add("SQRemark", info1.ApprovalRemark);
  13508. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  13509. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  13510. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  13511. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  13512. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  13513. dic.Add("QZRemark", info1.VisaInformationRemark);
  13514. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  13515. dic.Add("SQQZRemark", info1.SendVisaRemark);
  13516. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  13517. dic.Add("CQRemark", info1.IssueVisaRemark);
  13518. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  13519. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  13520. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  13521. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  13522. #region 填充word模板书签内容
  13523. foreach (var key in dic.Keys)
  13524. {
  13525. builder.MoveToBookmark(key);
  13526. builder.Write(dic[key]);
  13527. }
  13528. #endregion
  13529. var fileDir = AppSettingsHelper.Get("WordBasePath");
  13530. string fileName = $"{teamName}团出行准备流程表.doc";
  13531. string filePath = fileDir + $@"InvertedList/{fileName}";
  13532. doc.Save(filePath);
  13533. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  13534. return Ok(JsonView(true, "操作成功!", Url));
  13535. }
  13536. #endregion
  13537. #region 三公签证费用(签证费、代办费)
  13538. /// <summary>
  13539. /// 三公签证费用(签证费、代办费)
  13540. /// List
  13541. /// </summary>
  13542. /// <returns></returns>
  13543. [HttpPost]
  13544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13545. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  13546. {
  13547. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  13548. if (_view.Code != 0)
  13549. {
  13550. return Ok(JsonView(false, _view.Msg));
  13551. }
  13552. return Ok(JsonView(true, "操作成功!", _view.Data));
  13553. }
  13554. /// <summary>
  13555. /// 三公签证费用(签证费、代办费)
  13556. /// Add Or Update
  13557. /// </summary>
  13558. /// <returns></returns>
  13559. [HttpPost]
  13560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13561. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  13562. {
  13563. var _view = await _visaFeeInfoRep._Update(_dto);
  13564. if (_view.Code != 0)
  13565. {
  13566. return Ok(JsonView(false, _view.Msg));
  13567. }
  13568. return Ok(JsonView(true, _view.Msg));
  13569. }
  13570. #endregion
  13571. #region 酒店询价
  13572. /// <summary>
  13573. /// 酒店询价
  13574. /// Init
  13575. /// </summary>
  13576. /// <param name="dto"></param>
  13577. /// <returns></returns>
  13578. [HttpPost]
  13579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13580. public async Task<IActionResult> PostHotelInquiryInit()
  13581. {
  13582. var res = await _hotelInquiryRep._Init();
  13583. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13584. return Ok(JsonView(true, res.Msg, res.Data));
  13585. }
  13586. /// <summary>
  13587. /// 酒店询价
  13588. /// page Item
  13589. /// </summary>
  13590. /// <param name="_dto"></param>
  13591. /// <returns></returns>
  13592. [HttpPost]
  13593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13594. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  13595. {
  13596. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  13597. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13598. var view = res.Data as PageDataViewBase;
  13599. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  13600. }
  13601. /// <summary>
  13602. /// 酒店询价
  13603. /// info
  13604. /// </summary>
  13605. /// <param name="_dto"></param>
  13606. /// <returns></returns>
  13607. [HttpPost]
  13608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13609. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  13610. {
  13611. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  13612. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13613. return Ok(JsonView(true, res.Msg, res.Data));
  13614. }
  13615. /// <summary>
  13616. /// 酒店询价
  13617. /// Add Or Edit
  13618. /// </summary>
  13619. /// <param name="_dto"></param>
  13620. /// <returns></returns>
  13621. [HttpPost]
  13622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13623. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  13624. {
  13625. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  13626. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13627. return Ok(JsonView(true, res.Msg, res.Data));
  13628. }
  13629. /// <summary>
  13630. /// 酒店询价
  13631. /// Del
  13632. /// </summary>
  13633. /// <param name="_dto"></param>
  13634. /// <returns></returns>
  13635. [HttpPost]
  13636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13637. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  13638. {
  13639. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  13640. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13641. return Ok(JsonView(true, res.Msg, res.Data));
  13642. }
  13643. #endregion
  13644. #region 下载匹配op行程单
  13645. /// <summary>
  13646. /// 匹配op行程单
  13647. /// Init
  13648. /// </summary>
  13649. /// <param name="dto">团组列表请求dto</param>
  13650. /// <returns></returns>
  13651. [HttpPost]
  13652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13653. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  13654. {
  13655. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13656. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13657. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  13658. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  13659. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  13660. .Where(it => it.IsDel == 0)
  13661. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  13662. .OrderByDescending(it => it.CreateUserId)
  13663. .ToList();
  13664. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  13665. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13666. var diids = groupInfos.Select(it => it.Id).ToList();
  13667. List<string> countrys = new List<string>();
  13668. foreach (var item in country)
  13669. {
  13670. var data = _groupRepository.FormartTeamName(item);
  13671. var dataArray = _groupRepository.GroupSplitCountry(data);
  13672. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13673. }
  13674. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  13675. List<string> areaArray = new List<string>(); //GetGroupCityLine
  13676. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  13677. foreach (var item in areaItem)
  13678. {
  13679. string areaStr = item.Value;
  13680. if (!string.IsNullOrEmpty(areaStr))
  13681. {
  13682. string[] str1 = areaStr.Split("-");
  13683. if (str1.Length > 0)
  13684. {
  13685. areaArray.AddRange(str1);
  13686. }
  13687. }
  13688. }
  13689. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  13690. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  13691. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  13692. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  13693. .ToList();
  13694. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  13695. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  13696. .Where(it => countriesIds.Contains(it.Id))
  13697. .Select(it => new { it.Id, Name = it.Name_CN })
  13698. .ToList();
  13699. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  13700. .Select(it => it.TeamName).ToList();
  13701. stopwatch.Stop();
  13702. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  13703. }
  13704. ///// <summary>
  13705. ///// 匹配op行程单
  13706. ///// Init 查询区域数据
  13707. ///// </summary>
  13708. ///// <param name="dto">团组列表请求dto</param>
  13709. ///// <returns></returns>
  13710. //[HttpPost]
  13711. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13712. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  13713. //{
  13714. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13715. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  13716. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  13717. // if (string.IsNullOrEmpty(countriesDataStr))
  13718. // {
  13719. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  13720. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  13721. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  13722. // }
  13723. // else
  13724. // {
  13725. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  13726. // }
  13727. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  13728. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  13729. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  13730. // List<dynamic> childList = new List<dynamic>();
  13731. // int parentId = dto.CountriesId;
  13732. // if (provinceData.Count > 1)
  13733. // {
  13734. // foreach (var item1 in provinceData)
  13735. // {
  13736. // List<dynamic> childList1 = new List<dynamic>();
  13737. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  13738. // foreach (var item2 in citiesData1)
  13739. // {
  13740. // List<dynamic> childList2 = new List<dynamic>();
  13741. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13742. // foreach (var item3 in countiesData1)
  13743. // {
  13744. // childList2.Add(new
  13745. // {
  13746. // id = item3.Id,
  13747. // parentId = item2.Id,
  13748. // level = "district",
  13749. // name = item3.Name_CN,
  13750. // });
  13751. // }
  13752. // childList1.Add(new
  13753. // {
  13754. // id = item2.Id,
  13755. // parentId = item1.Id,
  13756. // level = "city",
  13757. // name = item2.Name_CN,
  13758. // childList = childList2
  13759. // });
  13760. // }
  13761. // childList.Add(new
  13762. // {
  13763. // id = item1.Id,
  13764. // parentId = parentId,
  13765. // level = "province",
  13766. // name = item1.Name_CN,
  13767. // childList = childList1
  13768. // });
  13769. // }
  13770. // //城市
  13771. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  13772. // foreach (var item2 in citiesData2)
  13773. // {
  13774. // List<dynamic> childList22 = new List<dynamic>();
  13775. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13776. // foreach (var item3 in countiesData1)
  13777. // {
  13778. // childList22.Add(new
  13779. // {
  13780. // id = item3.Id,
  13781. // parentId = item2.Id,
  13782. // level = "district",
  13783. // name = item3.Name_CN,
  13784. // });
  13785. // }
  13786. // childList.Add(new
  13787. // {
  13788. // id = item2.Id,
  13789. // parentId = parentId,
  13790. // level = "city",
  13791. // name = item2.Name_CN,
  13792. // childList = childList22
  13793. // });
  13794. // }
  13795. // }
  13796. // else
  13797. // {
  13798. // foreach (var item2 in citiesData)
  13799. // {
  13800. // string cname = item2.Name_CN;
  13801. // List<dynamic> childList1 = new List<dynamic>();
  13802. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13803. // foreach (var item3 in countiesData1)
  13804. // {
  13805. // childList1.Add(new
  13806. // {
  13807. // Id = item3.Id,
  13808. // parentId = item2.Id,
  13809. // level = "district",
  13810. // name = item3.Name_CN
  13811. // });
  13812. // }
  13813. // childList.Add(new
  13814. // {
  13815. // id = item2.Id,
  13816. // parentId = parentId,
  13817. // level = "city",
  13818. // name = item2.Name_CN,
  13819. // childList = childList1
  13820. // });
  13821. // }
  13822. // }
  13823. // stopwatch.Stop();
  13824. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  13825. //}
  13826. /// <summary>
  13827. /// 匹配op行程单
  13828. /// 接团信息列表 Page
  13829. /// </summary>
  13830. /// <param name="dto">团组列表请求dto</param>
  13831. /// <returns></returns>
  13832. [HttpPost]
  13833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13834. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  13835. {
  13836. var swatch = new Stopwatch();
  13837. swatch.Start();
  13838. #region 参数验证
  13839. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13840. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13841. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13842. #region 页面操作权限验证
  13843. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13844. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  13845. #endregion
  13846. #endregion
  13847. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13848. {
  13849. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  13850. string sqlWhere = "";
  13851. if (!string.IsNullOrEmpty(dto.Country))
  13852. {
  13853. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  13854. }
  13855. if (!string.IsNullOrEmpty(dto.Area))
  13856. {
  13857. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  13858. }
  13859. if (!string.IsNullOrEmpty(dto.TeamName))
  13860. {
  13861. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  13862. }
  13863. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  13864. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  13865. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  13866. swatch.Stop();
  13867. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  13868. }
  13869. else
  13870. {
  13871. return Ok(JsonView(false, "查询失败"));
  13872. }
  13873. }
  13874. /// <summary>
  13875. /// 匹配op行程单
  13876. /// 行程单下载
  13877. /// </summary>
  13878. /// <param name="dto">团组列表请求dto</param>
  13879. /// <returns></returns>
  13880. [HttpPost]
  13881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13882. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  13883. {
  13884. #region 参数验证
  13885. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13886. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13887. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13888. #region 页面操作权限验证
  13889. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13890. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  13891. #endregion
  13892. #endregion
  13893. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13894. {
  13895. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  13896. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  13897. }
  13898. else
  13899. {
  13900. return Ok(JsonView(false, "下载失败!"));
  13901. }
  13902. }
  13903. #endregion
  13904. #region 国家信息 数据 注释
  13905. //[HttpPost]
  13906. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  13907. //{
  13908. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  13909. // foreach (var item in dto)
  13910. // {
  13911. // infos.Add(new Grp_GroupsTaskAssignment()
  13912. // {
  13913. // DIId = item,
  13914. // CTId = 82,
  13915. // UId = 248,
  13916. // IsEnable = 1,
  13917. // CreateUserId = 233,
  13918. // CreateTime = DateTime.Now,
  13919. // IsDel = 0
  13920. // });
  13921. // infos.Add(new Grp_GroupsTaskAssignment()
  13922. // {
  13923. // DIId = item,
  13924. // CTId = 82,
  13925. // UId = 286,
  13926. // IsEnable = 1,
  13927. // CreateUserId = 233,
  13928. // CreateTime = DateTime.Now,
  13929. // IsDel = 0
  13930. // });
  13931. // }
  13932. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  13933. // return Ok("操作成功");
  13934. //}
  13935. //public class paramJsonDto
  13936. //{
  13937. // public List<CountriesInfo> str { get; set; }
  13938. //}
  13939. //[HttpPost]
  13940. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  13941. //{
  13942. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  13943. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  13944. // List<Sys_Cities> cities = new List<Sys_Cities>();
  13945. // List<Sys_Cities> districts = new List<Sys_Cities>();
  13946. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  13947. // _sqlSugar.BeginTran();
  13948. // int countitiesIndex = 0;
  13949. // foreach (var item in dto.str)
  13950. // {
  13951. // dynamic data = item.c;
  13952. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  13953. // if (data != null)
  13954. // {
  13955. // countitiesIndex++;
  13956. // foreach (var item1 in data)
  13957. // {
  13958. // string cnname = item1.cn;
  13959. // string enname = item1.en;
  13960. // Sys_Cities provinceInfo = new Sys_Cities()
  13961. // {
  13962. // CountriesId = countriesId,
  13963. // Name_CN = cnname,
  13964. // Name_EN = enname,
  13965. // ParentId = 0,
  13966. // IsCapital = 1,
  13967. // CreateUserId = 208,
  13968. // CreateTime = DateTime.Now,
  13969. // IsDel = 0
  13970. // };
  13971. // if (item1.lv == "province") //省份
  13972. // {
  13973. // provinceInfo.Level = 1;
  13974. // int provinceId = 0;
  13975. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  13976. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  13977. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  13978. // var data1 = item1.c;
  13979. // foreach (var item2 in data1)
  13980. // {
  13981. // if (item2.lv == "city")
  13982. // {
  13983. // string citycnname = item2.cn;
  13984. // string cityenname = item2.en;
  13985. // Sys_Cities cityInfo = new Sys_Cities()
  13986. // {
  13987. // CountriesId = countriesId,
  13988. // ParentId = provinceId,
  13989. // Level = 2,
  13990. // Name_CN = citycnname,
  13991. // Name_EN = cityenname,
  13992. // IsCapital = 1,
  13993. // CreateUserId = 208,
  13994. // CreateTime = DateTime.Now,
  13995. // IsDel = 0
  13996. // };
  13997. // if (item2.c != null)
  13998. // {
  13999. // int cityId = 0;
  14000. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  14001. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14002. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  14003. // foreach (var item3 in item2.c)
  14004. // {
  14005. // if (item3.lv == "district")
  14006. // {
  14007. // var districtInfo = new Sys_Cities()
  14008. // {
  14009. // CountriesId = countriesId,
  14010. // Name_CN = item3.cn,
  14011. // Name_EN = item3.en,
  14012. // Level = 3,
  14013. // ParentId = cityId,
  14014. // IsCapital = 1,
  14015. // CreateUserId = 208,
  14016. // CreateTime = DateTime.Now,
  14017. // IsDel = 0
  14018. // };
  14019. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14020. // //{
  14021. // districts.Add(districtInfo);
  14022. // //}
  14023. // }
  14024. // }
  14025. // }
  14026. // else
  14027. // {
  14028. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  14029. // //{
  14030. // cities.Add(cityInfo);
  14031. // //}
  14032. // }
  14033. // }
  14034. // }
  14035. // }
  14036. // else if (item1.lv == "city")//城市
  14037. // {
  14038. // provinceInfo.Level = 2;
  14039. // if (item1.c != null)
  14040. // {
  14041. // int cityId = 0;
  14042. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  14043. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14044. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14045. // foreach (var item3 in item1.c)
  14046. // {
  14047. // if (item3.lv == "district")
  14048. // {
  14049. // var districtInfo = new Sys_Cities()
  14050. // {
  14051. // CountriesId = countriesId,
  14052. // Name_CN = item3.cn,
  14053. // Name_EN = item3.en,
  14054. // Level = 3,
  14055. // ParentId = cityId,
  14056. // IsCapital = 1,
  14057. // CreateUserId = 208,
  14058. // CreateTime = DateTime.Now,
  14059. // IsDel = 0
  14060. // };
  14061. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14062. // //{
  14063. // districts.Add(districtInfo);
  14064. // //}
  14065. // }
  14066. // }
  14067. // }
  14068. // else
  14069. // {
  14070. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  14071. // //{
  14072. // cities.Add(provinceInfo);
  14073. // //}
  14074. // }
  14075. // }
  14076. // }
  14077. // }
  14078. // }
  14079. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  14080. // cities = cities.Distinct().ToList();
  14081. // districts = districts.Distinct().ToList();
  14082. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  14083. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  14084. // cities.AddRange(districts);
  14085. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  14086. // //_sqlSugar.RollbackTran();
  14087. // _sqlSugar.CommitTran();
  14088. // return Ok(JsonView(false, "操作成功!"));
  14089. //}
  14090. //[HttpPost]
  14091. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  14092. //{
  14093. // List<CountitiesInfo> infos = dto.MyProperty;
  14094. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  14095. // _sqlSugar.BeginTran();
  14096. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  14097. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  14098. // foreach (var item in infos)
  14099. // {
  14100. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  14101. // if (countryInfo != null)
  14102. // {
  14103. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  14104. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  14105. // if (cityInfo1 != null)
  14106. // {
  14107. // cityInfo1.IsCapital = 0;
  14108. // cityInfos.Add(cityInfo1);
  14109. // }
  14110. // }
  14111. // }
  14112. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  14113. // .UpdateColumns(it => it.IsCapital)
  14114. // .WhereColumns(it => it.Id)
  14115. // .ExecuteCommand();
  14116. // //_sqlSugar.RollbackTran();
  14117. // _sqlSugar.CommitTran();
  14118. // return Ok(JsonView(false, "操作成功!"));
  14119. //}
  14120. //public class CounrtiesDto
  14121. //{
  14122. // public List<CountitiesInfo> MyProperty { get; set; }
  14123. //}
  14124. //public class CountitiesInfo
  14125. //{
  14126. // /// <summary>
  14127. // /// 圣约翰
  14128. // /// </summary>
  14129. // public string capital_name_chinese { get; set; }
  14130. // /// <summary>
  14131. // ///
  14132. // /// </summary>
  14133. // public string capital_name { get; set; }
  14134. // /// <summary>
  14135. // ///
  14136. // /// </summary>
  14137. // public string country_type { get; set; }
  14138. // /// <summary>
  14139. // /// 安提瓜和巴布达
  14140. // /// </summary>
  14141. // public string country_name_chinese { get; set; }
  14142. // /// <summary>
  14143. // /// 安提瓜和巴布达
  14144. // /// </summary>
  14145. // public string country_name_chinese_short { get; set; }
  14146. // /// <summary>
  14147. // /// 安提瓜和巴布达
  14148. // /// </summary>
  14149. // public string country_name_chinese_UN { get; set; }
  14150. // /// <summary>
  14151. // ///
  14152. // /// </summary>
  14153. // public string country_name_english_abbreviation { get; set; }
  14154. // /// <summary>
  14155. // ///
  14156. // /// </summary>
  14157. // public string country_name_english_formal { get; set; }
  14158. // /// <summary>
  14159. // ///
  14160. // /// </summary>
  14161. // public string country_name_english_UN { get; set; }
  14162. // /// <summary>
  14163. // ///
  14164. // /// </summary>
  14165. // public string continent_name { get; set; }
  14166. // /// <summary>
  14167. // ///
  14168. // /// </summary>
  14169. // public string subregion_name { get; set; }
  14170. // /// <summary>
  14171. // ///
  14172. // /// </summary>
  14173. // public string country_code2 { get; set; }
  14174. // /// <summary>
  14175. // ///
  14176. // /// </summary>
  14177. // public string country_code3 { get; set; }
  14178. // /// <summary>
  14179. // ///
  14180. // /// </summary>
  14181. // public string phone_code { get; set; }
  14182. //}
  14183. //public class CountriesInfo : BasicInfo
  14184. //{
  14185. // public List<CitiesInfo> c { get; set; }
  14186. //}
  14187. //public class CitiesInfo : BasicInfo
  14188. //{
  14189. // public List<AreaInfo> c { get; set; }
  14190. //}
  14191. //public class AreaInfo : BasicInfo
  14192. //{
  14193. // public List<AreaInfo> c { get; set; }
  14194. //}
  14195. //public class BasicInfo
  14196. //{
  14197. // public string code { get; set; }
  14198. // public string cn { get; set; }
  14199. // public string lv { get; set; }
  14200. // public string en { get; set; }
  14201. //}
  14202. #endregion
  14203. #region 查看邀请方
  14204. /// <summary>
  14205. /// 查看邀请方
  14206. /// 邀请方信息 Init
  14207. /// </summary>
  14208. /// <param name="dto"></param>
  14209. /// <returns></returns>
  14210. [HttpPost]
  14211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14212. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  14213. {
  14214. string sqlWhere = string.Empty;
  14215. if (!string.IsNullOrEmpty(dto.Search))
  14216. {
  14217. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  14218. }
  14219. string sql = string.Format($@"Select
  14220. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  14221. Id,
  14222. UnitName
  14223. From Res_InvitationOfficialActivityData
  14224. Where IsDel = 0
  14225. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  14226. RefAsync<int> total = 0;
  14227. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14228. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  14229. }
  14230. /// <summary>
  14231. /// 查看邀请方
  14232. /// 国家信息 Init
  14233. /// </summary>
  14234. /// <param name="dto"></param>
  14235. /// <returns></returns>
  14236. [HttpPost]
  14237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14238. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  14239. {
  14240. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  14241. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  14242. var diids = groupInfos.Select(it => it.Id).ToList();
  14243. List<string> countrys = new List<string>();
  14244. foreach (var item in country)
  14245. {
  14246. var data = _groupRepository.FormartTeamName(item);
  14247. var dataArray = _groupRepository.GroupSplitCountry(data);
  14248. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  14249. }
  14250. countrys = countrys.Distinct().ToList();
  14251. for (int i = 0; i < countrys.Count; i++)
  14252. {
  14253. string item = countrys[i];
  14254. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  14255. {
  14256. countrys.Remove(item);
  14257. i--;
  14258. }
  14259. }
  14260. RefAsync<int> total = 0;
  14261. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  14262. .Where(it => countrys.Contains(it.Name_CN))
  14263. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14264. .Select(it => new { id = it.Id, name = it.Name_CN })
  14265. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14266. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14267. }
  14268. /// <summary>
  14269. /// 查看邀请方
  14270. /// 城市信息 Init
  14271. /// </summary>
  14272. /// <param name="dto"></param>
  14273. /// <returns></returns>
  14274. [HttpPost]
  14275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14276. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  14277. {
  14278. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  14279. RefAsync<int> total = 0;
  14280. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  14281. .Where(it => it.CountriesId == dto.CountiesId)
  14282. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14283. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  14284. .Select(it => new { id = it.Id, name = it.Name_CN })
  14285. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14286. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14287. }
  14288. /// <summary>
  14289. /// 查看邀请方
  14290. /// 团组名称 Init
  14291. /// </summary>
  14292. /// <param name="dto"></param>
  14293. /// <returns></returns>
  14294. [HttpPost]
  14295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14296. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  14297. {
  14298. var watch = new Stopwatch();
  14299. watch.Start();
  14300. RefAsync<int> total = 0;
  14301. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  14302. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  14303. .Where((oa, di) => oa.IsDel == 0)
  14304. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  14305. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  14306. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  14307. .Distinct()
  14308. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14309. watch.Stop();
  14310. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  14311. }
  14312. /// <summary>
  14313. /// 查看邀请方
  14314. /// 团组 & 邀请方信息
  14315. /// </summary>
  14316. /// <param name="dto"></param>
  14317. /// <returns></returns>
  14318. [HttpPost]
  14319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14320. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  14321. {
  14322. var watch = new Stopwatch();
  14323. watch.Start();
  14324. RefAsync<int> total = 0;
  14325. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  14326. .AS("Grp_DelegationInfo")
  14327. .Includes(x => x.InvitingInfos)
  14328. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  14329. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  14330. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  14331. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  14332. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  14333. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  14334. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14335. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  14336. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  14337. infos.ForEach(x =>
  14338. {
  14339. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  14340. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  14341. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  14342. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  14343. });
  14344. watch.Stop();
  14345. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  14346. }
  14347. #endregion
  14348. #region 报批行程
  14349. /// <summary>
  14350. /// 报批行程初始化
  14351. /// </summary>
  14352. /// <param name="dto"></param>
  14353. /// <returns></returns>
  14354. [HttpPost]
  14355. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  14356. {
  14357. const int chiNumber = 5;
  14358. var jw = JsonView(false);
  14359. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  14360. var group = groupList.First();
  14361. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14362. group = groupList.First(x => x.Id == diid);
  14363. if (group == null)
  14364. {
  14365. jw.Msg = "暂无团组!";
  14366. return Ok(jw);
  14367. }
  14368. var data = new
  14369. {
  14370. groupList = groupList.Select(x => new
  14371. {
  14372. x.TeamName,
  14373. x.Id
  14374. }),
  14375. content = new ArrayList(),
  14376. groupInfo = new
  14377. {
  14378. group.VisitDays,
  14379. group.TourCode,
  14380. group.VisitPNumber,
  14381. group.TeamName,
  14382. group.Id,
  14383. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  14384. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  14385. },
  14386. };
  14387. var resultArr = new ArrayList();
  14388. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  14389. if (content.Count == 0)
  14390. {
  14391. var stay = "-";
  14392. var cityPath = "-";
  14393. //添加城市路径以及住宿地
  14394. //黑屏代码数据
  14395. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14396. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14397. {
  14398. jw = JsonView(true, "黑屏代码有误!", data);
  14399. return Ok(jw);
  14400. }
  14401. foreach (DataRow row in dtBlack.Rows)
  14402. {
  14403. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14404. {
  14405. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  14406. return Ok(jw);
  14407. }
  14408. }
  14409. //黑屏代码获取时间区间
  14410. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14411. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14412. _sqlSugar.BeginTran();
  14413. for (int i = 0; i < timeArr.Count; i++)
  14414. {
  14415. stay = "-";
  14416. cityPath = "-";
  14417. DateTime NewData = DateTime.Parse(timeArr[i]);
  14418. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14419. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14420. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14421. if (tbSelect.Length > 0)
  14422. {
  14423. List<string> threeCodeStr = new List<string>();
  14424. foreach (var item in tbSelect)
  14425. {
  14426. var threeCode = item["Three"].ToString() ?? "";
  14427. if (threeCode.Length == 6)
  14428. {
  14429. var start = threeCode.Substring(0, 3);
  14430. var end = threeCode.Substring(3, 3);
  14431. if (threeCodeStr.Count == 0)
  14432. {
  14433. threeCodeStr.Add(start);
  14434. threeCodeStr.Add(end);
  14435. }
  14436. else
  14437. {
  14438. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14439. {
  14440. threeCodeStr.Add(end);
  14441. }
  14442. else
  14443. {
  14444. threeCodeStr.Add(start);
  14445. threeCodeStr.Add(end);
  14446. }
  14447. }
  14448. }
  14449. }
  14450. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14451. var last = threeCodeStr.Last();
  14452. foreach (var item in threeCodeStr)
  14453. {
  14454. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14455. if (item.Equals(last))
  14456. {
  14457. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14458. }
  14459. }
  14460. cityPath = cityPath.Trim('-');
  14461. }
  14462. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14463. appro.Diid = diid ?? -1;
  14464. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14465. appro.Id = thisId;
  14466. appro.CreateUserId = dto.UserId;
  14467. appro.CreateTime = DateTime.Now;
  14468. content.Add(appro);
  14469. }
  14470. _sqlSugar.CommitTran();
  14471. }
  14472. foreach (var x in content)
  14473. {
  14474. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  14475. if (chiList.Count < chiNumber)
  14476. {
  14477. for (int i = chiList.Count; i < chiNumber; i++)
  14478. {
  14479. chiList.Add(new Grp_ApprovalTravelDetails());
  14480. }
  14481. }
  14482. resultArr.Add(new
  14483. {
  14484. x.Id,
  14485. x.Date,
  14486. x.Diid,
  14487. chiList = chiList.Select(x1 => new
  14488. {
  14489. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14490. x1.Details,
  14491. x1.ParentId,
  14492. x1.Id
  14493. })
  14494. });
  14495. }
  14496. data = data with
  14497. {
  14498. content = resultArr,
  14499. };
  14500. jw = JsonView(true, "获取成功!", data);
  14501. return Ok(jw);
  14502. }
  14503. /// <summary>
  14504. /// 报批行程删除
  14505. /// </summary>
  14506. /// <param name="dto"></param>
  14507. /// <returns></returns>
  14508. [HttpPost]
  14509. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  14510. {
  14511. var jw = JsonView(false);
  14512. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14513. if (group == null)
  14514. {
  14515. jw.Msg = "团组参数有误!";
  14516. return Ok(jw);
  14517. }
  14518. try
  14519. {
  14520. _sqlSugar.BeginTran();
  14521. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  14522. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  14523. {
  14524. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14525. DeleteUserId = dto.uesrId,
  14526. IsDel = 1
  14527. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  14528. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  14529. {
  14530. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14531. DeleteUserId = dto.uesrId,
  14532. IsDel = 1
  14533. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  14534. _sqlSugar.CommitTran();
  14535. jw = JsonView(true, "删除成功");
  14536. }
  14537. catch (Exception ex)
  14538. {
  14539. jw = JsonView(false, ex.Message);
  14540. }
  14541. return Ok(jw);
  14542. }
  14543. /// <summary>
  14544. /// 报批行程保存
  14545. /// </summary>
  14546. /// <param name="dto"></param>
  14547. /// <returns></returns>
  14548. [HttpPost]
  14549. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  14550. {
  14551. var jw = JsonView(false);
  14552. var Find = dto.Arr.Find(x => x.id == 0);
  14553. if (Find != null)
  14554. {
  14555. jw.Msg = "生成的ID为0!";
  14556. return Ok(jw);
  14557. }
  14558. foreach (var item in dto.Arr)
  14559. {
  14560. foreach (var chi in item.chiList)
  14561. {
  14562. if (chi.parentId == 0)
  14563. {
  14564. chi.parentId = item.id;
  14565. }
  14566. }
  14567. }
  14568. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  14569. _sqlSugar.BeginTran();
  14570. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  14571. {
  14572. var parentIds = dto.Arr.Select(x => x.id).ToList();
  14573. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  14574. {
  14575. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14576. DeleteUserId = dto.UserId,
  14577. IsDel = 1
  14578. }).ExecuteCommand();
  14579. }
  14580. try
  14581. {
  14582. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  14583. {
  14584. CreateTime = DateTime.Now,
  14585. CreateUserId = dto.UserId,
  14586. Details = x.details,
  14587. ParentId = x.parentId,
  14588. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14589. Remark = "",
  14590. IsDel = 0
  14591. }).ToList()).ExecuteCommand();
  14592. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  14593. {
  14594. Id = x.id,
  14595. Details = x.details,
  14596. ParentId = x.parentId,
  14597. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14598. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  14599. {
  14600. Details = x.Details,
  14601. ParentId = x.ParentId,
  14602. Time = x.Time
  14603. }).ExecuteCommand();
  14604. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  14605. {
  14606. Id = x.id,
  14607. Date = x.date,
  14608. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  14609. {
  14610. Date = x.Date
  14611. }).ExecuteCommand();
  14612. _sqlSugar.CommitTran();
  14613. jw = JsonView(true, "保存成功!");
  14614. }
  14615. catch (Exception ex)
  14616. {
  14617. _sqlSugar.RollbackTran();
  14618. jw = JsonView(false, "保存失败!" + ex.Message);
  14619. }
  14620. return Ok(jw);
  14621. }
  14622. /// <summary>
  14623. /// 报批行程生成
  14624. /// </summary>
  14625. /// <param name="dto"></param>
  14626. /// <returns></returns>
  14627. [HttpPost]
  14628. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  14629. {
  14630. var jw = JsonView(false);
  14631. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14632. if (group == null)
  14633. {
  14634. jw.Msg = "暂无该团组!";
  14635. return Ok(jw);
  14636. }
  14637. //黑屏代码数据
  14638. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14639. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14640. {
  14641. jw.Msg = "黑屏代码有误!";
  14642. return Ok(jw);
  14643. }
  14644. foreach (DataRow row in dtBlack.Rows)
  14645. {
  14646. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14647. {
  14648. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  14649. return Ok(jw);
  14650. }
  14651. }
  14652. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14653. var resultArr = new ArrayList();
  14654. if (officialActivitiesArr.Count == 0)
  14655. {
  14656. jw.Msg = "暂无公务出访信息!";
  14657. return Ok(jw);
  14658. }
  14659. try
  14660. {
  14661. _sqlSugar.BeginTran();
  14662. DeleteApprovalJourney(new
  14663. Domain.Dtos.Groups.DeleteApprovalJourney
  14664. {
  14665. Diid = dto.Diid,
  14666. uesrId = dto.Userid
  14667. });
  14668. var stay = "-";
  14669. var cityPath = "-";
  14670. //添加城市路径以及住宿地
  14671. //黑屏代码获取时间区间
  14672. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14673. var empty = "【未收入该三字码!请机票同事录入】";
  14674. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14675. for (int i = 0; i < timeArr.Count; i++)
  14676. {
  14677. stay = "-";
  14678. cityPath = "-";
  14679. var chiarr = new List<Grp_ApprovalTravelDetails>();
  14680. DateTime NewData = DateTime.Parse(timeArr[i]);
  14681. 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();
  14682. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14683. if (tbSelect.Length > 0)
  14684. {
  14685. List<string> threeCodeStr = new List<string>();
  14686. bool isTrade = false;
  14687. string trip = string.Empty;
  14688. var rowLast = tbSelect.Last();
  14689. var rowFirst = tbSelect.First();
  14690. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  14691. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  14692. var takeOffTime = DateTime.Parse(timeArr[i]);
  14693. var fallToTime = DateTime.Parse(timeArr[i]);
  14694. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  14695. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  14696. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  14697. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  14698. foreach (var item in tbSelect)
  14699. {
  14700. var start = string.Empty;
  14701. var end = string.Empty;
  14702. var threeCode = item["Three"].ToString() ?? "";
  14703. if (threeCode.Length == 6)
  14704. {
  14705. start = threeCode.Substring(0, 3);
  14706. end = threeCode.Substring(3, 3);
  14707. if (threeCodeStr.Count == 0)
  14708. {
  14709. threeCodeStr.Add(start);
  14710. threeCodeStr.Add(end);
  14711. }
  14712. else
  14713. {
  14714. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14715. {
  14716. threeCodeStr.Add(end);
  14717. }
  14718. else
  14719. {
  14720. threeCodeStr.Add(start);
  14721. threeCodeStr.Add(end);
  14722. }
  14723. }
  14724. }
  14725. //处理机票信息
  14726. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  14727. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  14728. if (start_Object == null)
  14729. {
  14730. start_Object = new Res_ThreeCode()
  14731. {
  14732. AirPort = empty,
  14733. AirPort_En = empty,
  14734. City = empty,
  14735. Country = empty,
  14736. Four = empty,
  14737. Three = empty,
  14738. };
  14739. }
  14740. if (end_Object == null)
  14741. {
  14742. end_Object = new Res_ThreeCode()
  14743. {
  14744. AirPort = empty,
  14745. AirPort_En = empty,
  14746. City = empty,
  14747. Country = empty,
  14748. Four = empty,
  14749. Three = empty,
  14750. };
  14751. }
  14752. //机型判断
  14753. string airModel = item["AirModel"].ToString();
  14754. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  14755. string flightTime = item["FlightTime"].ToString();
  14756. if (flightTime!.Contains(":"))
  14757. {
  14758. flightTime = flightTime.Replace(":", "小时");
  14759. flightTime += "分钟";
  14760. }
  14761. if (flightTime.Contains("H"))
  14762. {
  14763. flightTime = flightTime.Replace("H", "小时");
  14764. }
  14765. if (flightTime.Contains("M"))
  14766. {
  14767. flightTime = flightTime.Replace("M", "分钟");
  14768. }
  14769. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  14770. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  14771. {
  14772. flightTime = flightDataTime.Hour > 0
  14773. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  14774. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  14775. ? flightDataTime.Minute.ToString() + "分钟" : "";
  14776. }
  14777. //航班号
  14778. string flightcode = item["Fliagtcode"].ToString();
  14779. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  14780. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  14781. if (aircompany == null)
  14782. {
  14783. aircompany = new Res_AirCompany
  14784. {
  14785. CnName = hsEmpty,
  14786. EnName = hsEmpty,
  14787. ShortCode = hsEmpty,
  14788. };
  14789. }
  14790. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  14791. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  14792. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  14793. if (isTrade)
  14794. {
  14795. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  14796. }
  14797. else
  14798. {
  14799. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  14800. }
  14801. }
  14802. chiarr.Add(new Grp_ApprovalTravelDetails
  14803. {
  14804. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  14805. CreateTime = DateTime.Now,
  14806. CreateUserId = dto.Userid,
  14807. ParentId = 0,
  14808. Details = trip
  14809. });
  14810. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14811. var last = threeCodeStr.Last();
  14812. foreach (var item in threeCodeStr)
  14813. {
  14814. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14815. if (item.Equals(last))
  14816. {
  14817. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14818. }
  14819. }
  14820. cityPath = cityPath.Trim('-');
  14821. }
  14822. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14823. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14824. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14825. appro.Diid = dto.Diid;
  14826. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14827. appro.Id = thisId;
  14828. appro.CreateUserId = dto.Userid;
  14829. appro.CreateTime = DateTime.Now;
  14830. foreach (var item in gwinfo)
  14831. {
  14832. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  14833. chi.Details = "拜访" + item.Client;
  14834. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  14835. {
  14836. chi.Details += "," + item.ReqSample;
  14837. }
  14838. chi.ParentId = thisId;
  14839. chi.Time = item.Time;
  14840. chiarr.Add(chi);
  14841. }
  14842. if (chiarr.Count < 5)
  14843. {
  14844. for (int j = chiarr.Count; j < 5; j++)
  14845. {
  14846. chiarr.Add(new
  14847. Grp_ApprovalTravelDetails());
  14848. }
  14849. }
  14850. resultArr.Add(new
  14851. {
  14852. appro.Id,
  14853. appro.Date,
  14854. appro.Diid,
  14855. chiList = chiarr.Select(x1 => new
  14856. {
  14857. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14858. x1.Details,
  14859. x1.ParentId,
  14860. x1.Id
  14861. })
  14862. });
  14863. }
  14864. _sqlSugar.CommitTran();
  14865. jw = JsonView(true, "生成成功!", resultArr);
  14866. }
  14867. catch (Exception ex)
  14868. {
  14869. jw.Code = 400;
  14870. jw.Msg = "生成失败!" + ex.Message;
  14871. }
  14872. return Ok(jw);
  14873. }
  14874. /// <summary>
  14875. /// 报批行程word导出
  14876. /// </summary>
  14877. /// <param name="dto"></param>
  14878. /// <returns></returns>
  14879. [HttpPost]
  14880. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  14881. {
  14882. var jw = JsonView(false);
  14883. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14884. if (group == null)
  14885. {
  14886. jw.Msg = "暂无该团组!";
  14887. return Ok(jw);
  14888. }
  14889. //模板路径
  14890. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  14891. //载入模板
  14892. Document doc = new Document(tempPath);
  14893. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14894. //获取所填表格的序数
  14895. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14896. Aspose.Words.Tables.Row titleRowClone = null;
  14897. Aspose.Words.Tables.Row CenterRowClone = null;
  14898. int index = 0;
  14899. int indexChi = 0;
  14900. int SetIndex = 0;
  14901. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  14902. //获取数据,放到datatable
  14903. foreach (var item in ApprovalTravelArr)
  14904. {
  14905. if (index > 0)
  14906. {
  14907. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  14908. tableOne.AppendChild(titleRowClone);
  14909. }
  14910. var textTime = item.Date;
  14911. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  14912. SetCells(tableOne, doc, SetIndex, 0, textTime);
  14913. SetIndex++;
  14914. if (ChiRep.Count > 0)
  14915. {
  14916. foreach (var itemChi in ChiRep)
  14917. {
  14918. var txtTime = itemChi.Time;
  14919. var txtDetail = itemChi.Details;
  14920. if (indexChi > 0)
  14921. {
  14922. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14923. tableOne.AppendChild(CenterRowClone);
  14924. }
  14925. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  14926. {
  14927. SetCells(tableOne, doc, SetIndex, 0, "");
  14928. SetCells(tableOne, doc, SetIndex, 1, "");
  14929. indexChi++;
  14930. SetIndex++;
  14931. break;
  14932. }
  14933. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  14934. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  14935. indexChi++;
  14936. SetIndex++;
  14937. }
  14938. }
  14939. else
  14940. {
  14941. if (indexChi > 0)
  14942. {
  14943. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14944. tableOne.AppendChild(CenterRowClone);
  14945. }
  14946. SetCells(tableOne, doc, SetIndex, 0, "");
  14947. SetCells(tableOne, doc, SetIndex, 1, "");
  14948. indexChi++;
  14949. SetIndex++;
  14950. }
  14951. index++;
  14952. }
  14953. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  14954. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14955. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14956. jw.Code = 200;
  14957. jw.Msg = "";
  14958. return Ok(jw);
  14959. }
  14960. private string intToString(int numberVal)
  14961. {
  14962. string numberval = numberVal.ToString();
  14963. Dictionary<char, string> Number = new Dictionary<char, string>();
  14964. Number.Add('1', "一");
  14965. Number.Add('2', "二");
  14966. Number.Add('3', "三");
  14967. Number.Add('4', "四");
  14968. Number.Add('5', "五");
  14969. Number.Add('6', "六");
  14970. Number.Add('7', "七");
  14971. Number.Add('8', "八");
  14972. Number.Add('9', "九");
  14973. string stringNumberVal = string.Empty;
  14974. for (int i = 0; i < numberval.Length; i++)
  14975. {
  14976. if (i == 0)
  14977. {
  14978. stringNumberVal += Number[numberval[i]];
  14979. }
  14980. else if (i >= 1)
  14981. {
  14982. if (numberval[i] == '0')
  14983. {
  14984. stringNumberVal = "十";
  14985. }
  14986. else
  14987. {
  14988. stringNumberVal += "十" + Number[numberval[i]];
  14989. }
  14990. }
  14991. }
  14992. return stringNumberVal;
  14993. }
  14994. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  14995. {
  14996. //获取table中的某个单元格,从0开始
  14997. Cell lshCell = table.Rows[rows].Cells[cells];
  14998. //将单元格中段落移除
  14999. foreach (Node item in lshCell.Paragraphs)
  15000. {
  15001. lshCell.Paragraphs.Remove(item);
  15002. }
  15003. if (val.Contains("\r\n"))
  15004. {
  15005. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  15006. foreach (var item in spArr)
  15007. {
  15008. //新建一个段落
  15009. Paragraph p = new Paragraph(doc);
  15010. var r = new Run(doc, item);
  15011. //把设置的值赋给之前新建的段落
  15012. p.AppendChild(r);
  15013. //将此段落加到单元格内
  15014. lshCell.AppendChild(p);
  15015. }
  15016. }
  15017. else
  15018. {
  15019. //新建一个段落
  15020. Paragraph p = new Paragraph(doc);
  15021. var r = new Run(doc, val);
  15022. //把设置的值赋给之前新建的段落
  15023. p.AppendChild(r);
  15024. //将此段落加到单元格内
  15025. lshCell.AppendChild(p);
  15026. }
  15027. }
  15028. [HttpPost]
  15029. public async Task<IActionResult> ServerHttp(string paramStr)
  15030. {
  15031. paramStr = paramStr.TrimEnd('\'');
  15032. paramStr = paramStr.TrimStart('\'');
  15033. JsonView jw = JsonView(false);
  15034. JObject param = JObject.Parse(paramStr);
  15035. if (!param.ContainsKey("url"))
  15036. {
  15037. jw.Msg = "url null";
  15038. return Ok(jw);
  15039. }
  15040. string url = param["url"]!.ToString();
  15041. var methon = "get";
  15042. Dictionary<string, string> headValues = null;
  15043. string bodyStr = string.Empty;
  15044. if (param.ContainsKey("methon"))
  15045. {
  15046. methon = param["methon"]!.ToString().ToLower();
  15047. }
  15048. if (param.ContainsKey("header"))
  15049. {
  15050. var header = param["header"]!.ToString();
  15051. JObject headerJobject = JObject.Parse(header);
  15052. headValues = new Dictionary<string, string>();
  15053. foreach (JProperty item in headerJobject.Properties())
  15054. {
  15055. var value = item.Value.ToString();
  15056. var head = item.Path;
  15057. headValues.Add(head, value);
  15058. }
  15059. }
  15060. HttpClient client = new HttpClient();
  15061. string responseString = string.Empty;
  15062. StringContent content = null;
  15063. if (headValues != null)
  15064. {
  15065. foreach (var item in headValues.Keys)
  15066. {
  15067. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  15068. {
  15069. if (param.ContainsKey("body"))
  15070. {
  15071. bodyStr = param["body"]!.ToString();
  15072. }
  15073. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  15074. }
  15075. else
  15076. {
  15077. client.DefaultRequestHeaders.Add(item, headValues[item]);
  15078. }
  15079. }
  15080. }
  15081. try
  15082. {
  15083. if (methon == "get")
  15084. {
  15085. responseString = await client.GetStringAsync(url);
  15086. }
  15087. else if (methon == "post")
  15088. {
  15089. var request = new HttpRequestMessage(HttpMethod.Post, url)
  15090. {
  15091. Content = content
  15092. };
  15093. var response = await client.SendAsync(request);
  15094. try
  15095. {
  15096. Stream responseStream = await response.Content.ReadAsStreamAsync();
  15097. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  15098. {
  15099. using (StreamReader reader = new StreamReader(gzipStream))
  15100. {
  15101. responseString = await reader.ReadToEndAsync();
  15102. }
  15103. }
  15104. }
  15105. catch (Exception)
  15106. {
  15107. responseString = await response.Content.ReadAsStringAsync();
  15108. }
  15109. }
  15110. else
  15111. {
  15112. responseString = "methon error";
  15113. }
  15114. jw = JsonView(true, "success", responseString);
  15115. }
  15116. catch (Exception ex)
  15117. {
  15118. jw.Msg = "error " + ex.Message;
  15119. jw.Data = ex.StackTrace;
  15120. }
  15121. finally
  15122. {
  15123. client.Dispose();
  15124. }
  15125. return Ok(jw);
  15126. }
  15127. #endregion
  15128. #region 团组接待意见调查
  15129. /// <summary>
  15130. /// 团组接待意见调查 - 信息管理
  15131. /// 基础数据(团组)
  15132. /// </summary>
  15133. /// <param name="dto"></param>
  15134. /// <returns></returns>
  15135. [HttpGet]
  15136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15137. public async Task<IActionResult> OpinionaireInit()
  15138. {
  15139. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  15140. .Select(x => new
  15141. {
  15142. x.Id,
  15143. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  15144. })
  15145. .OrderByDescending(x => x.Id)
  15146. .ToListAsync();
  15147. return Ok(JsonView(groupData, groupData.Count));
  15148. }
  15149. /// <summary>
  15150. /// 团组接待意见调查 - 信息管理
  15151. /// 列表
  15152. /// </summary>
  15153. /// <param name="groupId"></param>
  15154. /// <returns></returns>
  15155. [HttpGet("{groupId}")]
  15156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15157. public async Task<IActionResult> OpinionaireManageList(int groupId)
  15158. {
  15159. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15160. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  15161. .Select(x => new
  15162. {
  15163. x.Id,
  15164. x.TourGuideName,
  15165. x.CityName,
  15166. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  15167. x.CreateTime
  15168. })
  15169. .OrderBy(x => x.Id)
  15170. .ToListAsync();
  15171. return Ok(JsonView(data));
  15172. }
  15173. /// <summary>
  15174. /// 团组接待意见调查 - 信息管理
  15175. /// 保存
  15176. /// </summary>
  15177. /// <param name="dto"></param>
  15178. /// <returns></returns>
  15179. [HttpPost]
  15180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15181. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  15182. {
  15183. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15184. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15185. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15186. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  15187. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  15188. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  15189. _opinionaireRep.BeginTran();
  15190. if (addData != null && addData.Count > 0)
  15191. {
  15192. foreach (var item in addData)
  15193. {
  15194. item.CreateUserId = currUserInfo.UserId;
  15195. item.DiId = dto.DiId;
  15196. }
  15197. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  15198. }
  15199. if (updData != null && updData.Count > 0)
  15200. {
  15201. var upd = await _opinionaireRep._sqlSugar
  15202. .Updateable(updData)
  15203. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  15204. .WhereColumns(x => new { x.Id })
  15205. .ExecuteCommandAsync();
  15206. }
  15207. _opinionaireRep.CommitTran();
  15208. return Ok(JsonView("操作成功!"));
  15209. }
  15210. /// <summary>
  15211. /// 团组接待意见调查 - 信息管理
  15212. /// 删除
  15213. /// </summary>
  15214. /// <param name="id"></param>
  15215. /// <returns></returns>
  15216. [HttpDelete("{id}")]
  15217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15218. public async Task<IActionResult> OpinionaireManageDel(int id)
  15219. {
  15220. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15221. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15222. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  15223. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  15224. if (!del) return Ok(JsonView("操作失败!"));
  15225. return Ok(JsonView("操作成功!"));
  15226. }
  15227. /// <summary>
  15228. /// 团组接待意见调查 - 用户
  15229. /// 列表
  15230. /// </summary>
  15231. /// <param name="id"></param>
  15232. /// <returns></returns>
  15233. [HttpGet("{diId}")]
  15234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15235. public async Task<IActionResult> OpinionaireUserList(int diId)
  15236. {
  15237. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15238. var sql = string.Format(@"
  15239. SELECT
  15240. o.Id,
  15241. o.DiId,
  15242. di.TeamName AS 'GroupName',
  15243. di.VisitPNumber AS 'PeopleNumber',
  15244. di.ClientName AS 'LeadGroup',
  15245. di.VisitCountry AS 'Travel',
  15246. di.VisitDays AS 'Days',
  15247. o.CityName,
  15248. o.TourGuideName,
  15249. o.Catering,
  15250. o.CateringReason,
  15251. o.Stay,
  15252. o.StayReason,
  15253. o.[Route],
  15254. o.RouteReason,
  15255. o.OfficialActivity,
  15256. o.OfficialActivityReason,
  15257. o.TourGuide,
  15258. o.TourGuideReason,
  15259. o.[Translate],
  15260. o.TranslateReason,
  15261. o.Trip,
  15262. o.TripReason,
  15263. o.ESFileName,
  15264. o.SignatureDate,
  15265. o.Remark
  15266. FROM
  15267. Grp_Opinionaire o
  15268. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  15269. WHERE
  15270. o.IsDel = 0
  15271. AND o.DiId = {0}
  15272. ORDER BY
  15273. o.Id ASC", diId);
  15274. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  15275. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  15276. return Ok(JsonView(data));
  15277. }
  15278. /// <summary>
  15279. /// 团组接待意见调查 - 用户
  15280. /// 保存
  15281. /// </summary>
  15282. /// <param name="id"></param>
  15283. /// <returns></returns>
  15284. [HttpPost]
  15285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15286. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  15287. {
  15288. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  15289. foreach (var item in dto)
  15290. {
  15291. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  15292. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  15293. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  15294. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  15295. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  15296. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  15297. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  15298. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  15299. }
  15300. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  15301. if (!Directory.Exists(filePathBase))
  15302. {
  15303. Directory.CreateDirectory(filePathBase);
  15304. }
  15305. #region 上传文件
  15306. var filePaths = new List<string>();
  15307. foreach (var item in dto)
  15308. {
  15309. var file = item.File;
  15310. // 将文件保存到指定位置
  15311. var filePath = Path.Combine(filePathBase, file.FileName);
  15312. using (var stream = new FileStream(filePath, FileMode.Create))
  15313. {
  15314. await file.CopyToAsync(stream);
  15315. }
  15316. //验证文件是否上传成功
  15317. if (!System.IO.File.Exists(filePath))
  15318. {
  15319. foreach (var filePathStr in filePaths)
  15320. {
  15321. System.IO.File.Delete(filePathStr);
  15322. }
  15323. return Ok(JsonView(false, "文件上传失败!"));
  15324. }
  15325. item.ESFileName = file.FileName;
  15326. }
  15327. #endregion
  15328. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  15329. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  15330. .UpdateColumns(x => new
  15331. {
  15332. x.Catering,
  15333. x.CateringReason,
  15334. x.Stay,
  15335. x.StayReason,
  15336. x.Route,
  15337. x.RouteReason,
  15338. x.OfficialActivity,
  15339. x.OfficialActivityReason,
  15340. x.TourGuide,
  15341. x.TourGuideReason,
  15342. x.Translate,
  15343. x.TranslateReason,
  15344. x.Trip,
  15345. x.TripReason,
  15346. x.ESFileName,
  15347. x.SignatureDate,
  15348. x.Remark
  15349. })
  15350. .WhereColumns(x => new { x.Id })
  15351. .ExecuteCommandAsync();
  15352. if (upd < 1)
  15353. {
  15354. foreach (var filePathStr in filePaths)
  15355. {
  15356. System.IO.File.Delete(filePathStr);
  15357. }
  15358. return Ok(JsonView(false));
  15359. }
  15360. return Ok(JsonView(true));
  15361. }
  15362. #endregion
  15363. // /// <summary>
  15364. // ///
  15365. // /// </summary>
  15366. // /// <param name="_dto"></param>
  15367. // /// <returns></returns>
  15368. // [HttpPost]
  15369. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15370. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15371. // {
  15372. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15373. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  15374. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  15375. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15376. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  15377. // dic_psg.Add("客人", 974);
  15378. // dic_psg.Add("司机", 975);
  15379. // dic_psg.Add("导游", 976);
  15380. // dic_psg.Add("公司内部人员", 977);
  15381. // dic_psg.Add("司机/导游/公司内部人员", 978);
  15382. // foreach (var item in list_visa)
  15383. // {
  15384. // Grp_VisaInfo temp = new Grp_VisaInfo();
  15385. // temp.Id = item.Id;
  15386. // temp.DIId = item.DIId;
  15387. // temp.VisaClient = item.VisaClient;
  15388. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  15389. // temp.VisaCurrency = item.VisaCurrency;
  15390. // temp.IsThird = item.IsThird;
  15391. // if (dic_psg.ContainsKey(item.PassengerType))
  15392. // {
  15393. // temp.PassengerType = dic_psg[item.PassengerType];
  15394. // }
  15395. // else {
  15396. // temp.PassengerType = -1;
  15397. // }
  15398. // temp.VisaNumber = item.VisaNumber;
  15399. // temp.VisaFreeNumber = item.VisaFreeNumber;
  15400. // temp.CreateUserId = item.Operators;
  15401. // DateTime dt_ct;
  15402. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  15403. // if (b_ct)
  15404. // {
  15405. // temp.CreateTime = dt_ct;
  15406. // }
  15407. // else
  15408. // {
  15409. // temp.CreateTime = DateTime.Now;
  15410. // }
  15411. // temp.DeleteTime = "";
  15412. // temp.DeleteUserId = 0;
  15413. // temp.Remark = item.Remark;
  15414. // if (string.IsNullOrEmpty(temp.Remark)) {
  15415. // temp.Remark = "";
  15416. // }
  15417. // temp.IsDel = item.IsDel;
  15418. // temp.VisaDescription = item.VisaAttachment;
  15419. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  15420. //([Id]
  15421. // ,[DIId]
  15422. // ,[VisaClient]
  15423. // ,[VisaPrice]
  15424. // ,[VisaCurrency]
  15425. // ,[IsThird]
  15426. // ,[PassengerType]
  15427. // ,[VisaNumber]
  15428. // ,[VisaFreeNumber]
  15429. // ,[CreateUserId]
  15430. // ,[CreateTime]
  15431. // ,[DeleteTime]
  15432. // ,[DeleteUserId]
  15433. // ,[Remark]
  15434. // ,[IsDel]
  15435. // ,[visaDescription])
  15436. // VALUES
  15437. // ({0},{1},'{2}',{3},{4}
  15438. //,{5},{6},{7},{8},{9}
  15439. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  15440. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  15441. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  15442. //);
  15443. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  15444. // }
  15445. // return Ok(JsonView(true, "操作成功!"));
  15446. // }
  15447. /// <summary>
  15448. /// 123132123
  15449. /// </summary>
  15450. /// <param name="_dto"></param>
  15451. /// <returns></returns>
  15452. [HttpPost]
  15453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15454. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15455. {
  15456. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15457. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  15458. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  15459. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15460. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  15461. dicDetail.Add(789, 1034);
  15462. dicDetail.Add(790, 1035);
  15463. dicDetail.Add(791, 1036);
  15464. dicDetail.Add(792, 1037);
  15465. dicDetail.Add(793, 1038);
  15466. dicDetail.Add(794, 1039);
  15467. dicDetail.Add(795, 1040);
  15468. dicDetail.Add(796, 1041);
  15469. dicDetail.Add(797, 1042);
  15470. dicDetail.Add(798, 1043);
  15471. dicDetail.Add(801, 1044);
  15472. dicDetail.Add(802, 1045);
  15473. dicDetail.Add(803, 1046);
  15474. Dictionary<int, int> dic = new Dictionary<int, int>();
  15475. dic.Add(806, 1027);
  15476. dic.Add(807, 1028);
  15477. dic.Add(808, 1029);
  15478. dic.Add(809, 1030);
  15479. dic.Add(810, 1031);
  15480. dic.Add(811, 1032);
  15481. dic.Add(812, 1033);
  15482. foreach (var item in list_visa)
  15483. {
  15484. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  15485. temp.Coefficient = item.coefficient;
  15486. DateTime dtCrt;
  15487. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  15488. if (b1)
  15489. {
  15490. temp.CreateTime = dtCrt;
  15491. }
  15492. else
  15493. {
  15494. temp.CreateTime = DateTime.Now;
  15495. }
  15496. temp.CreateUserId = item.Operators;
  15497. temp.DeleteTime = "";
  15498. temp.DeleteUserId = 0;
  15499. temp.DiId = int.Parse(item.DIID);
  15500. temp.FilePath = item.FilePath;
  15501. temp.IsDel = item.IsDel;
  15502. temp.Price = item.Price;
  15503. temp.PriceCount = 1;
  15504. temp.PriceCurrency = item.Currency;
  15505. int detailId = 0;
  15506. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  15507. {
  15508. detailId = dicDetail[item.PriceTypeDetail];
  15509. }
  15510. temp.PriceDetailType = detailId;
  15511. temp.PriceDt = DateTime.Now;
  15512. temp.PriceName = item.PriceName;
  15513. temp.PriceSum = item.Price;
  15514. int tid = 0;
  15515. if (dic.ContainsKey(item.PriceType))
  15516. {
  15517. tid = dic[item.PriceType];
  15518. }
  15519. temp.PriceType = tid;
  15520. temp.Remark = item.Remark;
  15521. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  15522. }
  15523. return Ok(JsonView(true, "操作成功!"));
  15524. }
  15525. [HttpPost]
  15526. public IActionResult TimeTest()
  15527. {
  15528. var jw = JsonView(false, "error");
  15529. _sqlSugar.BeginTran();
  15530. try
  15531. {
  15532. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  15533. .Select(x => new Crm_NewClientData
  15534. {
  15535. Id = x.Id,
  15536. Client = x.Client,
  15537. Contact = x.Contact,
  15538. Location = x.Location,
  15539. })
  15540. .ToList();
  15541. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  15542. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  15543. Stopwatch stopwatch = new Stopwatch();
  15544. // 开始计时
  15545. stopwatch.Start();
  15546. foreach (var item in clientList)
  15547. {
  15548. EncryptionProcessor.DecryptProperties(item);
  15549. }
  15550. stopwatch.Stop();
  15551. jw.Code = 200;
  15552. jw.Data = stopwatch.ElapsedMilliseconds;
  15553. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  15554. }
  15555. catch (Exception ex)
  15556. {
  15557. jw.Code = 400;
  15558. jw.Msg = ex.Message;
  15559. }
  15560. return Ok(jw);
  15561. }
  15562. }
  15563. }