GroupsController.cs 782 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813
  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 Microsoft.AspNetCore.SignalR;
  9. using MySqlX.XDevAPI.Relational;
  10. using NPOI.HSSF.UserModel;
  11. using NPOI.POIFS.Crypt.Dsig;
  12. using NPOI.SS.Format;
  13. using NPOI.SS.Formula.Functions;
  14. using NPOI.SS.UserModel;
  15. using NPOI.SS.Util;
  16. using NPOI.XSSF.UserModel;
  17. using OASystem.API.OAMethodLib;
  18. using OASystem.API.OAMethodLib.APNs;
  19. using OASystem.API.OAMethodLib.File;
  20. using OASystem.API.OAMethodLib.Hub.HubClients;
  21. using OASystem.API.OAMethodLib.Hub.Hubs;
  22. using OASystem.API.OAMethodLib.JuHeAPI;
  23. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  24. using OASystem.Domain.Dtos.CRM;
  25. using OASystem.Domain.Dtos.FileDto;
  26. using OASystem.Domain.Dtos.Financial;
  27. using OASystem.Domain.Dtos.Groups;
  28. using OASystem.Domain.Entities.Customer;
  29. using OASystem.Domain.Entities.Financial;
  30. using OASystem.Domain.Entities.Groups;
  31. using OASystem.Domain.ViewModels;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.Statistics;
  34. using OASystem.Infrastructure.Repositories.Financial;
  35. using OASystem.Infrastructure.Repositories.Groups;
  36. using OfficeOpenXml;
  37. using Org.BouncyCastle.Asn1.Ocsp;
  38. using Quartz.Util;
  39. using SqlSugar;
  40. using SqlSugar.Extensions;
  41. using System.Collections;
  42. using System.Data;
  43. using System.Data.OleDb;
  44. using System.Diagnostics;
  45. using System.Globalization;
  46. using System.IO;
  47. using System.IO.Compression;
  48. using System.Net.Http;
  49. using System.Reflection.PortableExecutable;
  50. using System.Security.Cryptography;
  51. using Ubiety.Dns.Core;
  52. using static NPOI.POIFS.Crypt.CryptoFunctions;
  53. using static OASystem.API.OAMethodLib.JWTHelper;
  54. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  55. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  56. using Bookmark = Aspose.Words.Bookmark;
  57. using Cell = Aspose.Words.Tables.Cell;
  58. using Table = Aspose.Words.Tables.Table;
  59. namespace OASystem.API.Controllers
  60. {
  61. /// <summary>
  62. /// 团组相关
  63. /// </summary>
  64. //[Authorize]
  65. [Route("api/[controller]/[action]")]
  66. public class GroupsController : ControllerBase
  67. {
  68. private readonly ILogger<GroupsController> _logger;
  69. private readonly GrpScheduleRepository _grpScheduleRep;
  70. private readonly IMapper _mapper;
  71. private readonly DelegationInfoRepository _groupRepository;
  72. private readonly TaskAssignmentRepository _taskAssignmentRep;
  73. private readonly AirTicketResRepository _airTicketResRep;
  74. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  75. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  76. private readonly DelegationEnDataRepository _delegationEnDataRep;
  77. private readonly DelegationVisaRepository _delegationVisaRep;
  78. private readonly VisaPriceRepository _visaPriceRep;
  79. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  80. private readonly HotelPriceRepository _hotelPriceRep;
  81. private readonly CustomersRepository _customersRep;
  82. private readonly MessageRepository _message;
  83. private readonly SqlSugarClient _sqlSugar;
  84. private readonly TourClientListRepository _tourClientListRep;
  85. private readonly TeamRateRepository _teamRateRep;
  86. #region 成本相关
  87. private readonly CheckBoxsRepository _checkBoxs;
  88. private readonly GroupCostRepository _GroupCostRepository;
  89. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  90. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  91. #endregion
  92. private readonly SetDataRepository _setDataRep;
  93. private string url;
  94. private string path;
  95. private readonly EnterExitCostRepository _enterExitCostRep;
  96. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  97. private readonly UsersRepository _usersRep;
  98. private readonly IJuHeApiService _juHeApi;
  99. private readonly InvertedListRepository _invertedListRep;
  100. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  101. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  102. private readonly ThreeCodeRepository _threeCodeRepository;
  103. private readonly HotelInquiryRepository _hotelInquiryRep;
  104. private readonly FeeAuditRepository _feeAuditRep;
  105. private readonly VisaCommissionRepository _visaCommissionRep;
  106. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  107. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  108. private readonly List<CurrencyInfo> _currencyInit;
  109. private readonly List<int> _portTypeData;
  110. public GroupsController(
  111. ILogger<GroupsController> logger,
  112. IMapper mapper,
  113. IHubContext<ChatHub, IChatClient> hubContext,
  114. SqlSugarClient sqlSugar,
  115. GrpScheduleRepository grpScheduleRep,
  116. DelegationInfoRepository groupRepository,
  117. TaskAssignmentRepository taskAssignmentRep,
  118. AirTicketResRepository airTicketResRep,
  119. DecreasePaymentsRepository decreasePaymentsRep,
  120. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  121. DelegationEnDataRepository delegationEnDataRep,
  122. EnterExitCostRepository enterExitCostRep,
  123. DelegationVisaRepository delegationVisaRep,
  124. MessageRepository message,
  125. VisaPriceRepository visaPriceRep,
  126. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  127. CheckBoxsRepository checkBoxs,
  128. GroupCostRepository GroupCostRepository,
  129. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  130. GroupCostParameterRepository GroupCostParameterRepository,
  131. HotelPriceRepository hotelPriceRep,
  132. CustomersRepository customersRep,
  133. SetDataRepository setDataRep,
  134. TourClientListRepository tourClientListRep,
  135. TeamRateRepository teamRateRep,
  136. UsersRepository usersRep, IJuHeApiService juHeApi,
  137. InvertedListRepository invertedListRep,
  138. VisaFeeInfoRepository visaFeeInfoRep,
  139. TicketBlackCodeRepository ticketBlackCodeRep,
  140. HotelInquiryRepository hotelInquiryRep,
  141. ThreeCodeRepository threeCodeRepository,
  142. FeeAuditRepository feeAuditRep,
  143. VisaCommissionRepository visaCommissionRep,
  144. ForeignReceivablesRepository ffrRep,
  145. OpinionaireRepository opinionaireRep
  146. )
  147. {
  148. _logger = logger;
  149. _mapper = mapper;
  150. _grpScheduleRep = grpScheduleRep;
  151. _groupRepository = groupRepository;
  152. _taskAssignmentRep = taskAssignmentRep;
  153. _airTicketResRep = airTicketResRep;
  154. _sqlSugar = sqlSugar;
  155. url = AppSettingsHelper.Get("ExcelBaseUrl");
  156. path = AppSettingsHelper.Get("ExcelBasePath");
  157. if (!System.IO.Directory.Exists(path))
  158. {
  159. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  160. }
  161. _decreasePaymentsRep = decreasePaymentsRep;
  162. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  163. _delegationEnDataRep = delegationEnDataRep;
  164. _enterExitCostRep = enterExitCostRep;
  165. _delegationVisaRep = delegationVisaRep;
  166. _message = message;
  167. _visaPriceRep = visaPriceRep;
  168. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  169. _checkBoxs = checkBoxs;
  170. _GroupCostRepository = GroupCostRepository;
  171. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  172. _GroupCostParameterRepository = GroupCostParameterRepository;
  173. _hotelPriceRep = hotelPriceRep;
  174. _customersRep = customersRep;
  175. _setDataRep = setDataRep;
  176. _tourClientListRep = tourClientListRep;
  177. _teamRateRep = teamRateRep;
  178. _hubContext = hubContext;
  179. _usersRep = usersRep;
  180. _juHeApi = juHeApi;
  181. _invertedListRep = invertedListRep;
  182. _visaFeeInfoRep = visaFeeInfoRep;
  183. _ticketBlackCodeRep = ticketBlackCodeRep;
  184. _hotelInquiryRep = hotelInquiryRep;
  185. _threeCodeRepository = threeCodeRepository;
  186. _feeAuditRep = feeAuditRep;
  187. _visaCommissionRep = visaCommissionRep;
  188. _ffrRep = ffrRep;
  189. _opinionaireRep = opinionaireRep;
  190. _currencyInit = new List<CurrencyInfo>()
  191. {
  192. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  193. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  194. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  195. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  196. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  197. };
  198. _portTypeData = new List<int>() { 2, 3 };
  199. }
  200. #region 流程管控
  201. /// <summary>
  202. /// 获取团组流程管控信息
  203. /// </summary>
  204. /// <param name="paras">参数Json字符串</param>
  205. /// <returns></returns>
  206. [HttpPost]
  207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  208. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  209. {
  210. if (string.IsNullOrEmpty(_jsonDto.Paras))
  211. {
  212. return Ok(JsonView(false, "参数为空"));
  213. }
  214. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  215. if (_ScheduleDto != null)
  216. {
  217. if (_ScheduleDto.SearchType == 2)//获取列表
  218. {
  219. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  220. return Ok(JsonView(_grpScheduleViewList));
  221. }
  222. else//获取对象
  223. {
  224. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  225. if (_grpScheduleView != null)
  226. {
  227. return Ok(JsonView(_grpScheduleView));
  228. }
  229. }
  230. }
  231. else
  232. {
  233. return Ok(JsonView(false, "参数反序列化失败"));
  234. }
  235. return Ok(JsonView(false, "暂无数据!"));
  236. }
  237. /// <summary>
  238. /// 修改团组流程管控详细表数据
  239. /// </summary>
  240. /// <param name="paras"></param>
  241. /// <returns></returns>
  242. [HttpPost]
  243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  244. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  245. {
  246. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  247. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  248. .SetColumns(it => it.Duty == _detail.Duty)
  249. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  250. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  251. .SetColumns(it => it.JobContent == _detail.JobContent)
  252. .SetColumns(it => it.Remark == _detail.Remark)
  253. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  254. .Where(s => s.Id == dto.Id)
  255. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  256. .ExecuteCommandAsync();
  257. if (result > 0)
  258. {
  259. return Ok(JsonView(true, "保存成功!"));
  260. }
  261. return Ok(JsonView(false, "保存失败!"));
  262. }
  263. /// <summary>
  264. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  265. /// </summary>
  266. /// <param name="dto"></param>
  267. /// <returns></returns>
  268. [HttpPost]
  269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  270. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  271. {
  272. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  273. _detail.IsDel = 1;
  274. _detail.DeleteUserId = dto.Duty;
  275. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  276. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  277. .SetColumns(it => it.IsDel == _detail.IsDel)
  278. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  279. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  280. .Where(it => it.Id == dto.Id)
  281. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  282. //.WhereColumns(s => s.Id == dto.Id)
  283. .ExecuteCommandAsync();
  284. if (result > 0)
  285. {
  286. return Ok(JsonView(true, "删除成功!"));
  287. }
  288. return Ok(JsonView(false, "删除失败!"));
  289. }
  290. /// <summary>
  291. /// 增加团组流程管控详细表数据
  292. /// </summary>
  293. /// <param name="dto"></param>
  294. /// <returns></returns>
  295. [HttpPost]
  296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  298. {
  299. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  300. if (DateTime.Now < _detail.ExpectBeginDt)
  301. {
  302. _detail.StepStatus = 0;
  303. }
  304. else
  305. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  306. _detail.StepStatus = 1;
  307. }
  308. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  309. if (result > 0)
  310. {
  311. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  312. return Ok(JsonView(true, "添加成功!", _result));
  313. }
  314. return Ok(JsonView(false, "添加失败!"));
  315. }
  316. #endregion
  317. #region 团组基本信息
  318. /// <summary>
  319. /// 接团信息列表
  320. /// </summary>
  321. /// <param name="dto">团组列表请求dto</param>
  322. /// <returns></returns>
  323. [HttpPost]
  324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  325. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  326. {
  327. var groupData = await _groupRepository.GetGroupList(dto);
  328. if (groupData.Code != 0)
  329. {
  330. return Ok(JsonView(false, groupData.Msg));
  331. }
  332. return Ok(JsonView(groupData.Data));
  333. }
  334. /// <summary>
  335. /// 分页查询团组列表
  336. /// </summary>
  337. /// <param name="dto"></param>
  338. /// <returns></returns>
  339. [HttpPost]
  340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  341. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  342. {
  343. var watch = new Stopwatch();
  344. watch.Start();
  345. RefAsync<int> total = 0;
  346. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  347. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  348. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  349. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  350. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  351. .Distinct()
  352. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  353. watch.Stop();
  354. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  355. }
  356. /// <summary>
  357. /// 接团信息列表 Page
  358. /// </summary>
  359. /// <param name="dto">团组列表请求dto</param>
  360. /// <returns></returns>
  361. [HttpPost]
  362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  363. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  364. {
  365. #region 参数验证
  366. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  367. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  368. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  369. #region 页面操作权限验证
  370. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  371. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  372. #endregion
  373. #endregion
  374. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  375. {
  376. string sqlWhere = string.Empty;
  377. if (dto.IsSure == 0) //未完成
  378. {
  379. sqlWhere += string.Format(@" And IsSure = 0");
  380. }
  381. else if (dto.IsSure == 1) //已完成
  382. {
  383. sqlWhere += string.Format(@" And IsSure = 1");
  384. }
  385. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  386. {
  387. string tj = dto.SearchCriteria;
  388. 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}%')",
  389. tj, tj, tj, tj, tj);
  390. }
  391. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  392. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  393. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  394. JietuanOperator,IsSure,CreateTime,IsBid
  395. From (
  396. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  397. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  398. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  399. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  400. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  401. From Grp_DelegationInfo gdi
  402. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  403. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  404. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  405. Where gdi.IsDel = 0 {0}
  406. ) temp", sqlWhere);
  407. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  408. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  409. #region 处理所属部门
  410. /*
  411. * 1.sq 和 gyy 等显示 市场部
  412. * 2.王鸽和主管及张总还有管理员号统一国交部
  413. * 2-1. 4 管理员 ,21 张海麟
  414. */
  415. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  416. List<int> userIds1 = new List<int>() { 4, 21 };
  417. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  418. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  419. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  420. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  421. .ToList();
  422. foreach (var item in _DelegationList)
  423. {
  424. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  425. }
  426. #endregion
  427. var _view = new
  428. {
  429. PageFuncAuth = pageFunAuthView,
  430. Data = _DelegationList
  431. };
  432. return Ok(JsonView(true, "查询成功!", _view, total));
  433. }
  434. else
  435. {
  436. return Ok(JsonView(false, "查询失败"));
  437. }
  438. }
  439. /// <summary>
  440. /// 团组列表
  441. /// </summary>
  442. /// <returns></returns>
  443. [HttpPost]
  444. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  445. {
  446. #region 参数验证
  447. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  448. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  449. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  450. #region 页面操作权限验证
  451. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  452. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  453. #endregion
  454. #endregion
  455. if (dto.PortType != 1 && dto.PortType != 2)
  456. {
  457. return Ok(JsonView(false, "查询失败!"));
  458. }
  459. string orderbyStr = "order by gdi.CreateTime Desc";
  460. string sqlWhere = string.Empty;
  461. if (dto.IsSure == 0) //未完成
  462. {
  463. sqlWhere += string.Format(@" And IsSure = 0");
  464. }
  465. else if (dto.IsSure == 1) //已完成
  466. {
  467. sqlWhere += string.Format(@" And IsSure = 1");
  468. }
  469. //团组类型
  470. if (dto.TeamDid > 0)
  471. {
  472. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  473. }
  474. //团组名称
  475. if (!string.IsNullOrEmpty(dto.TeamName))
  476. {
  477. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  478. }
  479. //客户名称
  480. if (!string.IsNullOrEmpty(dto.ClientName))
  481. {
  482. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  483. }
  484. //客户单位
  485. if (!string.IsNullOrEmpty(dto.ClientUnit))
  486. {
  487. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  488. }
  489. //出访时间
  490. if (!string.IsNullOrEmpty(dto.visitDataTime))
  491. {
  492. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  493. orderbyStr = "order by gdi.VisitDate";
  494. }
  495. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  496. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  497. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  498. JietuanOperator,IsSure,CreateTime
  499. From (
  500. Select row_number() over({0}) as Row_Number,
  501. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  502. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  503. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  504. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  505. From Grp_DelegationInfo gdi
  506. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  507. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  508. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  509. Where gdi.IsDel = 0 {1}
  510. ) temp ", orderbyStr, sqlWhere);
  511. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  512. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  513. #region 处理所属部门
  514. /*
  515. * 1.sq 和 gyy 等显示 市场部
  516. * 2.王鸽和主管及张总还有管理员号统一国交部
  517. * 2-1. 4 管理员 ,21 张海麟
  518. */
  519. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  520. List<int> userIds1 = new List<int>() { 4, 21 };
  521. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  522. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  523. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  524. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  525. .ToList();
  526. foreach (var item in _DelegationList)
  527. {
  528. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  529. }
  530. #endregion
  531. var _view = new
  532. {
  533. PageFuncAuth = pageFunAuthView,
  534. Data = _DelegationList
  535. };
  536. return Ok(JsonView(true, "查询成功!", _view, total));
  537. }
  538. /// <summary>
  539. /// 接团信息详情
  540. /// </summary>
  541. /// <param name="dto">团组info请求dto</param>
  542. /// <returns></returns>
  543. [HttpPost]
  544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  545. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  546. {
  547. var groupData = await _groupRepository.GetGroupInfo(dto);
  548. if (groupData.Code != 0)
  549. {
  550. return Ok(JsonView(false, groupData.Msg));
  551. }
  552. return Ok(JsonView(groupData.Data));
  553. }
  554. /// <summary>
  555. /// 接团信息 编辑添加
  556. /// 基础信息数据源
  557. /// </summary>
  558. /// <param name="dto"></param>
  559. /// <returns></returns>
  560. [HttpPost]
  561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  562. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  563. {
  564. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  565. if (groupData.Code != 0)
  566. {
  567. return Ok(JsonView(false, groupData.Msg));
  568. }
  569. return Ok(JsonView(groupData.Data));
  570. }
  571. /// <summary>
  572. /// 接团信息 操作(增改)
  573. /// </summary>
  574. /// <param name="dto"></param>
  575. /// <returns></returns>
  576. [HttpPost]
  577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  578. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  579. {
  580. try
  581. {
  582. decimal ffrPrice = 0.00M;
  583. DateTime? visitDt = null;
  584. if (dto.Status == 2)
  585. {
  586. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  587. if (groupInfo != null)
  588. {
  589. ffrPrice = groupInfo.PaymentMoney;
  590. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  591. }
  592. }
  593. var groupData = await _groupRepository.GroupOperation(dto);
  594. if (groupData.Code != 0)
  595. {
  596. return Ok(JsonView(false, groupData.Msg));
  597. }
  598. int diId = 0;
  599. //添加时 默认加入团组汇率
  600. if (dto.Status == 1) //添加
  601. {
  602. diId = groupData.Data;
  603. //添加默认币种
  604. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  605. //默认分配权限
  606. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  607. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  608. var _managerIds = new List<int>() { 22, 32, 21 };
  609. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  610. if (userIds.Count > 0)
  611. {
  612. userIds.Add(208);
  613. //创建团组管控
  614. GroupStepForDelegation.CreateWorkStep(diId);
  615. //发送消息
  616. string groupName = dto.TeamName;
  617. string createGroupUser = string.Empty;
  618. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  619. if (userInfo != null) createGroupUser = userInfo.CnName;
  620. string title = $"系统通知";
  621. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  622. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  623. }
  624. //默认创建倒推表
  625. await _invertedListRep._Create(dto.UserId, diId);
  626. }
  627. else if (dto.Status == 2)
  628. {
  629. diId = dto.Id;
  630. }
  631. #region 签证人员团组时间通知
  632. #region 计算出访起止时间
  633. var startTime = new DateTime();
  634. var endTime = new DateTime();
  635. if (DateTime.TryParse(dto.VisitDate, out startTime))
  636. {
  637. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  638. }
  639. #endregion
  640. if (diId > 0)
  641. {
  642. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  643. }
  644. #endregion
  645. #region 团组操作默认添加/修改收款账单
  646. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  647. {
  648. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  649. .Where(x => x.IsDel == 0 &&
  650. x.Diid == diId &&
  651. x.Remark.Equals("预付款")
  652. )
  653. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  654. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  655. .FirstAsync();
  656. ffrInfo = new Fin_ForeignReceivables()
  657. {
  658. Diid = diId,
  659. PriceName = dto.ClientUnit,
  660. Price = dto.PaymentMoney,
  661. Count = 1,
  662. Unit = $"元",
  663. ItemSumPrice = dto.PaymentMoney,
  664. Rate = 1.0000M,
  665. Currency = 836,
  666. AddingWay = 0,
  667. CreateUserId = dto.UserId,
  668. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  669. Remark = $"预付款"
  670. };
  671. if (ffrInfo == null) //Add
  672. {
  673. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  674. }
  675. else //修改
  676. {
  677. await _sqlSugar.Updateable(ffrInfo)
  678. .UpdateColumns(x => new
  679. {
  680. x.PriceName,
  681. x.Price,
  682. x.ItemSumPrice,
  683. x.CreateTime,
  684. x.CreateUserId
  685. })
  686. .WhereColumns(x => x.Id)
  687. .ExecuteCommandAsync();
  688. }
  689. }
  690. #endregion
  691. return Ok(JsonView(true, "操作成功!", diId));
  692. }
  693. catch (Exception ex)
  694. {
  695. Logs("[response]" + JsonConvert.SerializeObject(dto));
  696. Logs(ex.Message);
  697. return Ok(JsonView(false, ex.Message));
  698. }
  699. }
  700. /// <summary>
  701. /// 接团流程操作(增改)
  702. /// 安卓端使用 建团时添加客户名单
  703. /// </summary>
  704. /// <param name="dto"></param>
  705. /// <returns></returns>
  706. [HttpPost]
  707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  708. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  709. {
  710. try
  711. {
  712. #region 参数验证
  713. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  714. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  715. #region 页面操作权限验证
  716. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  717. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  718. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  719. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  720. #endregion
  721. #endregion
  722. _sqlSugar.BeginTran();
  723. decimal ffrPrice = 0.00M;
  724. DateTime? visitDt = null;
  725. if (dto.Status == 2)
  726. {
  727. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  728. if (groupInfo != null)
  729. {
  730. ffrPrice = groupInfo.PaymentMoney;
  731. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  732. }
  733. }
  734. var _dto = new GroupOperationDto();
  735. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  736. var groupData = await _groupRepository.GroupOperation(_dto);
  737. if (groupData.Code != 0)
  738. {
  739. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  740. }
  741. int diId = 0;
  742. //添加时 默认加入团组汇率
  743. if (dto.Status == 1) //添加
  744. {
  745. diId = groupData.Data;
  746. //添加默认币种
  747. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  748. //默认分配权限
  749. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  750. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  751. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  752. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  753. if (userIds.Count > 0)
  754. {
  755. userIds.Add(208);
  756. //创建团组管控
  757. GroupStepForDelegation.CreateWorkStep(diId);
  758. //发送消息
  759. string groupName = dto.TeamName;
  760. string createGroupUser = string.Empty;
  761. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  762. if (userInfo != null) createGroupUser = userInfo.CnName;
  763. string title = $"系统通知";
  764. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  765. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  766. }
  767. #region 应用推送
  768. try
  769. {
  770. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  771. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  772. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  773. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  774. {
  775. List<string> userList = new List<string>() { users.QiyeChatUserId };
  776. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  777. }
  778. }
  779. catch (Exception ex)
  780. {
  781. }
  782. #endregion
  783. //默认创建倒推表
  784. await _invertedListRep._Create(dto.UserId, diId);
  785. }
  786. if (dto.Status == 2)
  787. {
  788. diId = dto.Id;
  789. if (diId == 0)
  790. {
  791. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  792. }
  793. }
  794. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  795. if (viewData.Code != 0)
  796. {
  797. _sqlSugar.RollbackTran();
  798. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  799. }
  800. #region 团组操作默认添加/修改收款账单
  801. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  802. {
  803. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  804. .Where(x => x.IsDel == 0 &&
  805. x.Diid == diId &&
  806. x.Remark.Equals("预付款")
  807. )
  808. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  809. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  810. .FirstAsync();
  811. ffrInfo = new Fin_ForeignReceivables()
  812. {
  813. Diid = diId,
  814. PriceName = dto.ClientUnit,
  815. Price = dto.PaymentMoney,
  816. Count = 1,
  817. Unit = $"元",
  818. ItemSumPrice = dto.PaymentMoney,
  819. Rate = 1.0000M,
  820. Currency = 836,
  821. AddingWay = 0,
  822. CreateUserId = dto.UserId,
  823. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  824. Remark = $"预付款"
  825. };
  826. if (ffrInfo == null) //Add
  827. {
  828. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  829. }
  830. else //修改
  831. {
  832. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  833. .UpdateColumns(x => new
  834. {
  835. x.PriceName,
  836. x.Price,
  837. x.ItemSumPrice,
  838. x.CreateTime,
  839. x.CreateUserId
  840. })
  841. .WhereColumns(x => x.Id)
  842. .ExecuteCommandAsync();
  843. }
  844. }
  845. #endregion
  846. #region 签证人员团组时间通知
  847. #region 计算出访起止时间
  848. var startTime = new DateTime();
  849. var endTime = new DateTime();
  850. if (DateTime.TryParse(dto.VisitDate, out startTime))
  851. {
  852. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  853. }
  854. #endregion
  855. if (diId > 0)
  856. {
  857. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  858. }
  859. #endregion
  860. _sqlSugar.CommitTran();
  861. return Ok(JsonView(true, "添加成功"));
  862. }
  863. catch (Exception ex)
  864. {
  865. _sqlSugar.RollbackTran();
  866. return Ok(JsonView(false, ex.Message));
  867. }
  868. }
  869. /// <summary>
  870. /// 接团信息 操作(删除)
  871. /// </summary>
  872. /// <param name="dto"></param>
  873. /// <returns></returns>
  874. [HttpPost]
  875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  876. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  877. {
  878. try
  879. {
  880. var groupData = await _groupRepository.GroupDel(dto);
  881. if (groupData.Code != 0)
  882. {
  883. return Ok(JsonView(false, groupData.Msg));
  884. }
  885. return Ok(JsonView(true));
  886. }
  887. catch (Exception ex)
  888. {
  889. Logs("[response]" + JsonConvert.SerializeObject(dto));
  890. Logs(ex.Message);
  891. return Ok(JsonView(false, ex.Message));
  892. }
  893. }
  894. /// <summary>
  895. /// 获取团组销售报价号
  896. /// 团组添加时 使用
  897. /// </summary>
  898. /// <returns></returns>
  899. [HttpPost]
  900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  901. public async Task<IActionResult> GetGroupSalesQuoteNo()
  902. {
  903. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  904. if (groupData.Code != 0)
  905. {
  906. return Ok(JsonView(false, groupData.Msg));
  907. }
  908. object salesQuoteNo = new
  909. {
  910. SalesQuoteNo = groupData.Data
  911. };
  912. return Ok(JsonView(salesQuoteNo));
  913. }
  914. /// <summary>
  915. /// 设置确认出团
  916. /// </summary>
  917. /// <param name="dto"></param>
  918. /// <returns></returns>
  919. [HttpPost]
  920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  921. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  922. {
  923. var groupData = await _groupRepository.ConfirmationGroup(dto);
  924. if (groupData.Code != 0)
  925. {
  926. return Ok(JsonView(false, groupData.Msg));
  927. }
  928. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  929. #region OA消息推送
  930. try
  931. {
  932. string groupName = groupInfo.TeamName;
  933. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  934. List<int> userIds = new List<int>();
  935. listUser.ForEach(s => userIds.Add(s.Id));
  936. string title = $"系统通知";
  937. string content = $"团组[{groupName}]已确认出团!";
  938. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  939. }
  940. catch (Exception ex)
  941. {
  942. }
  943. #endregion
  944. #region 应用推送
  945. try
  946. {
  947. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  948. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  949. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  950. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  951. {
  952. List<string> userList = new List<string>() { users.QiyeChatUserId };
  953. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  954. }
  955. }
  956. catch (Exception ex)
  957. {
  958. }
  959. #endregion
  960. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  961. return Ok(JsonView(true, "操作成功!", groupData.Data));
  962. }
  963. /// <summary>
  964. /// 获取团组名称data And 签证国别Data
  965. /// </summary>
  966. /// <param name="dto"></param>
  967. /// <returns></returns>
  968. [HttpPost]
  969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  970. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  971. {
  972. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  973. if (groupData.Code != 0)
  974. {
  975. return Ok(JsonView(false, groupData.Msg));
  976. }
  977. return Ok(JsonView(groupData.Data));
  978. }
  979. /// <summary>
  980. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  981. /// </summary>
  982. /// <returns></returns>
  983. [HttpPost]
  984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  985. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  986. {
  987. try
  988. {
  989. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  990. if (groupData.Code != 0)
  991. {
  992. return Ok(JsonView(false, groupData.Msg));
  993. }
  994. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  995. }
  996. catch (Exception ex)
  997. {
  998. return Ok(JsonView(false, "程序错误!"));
  999. throw;
  1000. }
  1001. }
  1002. /// <summary>
  1003. /// 团组清单 Excel
  1004. /// </summary>
  1005. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1006. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1007. /// <returns></returns>
  1008. [HttpGet]
  1009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1010. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1011. {
  1012. DateTime _beginDt, _endDt;
  1013. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1014. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1015. if (!beginBool && !endBool)
  1016. {
  1017. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1018. }
  1019. string sql = string.Format(@"
  1020. SELECT
  1021. ROW_NUMBER,
  1022. Id,
  1023. SalesQuoteNo,
  1024. TourCode,
  1025. TeamTypeId,
  1026. TeamType,
  1027. TeamLevId,
  1028. TeamLev,
  1029. TeamName,
  1030. ClientName,
  1031. ClientUnit,
  1032. VisitDate,
  1033. VisitDays,
  1034. VisitPNumber,
  1035. JietuanOperatorId,
  1036. JietuanOperator,
  1037. IsSure,
  1038. CreateTime,
  1039. IsBid
  1040. FROM
  1041. (
  1042. SELECT
  1043. ROW_NUMBER() OVER(
  1044. ORDER BY
  1045. gdi.CreateTime Desc
  1046. ) AS ROW_NUMBER,
  1047. gdi.Id,
  1048. SalesQuoteNo,
  1049. TourCode,
  1050. ssd.Id TeamTypeId,
  1051. ssd.Name TeamType,
  1052. ssd1.Id TeamLevId,
  1053. ssd1.Name TeamLev,
  1054. TeamName,
  1055. ClientName,
  1056. ClientUnit,
  1057. VisitDate,
  1058. VisitDays,
  1059. VisitPNumber,
  1060. JietuanOperator JietuanOperatorId,
  1061. su.CnName JietuanOperator,
  1062. IsSure,
  1063. gdi.CreateTime,
  1064. gdi.IsBid
  1065. FROM
  1066. Grp_DelegationInfo gdi
  1067. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1068. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1069. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1070. WHERE
  1071. gdi.IsDel = 0
  1072. AND gdi.IsBid = 0
  1073. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1074. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1075. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1076. #region 处理所属部门
  1077. /*
  1078. * 1.sq 和 gyy 等显示 市场部
  1079. * 2.王鸽和主管及张总还有管理员号统一国交部
  1080. * 2-1. 4 管理员 ,21 张海麟
  1081. */
  1082. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1083. List<int> userIds1 = new List<int>() { 4, 21 };
  1084. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1085. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1086. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1087. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1088. .ToListAsync();
  1089. foreach (var item in groupList)
  1090. {
  1091. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1092. }
  1093. #endregion
  1094. #region Excel
  1095. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1096. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1097. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1098. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1099. var fileName = $"团组清单({beginDt}{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1100. //载入模板
  1101. WorkbookDesigner designer = new WorkbookDesigner();
  1102. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1103. designer.SetDataSource("Titel", $"团组清单({beginDt}{endDt})");
  1104. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1105. dt.TableName = "GroupList";
  1106. designer.SetDataSource(dt);
  1107. designer.Process();
  1108. if (!Directory.Exists(savePath))
  1109. {
  1110. Directory.CreateDirectory(savePath);
  1111. }
  1112. string serverPath = $"{savePath}{fileName}";
  1113. designer.Workbook.Save(serverPath);
  1114. string rst = $"{servicePath}{ftpPath}{fileName}";
  1115. #endregion
  1116. return Ok(JsonView(true, "操作成功!", rst));
  1117. }
  1118. #endregion
  1119. #region 团组&签证
  1120. /// <summary>
  1121. /// 根据团组Id获取签证客户信息List
  1122. /// </summary>
  1123. /// <param name="dto">请求dto</param>
  1124. /// <returns></returns>
  1125. [HttpPost]
  1126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1127. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1128. {
  1129. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1130. if (groupData.Code != 0)
  1131. {
  1132. return Ok(JsonView(false, groupData.Msg));
  1133. }
  1134. return Ok(JsonView(groupData.Data));
  1135. }
  1136. /// <summary>
  1137. /// IOS获取团组签证拍照上传进度01(团组列表)
  1138. /// </summary>
  1139. /// <param name="dto">请求dto</param>
  1140. /// <returns></returns>
  1141. [HttpPost]
  1142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1143. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1144. {
  1145. if (dto == null)
  1146. {
  1147. return Ok(JsonView(false, "参数为空"));
  1148. }
  1149. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1150. return Ok(JsonView(visaList));
  1151. }
  1152. /// <summary>
  1153. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1154. /// </summary>
  1155. /// <returns></returns>
  1156. [HttpPost]
  1157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1158. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1159. {
  1160. if (dto == null)
  1161. {
  1162. return Ok(JsonView(false, "请求错误:"));
  1163. }
  1164. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1165. return Ok(JsonView(list));
  1166. }
  1167. /// <summary>
  1168. /// IOS获取团组签证拍照上传进度03(相册)
  1169. /// </summary>
  1170. /// <returns></returns>
  1171. [HttpPost]
  1172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1173. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1174. {
  1175. if (dto == null)
  1176. {
  1177. return Ok(JsonView(false, "请求错误:"));
  1178. }
  1179. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1180. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1181. list.ForEach(s => s.url = url);
  1182. return Ok(JsonView(list));
  1183. }
  1184. /// <summary>
  1185. /// IOS获取团组签证拍照上传进度04(图片上传)
  1186. /// </summary>
  1187. /// <param name="dto"></param>
  1188. /// <returns></returns>
  1189. [HttpPost]
  1190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1191. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1192. {
  1193. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1194. //if (!string.IsNullOrEmpty(result))
  1195. //{
  1196. //}
  1197. //else {
  1198. // return Ok(JsonView(false, "上传失败"));
  1199. //}
  1200. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1201. int sucNum = 0;
  1202. try
  1203. {
  1204. foreach (var item in dto.base64DataList)
  1205. {
  1206. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1207. string result = decodeBase64ToImage(item, imageName);
  1208. if (!string.IsNullOrEmpty(result))
  1209. {
  1210. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1211. pic.CreateUserId = dto.CreateUserId;
  1212. pic.PicName = imageName;
  1213. pic.PicPath = result;
  1214. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1215. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1216. if (insertResult > 0)
  1217. {
  1218. sucNum++;
  1219. }
  1220. }
  1221. }
  1222. }
  1223. catch (Exception ex)
  1224. {
  1225. return Ok(JsonView(false, ex.Message));
  1226. }
  1227. string msg = string.Format(@"成功上传{0}张", sucNum);
  1228. return Ok(JsonView(true, msg));
  1229. }
  1230. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1231. {
  1232. string filename = "";//声明一个string类型的相对路径
  1233. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1234. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1235. try//会有异常抛出,try,catch一下
  1236. {
  1237. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1238. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1239. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1240. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1241. //文件名称
  1242. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1243. //上传的文件的路径
  1244. string filePath = "";
  1245. if (!Directory.Exists(fileDir))
  1246. {
  1247. Directory.CreateDirectory(fileDir);
  1248. }
  1249. //上传的文件的路径
  1250. filePath = fileDir + filename;
  1251. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1252. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1253. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1254. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1255. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1256. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1257. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1258. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1259. bitmap.Dispose();
  1260. }
  1261. catch (Exception e)
  1262. {
  1263. string massage = e.Message;
  1264. Logs("IOS图片上传Error:" + massage);
  1265. //filename = e.Message;
  1266. }
  1267. return filename;//返回相对路径
  1268. }
  1269. /// <summary>
  1270. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1271. /// </summary>
  1272. /// <param name="dto"></param>
  1273. /// <returns></returns>
  1274. [HttpPost]
  1275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1276. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1277. {
  1278. if (dto == null)
  1279. {
  1280. return Ok(JsonView(false, "请求错误:"));
  1281. }
  1282. string msg = "参数错误";
  1283. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1284. {
  1285. try
  1286. {
  1287. //_delegationVisaRep.BeginTran();
  1288. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1289. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1290. .Where(s => s.Id == dto.visaProgressCustomerId)
  1291. .ExecuteCommandAsync();
  1292. if (updCount > 0 && dto.publishCode == 1)
  1293. {
  1294. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1295. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1296. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1297. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1298. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1299. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1300. if (groupData == null)
  1301. {
  1302. _delegationVisaRep.RollbackTran();
  1303. }
  1304. string title = string.Format(@"[签证进度更新]");
  1305. string content = string.Format(@"测试文本");
  1306. bool rst = await _message.AddMsg(new MessageDto()
  1307. {
  1308. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1309. IssuerId = dto.publisher,
  1310. Title = title,
  1311. Content = content,
  1312. ReleaseTime = DateTime.Now,
  1313. UIdList = new List<int> {
  1314. 234
  1315. }
  1316. });
  1317. if (rst)
  1318. {
  1319. return Ok(JsonView(true, "发送通知成功"));
  1320. }
  1321. }
  1322. //_delegationVisaRep.CommitTran();
  1323. }
  1324. catch (Exception)
  1325. {
  1326. //_delegationVisaRep.RollbackTran();
  1327. }
  1328. }
  1329. return Ok(JsonView(true, msg));
  1330. }
  1331. #endregion
  1332. #region 团组任务分配
  1333. /// <summary>
  1334. /// 团组任务分配初始化
  1335. /// </summary>
  1336. /// <param name="dto"></param>
  1337. /// <returns></returns>
  1338. [HttpPost]
  1339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1340. public async Task<IActionResult> GetTaskAssignmen()
  1341. {
  1342. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1343. if (groupData.Code != 0)
  1344. {
  1345. return Ok(JsonView(false, groupData.Msg));
  1346. }
  1347. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1348. }
  1349. /// <summary>
  1350. /// 团组任务分配查询
  1351. /// </summary>
  1352. /// <param name="dto"></param>
  1353. /// <returns></returns>
  1354. [HttpPost]
  1355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1356. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1357. {
  1358. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1359. if (groupData.Code != 0)
  1360. {
  1361. return Ok(JsonView(false, groupData.Msg));
  1362. }
  1363. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1364. }
  1365. /// <summary>
  1366. /// 团组任务分配操作
  1367. /// </summary>
  1368. /// <param name="dto"></param>
  1369. /// <returns></returns>
  1370. [HttpPost]
  1371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1372. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1373. {
  1374. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1375. if (groupData.Code != 0)
  1376. {
  1377. return Ok(JsonView(false, groupData.Msg));
  1378. }
  1379. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1380. }
  1381. /// <summary>
  1382. /// 团组任务分配
  1383. /// 批量分配
  1384. /// 查询团组
  1385. /// </summary>
  1386. /// <param name="dto"></param>
  1387. /// <returns></returns>
  1388. [HttpPost]
  1389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1390. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1391. {
  1392. //参数验证
  1393. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1394. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1395. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1396. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1397. }
  1398. /// <summary>
  1399. /// 团组任务分配
  1400. /// 批量分配
  1401. /// </summary>
  1402. /// <param name="dto"></param>
  1403. /// <returns></returns>
  1404. [HttpPost]
  1405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1406. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1407. {
  1408. //参数验证
  1409. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1410. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1411. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1412. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1413. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1414. }
  1415. #endregion
  1416. #region 团组费用审核
  1417. /// <summary>
  1418. /// 费用审核
  1419. /// 团组列表 Page
  1420. /// </summary>
  1421. /// <param name="_dto">团组列表请求dto</param>
  1422. /// <returns></returns>
  1423. [HttpPost]
  1424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1425. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1426. {
  1427. #region 参数验证
  1428. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1429. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1430. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1431. #region 页面操作权限验证
  1432. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1433. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1434. #endregion
  1435. #endregion
  1436. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1437. {
  1438. string sqlWhere = string.Empty;
  1439. if (_dto.IsSure == 0) //未完成
  1440. {
  1441. sqlWhere += string.Format(@" And IsSure = 0");
  1442. }
  1443. else if (_dto.IsSure == 1) //已完成
  1444. {
  1445. sqlWhere += string.Format(@" And IsSure = 1");
  1446. }
  1447. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1448. {
  1449. string tj = _dto.SearchCriteria;
  1450. 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}%')",
  1451. tj, tj, tj, tj, tj);
  1452. }
  1453. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1454. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1455. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1456. From (
  1457. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1458. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1459. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1460. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1461. From Grp_DelegationInfo gdi
  1462. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1463. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1464. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1465. Where gdi.IsDel = 0 {0}
  1466. ) temp ", sqlWhere);
  1467. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1468. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1469. var _view = new
  1470. {
  1471. PageFuncAuth = pageFunAuthView,
  1472. Data = _DelegationList
  1473. };
  1474. return Ok(JsonView(true, "查询成功!", _view, total));
  1475. }
  1476. else
  1477. {
  1478. return Ok(JsonView(false, "查询失败"));
  1479. }
  1480. }
  1481. /// <summary>
  1482. /// 获取团组费用审核
  1483. /// </summary>
  1484. /// <param name="paras">参数Json字符串</param>
  1485. /// <returns></returns>
  1486. [HttpPost]
  1487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1488. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1489. {
  1490. try
  1491. {
  1492. #region 参数验证
  1493. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1494. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1495. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1496. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1497. #region 页面操作权限验证
  1498. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1499. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1500. #endregion
  1501. #endregion
  1502. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1503. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1504. #region 费用清单
  1505. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1506. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1507. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1508. List<Grp_CreditCardPayment> entityList = _groupRepository
  1509. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1510. .Where(exp.ToExpression())
  1511. .ToList();
  1512. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1513. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1514. /*
  1515. * 76://酒店预订
  1516. */
  1517. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1518. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1519. .ToListAsync();
  1520. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1521. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1522. .ToListAsync();
  1523. /*
  1524. * 79://车/导游地接
  1525. */
  1526. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1527. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1528. .ToListAsync();
  1529. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1530. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1531. .ToListAsync();
  1532. /*
  1533. * 80: //签证
  1534. */
  1535. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1536. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1537. .ToListAsync();
  1538. /*
  1539. *81: //邀请/公务活动
  1540. */
  1541. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1542. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1543. .ToListAsync();
  1544. /*
  1545. * 82: //团组客户保险
  1546. */
  1547. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1548. /*
  1549. * Lable = 85 机票预订
  1550. */
  1551. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1552. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1553. .ToListAsync();
  1554. /*
  1555. * 85 机票预定
  1556. */
  1557. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1558. /*
  1559. * 98 其他款项
  1560. */
  1561. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1562. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1563. .ToListAsync();
  1564. /*
  1565. * 285:收款退还
  1566. */
  1567. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1568. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1569. .ToListAsync();
  1570. /*
  1571. * 1015: //超支费用
  1572. */
  1573. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1574. /*
  1575. * 币种信息
  1576. */
  1577. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1578. /*
  1579. * 车/导游地接 费用类型
  1580. */
  1581. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1582. /*
  1583. * 车/导游地接 费用类型
  1584. */
  1585. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1586. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1587. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1588. /*
  1589. * 用户信息
  1590. */
  1591. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1592. /*
  1593. * 费用模块
  1594. */
  1595. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1596. string priceModule = string.Empty;
  1597. if (sdPriceName != null)
  1598. {
  1599. priceModule = sdPriceName.Name;
  1600. }
  1601. /*
  1602. * 成本信息
  1603. */
  1604. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1605. decimal _groupRate = 0.0000M;
  1606. string _groupCurrencyCode = "-";
  1607. if (groupCost != null)
  1608. {
  1609. _groupRate = groupCost.Rate;
  1610. if (int.TryParse(groupCost.Currency, out int _currency))
  1611. {
  1612. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1613. }
  1614. else _groupCurrencyCode = groupCost.Currency;
  1615. }
  1616. string costContentSql = $"Select * From Grp_GroupCost";
  1617. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1618. //处理日期为空的天数
  1619. for (int i = 0; i < groupCostDetails.Count; i++)
  1620. if (i != 0)
  1621. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1622. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1623. /*
  1624. * 处理详情数据
  1625. */
  1626. foreach (var entity in entityList)
  1627. {
  1628. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1629. _detail.Id = entity.Id;
  1630. _detail.PriceName = priceModule;
  1631. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1632. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1633. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1634. //处理金额
  1635. if (entity.CTable == 1015)
  1636. {
  1637. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1638. if (czInfo != null)
  1639. {
  1640. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1641. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1642. }
  1643. }
  1644. /*
  1645. * 应付款金额
  1646. */
  1647. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1648. string PaymentCurrency_WaitPay = "Unknown";
  1649. string hotelCurrncyCode = "Unknown";
  1650. string hotelCurrncyName = "Unknown";
  1651. if (sdPaymentCurrency_WaitPay != null)
  1652. {
  1653. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1654. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1655. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1656. if (hotelCurrncyCode.Equals("CNY"))
  1657. {
  1658. entity.DayRate = 1.0000M;
  1659. }
  1660. }
  1661. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1662. /*
  1663. * 此次付款金额
  1664. */
  1665. decimal CurrPayStr = 0.00M,
  1666. OriginalCurrPay = 0.00M;
  1667. if (entity.PayPercentage == 0)
  1668. {
  1669. if (entity.PayThenMoney != 0)
  1670. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1671. }
  1672. else
  1673. {
  1674. if (entity.PayMoney != 0)
  1675. {
  1676. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1677. }
  1678. }
  1679. if (_dto.Label == 79)
  1680. {
  1681. string original = string.Empty;
  1682. if (hotelCurrncyCode.Equals("CNY"))
  1683. {
  1684. OriginalCurrPay = CurrPayStr;
  1685. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1686. }
  1687. else
  1688. {
  1689. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1690. //760 EUR(7600.00 CNY)
  1691. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1692. }
  1693. }
  1694. else
  1695. {
  1696. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1697. }
  1698. /*
  1699. * 剩余尾款
  1700. */
  1701. decimal BalanceStr = 0;
  1702. if (CurrPayStr != 0)
  1703. {
  1704. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1705. BalanceStr = 0;
  1706. else
  1707. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1708. }
  1709. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1710. /*
  1711. * Bus名称
  1712. */
  1713. _detail.BusName = "待增加";
  1714. /*
  1715. *费用所属
  1716. */
  1717. switch (entity.CTable)
  1718. {
  1719. case 76://酒店预订
  1720. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1721. if (hotelReservations != null)
  1722. {
  1723. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1724. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1725. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1726. string roomFeeStr = "", roomFeestr1 = "";
  1727. //是否比较房型价格
  1728. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1729. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1730. roomFeeStr += $"<br/>";
  1731. if (hotelReservations.SingleRoomPrice > 0)
  1732. {
  1733. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1734. __isSingle = true;
  1735. }
  1736. if (hotelReservations.DoubleRoomPrice > 0)
  1737. {
  1738. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1739. __isDouble = true;
  1740. }
  1741. if (hotelReservations.SuiteRoomPrice > 0)
  1742. {
  1743. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1744. __isSuite = true;
  1745. }
  1746. if (hotelReservations.OtherRoomPrice > 0)
  1747. {
  1748. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1749. __isOther = true;
  1750. }
  1751. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1752. else roomFeeStr += " 0.00 * 0";
  1753. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1754. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1755. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1756. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1757. /*
  1758. * 费用类型
  1759. * 1:房费
  1760. * 2:早餐
  1761. * 3:地税
  1762. * 4:城市税
  1763. * </summary>
  1764. */
  1765. //地税
  1766. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1767. if (governmentRentData != null)
  1768. {
  1769. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1770. governmentRentFee = governmentRentData.Price;
  1771. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1772. if (governmentRentCurrData != null)
  1773. {
  1774. governmentRentCode = governmentRentCurrData.Name;
  1775. governmentRentName = $"({governmentRentCurrData.Remark})";
  1776. }
  1777. }
  1778. //城市税
  1779. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1780. if (cityTaxData != null)
  1781. {
  1782. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1783. cityTaxFee = cityTaxData.Price;
  1784. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1785. if (cityTaxCurrData != null)
  1786. {
  1787. cityTaxCode = cityTaxCurrData.Name;
  1788. cityTaxName = $"({cityTaxCurrData.Remark})";
  1789. }
  1790. }
  1791. //酒店早餐
  1792. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1793. if (breakfastData != null)
  1794. {
  1795. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1796. breakfastFee = breakfastData.Price;
  1797. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1798. if (breakfastCurrData != null)
  1799. {
  1800. breakfastCode = breakfastCurrData.Name;
  1801. breakfastName = $"({breakfastCurrData.Remark})";
  1802. }
  1803. }
  1804. //房间费用
  1805. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1806. if (roomData != null)
  1807. {
  1808. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1809. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1810. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1811. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1812. roomFee = roomData.Price;
  1813. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1814. if (roomCurrData != null)
  1815. {
  1816. roomCode = roomCurrData.Name;
  1817. roomName = $"({roomCurrData.Remark})";
  1818. }
  1819. }
  1820. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1821. string hotelCostStr = "";
  1822. decimal hotelCsotTotal = 0.00M;
  1823. if (groupCost != null)
  1824. {
  1825. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1826. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1827. }
  1828. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1829. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1830. string hotelCost_day = "";
  1831. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1832. foreach (var item in hotelCostDetails1)
  1833. {
  1834. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1835. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1836. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1837. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1838. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1839. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1840. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1841. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1842. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1843. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1844. hotelCost_day += @$"<br/>";
  1845. }
  1846. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1847. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1848. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1849. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1850. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1851. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1852. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1853. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1854. $"房间说明: {hotelReservations.Remark} <br/>" +
  1855. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1856. $"{hotelBreakfastStr}" +
  1857. $"{hotelGovernmentRentStr}" +
  1858. $"{hotelCityTaxStr}";
  1859. _detail.PriceNameContent = hotelReservations.HotelName;
  1860. }
  1861. break;
  1862. case 79://车/导游地接
  1863. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1864. if (touristGuideGroundReservations != null)
  1865. {
  1866. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1867. {
  1868. _detail.BusName = touristGuideGroundReservations.BusName;
  1869. }
  1870. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1871. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1872. //if (isInt)
  1873. //{
  1874. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1875. // if (cityInfo != null)
  1876. // {
  1877. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1878. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1879. // if (carFeeItem != null)
  1880. // {
  1881. // nameContent += $@"({carFeeItem.Name})";
  1882. // }
  1883. // _detail.PriceNameContent = nameContent;
  1884. // }
  1885. //}
  1886. //else
  1887. //{
  1888. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1889. //}
  1890. var touristGuideGroundReservationsContents =
  1891. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1892. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1893. foreach (var item in touristGuideGroundReservationsContents)
  1894. {
  1895. string typeName = "Unknown";
  1896. string carCurrencyCode = "Unknown";
  1897. string carCurrencyName = "Unknown";
  1898. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1899. if (carTypeData != null) typeName = carTypeData.Name;
  1900. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1901. if (currencyData != null)
  1902. {
  1903. carCurrencyCode = currencyData.Name;
  1904. carCurrencyName = currencyData.Remark;
  1905. }
  1906. //op、成本 币种是否一致
  1907. bool IsCurrencyAgreement = false;
  1908. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1909. string opCostStr = string.Empty;
  1910. decimal opCostTypePrice = 0.00M;
  1911. #region 处理成本各项费用
  1912. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1913. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1914. if (opCost.Count > 0)
  1915. {
  1916. switch (item.SId)
  1917. {
  1918. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1919. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1920. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1921. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1922. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1923. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1924. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1925. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1926. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1927. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1928. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1929. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1930. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1931. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1932. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1933. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1934. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1935. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1936. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1937. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1938. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1939. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1940. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1941. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1942. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1943. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1944. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1945. }
  1946. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1947. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1948. }
  1949. #endregion
  1950. string opTypeStr = $"{typeName}{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1951. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1952. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1953. $"{opTypeStr} {opCostStr}<br/>" +
  1954. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1955. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1956. }
  1957. _detail.PriceMsgContent = priceMsg;
  1958. }
  1959. break;
  1960. case 80: //签证
  1961. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1962. if (visaInfo != null)
  1963. {
  1964. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1965. _detail.PriceNameContent = visaInfo.VisaDescription;
  1966. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1967. }
  1968. break;
  1969. case 81: //邀请/公务活动
  1970. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1971. if (_ioa != null)
  1972. {
  1973. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1974. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1975. sendCurrName = "Unknown", //快递费用币种 Name
  1976. sendCurrCode = "Unknown", //快递费用币种 Code
  1977. eventsCurrName = "Unknown", //公务活动费币种 Name
  1978. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1979. translateCurrName = "Unknown", //公务翻译费 Name
  1980. translateCurrCode = "Unknown"; //公务翻译费 Code
  1981. #region 处理费用币种
  1982. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1983. if (inviteCurrData != null)
  1984. {
  1985. inviteCurrName = inviteCurrData.Remark;
  1986. inviteCurrCode = inviteCurrData.Name;
  1987. }
  1988. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1989. if (sendCurrData != null)
  1990. {
  1991. sendCurrName = sendCurrData.Remark;
  1992. sendCurrCode = sendCurrData.Name;
  1993. }
  1994. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1995. if (eventsCurrData != null)
  1996. {
  1997. eventsCurrName = eventsCurrData.Remark;
  1998. eventsCurrCode = eventsCurrData.Name;
  1999. }
  2000. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2001. if (translateCurrData != null)
  2002. {
  2003. translateCurrName = translateCurrData.Remark;
  2004. translateCurrCode = translateCurrData.Name;
  2005. }
  2006. #endregion
  2007. _detail.PriceNameContent = _ioa.InviterArea;
  2008. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2009. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2010. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2011. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2012. $@"备注:" + _ioa.Remark + "<br/>";
  2013. }
  2014. break;
  2015. case 82: //团组客户保险
  2016. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2017. if (customers != null)
  2018. {
  2019. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2020. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2021. }
  2022. break;
  2023. case 85: //机票预订
  2024. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2025. if (jpRes != null)
  2026. {
  2027. string FlightsDescription = jpRes.FlightsDescription;
  2028. string PriceDescription = jpRes.PriceDescription;
  2029. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2030. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2031. }
  2032. break;
  2033. case 98://其他款项
  2034. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2035. if (gdpRes != null)
  2036. {
  2037. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2038. _detail.PriceNameContent = gdpRes.PriceName;
  2039. }
  2040. break;
  2041. case 285://收款退还
  2042. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2043. if (refundAndOtherMoney != null)
  2044. {
  2045. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2046. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2047. }
  2048. break;
  2049. case 751://酒店早餐
  2050. break;
  2051. case 1015://超支费用
  2052. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2053. if (groupExtraCost != null)
  2054. {
  2055. _detail.PriceNameContent = groupExtraCost.PriceName;
  2056. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2057. }
  2058. break;
  2059. default:
  2060. break;
  2061. }
  2062. /*
  2063. * 申请人
  2064. */
  2065. string operatorName = " - ";
  2066. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2067. if (_opUser != null)
  2068. {
  2069. operatorName = _opUser.CnName;
  2070. }
  2071. _detail.OperatorName = operatorName;
  2072. /*
  2073. * 审核人
  2074. */
  2075. string auditOperatorName = "Unknown";
  2076. if (entity.AuditGMOperate == 0)
  2077. auditOperatorName = " - ";
  2078. else if (entity.AuditGMOperate == 4)
  2079. auditOperatorName = "自动审核";
  2080. else
  2081. {
  2082. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2083. if (_adUser != null)
  2084. {
  2085. auditOperatorName = _adUser.CnName;
  2086. }
  2087. }
  2088. _detail.AuditOperatorName = auditOperatorName;
  2089. /*
  2090. * 超预算比例
  2091. */
  2092. string overBudgetStr = "";
  2093. if (entity.ExceedBudget == -1)
  2094. 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
  2108. overBudgetStr = entity.ExceedBudget.ToString("P");
  2109. _detail.OverBudget = overBudgetStr;
  2110. /*
  2111. * 已审核金额
  2112. */
  2113. decimal auditFee = 0.00M;
  2114. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2115. /*
  2116. * 费用总计
  2117. */
  2118. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2119. {
  2120. CurrencyId = entity.PaymentCurrency,
  2121. CurrencyName = PaymentCurrency_WaitPay,
  2122. AmountPayable = entity.PayMoney,
  2123. ThisPayment = OriginalCurrPay,
  2124. BalancePayment = BalanceStr,
  2125. AuditedFunds = auditFee
  2126. });
  2127. _detail.IsAuditGM = entity.IsAuditGM;
  2128. detailList.Add(_detail);
  2129. }
  2130. #endregion
  2131. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2132. /*
  2133. * 下方描述处理
  2134. */
  2135. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2136. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2137. if (ccpCurrencyPrice != null)
  2138. {
  2139. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2140. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2141. }
  2142. else
  2143. {
  2144. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2145. }
  2146. string amountPayableStr = string.Format(@"应付款总金额: ");
  2147. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2148. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2149. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2150. foreach (var item in nonDuplicat)
  2151. {
  2152. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2153. if (strs.Count > 0)
  2154. {
  2155. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2156. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2157. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2158. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2159. //单独处理此次付款金额
  2160. if (item.CurrencyId == 836) //人民币
  2161. {
  2162. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2163. }
  2164. else
  2165. {
  2166. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2167. }
  2168. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2169. //单独处理已审核费用
  2170. if (item.CurrencyId == 836) //人民币
  2171. {
  2172. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2173. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2174. }
  2175. else
  2176. {
  2177. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2178. }
  2179. }
  2180. }
  2181. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2182. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2183. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2184. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2185. var _view1 = new
  2186. {
  2187. PageFuncAuth = pageFunAuthView,
  2188. Data = _view
  2189. };
  2190. return Ok(JsonView(_view1));
  2191. }
  2192. catch (Exception ex)
  2193. {
  2194. return Ok(JsonView(false, ex.Message));
  2195. }
  2196. }
  2197. /// <summary>
  2198. /// 费用审核
  2199. /// 修改团组费用审核状态
  2200. /// </summary>
  2201. /// <param name="_dto">参数Json字符串</param>
  2202. /// <returns></returns>
  2203. [HttpPost]
  2204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2205. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2206. {
  2207. #region 参数验证
  2208. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2209. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2210. #endregion
  2211. #region 页面操作权限验证
  2212. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2213. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2214. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2215. #endregion
  2216. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2217. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2218. DateTime dtNow = DateTime.Now;
  2219. _groupRepository.BeginTran();
  2220. int rst = 0;
  2221. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2222. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2223. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2224. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2225. List<dynamic> msgDatas = new List<dynamic>();
  2226. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2227. foreach (var item in idList)
  2228. {
  2229. int CreditId = int.Parse(item);
  2230. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2231. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2232. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2233. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2234. .Where(s => s.Id == CreditId)
  2235. .ExecuteCommandAsync();
  2236. if (result < 1)
  2237. {
  2238. rst = -1;
  2239. _groupRepository.RollbackTran();
  2240. return Ok(JsonView(false, "操作失败并回滚!"));
  2241. }
  2242. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2243. if (creditData != null)
  2244. {
  2245. #region 应用通知配置
  2246. try
  2247. {
  2248. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2249. }
  2250. catch (Exception ex)
  2251. {
  2252. }
  2253. #endregion
  2254. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2255. string groupNameStr = string.Empty;
  2256. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2257. if (groupData != null) groupNameStr = groupData.TeamName;
  2258. string creditTypeStr = string.Empty;
  2259. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2260. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2261. string creditCurrency = string.Empty;
  2262. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2263. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2264. if (creditCurrency.Equals("CNY"))
  2265. {
  2266. creditData.DayRate = 1.0000M;
  2267. }
  2268. if (creditData.PayPercentage == 0.00M)
  2269. {
  2270. creditData.PayPercentage = 100M;
  2271. }
  2272. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2273. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2274. string msgContent = "";
  2275. if (creditCurrency.Equals("CNY"))
  2276. {
  2277. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2278. }
  2279. else
  2280. {
  2281. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2282. }
  2283. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2284. }
  2285. }
  2286. if (rst == 0)
  2287. {
  2288. _groupRepository.CommitTran();
  2289. foreach (var item in msgDatas)
  2290. {
  2291. //发送消息
  2292. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2293. }
  2294. #region 应用推送
  2295. try
  2296. {
  2297. foreach (var ccpId in dic_ccp_user.Keys)
  2298. {
  2299. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2300. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2301. }
  2302. }
  2303. catch (Exception)
  2304. {
  2305. }
  2306. #endregion
  2307. return Ok(JsonView(true, "操作成功!"));
  2308. }
  2309. return Ok(JsonView(false, "操作失败!"));
  2310. }
  2311. #endregion
  2312. #region 机票费用录入
  2313. /// <summary>
  2314. /// 机票录入当前登录人可操作团组
  2315. /// </summary>
  2316. /// <param name="dto"></param>
  2317. /// <returns></returns>
  2318. [HttpPost]
  2319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2320. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2321. {
  2322. try
  2323. {
  2324. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2325. if (groupData.Code != 0)
  2326. {
  2327. return Ok(JsonView(false, groupData.Msg));
  2328. }
  2329. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2330. }
  2331. catch (Exception ex)
  2332. {
  2333. return Ok(JsonView(false, "程序错误!"));
  2334. throw;
  2335. }
  2336. }
  2337. /// <summary>
  2338. /// 机票费用录入列表
  2339. /// </summary>
  2340. /// <param name="dto"></param>
  2341. /// <returns></returns>
  2342. [HttpPost]
  2343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2344. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2345. {
  2346. try
  2347. {
  2348. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2349. if (groupData.Code != 0)
  2350. {
  2351. return Ok(JsonView(false, groupData.Msg));
  2352. }
  2353. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2354. }
  2355. catch (Exception ex)
  2356. {
  2357. return Ok(JsonView(false, ex.Message));
  2358. throw;
  2359. }
  2360. }
  2361. /// <summary>
  2362. /// 根据id查询费用录入信息
  2363. /// </summary>
  2364. /// <param name="dto"></param>
  2365. /// <returns></returns>
  2366. [HttpPost]
  2367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2368. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2369. {
  2370. Result groupData = await _airTicketResRep.AirTicketResById(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. /// <summary>
  2378. /// 机票费用录入操作(Status:1.新增,2.修改)
  2379. /// </summary>
  2380. /// <param name="dto"></param>
  2381. /// <returns></returns>
  2382. [HttpPost]
  2383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2384. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2385. {
  2386. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2387. if (groupData.Code != 0)
  2388. {
  2389. return Ok(JsonView(false, groupData.Msg));
  2390. }
  2391. #region 应用推送
  2392. try
  2393. {
  2394. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2395. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2396. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2397. //2024-10-21 新增LZ UID
  2398. var userIds = new List<int>() { 21 };
  2399. string title = $"系统通知";
  2400. string content = "";
  2401. var diId = dto.AirTicketResOpData.DiId;
  2402. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2403. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2404. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2405. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2406. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2407. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2408. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2409. }
  2410. catch (Exception ex)
  2411. {
  2412. }
  2413. #endregion
  2414. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2415. }
  2416. /// <summary>
  2417. /// 根据舱位类型查询接团客户名单信息
  2418. /// </summary>
  2419. /// <param name="dto"></param>
  2420. /// <returns></returns>
  2421. [HttpPost]
  2422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2423. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2424. {
  2425. try
  2426. {
  2427. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2428. if (crm_Groups.Count != 0)
  2429. {
  2430. List<dynamic> Customer = new List<dynamic>();
  2431. foreach (var item in crm_Groups)
  2432. {
  2433. var data = new
  2434. {
  2435. Id = item.Id,
  2436. Pinyin = item.Pinyin,
  2437. Name = item.LastName + item.FirstName
  2438. };
  2439. Customer.Add(data);
  2440. }
  2441. return Ok(JsonView(true, "查询成功!", Customer));
  2442. }
  2443. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2444. }
  2445. catch (Exception ex)
  2446. {
  2447. return Ok(JsonView(false, "程序错误!"));
  2448. throw;
  2449. }
  2450. }
  2451. /// <summary>
  2452. /// 根据团号获取客户信息
  2453. /// </summary>
  2454. /// <param name="dto"></param>
  2455. /// <returns></returns>
  2456. [HttpPost]
  2457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2458. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2459. {
  2460. var jw = JsonView(false);
  2461. if (dto.DIID < 1)
  2462. {
  2463. jw.Msg += "请输入正确的diid";
  2464. return Ok(jw);
  2465. }
  2466. var arr = getSimplClientList(dto.DIID);
  2467. jw = JsonView(true, "获取成功!", arr);
  2468. return Ok(jw);
  2469. }
  2470. private List<SimplClientInfo> getSimplClientList(int diId)
  2471. {
  2472. 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);
  2473. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2474. return arr;
  2475. }
  2476. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2477. {
  2478. string result = origin;
  2479. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2480. {
  2481. string[] temparr = origin.Split(',');
  2482. string fistrStr = temparr[0];
  2483. int count = temparr.Count();
  2484. int tempId;
  2485. bool success = int.TryParse(fistrStr, out tempId);
  2486. if (success)
  2487. {
  2488. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2489. if (tempInfo != null)
  2490. {
  2491. if (count > 1)
  2492. {
  2493. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2494. }
  2495. else
  2496. {
  2497. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2498. }
  2499. }
  2500. }
  2501. }
  2502. return result;
  2503. }
  2504. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2505. {
  2506. string result = origin;
  2507. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2508. {
  2509. string[] temparr = origin.Split(',');
  2510. result = "";
  2511. foreach (var item in temparr)
  2512. {
  2513. int tempId;
  2514. bool success = int.TryParse(item, out tempId);
  2515. if (success)
  2516. {
  2517. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2518. if (tempInfo != null)
  2519. {
  2520. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2521. }
  2522. }
  2523. }
  2524. }
  2525. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2526. return result;
  2527. }
  2528. /// <summary>
  2529. /// 机票费用录入,删除
  2530. /// </summary>
  2531. /// <param name="dto"></param>
  2532. /// <returns></returns>
  2533. [HttpPost]
  2534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2535. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2536. {
  2537. try
  2538. {
  2539. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2540. if (res)
  2541. {
  2542. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2543. {
  2544. IsDel = 1,
  2545. DeleteUserId = dto.DeleteUserId,
  2546. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2547. }).ExecuteCommandAsync();
  2548. return Ok(JsonView(true, "删除成功!"));
  2549. }
  2550. return Ok(JsonView(false, "删除失败!"));
  2551. }
  2552. catch (Exception ex)
  2553. {
  2554. return Ok(JsonView(false, "程序错误!"));
  2555. throw;
  2556. }
  2557. }
  2558. /// <summary>
  2559. /// 导出机票录入报表
  2560. /// </summary>
  2561. /// <param name="dto"></param>
  2562. /// <returns></returns>
  2563. [HttpPost]
  2564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2565. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2566. {
  2567. try
  2568. {
  2569. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2570. if (groupData.Code != 0)
  2571. {
  2572. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2573. }
  2574. else
  2575. {
  2576. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2577. if (AirTicketReservations.Count != 0)
  2578. {
  2579. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2580. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2581. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2582. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2583. WorkbookDesigner designer = new WorkbookDesigner();
  2584. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2585. decimal countCost = 0;
  2586. foreach (var item in AirTicketReservations)
  2587. {
  2588. #region 处理客人姓名
  2589. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2590. item.ClientName = clientNames;
  2591. #endregion
  2592. if (item.BankType == "其他")
  2593. {
  2594. item.BankNo = "--";
  2595. }
  2596. else
  2597. {
  2598. if (!string.IsNullOrEmpty(item.BankType))
  2599. {
  2600. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2601. }
  2602. }
  2603. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2604. item.Price = System.Decimal.Round(item.Price, 2);
  2605. countCost += Convert.ToDecimal(item.Price);
  2606. }
  2607. designer.SetDataSource("Export", AirTicketReservations);
  2608. designer.SetDataSource("ExportDiCode", diCode);
  2609. designer.SetDataSource("ExportDiName", diName);
  2610. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2611. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2612. designer.Process();
  2613. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2614. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2615. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2616. return Ok(JsonView(true, "成功", url = rst));
  2617. }
  2618. else
  2619. {
  2620. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2621. }
  2622. }
  2623. }
  2624. catch (Exception ex)
  2625. {
  2626. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2627. throw;
  2628. }
  2629. }
  2630. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2631. /// <summary>
  2632. /// 行程单导出
  2633. /// </summary>
  2634. /// <param name="dto"></param>
  2635. /// <returns></returns>
  2636. [HttpPost]
  2637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2638. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2639. {
  2640. try
  2641. {
  2642. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2643. if (groupData.Code != 0)
  2644. {
  2645. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2646. }
  2647. else
  2648. {
  2649. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2650. if (dto.Language == "CN")
  2651. {
  2652. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2653. DocumentBuilder builder = new DocumentBuilder(doc);
  2654. int tableIndex = 0;//表格索引
  2655. //得到文档中的第一个表格
  2656. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2657. foreach (var item in _AirTicketReservations)
  2658. {
  2659. #region 处理固定数据
  2660. string[] FlightsCode = item.FlightsCode.Split('/');
  2661. if (FlightsCode.Length != 0)
  2662. {
  2663. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2664. if (_AirCompany != null)
  2665. {
  2666. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2667. }
  2668. else
  2669. {
  2670. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2671. }
  2672. }
  2673. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2674. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2675. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2676. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2677. string name = "";
  2678. foreach (string clientName in nameArray)
  2679. {
  2680. if (!name.Contains(clientName))
  2681. {
  2682. name += clientName + ",";
  2683. }
  2684. }
  2685. if (!string.IsNullOrWhiteSpace(name))
  2686. {
  2687. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2688. }
  2689. else
  2690. {
  2691. table.Range.Bookmarks["ClientName"].Text = "--";
  2692. }
  2693. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2694. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2695. table.Range.Bookmarks["JointTicket"].Text = "--";
  2696. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2697. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2698. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2699. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2700. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2701. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2702. #endregion
  2703. #region 循环数据处理
  2704. List<AirInfo> airs = new List<AirInfo>();
  2705. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2706. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2707. for (int i = 0; i < FlightsCode.Length; i++)
  2708. {
  2709. AirInfo air = new AirInfo();
  2710. string[] tempstr = DayArray[i]
  2711. .Replace("\r\n", string.Empty)
  2712. .Replace("\\r\\n", string.Empty)
  2713. .TrimStart().TrimEnd()
  2714. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2715. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2716. string starCity = "";
  2717. if (star_Three != null)
  2718. {
  2719. starCity = star_Three.AirPort;
  2720. }
  2721. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2722. string EndCity = "";
  2723. if (End_Three != null)
  2724. {
  2725. EndCity = End_Three.AirPort;
  2726. }
  2727. air.Destination = starCity + "/" + EndCity;
  2728. air.Flight = FlightsCode[i];
  2729. air.SeatingClass = item.CTypeName;
  2730. string dateTime = tempstr[2];
  2731. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2732. air.FlightDate = DateTemp;
  2733. air.DepartureTime = tempstr[5];
  2734. air.LandingTime = tempstr[6];
  2735. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2736. air.TicketStatus = "--";
  2737. air.Luggage = "--";
  2738. air.DepartureTerminal = "--";
  2739. air.LandingTerminal = "--";
  2740. airs.Add(air);
  2741. }
  2742. int row = 13;
  2743. for (int i = 0; i < airs.Count; i++)
  2744. {
  2745. if (airs.Count > 2)
  2746. {
  2747. for (int j = 0; j < airs.Count - 2; j++)
  2748. {
  2749. var CopyRow = table.Rows[12].Clone(true);
  2750. table.Rows.Add(CopyRow);
  2751. }
  2752. }
  2753. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2754. int index = 0;
  2755. foreach (PropertyInfo property in properties)
  2756. {
  2757. string value = property.GetValue(airs[i]).ToString();
  2758. Cell ishcel0 = table.Rows[row].Cells[index];
  2759. Paragraph p = new Paragraph(doc);
  2760. string s = value;
  2761. p.AppendChild(new Run(doc, s));
  2762. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2763. ishcel0.AppendChild(p);
  2764. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2765. index++;
  2766. }
  2767. row++;
  2768. }
  2769. #endregion
  2770. Paragraph lastParagraph = new Paragraph(doc);
  2771. //第一个表格末尾加段落
  2772. table.ParentNode.InsertAfter(lastParagraph, table);
  2773. //复制第一个表格
  2774. Table cloneTable = (Table)table.Clone(true);
  2775. //在文档末尾段落后面加入复制的表格
  2776. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2777. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2778. {
  2779. int rownewsIndex = 13;
  2780. for (int i = 0; i < 2; i++)
  2781. {
  2782. var CopyRow = table.Rows[12].Clone(true);
  2783. table.Rows.RemoveAt(13);
  2784. table.Rows.Add(CopyRow);
  2785. rownewsIndex++;
  2786. }
  2787. }
  2788. else
  2789. {
  2790. table.Rows.RemoveAt(12);
  2791. }
  2792. cloneTable.Rows.RemoveAt(12);
  2793. }
  2794. if (_AirTicketReservations.Count != 0)
  2795. {
  2796. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2797. if (FlightsCode.Length != 0)
  2798. {
  2799. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2800. if (_AirCompany != null)
  2801. {
  2802. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2803. }
  2804. else
  2805. {
  2806. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2807. }
  2808. }
  2809. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2810. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2811. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2812. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2813. string name = "";
  2814. foreach (string clientName in nameArray)
  2815. {
  2816. if (!name.Contains(clientName))
  2817. {
  2818. name += clientName + ",";
  2819. }
  2820. }
  2821. if (!string.IsNullOrWhiteSpace(name))
  2822. {
  2823. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2824. }
  2825. else
  2826. {
  2827. table.Range.Bookmarks["ClientName"].Text = "--";
  2828. }
  2829. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2830. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2831. table.Range.Bookmarks["JointTicket"].Text = "--";
  2832. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2833. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2834. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2835. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2836. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2837. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2838. }
  2839. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2840. //保存合并后的文档
  2841. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2842. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2843. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2844. return Ok(JsonView(true, "成功!", rst));
  2845. }
  2846. else
  2847. {
  2848. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2849. DocumentBuilder builder = new DocumentBuilder(doc);
  2850. int tableIndex = 0;//表格索引
  2851. //得到文档中的第一个表格
  2852. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2853. List<string> texts = new List<string>();
  2854. foreach (var item in _AirTicketReservations)
  2855. {
  2856. string[] FlightsCode = item.FlightsCode.Split('/');
  2857. if (FlightsCode.Length != 0)
  2858. {
  2859. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2860. if (_AirCompany != null)
  2861. {
  2862. if (!transDic.ContainsKey(_AirCompany.CnName))
  2863. {
  2864. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2865. }
  2866. }
  2867. else
  2868. {
  2869. if (!transDic.ContainsKey("--"))
  2870. {
  2871. transDic.Add("--", "--");
  2872. }
  2873. }
  2874. }
  2875. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2876. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2877. string name = "";
  2878. foreach (string clientName in nameArray)
  2879. {
  2880. name += clientName + ",";
  2881. }
  2882. if (!texts.Contains(name))
  2883. {
  2884. texts.Add(name);
  2885. }
  2886. List<AirInfo> airs = new List<AirInfo>();
  2887. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2888. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2889. for (int i = 0; i < FlightsCode.Length; i++)
  2890. {
  2891. AirInfo air = new AirInfo();
  2892. string[] tempstr = DayArray[i]
  2893. .Replace("\r\n", string.Empty)
  2894. .Replace("\\r\\n", string.Empty)
  2895. .TrimStart().TrimEnd()
  2896. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2897. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2898. if (star_Three != null)
  2899. {
  2900. if (!transDic.ContainsKey(star_Three.AirPort))
  2901. {
  2902. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2903. }
  2904. }
  2905. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2906. if (End_Three != null)
  2907. {
  2908. if (!transDic.ContainsKey(End_Three.AirPort))
  2909. {
  2910. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2911. }
  2912. }
  2913. if (!texts.Contains(item.CTypeName))
  2914. {
  2915. texts.Add(item.CTypeName);
  2916. }
  2917. }
  2918. }
  2919. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2920. if (transData.Count > 0)
  2921. {
  2922. foreach (TranslateResult item in transData)
  2923. {
  2924. if (!transDic.ContainsKey(item.Query))
  2925. {
  2926. transDic.Add(item.Query, item.Translation);
  2927. }
  2928. }
  2929. }
  2930. foreach (var item in _AirTicketReservations)
  2931. {
  2932. #region 处理固定数据
  2933. string[] FlightsCode = item.FlightsCode.Split('/');
  2934. if (FlightsCode.Length != 0)
  2935. {
  2936. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2937. if (_AirCompany != null)
  2938. {
  2939. string str = "--";
  2940. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2941. if (!string.IsNullOrEmpty(translateResult))
  2942. {
  2943. str = translateResult;
  2944. str = _airTicketResRep.Processing(str);
  2945. }
  2946. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2947. }
  2948. else
  2949. {
  2950. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2951. }
  2952. }
  2953. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2954. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2955. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2956. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2957. string names = "";
  2958. foreach (string clientName in nameArray)
  2959. {
  2960. names += clientName + ",";
  2961. }
  2962. if (!string.IsNullOrWhiteSpace(names))
  2963. {
  2964. string str = "--";
  2965. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2966. if (!string.IsNullOrEmpty(translateResult))
  2967. {
  2968. str = translateResult;
  2969. str = _airTicketResRep.Processing(str);
  2970. }
  2971. table.Range.Bookmarks["ClientName"].Text = str;
  2972. }
  2973. else
  2974. {
  2975. table.Range.Bookmarks["ClientName"].Text = "--";
  2976. }
  2977. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2978. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2979. table.Range.Bookmarks["JointTicket"].Text = "--";
  2980. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2981. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2982. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2983. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2984. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2985. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2986. #endregion
  2987. #region 循环数据处理
  2988. List<AirInfo> airs = new List<AirInfo>();
  2989. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2990. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2991. for (int i = 0; i < FlightsCode.Length; i++)
  2992. {
  2993. AirInfo air = new AirInfo();
  2994. string[] tempstr = DayArray[i]
  2995. .Replace("\r\n", string.Empty)
  2996. .Replace("\\r\\n", string.Empty)
  2997. .TrimStart().TrimEnd()
  2998. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2999. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3000. string starCity = "";
  3001. if (star_Three != null)
  3002. {
  3003. string str2 = "--";
  3004. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3005. if (!string.IsNullOrEmpty(translateResult2))
  3006. {
  3007. str2 = translateResult2;
  3008. str2 = _airTicketResRep.Processing(str2);
  3009. }
  3010. starCity = str2;
  3011. }
  3012. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3013. string EndCity = "";
  3014. if (End_Three != null)
  3015. {
  3016. string str1 = "--";
  3017. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3018. if (!string.IsNullOrEmpty(translateResult1))
  3019. {
  3020. str1 = translateResult1;
  3021. str1 = _airTicketResRep.Processing(str1);
  3022. }
  3023. EndCity = str1;
  3024. }
  3025. air.Destination = starCity + "/" + EndCity;
  3026. air.Flight = FlightsCode[i];
  3027. string str = "--";
  3028. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3029. if (!string.IsNullOrEmpty(translateResult))
  3030. {
  3031. str = translateResult;
  3032. str = _airTicketResRep.Processing(str);
  3033. }
  3034. air.SeatingClass = str;
  3035. string dateTime = tempstr[2];
  3036. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3037. air.FlightDate = DateTemp;
  3038. air.DepartureTime = tempstr[5];
  3039. air.LandingTime = tempstr[6];
  3040. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3041. air.TicketStatus = "--";
  3042. air.Luggage = "--";
  3043. air.DepartureTerminal = "--";
  3044. air.LandingTerminal = "--";
  3045. airs.Add(air);
  3046. }
  3047. int row = 13;
  3048. for (int i = 0; i < airs.Count; i++)
  3049. {
  3050. if (airs.Count > 2)
  3051. {
  3052. for (int j = 0; j < airs.Count - 2; j++)
  3053. {
  3054. var CopyRow = table.Rows[12].Clone(true);
  3055. table.Rows.Add(CopyRow);
  3056. }
  3057. }
  3058. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3059. int index = 0;
  3060. foreach (PropertyInfo property in properties)
  3061. {
  3062. string value = property.GetValue(airs[i]).ToString();
  3063. Cell ishcel0 = table.Rows[row].Cells[index];
  3064. Paragraph p = new Paragraph(doc);
  3065. string s = value;
  3066. p.AppendChild(new Run(doc, s));
  3067. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3068. ishcel0.AppendChild(p);
  3069. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3070. //ishcel0.CellFormat.VerticalAlignment=
  3071. index++;
  3072. }
  3073. row++;
  3074. }
  3075. #endregion
  3076. Paragraph lastParagraph = new Paragraph(doc);
  3077. //第一个表格末尾加段落
  3078. table.ParentNode.InsertAfter(lastParagraph, table);
  3079. //复制第一个表格
  3080. Table cloneTable = (Table)table.Clone(true);
  3081. //在文档末尾段落后面加入复制的表格
  3082. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3083. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3084. {
  3085. int rownewsIndex = 13;
  3086. for (int i = 0; i < 2; i++)
  3087. {
  3088. var CopyRow = table.Rows[12].Clone(true);
  3089. table.Rows.RemoveAt(13);
  3090. table.Rows.Add(CopyRow);
  3091. rownewsIndex++;
  3092. }
  3093. }
  3094. else
  3095. {
  3096. table.Rows.RemoveAt(12);
  3097. }
  3098. cloneTable.Rows.RemoveAt(12);
  3099. }
  3100. if (_AirTicketReservations.Count != 0)
  3101. {
  3102. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3103. if (FlightsCode.Length != 0)
  3104. {
  3105. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3106. if (_AirCompany != null)
  3107. {
  3108. string str = "--";
  3109. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3110. if (!string.IsNullOrEmpty(translateResult))
  3111. {
  3112. str = translateResult;
  3113. str = _airTicketResRep.Processing(str);
  3114. }
  3115. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3116. }
  3117. else
  3118. {
  3119. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3120. }
  3121. }
  3122. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3123. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3124. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3125. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3126. string names = "";
  3127. foreach (string clientName in nameArray)
  3128. {
  3129. names += clientName + ",";
  3130. }
  3131. if (!string.IsNullOrWhiteSpace(names))
  3132. {
  3133. string str = "--";
  3134. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3135. if (!string.IsNullOrEmpty(translateResult))
  3136. {
  3137. str = translateResult;
  3138. str = _airTicketResRep.Processing(str);
  3139. }
  3140. table.Range.Bookmarks["ClientName"].Text = str;
  3141. }
  3142. else
  3143. {
  3144. table.Range.Bookmarks["ClientName"].Text = "--";
  3145. }
  3146. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3147. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3148. table.Range.Bookmarks["JointTicket"].Text = "--";
  3149. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3150. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3151. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3152. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3153. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3154. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3155. }
  3156. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3157. //保存合并后的文档
  3158. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3159. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3160. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3161. return Ok(JsonView(true, "成功!", rst));
  3162. }
  3163. }
  3164. }
  3165. catch (Exception ex)
  3166. {
  3167. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3168. throw;
  3169. }
  3170. }
  3171. #endregion
  3172. #region 团组增减款项 --> 其他款项
  3173. /// <summary>
  3174. /// 团组增减款项下拉框绑定
  3175. /// </summary>
  3176. /// <param name="dto"></param>
  3177. /// <returns></returns>
  3178. [HttpPost]
  3179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3180. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3181. {
  3182. #region 参数验证
  3183. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3184. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3185. #endregion
  3186. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3187. }
  3188. /// <summary>
  3189. /// 根据团组Id查询团组增减款项
  3190. /// </summary>
  3191. /// <param name="dto"></param>
  3192. /// <returns></returns>
  3193. [HttpPost]
  3194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3195. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3196. {
  3197. #region 参数验证
  3198. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3199. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3200. #endregion
  3201. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3202. }
  3203. /// <summary>
  3204. /// 团组增减款项操作(Status:1.新增,2.修改)
  3205. /// </summary>
  3206. /// <param name="dto"></param>
  3207. /// <returns></returns>
  3208. [HttpPost]
  3209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3210. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3211. {
  3212. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3213. if (groupData.Code != 200)
  3214. {
  3215. return Ok(JsonView(false, groupData.Msg));
  3216. }
  3217. #region 应用推送
  3218. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3219. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3220. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3221. //自动审核
  3222. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3223. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3224. //2024-10-21 新增LZ UID
  3225. var userIds = new List<int>() { 21 };
  3226. string title = $"系统通知";
  3227. string content = "";
  3228. var diId = dto.DiId;
  3229. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3230. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3231. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3232. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3233. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3234. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3235. #endregion
  3236. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3237. }
  3238. /// <summary>
  3239. /// 团组增减款项操作 删除
  3240. /// </summary>
  3241. /// <param name="dto"></param>
  3242. /// <returns></returns>
  3243. [HttpPost]
  3244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3245. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3246. {
  3247. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3248. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3249. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3250. if (res.Code == 0)
  3251. {
  3252. return Ok(JsonView(true, "删除成功!"));
  3253. }
  3254. return Ok(JsonView(false, "删除失败!"));
  3255. }
  3256. /// <summary>
  3257. /// 根据团组增减款项Id查询
  3258. /// </summary>
  3259. /// <param name="dto"></param>
  3260. /// <returns></returns>
  3261. [HttpPost]
  3262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3263. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3264. {
  3265. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3266. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3267. }
  3268. /// <summary>
  3269. /// 查询供应商名称
  3270. /// </summary>
  3271. /// <param name="dto"></param>
  3272. /// <returns></returns>
  3273. [HttpPost]
  3274. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3275. {
  3276. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3277. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3278. ?? new List<Grp_DecreasePayments>();
  3279. dbResult = dbResult.Distinct(new
  3280. ProductComparer()).ToList();
  3281. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3282. {
  3283. x.Id,
  3284. x.SupplierAddress,
  3285. x.SupplierArea,
  3286. x.SupplierContact,
  3287. x.SupplierContactNumber,
  3288. x.SupplierEmail,
  3289. x.SupplierName,
  3290. x.SupplierSocialAccount,
  3291. x.SupplierTypeId,
  3292. }).ToList());
  3293. return Ok(jw);
  3294. }
  3295. /// <summary>
  3296. /// 团组增减款项 OTA匹配
  3297. /// </summary>
  3298. /// <param name="file"></param>
  3299. /// <returns></returns>
  3300. [HttpPost]
  3301. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3302. {
  3303. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3304. string fileName = file.FileName;
  3305. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3306. {
  3307. return Ok(JsonView(false, "请上传Excel文件!"));
  3308. }
  3309. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3310. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3311. if (!Directory.Exists(path))
  3312. {
  3313. Directory.CreateDirectory(path);
  3314. }
  3315. var filePath = @$"{path}/{fileName}";
  3316. //保存文件
  3317. using (FileStream fs = System.IO.File.Create(filePath))
  3318. {
  3319. file.CopyTo(fs);
  3320. fs.Flush();
  3321. }
  3322. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3323. //读取ExcelFile
  3324. DataTable dt = ConvertExcelToDataTable(filePath);
  3325. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3326. dt.TableName = "TB";
  3327. //修改table列名
  3328. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3329. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3330. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3331. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3332. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3333. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3334. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3335. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3336. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3337. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3338. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3339. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3340. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3341. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3342. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3343. var otaOrderNos = new List<string>();
  3344. foreach (DataRow item in dt.Rows)
  3345. {
  3346. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3347. }
  3348. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3349. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3350. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3351. .Select((dp, di) => new
  3352. {
  3353. dp.PriceName,
  3354. dp.OTAOrderNo,
  3355. dp.FeeTotal,
  3356. di.TeamName,
  3357. })
  3358. .ToListAsync();
  3359. foreach (DataRow item in dt.Rows)
  3360. {
  3361. var otaOrderNo = item["OTAOrderNo"].ToString();
  3362. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3363. if (oaData == null) continue;
  3364. item["GroupName"] = oaData.TeamName;
  3365. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3366. }
  3367. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3368. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3369. List<DataTable> datas = new List<DataTable>();
  3370. datas.Add(dt);
  3371. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3372. return Ok(JsonView(true, "操作成功", new { url = url }));
  3373. }
  3374. #region
  3375. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3376. {
  3377. // 创建Workbook对象
  3378. Workbook workbook = new Workbook(excelFilePath);
  3379. // 获取第一个工作表
  3380. Worksheet worksheet = workbook.Worksheets[0];
  3381. // 将工作表转换为DataTable
  3382. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3383. return dataTable;
  3384. }
  3385. #endregion
  3386. #endregion
  3387. #region 文件上传、删除
  3388. /// <summary>
  3389. /// region 文件上传 可以带参数
  3390. /// </summary>
  3391. /// <param name="file"></param>
  3392. /// <returns></returns>
  3393. [HttpPost]
  3394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3395. public async Task<IActionResult> UploadProject(IFormFile file)
  3396. {
  3397. //var TypeName = Request.Headers["TypeName"].ToString();
  3398. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3399. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3400. ////文件名称
  3401. //string projectFileName = file.FileName;
  3402. ////上传的文件的路径
  3403. //string filePath = $"{fileDir}/{projectFileName}";
  3404. //if (TypeName == "A")//A代表团组增减款项
  3405. //{
  3406. // filePath = fileDir + $@"\团组增减款项相关文件";
  3407. // if (!Directory.Exists(filePath))
  3408. // {
  3409. // Directory.CreateDirectory(filePath);
  3410. // }
  3411. // //上传的文件的路径
  3412. // filePath += $@"\{projectFileName}";
  3413. //}
  3414. //else if (TypeName == "B")//B代表商邀相关文件
  3415. //{
  3416. // //上传的文件的路径
  3417. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3418. // if (!Directory.Exists(filePath))
  3419. // {
  3420. // Directory.CreateDirectory(filePath);
  3421. // }
  3422. // //上传的文件的路径
  3423. // filePath = $@"\{projectFileName}";
  3424. //}
  3425. //try
  3426. //{
  3427. // using (FileStream fs = System.IO.File.Create(filePath))
  3428. // {
  3429. // file.CopyTo(fs);
  3430. // fs.Flush();
  3431. // }
  3432. //}
  3433. //catch (Exception ex)
  3434. //{
  3435. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3436. //}
  3437. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3438. try
  3439. {
  3440. var TypeName = Request.Headers["TypeName"].ToString();
  3441. if (file != null)
  3442. {
  3443. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3444. //文件名称
  3445. string projectFileName = file.FileName;
  3446. //上传的文件的路径
  3447. string filePath = $"{fileDir}/{projectFileName}";
  3448. if (TypeName == "A")//A代表团组增减款项
  3449. {
  3450. if (!Directory.Exists(fileDir))
  3451. {
  3452. Directory.CreateDirectory(fileDir);
  3453. }
  3454. //上传的文件的路径
  3455. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3456. }
  3457. else if (TypeName == "B")//B代表商邀相关文件
  3458. {
  3459. if (!Directory.Exists(fileDir))
  3460. {
  3461. Directory.CreateDirectory(fileDir);
  3462. }
  3463. //上传的文件的路径
  3464. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3465. }
  3466. using (FileStream fs = System.IO.File.Create(filePath))
  3467. {
  3468. file.CopyTo(fs);
  3469. fs.Flush();
  3470. }
  3471. return Ok(JsonView(true, "上传成功!", projectFileName));
  3472. }
  3473. else
  3474. {
  3475. return Ok(JsonView(false, "上传失败!"));
  3476. }
  3477. }
  3478. catch (Exception ex)
  3479. {
  3480. return Ok(JsonView(false, "程序错误!"));
  3481. }
  3482. }
  3483. /// <summary>
  3484. /// 删除指定文件
  3485. /// </summary>
  3486. /// <param name="dto"></param>
  3487. /// <returns></returns>
  3488. [HttpPost]
  3489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3490. public async Task<IActionResult> DelFile(DelFileDto dto)
  3491. {
  3492. try
  3493. {
  3494. var TypeName = Request.Headers["TypeName"].ToString();
  3495. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3496. string filePath = "";
  3497. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3498. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3499. int id = 0;
  3500. if (TypeName == "A")
  3501. {
  3502. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3503. // 删除该文件
  3504. System.IO.File.Delete(filePath);
  3505. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3506. .Where(a => a.Id == dto.Id)
  3507. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3508. .ExecuteCommandAsync();
  3509. }
  3510. else if (TypeName == "B")
  3511. {
  3512. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3513. // 删除该文件
  3514. System.IO.File.Delete(filePath);
  3515. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3516. if (info != null)
  3517. {
  3518. string[] files = new string[] { };
  3519. if (!string.IsNullOrEmpty(info.Attachment))
  3520. {
  3521. try
  3522. {
  3523. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3524. }
  3525. catch (Exception)
  3526. {
  3527. files = new List<string>() { info.Attachment }.ToArray();
  3528. }
  3529. }
  3530. if (files.Length > 0)
  3531. {
  3532. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3533. string filePath2 = string.Empty;
  3534. if (files1.Length > 0)
  3535. {
  3536. filePath2 = JsonConvert.SerializeObject(files1);
  3537. }
  3538. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3539. .Where(a => a.Id == dto.Id)
  3540. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3541. .ExecuteCommandAsync();
  3542. }
  3543. }
  3544. }
  3545. if (id != 0)
  3546. {
  3547. return Ok(JsonView(true, "成功!"));
  3548. }
  3549. else
  3550. {
  3551. return Ok(JsonView(false, "失败!"));
  3552. }
  3553. }
  3554. catch (Exception ex)
  3555. {
  3556. return Ok(JsonView(false, "程序错误!"));
  3557. throw;
  3558. }
  3559. }
  3560. /// <summary>
  3561. /// 文件上传多个文件 可以带参数
  3562. /// </summary>
  3563. /// <param name="file"></param>
  3564. /// <returns></returns>
  3565. [HttpPost]
  3566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3567. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3568. {
  3569. try
  3570. {
  3571. var TypeName = Request.Headers["TypeName"].ToString();
  3572. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3573. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3574. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3575. var filePahts = new List<string>();
  3576. foreach (var file in files)
  3577. {
  3578. //文件名称
  3579. string projectFileName = file.FileName;
  3580. //上传的文件的路径
  3581. string filePath = $"{fileDir}/{projectFileName}";
  3582. if (TypeName == "A")//A代表团组增减款项
  3583. {
  3584. if (!Directory.Exists(fileDir))
  3585. {
  3586. Directory.CreateDirectory(fileDir);
  3587. }
  3588. //上传的文件的路径
  3589. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3590. }
  3591. else if (TypeName == "B")//B代表商邀相关文件
  3592. {
  3593. if (!Directory.Exists(fileDir))
  3594. {
  3595. Directory.CreateDirectory(fileDir);
  3596. }
  3597. //上传的文件的路径
  3598. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3599. }
  3600. using (FileStream fs = System.IO.File.Create(filePath))
  3601. {
  3602. file.CopyTo(fs);
  3603. fs.Flush();
  3604. }
  3605. filePahts.Add(projectFileName);
  3606. }
  3607. return Ok(JsonView(true, "上传成功!", filePahts));
  3608. }
  3609. catch (Exception ex)
  3610. {
  3611. return Ok(JsonView(false, "程序错误!"));
  3612. }
  3613. }
  3614. #endregion
  3615. #region 商邀费用录入
  3616. /// <summary>
  3617. /// 根据团组Id查询商邀费用列表
  3618. /// </summary>
  3619. /// <param name="dto"></param>
  3620. /// <returns></returns>
  3621. [HttpPost]
  3622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3623. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3624. {
  3625. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3626. if (groupData.Code != 0)
  3627. {
  3628. return Ok(JsonView(false, groupData.Msg));
  3629. }
  3630. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3631. }
  3632. /// <summary>
  3633. /// 商邀费用列表
  3634. /// 下载文件
  3635. /// </summary>
  3636. /// <param name="dto"></param>
  3637. /// <returns></returns>
  3638. [HttpGet("{id}")]
  3639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3640. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3641. {
  3642. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3643. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3644. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3645. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3646. var filePaths = new List<string>();
  3647. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3648. try
  3649. {
  3650. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3651. }
  3652. catch (Exception ex)
  3653. {
  3654. filePaths.Add(info.Attachment);
  3655. }
  3656. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3657. for (int i = 0; i < filePaths.Count; i++)
  3658. {
  3659. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3660. }
  3661. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3662. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3663. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3664. {
  3665. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3666. {
  3667. foreach (string filePath in filePaths)
  3668. {
  3669. if (System.IO.File.Exists(filePath))
  3670. {
  3671. // 获取文件名
  3672. string fileName = Path.GetFileName(filePath);
  3673. // 将文件添加到ZIP归档中
  3674. zipArchive.CreateEntryFromFile(filePath, fileName);
  3675. }
  3676. }
  3677. }
  3678. }
  3679. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3680. }
  3681. /// <summary>
  3682. /// 商邀费用 Info Page 基础数据源
  3683. /// </summary>
  3684. /// <param name="dto"></param>
  3685. /// <returns></returns>
  3686. [HttpPost]
  3687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3688. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3689. {
  3690. try
  3691. {
  3692. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3693. if (groupData.Code != 0)
  3694. {
  3695. return Ok(JsonView(false, groupData.Msg));
  3696. }
  3697. return Ok(JsonView(true, "操作成功", groupData.Data));
  3698. }
  3699. catch (Exception ex)
  3700. {
  3701. return Ok(JsonView(false, ex.Message));
  3702. throw;
  3703. }
  3704. }
  3705. /// <summary>
  3706. /// 根据商邀费用ID查询C表和商邀费用数据
  3707. /// </summary>
  3708. /// <param name="dto"></param>
  3709. /// <returns></returns>
  3710. [HttpPost]
  3711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3712. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3713. {
  3714. try
  3715. {
  3716. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3717. if (groupData.Code != 0)
  3718. {
  3719. return Ok(JsonView(false, groupData.Msg));
  3720. }
  3721. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3722. }
  3723. catch (Exception ex)
  3724. {
  3725. return Ok(JsonView(false, ex.Message));
  3726. throw;
  3727. }
  3728. }
  3729. /// <summary>
  3730. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3731. /// </summary>
  3732. /// <param name="dto"></param>
  3733. /// <returns></returns>
  3734. [HttpPost]
  3735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3736. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3737. {
  3738. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3739. if (groupData.Code != 0)
  3740. {
  3741. return Ok(JsonView(false, groupData.Msg));
  3742. }
  3743. #region 应用推送
  3744. try
  3745. {
  3746. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3747. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3748. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3749. //2024-10-21 新增LZ UID
  3750. var userIds = new List<int>() { 21 };
  3751. string title = $"系统通知";
  3752. string content = "";
  3753. var diId = dto.DiId;
  3754. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3755. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3756. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3757. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3758. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3759. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3760. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3761. }
  3762. catch (Exception ex)
  3763. {
  3764. }
  3765. #endregion
  3766. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3767. }
  3768. /// <summary>
  3769. /// 商邀删除
  3770. /// </summary>
  3771. /// <param name="dto"></param>
  3772. /// <returns></returns>
  3773. [HttpPost]
  3774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3775. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3776. {
  3777. try
  3778. {
  3779. _sqlSugar.BeginTran();
  3780. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3781. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3782. {
  3783. IsDel = 1,
  3784. DeleteUserId = dto.DeleteUserId,
  3785. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3786. })
  3787. .Where(it => it.Id == dto.Id)
  3788. .ExecuteCommand();
  3789. if (res1 > 0)
  3790. {
  3791. int _diId = 0;
  3792. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3793. if (_ioaInfo != null)
  3794. {
  3795. _diId = _ioaInfo.DiId;
  3796. }
  3797. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3798. .SetColumns(a => new Grp_CreditCardPayment()
  3799. {
  3800. IsDel = 1,
  3801. DeleteUserId = dto.DeleteUserId,
  3802. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3803. })
  3804. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3805. .ExecuteCommand();
  3806. if (res2 > 0)
  3807. {
  3808. _sqlSugar.CommitTran();
  3809. return Ok(JsonView(true, "删除成功!"));
  3810. }
  3811. }
  3812. _sqlSugar.RollbackTran();
  3813. return Ok(JsonView(false, "删除失败"));
  3814. }
  3815. catch (Exception ex)
  3816. {
  3817. _sqlSugar.RollbackTran();
  3818. return Ok(JsonView(false, ex.Message));
  3819. }
  3820. }
  3821. /// <summary>
  3822. /// 团组模块文件上传
  3823. /// </summary>
  3824. /// <param name="dto"></param>
  3825. /// <returns></returns>
  3826. [HttpPost]
  3827. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3828. {
  3829. var jw = JsonView(false);
  3830. long M = 1024 * 1024;
  3831. if (dto.Files == null || dto.Files.Count == 0)
  3832. {
  3833. jw.Msg = "无文件信息!";
  3834. return Ok(jw);
  3835. }
  3836. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3837. {
  3838. jw.Msg = "文件大小超过20M!";
  3839. return Ok(jw);
  3840. }
  3841. //var nameSp = dto.File.FileName.Split(".");
  3842. //if (nameSp.Length < 2)
  3843. //{
  3844. // jw.Msg = "拓展名称有误!";
  3845. // return Ok(jw);
  3846. //}
  3847. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3848. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3849. //{
  3850. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3851. // return Ok(jw);
  3852. //}
  3853. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3854. if (Ctable == null)
  3855. {
  3856. jw.Msg = "Ctable指向有误!";
  3857. return Ok(jw);
  3858. }
  3859. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3860. if (groupInfo == null)
  3861. {
  3862. jw.Msg = "团组信息不存在!";
  3863. return Ok(jw);
  3864. }
  3865. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3866. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3867. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3868. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3869. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3870. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3871. try
  3872. {
  3873. if (!Directory.Exists(fileBase))
  3874. {
  3875. Directory.CreateDirectory(fileBase);
  3876. }
  3877. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3878. foreach (var fileStream in dto.Files)
  3879. {
  3880. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3881. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3882. {
  3883. Cid = dto.Cid,
  3884. CreateTime = DateTime.Now,
  3885. CreateUserId = dto.Userid,
  3886. Ctable = dto.Ctable,
  3887. Diid = dto.Diid,
  3888. IsDel = 0,
  3889. FilePath = saveFilePath,
  3890. FileName = fileStream.FileName
  3891. };
  3892. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3893. {
  3894. fileStream.CopyTo(fs);
  3895. fs.Flush();
  3896. }
  3897. saveArr.Add(file);
  3898. }
  3899. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3900. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3901. jw = JsonView(true, "保存成功!", new
  3902. {
  3903. count = addResult,
  3904. filesName = saveArr.Select(x => x.FileName)
  3905. });
  3906. }
  3907. catch (Exception ex)
  3908. {
  3909. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3910. {
  3911. count = 0,
  3912. filesName = new string[0],
  3913. });
  3914. }
  3915. return Ok(jw);
  3916. }
  3917. /// <summary>
  3918. /// 查询各模块已保存文件
  3919. /// </summary>
  3920. /// <param name="dto"></param>
  3921. /// <returns></returns>
  3922. [HttpPost]
  3923. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3924. {
  3925. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3926. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3927. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3928. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3929. {
  3930. expression = Expressionable.Create<Grp_GroupModelFile>()
  3931. .And(x => visaIds.Contains(x.CreateUserId));
  3932. }
  3933. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3934. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3935. .Where(expression.ToExpression())
  3936. .ToList();
  3937. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3938. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3939. {
  3940. x.FileName,
  3941. x.Id,
  3942. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3943. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3944. })));
  3945. }
  3946. /// <summary>
  3947. /// 下载该团组下的所有文件
  3948. /// </summary>
  3949. /// <param name="dto"></param>
  3950. /// <returns></returns>
  3951. [HttpPost]
  3952. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3953. {
  3954. var jw = JsonView(false);
  3955. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3956. if (groupInfo == null)
  3957. {
  3958. jw.Msg = "团组信息不存在!";
  3959. return Ok(jw);
  3960. }
  3961. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3962. var isModule = Convert.ToBoolean(dto.isModule);
  3963. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3964. IOOperatorHelper io = new IOOperatorHelper();
  3965. if (isModule)
  3966. {
  3967. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3968. foreach (var moduleArr in moduleGroup)
  3969. {
  3970. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3971. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3972. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3973. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3974. foreach (var item in moduleArr)
  3975. {
  3976. if (System.IO.File.Exists(item.FilePath))
  3977. {
  3978. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3979. {
  3980. byte[] bytes = new byte[fileStream.Length];
  3981. fileStream.Read(bytes, 0, bytes.Length);
  3982. fileStream.Close();
  3983. Stream stream = new MemoryStream(bytes);
  3984. chiZips.Add(item.FileName, stream);
  3985. }
  3986. }
  3987. }
  3988. if (chiZips.Count > 0)
  3989. {
  3990. var byts = io.ConvertZipStream(chiZips);
  3991. Stream stream = new MemoryStream(byts);
  3992. Zips.Add(key.Name + "_.zip", stream);
  3993. }
  3994. }
  3995. }
  3996. else
  3997. {
  3998. foreach (var item in dbQuery)
  3999. {
  4000. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4001. {
  4002. byte[] bytes = new byte[fileStream.Length];
  4003. fileStream.Read(bytes, 0, bytes.Length);
  4004. fileStream.Close();
  4005. Stream stream = new MemoryStream(bytes);
  4006. while (Zips.Keys.Contains(item.FileName))
  4007. {
  4008. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4009. }
  4010. Zips.Add(item.FileName, stream);
  4011. }
  4012. }
  4013. }
  4014. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4015. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4016. if (Zips.Count > 0)
  4017. {
  4018. var byts = io.ConvertZipStream(Zips);
  4019. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4020. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4021. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4022. }
  4023. else
  4024. {
  4025. jw.Msg = "暂无生成文件!";
  4026. }
  4027. return Ok(jw);
  4028. }
  4029. /// <summary>
  4030. /// 下载该团组下此模块的所有文件
  4031. /// </summary>
  4032. /// <param name="dto"></param>
  4033. /// <returns></returns>
  4034. [HttpPost]
  4035. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4036. {
  4037. var jw = JsonView(false);
  4038. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4039. if (groupInfo == null)
  4040. {
  4041. jw.Msg = "团组信息不存在!";
  4042. return Ok(jw);
  4043. }
  4044. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4045. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4046. && x.IsDel == 0);
  4047. if (key == null)
  4048. {
  4049. jw.Msg = "Ctable指向错误!";
  4050. return Ok(jw);
  4051. }
  4052. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4053. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4054. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4055. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4056. IOOperatorHelper io = new IOOperatorHelper();
  4057. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4058. foreach (var item in dbQuery)
  4059. {
  4060. if (System.IO.File.Exists(item.FilePath))
  4061. {
  4062. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4063. {
  4064. byte[] bytes = new byte[fileStream.Length];
  4065. fileStream.Read(bytes, 0, bytes.Length);
  4066. fileStream.Close();
  4067. Stream stream = new MemoryStream(bytes);
  4068. while (Zips.Keys.Contains(item.FileName))
  4069. {
  4070. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4071. }
  4072. Zips.Add(item.FileName, stream);
  4073. }
  4074. }
  4075. }
  4076. if (Zips.Count > 0)
  4077. {
  4078. var byts = io.ConvertZipStream(Zips);
  4079. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4080. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4081. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4082. }
  4083. else
  4084. {
  4085. jw.Msg = "暂无生成文件!";
  4086. }
  4087. return Ok(jw);
  4088. }
  4089. /// <summary>
  4090. /// 删除该团组下的指定文件
  4091. /// </summary>
  4092. /// <param name="dto"></param>
  4093. /// <returns></returns>
  4094. [HttpPost]
  4095. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4096. {
  4097. var jw = JsonView(false);
  4098. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4099. if (sing == null)
  4100. {
  4101. jw.Msg = "暂无";
  4102. return Ok(jw);
  4103. }
  4104. if (System.IO.File.Exists(sing.FilePath))
  4105. {
  4106. try
  4107. {
  4108. System.IO.File.Delete(sing.FilePath);
  4109. }
  4110. catch (Exception ex)
  4111. {
  4112. jw.Msg = "删除失败!" + ex.Message;
  4113. return Ok(jw);
  4114. }
  4115. }
  4116. sing.IsDel = 1;
  4117. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4118. sing.DeleteUserId = dto.UserId;
  4119. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4120. jw = JsonView(true, "删除成功!");
  4121. return Ok(jw);
  4122. }
  4123. #endregion
  4124. #region 团组英文资料
  4125. /// <summary>
  4126. /// 查询团组英文所有资料
  4127. /// </summary>
  4128. /// <param name="dto"></param>
  4129. /// <returns></returns>
  4130. [HttpPost]
  4131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4132. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4133. {
  4134. try
  4135. {
  4136. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4137. if (groupData.Code != 0)
  4138. {
  4139. return Ok(JsonView(false, groupData.Msg));
  4140. }
  4141. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4142. }
  4143. catch (Exception ex)
  4144. {
  4145. return Ok(JsonView(false, "程序错误!"));
  4146. throw;
  4147. }
  4148. }
  4149. /// <summary>
  4150. /// 团组英文资料操作(Status:1.新增,2.修改)
  4151. /// </summary>
  4152. /// <param name="dto"></param>
  4153. /// <returns></returns>
  4154. [HttpPost]
  4155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4156. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4157. {
  4158. try
  4159. {
  4160. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4161. if (groupData.Code != 0)
  4162. {
  4163. return Ok(JsonView(false, groupData.Msg));
  4164. }
  4165. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4166. }
  4167. catch (Exception ex)
  4168. {
  4169. return Ok(JsonView(false, "程序错误!"));
  4170. throw;
  4171. }
  4172. }
  4173. /// <summary>
  4174. /// 团组英文资料Id查询数据
  4175. /// </summary>
  4176. /// <param name="dto"></param>
  4177. /// <returns></returns>
  4178. [HttpPost]
  4179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4180. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4181. {
  4182. try
  4183. {
  4184. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4185. if (_DelegationEnData != null)
  4186. {
  4187. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4188. }
  4189. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4190. }
  4191. catch (Exception ex)
  4192. {
  4193. return Ok(JsonView(false, "程序错误!"));
  4194. throw;
  4195. }
  4196. }
  4197. /// <summary>
  4198. /// 团组英文资料删除
  4199. /// </summary>
  4200. /// <param name="dto"></param>
  4201. /// <returns></returns>
  4202. [HttpPost]
  4203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4204. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4205. {
  4206. try
  4207. {
  4208. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4209. if (!res)
  4210. {
  4211. return Ok(JsonView(false, "删除失败"));
  4212. }
  4213. return Ok(JsonView(true, "删除成功!"));
  4214. }
  4215. catch (Exception ex)
  4216. {
  4217. return Ok(JsonView(false, "程序错误!"));
  4218. throw;
  4219. }
  4220. }
  4221. #endregion
  4222. #region 导出邀请函
  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> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4231. {
  4232. try
  4233. {
  4234. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4235. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4236. if (dto.DiId == 0)
  4237. {
  4238. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4239. }
  4240. else
  4241. {
  4242. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4243. }
  4244. return Ok(JsonView(true, "查询成功!", new
  4245. {
  4246. deleClient = crm_Deles,
  4247. delegations = grp_Delegations
  4248. }));
  4249. }
  4250. catch (Exception ex)
  4251. {
  4252. return Ok(JsonView(false, "程序错误!"));
  4253. throw;
  4254. }
  4255. }
  4256. /// <summary>
  4257. /// 导出邀请函
  4258. /// </summary>
  4259. /// <param name="dto"></param>
  4260. /// <returns></returns>
  4261. [HttpPost]
  4262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4263. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4264. {
  4265. #region 参数验证
  4266. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4267. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4268. #endregion
  4269. try
  4270. {
  4271. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4272. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4273. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4274. From Grp_TourClientList tcl
  4275. Left Join
  4276. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4277. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4278. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4279. From Crm_DeleClient dc
  4280. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4281. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4282. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4283. Where dc.IsDel = 0) temp
  4284. On temp.DcId =tcl.ClientId
  4285. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4286. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4287. List<string> texts = new List<string>();
  4288. if (datas.Count != 0)
  4289. {
  4290. foreach (TourClientListDetailsView item in datas)
  4291. {
  4292. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4293. {
  4294. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4295. }
  4296. else
  4297. {
  4298. string name = item.LastName + item.FirstName;
  4299. texts.Add(name);
  4300. }
  4301. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4302. {
  4303. if (!transDic.ContainsKey(item.Job))
  4304. {
  4305. texts.Add(item.Job);
  4306. }
  4307. }
  4308. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4309. {
  4310. texts.Add(item.CompanyFullName);
  4311. }
  4312. }
  4313. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4314. if (transData.Count > 0)
  4315. {
  4316. foreach (TranslateResult item in transData)
  4317. {
  4318. if (!transDic.ContainsKey(item.Query))
  4319. {
  4320. transDic.Add(item.Query, item.Translation);
  4321. }
  4322. }
  4323. }
  4324. List<GuestList> list = new List<GuestList>();
  4325. foreach (TourClientListDetailsView dele in datas)
  4326. {
  4327. GuestList guestList = new GuestList();
  4328. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4329. {
  4330. guestList.Name = dele.Pinyin;
  4331. }
  4332. else
  4333. {
  4334. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4335. guestList.Name = Name;
  4336. }
  4337. if (dele.Sex == 0)
  4338. {
  4339. guestList.Sex = "Male";
  4340. }
  4341. else if (dele.Sex == 1)
  4342. {
  4343. guestList.Sex = "Female";
  4344. }
  4345. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4346. if (!string.IsNullOrEmpty(dele.Job))
  4347. {
  4348. guestList.Job = dele.Job;
  4349. }
  4350. list.Add(guestList);
  4351. }
  4352. //载入模板
  4353. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4354. DocumentBuilder builder = new DocumentBuilder(doc);
  4355. //获取word里所有表格
  4356. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4357. //获取所填表格的序数
  4358. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4359. var rowStart = tableOne.Rows[0]; //获取第1行
  4360. //循环赋值
  4361. for (int i = 0; i < list.Count; i++)
  4362. {
  4363. builder.MoveToCell(0, i + 1, 0, 0);
  4364. builder.Write(list[i].Name.ToString());
  4365. builder.MoveToCell(0, i + 1, 1, 0);
  4366. builder.Write(list[i].Sex.ToString());
  4367. builder.MoveToCell(0, i + 1, 2, 0);
  4368. builder.Write(list[i].DOB.ToString());
  4369. builder.MoveToCell(0, i + 1, 3, 0);
  4370. builder.Write(list[i].Job.ToString());
  4371. }
  4372. //删除多余行
  4373. while (tableOne.Rows.Count > list.Count + 1)
  4374. {
  4375. tableOne.Rows.RemoveAt(list.Count + 1);
  4376. }
  4377. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4378. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4379. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4380. doc.Save(filePath);
  4381. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4382. return Ok(JsonView(true, "操作成功!", Url));
  4383. }
  4384. else
  4385. {
  4386. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4387. }
  4388. }
  4389. catch (Exception ex)
  4390. {
  4391. return Ok(JsonView(false, ex.Message));
  4392. throw;
  4393. }
  4394. }
  4395. #endregion
  4396. #region 团组经理模块 出入境费用
  4397. ///// <summary>
  4398. ///// 团组模块 - 出入境费用
  4399. ///// </summary>
  4400. ///// <returns></returns>
  4401. //[HttpPost]
  4402. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4403. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4404. //{
  4405. // try
  4406. // {
  4407. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4408. // if (data.Code != 0)
  4409. // {
  4410. // return Ok(JsonView(false, data.Msg));
  4411. // }
  4412. // return Ok(JsonView(true, "查询成功!"));
  4413. // }
  4414. // catch (Exception ex)
  4415. // {
  4416. // return Ok(JsonView(false, ex.Message));
  4417. // throw;
  4418. // }
  4419. //}
  4420. /// <summary>
  4421. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4422. /// </summary>
  4423. /// <returns></returns>
  4424. [HttpPost]
  4425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4426. public async Task<IActionResult> SetDayAndCostAreaChange()
  4427. {
  4428. try
  4429. {
  4430. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4431. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4432. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4433. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4434. foreach (var item in unite) //处理交集数据
  4435. {
  4436. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4437. }
  4438. foreach (var item in merge) //处理差集数据
  4439. {
  4440. int nationalTravelFeeId = 0;
  4441. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4442. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4443. else
  4444. {
  4445. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4446. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4447. }
  4448. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4449. }
  4450. //只更新dayAndCost 的 nationalTravelFeeId;
  4451. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4452. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4453. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4454. }
  4455. catch (Exception ex)
  4456. {
  4457. return Ok(JsonView(false, ex.Message));
  4458. throw;
  4459. }
  4460. }
  4461. /// <summary>
  4462. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4463. /// </summary>
  4464. /// <returns></returns>
  4465. [HttpPost]
  4466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4467. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4468. {
  4469. try
  4470. {
  4471. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4472. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4473. //SetDataInfoView
  4474. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4475. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4476. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4477. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4478. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4479. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4480. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4481. //默认币种显示
  4482. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4483. {
  4484. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4485. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4486. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4487. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4488. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4489. };
  4490. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4491. if (_currencyRate.Count > 0)
  4492. {
  4493. foreach (var item in _currencyInfos)
  4494. {
  4495. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4496. if (rateInfo != null)
  4497. {
  4498. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4499. rate1 *= 1.035M;
  4500. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4501. }
  4502. }
  4503. }
  4504. return Ok(JsonView(true, "查询成功!", new
  4505. {
  4506. GroupNameData = groupNameData.Data,
  4507. CurrencyData = _CurrencyData,
  4508. WordTypeData = _WordTypeData,
  4509. ExcelTypeData = _ExcelTypeData,
  4510. CurrencyInit = _currencyInfos
  4511. }));
  4512. }
  4513. catch (Exception ex)
  4514. {
  4515. return Ok(JsonView(false, ex.Message));
  4516. throw;
  4517. }
  4518. }
  4519. /// <summary>
  4520. /// 团组模块 - 出入境费用
  4521. /// 实时汇率 tips
  4522. /// 签证费用 tips
  4523. /// 机票费用 tips
  4524. /// </summary>
  4525. /// <returns></returns>
  4526. [HttpPost]
  4527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4528. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4529. {
  4530. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4531. //默认币种显示
  4532. var _currencyInfos = _currencyInit;
  4533. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4534. List<dynamic> reteInfos = new List<dynamic>();
  4535. if (_currencyRate.Count > 0)
  4536. {
  4537. foreach (var item in _currencyInfos)
  4538. {
  4539. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4540. if (rateInfo != null)
  4541. {
  4542. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4543. decimal rate1 = item.Rate;
  4544. rate1 *= 1.03M;
  4545. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4546. reteInfos.Add(new
  4547. {
  4548. currCode = item.CurrencyCode,
  4549. currName = item.CurrencyName,
  4550. rate = rate2,
  4551. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4552. });
  4553. }
  4554. }
  4555. }
  4556. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4557. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4558. return Ok(JsonView(true, "查询成功!", new
  4559. {
  4560. //GroupNameData = groupNameData.Data,
  4561. visaData = visaData.Data,
  4562. airData = airData.Data,
  4563. reteInfos = reteInfos
  4564. }));
  4565. }
  4566. /// <summary>
  4567. /// 团组模块 - 出入境费用 - Info
  4568. /// </summary>
  4569. /// <returns></returns>
  4570. [HttpPost]
  4571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4572. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4573. {
  4574. try
  4575. {
  4576. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4577. if (data.Code != 0)
  4578. {
  4579. return Ok(JsonView(false, data.Msg));
  4580. }
  4581. return Ok(JsonView(true, "查询成功!", data.Data));
  4582. }
  4583. catch (Exception ex)
  4584. {
  4585. return Ok(JsonView(false, ex.Message));
  4586. }
  4587. }
  4588. /// <summary>
  4589. /// 团组模块 - 出入境费用 - Add And Update
  4590. /// </summary>
  4591. /// <returns></returns>
  4592. [HttpPost]
  4593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4594. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4595. {
  4596. try
  4597. {
  4598. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4599. if (dto.DayOtherPriceData.Any())
  4600. {
  4601. var inserList = dto.DayOtherPriceData
  4602. .Where(x => x.Id == 0)
  4603. .Select(x => new Grp_DayOtherPrice
  4604. {
  4605. Cost = x.Cost,
  4606. Id = x.Id,
  4607. CreateTime = DateTime.Now,
  4608. CreateUserId = dto.UserId,
  4609. Currency = x.Currency,
  4610. Diid = x.DiId,
  4611. Index = x.Index,
  4612. IsDel = 0,
  4613. SetDataId = x.SetDataId,
  4614. SubTotal = x.SubTotal,
  4615. Remark = x.Remark
  4616. })
  4617. .ToList();
  4618. var updateList = dto.DayOtherPriceData
  4619. .Where(x => x.Id != 0)
  4620. .Select(x => new Grp_DayOtherPrice
  4621. {
  4622. Cost = x.Cost,
  4623. Id = x.Id,
  4624. CreateTime = DateTime.Now,
  4625. CreateUserId = dto.UserId,
  4626. Currency = x.Currency,
  4627. Diid = x.DiId,
  4628. Index = x.Index,
  4629. IsDel = 0,
  4630. SetDataId = x.SetDataId,
  4631. SubTotal = x.SubTotal,
  4632. Remark = x.Remark
  4633. })
  4634. .ToList();
  4635. //添加
  4636. _sqlSugar.BeginTran();
  4637. if (inserList.Any())
  4638. {
  4639. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4640. }
  4641. if (updateList.Any())
  4642. {
  4643. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4644. }
  4645. _sqlSugar.CommitTran();
  4646. }
  4647. if (data.Code != 0)
  4648. {
  4649. return Ok(JsonView(false, data.Msg));
  4650. }
  4651. //生成默认文件pdf并且通知人员
  4652. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4653. {
  4654. DiId = dto.DiId,
  4655. ExportType = 1,
  4656. SubTypeId = 1005
  4657. }, "pdf");
  4658. //发送通知
  4659. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4660. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4661. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4662. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4663. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4664. //汇率信息记录
  4665. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4666. return Ok(JsonView(true, data.Msg, data.Data));
  4667. }
  4668. catch (Exception ex)
  4669. {
  4670. return Ok(JsonView(false, ex.Message));
  4671. }
  4672. }
  4673. /// <summary>
  4674. /// 团组模块 - 出入境费用 - Confirm 费用
  4675. /// </summary>
  4676. /// <returns></returns>
  4677. [HttpPost]
  4678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4679. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4680. {
  4681. //TODO:测试完毕需把对应的用户ID更改
  4682. //1、数据表添加字段
  4683. //2、更改字段接口()
  4684. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4685. //3、确认成功 给财务发送消息
  4686. if (_view.Code == 200)
  4687. {
  4688. if (dto.Type == 1)
  4689. {
  4690. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4691. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4692. }
  4693. }
  4694. return Ok(_view);
  4695. }
  4696. /// <summary>
  4697. /// 团组模块 - 出入境费用 - File downlaod
  4698. /// </summary>
  4699. /// <param name="dto"></param>
  4700. /// <returns></returns>
  4701. [HttpPost]
  4702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4703. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4704. {
  4705. try
  4706. {
  4707. if (dto.DiId < 1)
  4708. {
  4709. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4710. }
  4711. if (dto.ExportType < 1)
  4712. {
  4713. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4714. }
  4715. if (dto.SubTypeId < 1)
  4716. {
  4717. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4718. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4719. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4720. 3 团组成员名单 1 团组成员名单", ""));
  4721. }
  4722. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4723. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4724. if (_EnterExitCosts == null)
  4725. {
  4726. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4727. }
  4728. //数据源
  4729. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4730. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4731. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4732. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4733. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4734. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4735. .LeftJoin<Sys_SetData>((x, a, b) => a.IsDel == 0 && a.Id == x.Currency)
  4736. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4737. .Select((x, a, b) => new
  4738. {
  4739. x.Index,
  4740. itemName = a.Name,
  4741. CurrencyStr = b.Name,
  4742. x.Cost,
  4743. x.SubTotal,
  4744. })
  4745. .OrderBy((x) => x.Index)
  4746. .ToList(); //其他款项费用
  4747. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4748. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4749. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4750. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4751. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4752. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4753. .Select((tcl, dc, cc) => new
  4754. {
  4755. Name = dc.LastName + dc.FirstName,
  4756. Sex = dc.Sex,
  4757. Birthday = dc.BirthDay,
  4758. Company = cc.CompanyFullName,
  4759. Job = dc.Job
  4760. })
  4761. .ToList();
  4762. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4763. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4764. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4765. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4766. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4767. if (dto.ExportType == 1) //明细表
  4768. {
  4769. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4770. {
  4771. //获取模板
  4772. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4773. //载入模板
  4774. Document doc = new Document(tempPath);
  4775. DocumentBuilder builder = new DocumentBuilder(doc);
  4776. //利用键值对存放数据
  4777. Dictionary<string, string> dic = new Dictionary<string, string>();
  4778. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4779. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4780. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4781. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4782. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4783. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4784. //境内费用(其他费用)
  4785. if (_EnterExitCosts.ChoiceOne == 1)
  4786. {
  4787. string row1_1 = "";
  4788. if (_EnterExitCosts.Visa > 0)
  4789. {
  4790. //insidePayTotal += _EnterExitCosts.Visa;
  4791. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4792. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4793. {
  4794. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4795. }
  4796. }
  4797. string row1_2 = "";
  4798. if (_EnterExitCosts.YiMiao > 0)
  4799. {
  4800. //insidePayTotal += _EnterExitCosts.YiMiao;
  4801. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4802. }
  4803. if (_EnterExitCosts.HeSuan > 0)
  4804. {
  4805. //insidePayTotal += _EnterExitCosts.HeSuan;
  4806. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4807. }
  4808. if (_EnterExitCosts.Service > 0)
  4809. {
  4810. //insidePayTotal += _EnterExitCosts.Service;
  4811. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4812. }
  4813. string row1_3 = "";
  4814. if (_EnterExitCosts.Safe > 0)
  4815. {
  4816. //insidePayTotal += _EnterExitCosts.Safe;
  4817. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4818. }
  4819. if (_EnterExitCosts.Ticket > 0)
  4820. {
  4821. //insidePayTotal += _EnterExitCosts.Ticket;
  4822. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4823. }
  4824. string row1 = "";
  4825. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4826. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4827. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4828. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4829. dic.Add("Row1Str", row1);
  4830. }
  4831. string airTotalStr = string.Empty,
  4832. airPriceStr = string.Empty;
  4833. //经济舱
  4834. if (_EnterExitCosts.SumJJC == 1)
  4835. {
  4836. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4837. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4838. }
  4839. //公务舱
  4840. if (_EnterExitCosts.SumGWC == 1)
  4841. {
  4842. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4843. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4844. }
  4845. //头等舱
  4846. if (_EnterExitCosts.SumTDC == 1)
  4847. {
  4848. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4849. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4850. }
  4851. dic.Add("AirTotalStr", airTotalStr);
  4852. dic.Add("AirPriceStr", airPriceStr);
  4853. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4854. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4855. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4856. int table1Row = 0,
  4857. table2Row = 0,
  4858. table3Row = 0,
  4859. table4Row = 0,
  4860. table5Row = 0;
  4861. //住宿费
  4862. if (_EnterExitCosts.ChoiceThree == 1)
  4863. {
  4864. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4865. table1Row = dac1.Count;
  4866. #region 填充word表格内容
  4867. for (int i = 0; i < dac1.Count; i++)
  4868. {
  4869. Grp_DayAndCost dac = dac1[i];
  4870. if (dac == null) continue;
  4871. builder.MoveToCell(0, i, 0, 0);
  4872. builder.Write("第" + dac.Days.ToString() + "晚:");
  4873. builder.MoveToCell(0, i, 1, 0);
  4874. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4875. //builder.Write(dac.Place == null ? "" : dac.Place);
  4876. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4877. builder.MoveToCell(0, i, 2, 0);
  4878. builder.Write("费用标准:");
  4879. string curr = "";
  4880. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4881. if (currData != null)
  4882. {
  4883. curr = currData.Name;
  4884. }
  4885. builder.MoveToCell(0, i, 3, 0);
  4886. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4887. builder.MoveToCell(0, i, 4, 0);
  4888. builder.Write("费用小计:");
  4889. builder.MoveToCell(0, i, 5, 0);
  4890. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4891. }
  4892. #endregion
  4893. }
  4894. else dic.Add("SubZS", "0.00");
  4895. //删除多余行
  4896. while (table1.Rows.Count > table1Row)
  4897. {
  4898. table1.Rows.RemoveAt(table1Row);
  4899. }
  4900. //伙食费
  4901. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4902. if (_EnterExitCosts.ChoiceFour == 1)
  4903. {
  4904. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4905. table2Row = dac2.Count;
  4906. #region 填充word表格内容
  4907. for (int i = 0; i < dac2.Count; i++)
  4908. {
  4909. Grp_DayAndCost dac = dac2[i];
  4910. if (dac == null) continue;
  4911. builder.MoveToCell(1, i, 0, 0);
  4912. builder.Write("第" + dac.Days.ToString() + "天:");
  4913. builder.MoveToCell(1, i, 1, 0);
  4914. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4915. builder.MoveToCell(1, i, 2, 0);
  4916. builder.Write("费用标准:");
  4917. string curr = "";
  4918. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4919. if (currData != null)
  4920. {
  4921. curr = currData.Name;
  4922. }
  4923. builder.MoveToCell(1, i, 3, 0);
  4924. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4925. builder.MoveToCell(1, i, 4, 0);
  4926. builder.Write("费用小计:");
  4927. builder.MoveToCell(1, i, 5, 0);
  4928. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4929. }
  4930. #endregion
  4931. }
  4932. else dic.Add("SubHS", "0.00");
  4933. //删除多余行
  4934. while (table2.Rows.Count > table2Row)
  4935. {
  4936. table2.Rows.RemoveAt(table2Row);
  4937. }
  4938. //公杂费
  4939. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4940. if (_EnterExitCosts.ChoiceFive == 1)
  4941. {
  4942. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4943. table3Row = dac3.Count;
  4944. #region 填充word表格内容
  4945. for (int i = 0; i < dac3.Count; i++)
  4946. {
  4947. Grp_DayAndCost dac = dac3[i];
  4948. if (dac == null) continue;
  4949. builder.MoveToCell(2, i, 0, 0);
  4950. builder.Write("第" + dac.Days.ToString() + "天:");
  4951. builder.MoveToCell(2, i, 1, 0);
  4952. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4953. builder.MoveToCell(2, i, 2, 0);
  4954. builder.Write("费用标准:");
  4955. string curr = "";
  4956. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4957. if (currData != null)
  4958. {
  4959. curr = currData.Name;
  4960. }
  4961. builder.MoveToCell(2, i, 3, 0);
  4962. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4963. builder.MoveToCell(2, i, 4, 0);
  4964. builder.Write("费用小计:");
  4965. builder.MoveToCell(2, i, 5, 0);
  4966. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4967. }
  4968. //删除多余行
  4969. while (table3.Rows.Count > table3Row)
  4970. {
  4971. table3.Rows.RemoveAt(table3Row);
  4972. }
  4973. #endregion
  4974. }
  4975. else dic.Add("SubGZF", "0.00");
  4976. //删除多余行
  4977. while (table3.Rows.Count > table3Row)
  4978. {
  4979. table3.Rows.RemoveAt(table3Row);
  4980. }
  4981. //培训费
  4982. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4983. if (_EnterExitCosts.ChoiceSix == 1)
  4984. {
  4985. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4986. dic.Add("SubPX", pxStr);
  4987. table4Row = dac4.Count;
  4988. #region 填充word表格内容
  4989. for (int i = 0; i < dac4.Count; i++)
  4990. {
  4991. Grp_DayAndCost dac = dac4[i];
  4992. if (dac == null) continue;
  4993. builder.MoveToCell(3, i, 0, 0);
  4994. builder.Write("第" + dac.Days.ToString() + "天:");
  4995. builder.MoveToCell(3, i, 1, 0);
  4996. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4997. builder.MoveToCell(3, i, 2, 0);
  4998. builder.Write("费用标准:");
  4999. string curr = "";
  5000. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5001. if (currData != null)
  5002. {
  5003. curr = currData.Name;
  5004. }
  5005. builder.MoveToCell(3, i, 3, 0);
  5006. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5007. builder.MoveToCell(3, i, 4, 0);
  5008. builder.Write("费用小计:");
  5009. builder.MoveToCell(3, i, 5, 0);
  5010. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5011. }
  5012. #endregion
  5013. }
  5014. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5015. //删除多余行
  5016. while (table4.Rows.Count > table4Row)
  5017. {
  5018. table4.Rows.RemoveAt(table4Row);
  5019. }
  5020. //其他费用
  5021. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5022. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5023. {
  5024. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5025. dic.Add("titleQi", qtStr);
  5026. table5Row = dac5.Count;
  5027. #region 填充word表格内容
  5028. for (int i = 0; i < dac5.Count; i++)
  5029. {
  5030. var dac = dac5[i];
  5031. if (dac == null) continue;
  5032. builder.MoveToCell(4, i, 0, 0);
  5033. builder.Write("第" + dac.Index.ToString() + "项:");
  5034. builder.MoveToCell(4, i, 1, 0);
  5035. builder.Write(dac.itemName);
  5036. builder.MoveToCell(4, i, 2, 0);
  5037. builder.Write("费用标准:");
  5038. builder.MoveToCell(4, i, 3, 0);
  5039. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5040. builder.MoveToCell(4, i, 4, 0);
  5041. builder.Write("费用小计:");
  5042. builder.MoveToCell(4, i, 5, 0);
  5043. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5044. }
  5045. #endregion
  5046. }
  5047. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5048. //删除多余行
  5049. while (table5.Rows.Count > table5Row)
  5050. {
  5051. table5.Rows.RemoveAt(table5Row);
  5052. }
  5053. //加上其他费用
  5054. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5055. decimal subJJC = 0.00M,
  5056. subGWC = 0.00M,
  5057. subTDC = 0.00M;
  5058. //经济舱
  5059. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5060. //公务舱
  5061. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5062. //头等舱
  5063. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5064. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5065. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5066. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5067. #region 填充word模板书签内容
  5068. foreach (var key in dic.Keys)
  5069. {
  5070. Bookmark bookmark = doc.Range.Bookmarks[key];
  5071. if (bookmark != null)
  5072. {
  5073. builder.MoveToBookmark(key);
  5074. builder.Write(dic[key]);
  5075. }
  5076. }
  5077. #endregion
  5078. //文件名
  5079. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5080. AsposeHelper.removewatermark_v2180();
  5081. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5082. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5083. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5084. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5085. }
  5086. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5087. {
  5088. //获取模板
  5089. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5090. //载入模板
  5091. Document doc = new Document(tempPath);
  5092. DocumentBuilder builder = new DocumentBuilder(doc);
  5093. Dictionary<string, string> dic = new Dictionary<string, string>();
  5094. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5095. {
  5096. List<string> list = new List<string>();
  5097. try
  5098. {
  5099. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5100. foreach (var item in spilitArr)
  5101. {
  5102. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5103. var depCode = spDotandEmpty[2].Substring(0, 3);
  5104. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5105. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5106. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5107. list.Add(depName);
  5108. list.Add(arrName);
  5109. }
  5110. list = list.Distinct().ToList();
  5111. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5112. }
  5113. catch (Exception)
  5114. {
  5115. dic.Add("ReturnCode", "行程录入不正确!");
  5116. }
  5117. }
  5118. else
  5119. {
  5120. dic.Add("ReturnCode", "未录入行程!");
  5121. }
  5122. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5123. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5124. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5125. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5126. {
  5127. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5128. dic.Add("Day", sp.Days.ToString());
  5129. }
  5130. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5131. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5132. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5133. //dic.Add("Names", Names);
  5134. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5135. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5136. decimal dac1totalPrice = 0.00M;
  5137. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5138. foreach (var dac in dac1)
  5139. {
  5140. if (dac.SubTotal == 0.00M)
  5141. {
  5142. continue;
  5143. }
  5144. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5145. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5146. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5147. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5148. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5149. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5150. builder.Write(currency);//币种
  5151. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5152. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5153. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5154. builder.Write("");//人数
  5155. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5156. builder.Write("");//天数
  5157. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5158. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5159. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5160. decimal rate = 0.00M;
  5161. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5162. builder.Write(rate.ToString("#0.0000"));//汇率
  5163. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5164. decimal rbmPrice = dac.SubTotal;
  5165. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5166. accommodationStartIndex++;
  5167. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5168. }
  5169. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5170. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5171. {
  5172. table1.Rows.RemoveAt(i - 1);
  5173. foodandotherStartIndex--;
  5174. }
  5175. if (dac2.Count == dac3.Count)//国家 币种 金额
  5176. {
  5177. for (int i = 0; i < dac2.Count; i++)
  5178. {
  5179. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5180. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5181. }
  5182. }
  5183. decimal dac2totalPrice = 0.00M;
  5184. foreach (var dac in dac2)
  5185. {
  5186. if (dac.SubTotal == 0)
  5187. {
  5188. continue;
  5189. }
  5190. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5191. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5192. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5193. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5194. builder.Write(currency);//币种
  5195. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5196. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5197. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5198. builder.Write("");//人数
  5199. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5200. builder.Write("");//天数
  5201. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5202. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5203. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5204. decimal rate = 0.00M;
  5205. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5206. builder.Write(rate.ToString("#0.0000"));//汇率
  5207. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5208. decimal rbmPrice = dac.SubTotal;
  5209. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5210. foodandotherStartIndex++;
  5211. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5212. }
  5213. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5214. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5215. {
  5216. table1.Rows.RemoveAt(i - 1);
  5217. }
  5218. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5219. string otherFeeStr = "";
  5220. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5221. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5222. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5223. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5224. foreach (var otherInfo in dac5)
  5225. {
  5226. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5227. }
  5228. #endregion
  5229. if (otherFeeStr.Length > 0)
  5230. {
  5231. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5232. otherFeeStr = $"({otherFeeStr})";
  5233. dic.Add("OtherFeeStr", otherFeeStr);
  5234. }
  5235. //总计
  5236. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5237. //国际旅费
  5238. string outsideAir = string.Empty;
  5239. string allPriceAir = string.Empty;
  5240. if (_EnterExitCosts.SumJJC == 1)
  5241. {
  5242. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5243. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5244. }
  5245. if (_EnterExitCosts.SumGWC == 1)
  5246. {
  5247. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5248. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5249. }
  5250. if (_EnterExitCosts.SumTDC == 1)
  5251. {
  5252. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5253. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5254. }
  5255. dic.Add("InTravelPrice", $"({outsideAir})");
  5256. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5257. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5258. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5259. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5260. foreach (var key in dic.Keys)
  5261. {
  5262. builder.MoveToBookmark(key);
  5263. builder.Write(dic[key]);
  5264. }
  5265. //模板文件名
  5266. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5267. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5268. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5269. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5270. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5271. }
  5272. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5273. {
  5274. //获取模板
  5275. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5276. //载入模板
  5277. WorkbookDesigner designer = new WorkbookDesigner();
  5278. designer.Workbook = new Workbook(tempPath);
  5279. Dictionary<string, string> dic = new Dictionary<string, string>();
  5280. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5281. {
  5282. List<string> list = new List<string>();
  5283. try
  5284. {
  5285. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5286. foreach (var item in spilitArr)
  5287. {
  5288. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5289. var depCode = spDotandEmpty[2].Substring(0, 3);
  5290. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5291. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5292. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5293. list.Add(depName);
  5294. list.Add(arrName);
  5295. }
  5296. list = list.Distinct().ToList();
  5297. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5298. }
  5299. catch (Exception)
  5300. {
  5301. dic.Add("ReturnCode", "行程录入不正确!");
  5302. }
  5303. }
  5304. else
  5305. {
  5306. dic.Add("ReturnCode", "未录入行程!");
  5307. }
  5308. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5309. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5310. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5311. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5312. {
  5313. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5314. dic.Add("Day", sp.Days.ToString());
  5315. }
  5316. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5317. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5318. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5319. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5320. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5321. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5322. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5323. designer.SetDataSource("Name", Names);
  5324. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5325. designer.SetDataSource("Day", dic["Day"] + "天");
  5326. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5327. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5328. int startIndex = 10;
  5329. const int startIndexcopy = 10;
  5330. if (dac2.Count == dac3.Count)//国家 币种 金额
  5331. {
  5332. for (int i = 0; i < dac2.Count; i++)
  5333. {
  5334. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5335. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5336. }
  5337. }
  5338. DataTable dtdac1 = new DataTable();
  5339. List<string> place = new List<string>();
  5340. dtdac1.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. DataTable dtdac2 = new DataTable();
  5351. dtdac2.Columns.AddRange(new DataColumn[] {
  5352. new DataColumn(){ ColumnName = "city"},
  5353. new DataColumn(){ ColumnName = "curr"},
  5354. new DataColumn(){ ColumnName = "criterion"},
  5355. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5356. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5357. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5358. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5359. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5360. });
  5361. dtdac1.TableName = "tb1";
  5362. dtdac2.TableName = "tb2";
  5363. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5364. foreach (var item in dac1)
  5365. {
  5366. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5367. if (place.Contains(item.Place))
  5368. {
  5369. continue;
  5370. }
  5371. DataRow row = dtdac1.NewRow();
  5372. row["city"] = item.Place;
  5373. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5374. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5375. row["curr"] = currency;
  5376. row["rate"] = rate.ToString("#0.0000");
  5377. row["criterion"] = item.Cost.ToString("#0.00");
  5378. row["number"] = 1;
  5379. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5380. //row["costRMB"] = rbmPrice;
  5381. dtdac1.Rows.Add(row);
  5382. place.Add(item.Place);
  5383. }
  5384. place = new List<string>();
  5385. foreach (var item in dac2)
  5386. {
  5387. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5388. if (place.Contains(item.Place))
  5389. {
  5390. continue;
  5391. }
  5392. DataRow row = dtdac2.NewRow();
  5393. row["city"] = item.Place;
  5394. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5395. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5396. row["curr"] = currency;
  5397. row["rate"] = rate.ToString("#0.0000");
  5398. row["criterion"] = item.Cost.ToString("#0.00");
  5399. row["number"] = 1;
  5400. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5401. //row["cost"] = item.SubTotal;
  5402. //row["costRMB"] = rbmPrice;
  5403. dtdac2.Rows.Add(row);
  5404. place.Add(item.Place);
  5405. //dac2totalPrice += rbmPrice;
  5406. }
  5407. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5408. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5409. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5410. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5411. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5412. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5413. string cell4Str1 = string.Empty;
  5414. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5415. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5416. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5417. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5418. string cellStr = $" 5.其他费用(";
  5419. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5420. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5421. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5422. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5423. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5424. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5425. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5426. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5427. foreach (var otherInfo in dac5)
  5428. {
  5429. cellStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5430. }
  5431. #endregion
  5432. if (cellStr.Length > 8)
  5433. {
  5434. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5435. }
  5436. cellStr += ")";
  5437. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5438. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5439. decimal pxFee = dac4.Sum(it => it.Cost);
  5440. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5441. string celllastStr1 = "";
  5442. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5443. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5444. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5445. celllastStr1 += $",国际旅费 元";
  5446. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5447. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5448. designer.SetDataSource("cell4Str", cell4Str);
  5449. designer.SetDataSource("cellStr", cellStr);
  5450. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5451. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5452. designer.SetDataSource("celllastStr", celllastStr);
  5453. Workbook wb = designer.Workbook;
  5454. var sheet = wb.Worksheets[0];
  5455. //绑定datatable数据集
  5456. designer.SetDataSource(dtdac1);
  5457. designer.SetDataSource(dtdac2);
  5458. designer.Process();
  5459. var rowStart = dtdac1.Rows.Count;
  5460. while (rowStart > 0)
  5461. {
  5462. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5463. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5464. startIndex++;
  5465. rowStart--;
  5466. }
  5467. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5468. startIndex += 1; //总计行
  5469. rowStart = dtdac2.Rows.Count;
  5470. while (rowStart > 0)
  5471. {
  5472. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5473. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5474. startIndex++;
  5475. rowStart--;
  5476. }
  5477. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5478. wb.CalculateFormula(true);
  5479. //模板文件名
  5480. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5481. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5482. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5483. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5484. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5485. }
  5486. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5487. {
  5488. //获取模板
  5489. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5490. //载入模板
  5491. Document doc = new Document(tempPath);
  5492. DocumentBuilder builder = new DocumentBuilder(doc);
  5493. Dictionary<string, string> dic = new Dictionary<string, string>();
  5494. dic.Add("GroupName", _DelegationInfo.TeamName);
  5495. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5496. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5497. string missionLeaderJob = "";//负责人job
  5498. int groupNumber = 0; //团人数
  5499. if (DeleClientList.Count > 0)
  5500. {
  5501. missionLeader = DeleClientList[0]?.Name ?? "";
  5502. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5503. }
  5504. dic.Add("MissionLeader", missionLeader); //团负责人
  5505. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5506. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5507. #region MyRegion
  5508. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5509. //{
  5510. // List<string> list = new List<string>();
  5511. // try
  5512. // {
  5513. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5514. // foreach (var item in spilitArr)
  5515. // {
  5516. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5517. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5518. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5519. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5520. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5521. // list.Add(depName);
  5522. // list.Add(arrName);
  5523. // }
  5524. // list = list.Distinct().ToList();
  5525. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5526. // }
  5527. // catch (Exception)
  5528. // {
  5529. // dic.Add("ReturnCode", "行程录入不正确!");
  5530. // }
  5531. //}
  5532. //else
  5533. //{
  5534. // dic.Add("ReturnCode", "未录入行程!");
  5535. //}
  5536. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5537. dic.Add("ReturnCode", string.Join("、", countrys));
  5538. #endregion
  5539. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5540. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5541. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5542. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5543. //{
  5544. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5545. // dic.Add("Day", sp.Days.ToString());
  5546. //}
  5547. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5548. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5549. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5550. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5551. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5552. //培训人员名单
  5553. int cultivateRowIndex = 7;
  5554. foreach (var item in DeleClientList)
  5555. {
  5556. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5557. builder.Write(item.Name);
  5558. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5559. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5560. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5561. string birthDay = "";
  5562. if (item.Birthday != null)
  5563. {
  5564. DateTime dt = Convert.ToDateTime(item.Birthday);
  5565. birthDay = $"{dt.Year}.{dt.Month}";
  5566. }
  5567. builder.Write(birthDay);
  5568. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5569. builder.Write(item.Company);
  5570. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5571. builder.Write(item.Job);
  5572. cultivateRowIndex++;
  5573. }
  5574. //删除多余行
  5575. //cultivateRowIndex -= 2;
  5576. int delRows = 10 + 7 - cultivateRowIndex;
  5577. if (delRows > 0)
  5578. {
  5579. for (int i = 0; i < delRows; i++)
  5580. {
  5581. table1.Rows.RemoveAt(cultivateRowIndex);
  5582. //cultivateRowIndex++;
  5583. }
  5584. }
  5585. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5586. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5587. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5588. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5589. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5590. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5591. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5592. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5593. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5594. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5595. //其他费用
  5596. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5597. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5598. //其他费用合计
  5599. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5600. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5601. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5602. //公务舱合计
  5603. //国际旅费
  5604. string outsideJJ = "";
  5605. string allPriceJJ = "";
  5606. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5607. {
  5608. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5609. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5610. }
  5611. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5612. {
  5613. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5614. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5615. }
  5616. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5617. {
  5618. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5619. dic.Add("AirFeeTotal", airFeeTotalStr);
  5620. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5621. dic.Add("FeeTotal", feeTotalStr);
  5622. }
  5623. foreach (var key in dic.Keys)
  5624. {
  5625. builder.MoveToBookmark(key);
  5626. builder.Write(dic[key]);
  5627. }
  5628. //模板文件名
  5629. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5630. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5631. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5632. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5633. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5634. }
  5635. }
  5636. else if (dto.ExportType == 2) //表格
  5637. {
  5638. //利用键值对存放数据
  5639. Dictionary<string, string> dic = new Dictionary<string, string>();
  5640. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5641. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5642. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5643. dic.Add("Day", sp.Days.ToString());
  5644. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5645. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5646. {
  5647. //获取模板
  5648. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5649. //载入模板
  5650. Document doc = new Document(tempPath);
  5651. DocumentBuilder builder = new DocumentBuilder(doc);
  5652. dic.Add("TeamName", _DelegationInfo.TeamName);
  5653. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5654. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5655. string missionLeaderName = "",
  5656. missionLeaderJob = "";
  5657. if (DeleClientList.Count > 0)
  5658. {
  5659. missionLeaderName = DeleClientList[0].Name;
  5660. missionLeaderJob = DeleClientList[0].Job;
  5661. }
  5662. dic.Add("MissionLeaderName", missionLeaderName);
  5663. dic.Add("MissionLeaderJob", missionLeaderJob);
  5664. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5665. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5666. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5667. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5668. int rowCount = 10;//总人数行
  5669. int startRowIndex = 7; //起始行
  5670. for (int i = 0; i < DeleClientList.Count; i++)
  5671. {
  5672. builder.MoveToCell(0, startRowIndex, 0, 0);
  5673. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5674. builder.MoveToCell(0, startRowIndex, 1, 0);
  5675. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5676. builder.Write(sex);//性别
  5677. builder.MoveToCell(0, startRowIndex, 2, 0);
  5678. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5679. builder.MoveToCell(0, startRowIndex, 3, 0);
  5680. builder.Write(DeleClientList[i].Company);//工作单位
  5681. builder.MoveToCell(0, startRowIndex, 4, 0);
  5682. builder.Write(DeleClientList[i].Job);//职务及级别
  5683. builder.MoveToCell(0, startRowIndex, 5, 0);
  5684. builder.Write("");//人员属性
  5685. builder.MoveToCell(0, startRowIndex, 6, 0);
  5686. builder.Write("");//上次出国时间
  5687. startRowIndex++;
  5688. }
  5689. int nullRow = rowCount - DeleClientList.Count;//空行
  5690. for (int i = 0; i < nullRow; i++)
  5691. {
  5692. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5693. }
  5694. foreach (var key in dic.Keys)
  5695. {
  5696. builder.MoveToBookmark(key);
  5697. builder.Write(dic[key]);
  5698. }
  5699. //模板文件名
  5700. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5701. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5702. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5703. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5704. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5705. }
  5706. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5707. {
  5708. //获取模板
  5709. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5710. //载入模板
  5711. Document doc = new Document(tempPath);
  5712. DocumentBuilder builder = new DocumentBuilder(doc);
  5713. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5714. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5715. dic.Add("Names", Names);
  5716. int accommodationRows = 12, foodandotherRows = 12;
  5717. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5718. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5719. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5720. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5721. int accommodationStartIndex = 6;
  5722. decimal dac1totalPrice = 0.00M;
  5723. foreach (var dac in dac1)
  5724. {
  5725. if (dac.SubTotal == 0)
  5726. {
  5727. continue;
  5728. }
  5729. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5730. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5731. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5732. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5733. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5734. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5735. builder.Write(currency);//币种
  5736. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5737. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5738. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5739. builder.Write("");//人数
  5740. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5741. builder.Write("");//天数
  5742. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5743. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5744. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5745. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5746. builder.Write(rate.ToString("#0.0000"));//汇率
  5747. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5748. decimal rbmPrice = rate * dac.SubTotal;
  5749. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5750. accommodationStartIndex++;
  5751. dac1totalPrice += rbmPrice;
  5752. }
  5753. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5754. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5755. builder.Write("小计");
  5756. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5757. builder.Write(dac1totalPrice.ToString("#0.00"));
  5758. accommodationStartIndex++;
  5759. int nullRow = accommodationRows - dac1.Count;
  5760. //删除空行
  5761. //if (nullRow > 0)
  5762. //{
  5763. // int rowIndex = accommodationStartIndex;
  5764. // for (int i = 0; i < nullRow; i++)
  5765. // {
  5766. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5767. // row.Remove();
  5768. // rowIndex++;
  5769. // }
  5770. //}
  5771. if (dac2.Count == dac3.Count)//国家 币种 金额
  5772. {
  5773. for (int i = 0; i < dac2.Count; i++)
  5774. {
  5775. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5776. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5777. }
  5778. }
  5779. int foodandotherStartIndex = 19;//
  5780. decimal dac2totalPrice = 0.00M;
  5781. foreach (var dac in dac2)
  5782. {
  5783. if (dac.SubTotal == 0)
  5784. {
  5785. continue;
  5786. }
  5787. //foodandotherStartIndex = 12;
  5788. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5789. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5790. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5791. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5792. builder.Write(currency);//币种
  5793. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5794. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5795. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5796. builder.Write("");//人数
  5797. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5798. builder.Write("");//天数
  5799. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5800. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5801. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5802. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5803. builder.Write(rate.ToString("#0.0000"));//汇率
  5804. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5805. decimal rbmPrice = rate * dac.SubTotal;
  5806. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5807. foodandotherStartIndex++;
  5808. dac2totalPrice += rbmPrice;
  5809. }
  5810. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5811. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5812. //删除空行
  5813. //if (dac2.Count < foodandotherRows)
  5814. //{
  5815. // while (table2.Rows.Count > dac2.Count)
  5816. // {
  5817. // table2.Rows.RemoveAt(dac2.Count);
  5818. // }
  5819. //}
  5820. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5821. string otherFeeStr = "";
  5822. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5823. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5824. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5825. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5826. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5827. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5828. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5829. foreach (var otherInfo in dac5)
  5830. {
  5831. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5832. }
  5833. #endregion
  5834. if (otherFeeStr.Length > 0)
  5835. {
  5836. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5837. otherFeeStr = $"({otherFeeStr})";
  5838. dic.Add("OtherFeeStr", otherFeeStr);
  5839. }
  5840. foreach (var key in dic.Keys)
  5841. {
  5842. builder.MoveToBookmark(key);
  5843. builder.Write(dic[key]);
  5844. }
  5845. //模板文件名
  5846. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5847. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5848. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5849. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5850. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5851. }
  5852. }
  5853. else if (dto.ExportType == 3)
  5854. {
  5855. if (dto.SubTypeId == 1) //团组成员名单
  5856. {
  5857. if (DeleClientList.Count < 1)
  5858. {
  5859. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5860. }
  5861. //获取模板
  5862. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5863. //载入模板
  5864. Document doc = new Document(tempPath);
  5865. DocumentBuilder builder = new DocumentBuilder(doc);
  5866. //获取word里所有表格
  5867. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5868. //获取所填表格的序数
  5869. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5870. var rowStart = tableOne.Rows[0]; //获取第1行
  5871. //循环赋值
  5872. for (int i = 0; i < DeleClientList.Count; i++)
  5873. {
  5874. builder.MoveToCell(0, i + 1, 0, 0);
  5875. builder.Write(DeleClientList[i].Name);
  5876. builder.MoveToCell(0, i + 1, 1, 0);
  5877. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5878. builder.Write(sex);
  5879. builder.MoveToCell(0, i + 1, 2, 0);
  5880. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5881. builder.MoveToCell(0, i + 1, 3, 0);
  5882. builder.Write(DeleClientList[i].Company);
  5883. builder.MoveToCell(0, i + 1, 4, 0);
  5884. builder.Write(DeleClientList[i].Job);
  5885. }
  5886. //删除多余行
  5887. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5888. {
  5889. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5890. }
  5891. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5892. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5893. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5894. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5895. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5896. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5897. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5898. }
  5899. }
  5900. return Ok(JsonView(400, "操作失败!", ""));
  5901. }
  5902. catch (Exception ex)
  5903. {
  5904. return Ok(JsonView(400, ex.Message, ""));
  5905. }
  5906. }
  5907. /// <summary>
  5908. /// 获取三公费用标准city
  5909. /// </summary>
  5910. /// <param name="placeData"></param>
  5911. /// <param name="nationalTravelFeeId"></param>
  5912. /// <returns></returns>
  5913. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5914. {
  5915. string _city = string.Empty;
  5916. if (placeData.Count < 1) return _city;
  5917. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5918. if (data == null) return _city;
  5919. string country = data.Country;
  5920. string city = data.City;
  5921. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5922. else _city = city;
  5923. return _city;
  5924. }
  5925. /// <summary>
  5926. /// 团组模块 - 出入境费用 - 明细表导出
  5927. /// </summary>
  5928. /// <returns></returns>
  5929. [HttpPost]
  5930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5931. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5932. {
  5933. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5934. if (data.Code != 0)
  5935. {
  5936. return Ok(JsonView(false, data.Msg));
  5937. }
  5938. return Ok(JsonView(true, data.Msg, data.Data));
  5939. }
  5940. /// <summary>
  5941. /// 团组模块 - 出入境费用 - 一键清空
  5942. /// </summary>
  5943. /// <returns></returns>
  5944. [HttpPost]
  5945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5946. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5947. {
  5948. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5949. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5950. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5951. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5952. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5953. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5954. .SetColumns(x => new Grp_DayOtherPrice
  5955. {
  5956. IsDel = 1,
  5957. DeleteUserId = dto.UserId,
  5958. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5959. })
  5960. .ExecuteCommandAsync();
  5961. if (_view.Code == 0)
  5962. {
  5963. return Ok(JsonView(true, "操作成功"));
  5964. }
  5965. return Ok(JsonView(false, "操作失败"));
  5966. }
  5967. /// <summary>
  5968. /// 团组模块 - 出入境费用 - 子项删除
  5969. /// </summary>
  5970. /// <returns></returns>
  5971. [HttpPost]
  5972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5973. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5974. {
  5975. try
  5976. {
  5977. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5978. if (data.Code != 0)
  5979. {
  5980. return Ok(JsonView(false, data.Msg));
  5981. }
  5982. return Ok(JsonView(true, "操作成功!", data.Data));
  5983. }
  5984. catch (Exception ex)
  5985. {
  5986. return Ok(JsonView(false, ex.Message));
  5987. }
  5988. }
  5989. /// <summary>
  5990. /// 删除三公其他费用
  5991. /// </summary>
  5992. /// <param name="dto"></param>
  5993. /// <returns></returns>
  5994. [HttpPost]
  5995. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  5996. {
  5997. var jw = JsonView(false,"删除失败!");
  5998. var data = new Grp_DayOtherPrice()
  5999. {
  6000. Id = dto.Id,
  6001. IsDel = 1,
  6002. DeleteUserId = dto.DeleteUserId,
  6003. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6004. };
  6005. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6006. if (del > 0)
  6007. {
  6008. jw.Code = 200;
  6009. jw.Msg = "删除成功!";
  6010. }
  6011. return Ok(jw);
  6012. }
  6013. /// <summary>
  6014. /// 团组模块 - 出入境国家费用标准 List
  6015. /// </summary>
  6016. /// <returns></returns>
  6017. [HttpPost]
  6018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6019. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6020. {
  6021. try
  6022. {
  6023. Stopwatch sw = new Stopwatch();
  6024. sw.Start();
  6025. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6026. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6027. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6028. Where gntf.Isdel = 0");
  6029. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6030. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6031. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6032. //foreach (var item in nationalTravel)
  6033. //{
  6034. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6035. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6036. // if (otherData != null)
  6037. // {
  6038. // cityData.Remove(otherData);
  6039. // cityData.Add(otherData);
  6040. // }
  6041. // nationalTravelFeeData1.Add(new
  6042. // {
  6043. // Country = item.Country,
  6044. // CityData = cityData
  6045. // });
  6046. //}
  6047. sw.Stop();
  6048. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6049. }
  6050. catch (Exception ex)
  6051. {
  6052. return Ok(JsonView(false, ex.Message));
  6053. throw;
  6054. }
  6055. }
  6056. /// <summary>
  6057. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6058. /// </summary>
  6059. /// <returns></returns>
  6060. [HttpPost]
  6061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6062. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6063. {
  6064. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6065. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6066. List<string> countryData = new List<string>();
  6067. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6068. countryData = countryData.Distinct().ToList();
  6069. List<dynamic> dataSource = new List<dynamic>();
  6070. foreach (var item in countryData)
  6071. {
  6072. List<string> cityData1 = new List<string>();
  6073. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6074. var countryData2 = new
  6075. {
  6076. CountryName = item,
  6077. CityData = cityData1
  6078. };
  6079. dataSource.Add(countryData2);
  6080. }
  6081. return Ok(JsonView(true, "查询成功!", dataSource));
  6082. }
  6083. /// <summary>
  6084. /// 团组模块 - 出入境国家费用标准 Page List
  6085. /// </summary>
  6086. /// <returns></returns>
  6087. [HttpPost]
  6088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6089. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6090. {
  6091. int portId = dto.PortType;
  6092. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6093. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6094. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6095. string whereSql = string.Empty;
  6096. if (!string.IsNullOrEmpty(dto.Country))
  6097. {
  6098. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6099. }
  6100. if (!string.IsNullOrEmpty(dto.City))
  6101. {
  6102. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6103. }
  6104. string pageSql = string.Format(@"Select * From (
  6105. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6106. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6107. From Grp_NationalTravelFee gntf
  6108. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6109. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6110. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6111. RefAsync<int> total = 0;
  6112. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6113. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6114. }
  6115. /// <summary>
  6116. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6117. /// </summary>
  6118. /// <returns></returns>
  6119. [HttpPost]
  6120. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6121. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6122. {
  6123. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6124. int portId = dto.PortType;
  6125. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6126. string whereSql = string.Empty;
  6127. if (!string.IsNullOrEmpty(dto.Country))
  6128. {
  6129. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6130. }
  6131. if (!string.IsNullOrEmpty(dto.City))
  6132. {
  6133. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6134. }
  6135. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6136. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6137. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6138. From Grp_NationalTravelFee gntf
  6139. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6140. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6141. Where gntf.Isdel = 0 {0} ", whereSql);
  6142. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6143. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6144. }
  6145. /// <summary>
  6146. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6147. /// </summary>
  6148. /// <returns></returns>
  6149. [HttpPost]
  6150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6151. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6152. {
  6153. try
  6154. {
  6155. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6156. if (data.Code != 0)
  6157. {
  6158. return Ok(JsonView(false, data.Msg));
  6159. }
  6160. return Ok(JsonView(true, "操作成功!", data.Data));
  6161. }
  6162. catch (Exception ex)
  6163. {
  6164. return Ok(JsonView(false, ex.Message));
  6165. }
  6166. }
  6167. /// <summary>
  6168. /// 团组模块 - 出入境国家费用标准 - Del
  6169. /// </summary>
  6170. /// <returns></returns>
  6171. [HttpPost]
  6172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6173. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6174. {
  6175. try
  6176. {
  6177. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6178. {
  6179. Id = dto.Id,
  6180. DeleteUserId = dto.DeleteUserId,
  6181. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6182. IsDel = 1
  6183. };
  6184. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6185. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6186. .WhereColumns(it => new { it.Id })
  6187. .ExecuteCommandAsync();
  6188. if (delStatus <= 0)
  6189. {
  6190. return Ok(JsonView(false, "删除失败!"));
  6191. }
  6192. return Ok(JsonView(true, "操作成功!"));
  6193. }
  6194. catch (Exception ex)
  6195. {
  6196. return Ok(JsonView(false, ex.Message));
  6197. }
  6198. }
  6199. /// <summary>
  6200. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6201. /// 注:Get 请求Headers 加 Token
  6202. /// </summary>
  6203. /// <param name="groupId"></param>
  6204. /// <returns></returns>
  6205. [HttpGet("{groupId}")]
  6206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6207. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6208. {
  6209. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6210. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6211. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6212. data.ForEach(x =>
  6213. {
  6214. x.CreateUserId = _currUserInfo.UserId;
  6215. });
  6216. if (data.Count > 0)
  6217. {
  6218. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6219. if (add > 0)
  6220. {
  6221. return Ok(JsonView(true, "操作成功!"));
  6222. }
  6223. }
  6224. return Ok(JsonView(false, "未操作!"));
  6225. }
  6226. #endregion
  6227. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6228. /// <summary>
  6229. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6230. /// </summary>
  6231. /// <returns></returns>
  6232. [HttpPost]
  6233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6234. public async Task<IActionResult> PostEnterExitCostMobileDataSource(PortDtoBase dto)
  6235. {
  6236. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6237. //SetDataInfoView
  6238. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6239. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6240. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6241. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6242. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6243. //默认币种显示
  6244. var _currencyInfos = _currencyInit;
  6245. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6246. if (_currencyRate.Count > 0)
  6247. {
  6248. foreach (var item in _currencyInfos)
  6249. {
  6250. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6251. if (rateInfo != null)
  6252. {
  6253. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6254. rate1 *= 1.035M;
  6255. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6256. }
  6257. }
  6258. }
  6259. return Ok(JsonView(true, "查询成功!", new
  6260. {
  6261. WordTypeData = _WordTypeData,
  6262. ExcelTypeData = _ExcelTypeData,
  6263. CurrencyInit = _currencyInfos
  6264. }));
  6265. }
  6266. /// <summary>
  6267. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6268. /// </summary>
  6269. /// <returns></returns>
  6270. [HttpPost]
  6271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6272. public async Task<IActionResult> PostEnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6273. {
  6274. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6275. RefAsync<int> total = 0;
  6276. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6277. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6278. .WhereIF(!string.IsNullOrEmpty(dto.GroupName), x => x.TeamName.Contains(dto.GroupName))
  6279. .Select(x => new
  6280. {
  6281. Id = x.Id,
  6282. GroupName = x.TeamName
  6283. })
  6284. .OrderByDescending(x => x.Id)
  6285. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6286. return Ok(JsonView(true, "查询成功!", data, total));
  6287. }
  6288. /// <summary>
  6289. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6290. /// </summary>
  6291. /// <returns></returns>
  6292. [HttpPost]
  6293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6294. public async Task<IActionResult> PostEnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6295. {
  6296. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6297. RefAsync<int> total = 0;
  6298. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6299. .Where(x => x.IsDel == 0 && x.STid == 66)
  6300. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6301. .Select(x => new
  6302. {
  6303. id = x.Id,
  6304. name = x.Name,
  6305. remark = x.Remark,
  6306. })
  6307. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6308. return Ok(JsonView(true, "查询成功!", data, total));
  6309. }
  6310. /// <summary>
  6311. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6312. /// </summary>
  6313. /// <returns></returns>
  6314. [HttpPost]
  6315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6316. public async Task<IActionResult> PostEnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6317. {
  6318. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6319. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6320. var tipsData = new List<int>() {1,2,3 };
  6321. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6322. if (dto.TipsType == 1)
  6323. {
  6324. //默认币种显示
  6325. var _currencyInfos = _currencyInit;
  6326. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6327. List<dynamic> reteInfos = new List<dynamic>();
  6328. if (_currencyRate.Count > 0)
  6329. {
  6330. foreach (var item in _currencyInfos)
  6331. {
  6332. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6333. if (rateInfo != null)
  6334. {
  6335. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6336. decimal rate1 = item.Rate;
  6337. rate1 *= 1.03M;
  6338. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6339. reteInfos.Add(new
  6340. {
  6341. currCode = item.CurrencyCode,
  6342. currName = item.CurrencyName,
  6343. rate = rate2,
  6344. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6345. });
  6346. }
  6347. }
  6348. }
  6349. return Ok(JsonView(true, "查询成功!", reteInfos));
  6350. }
  6351. else if (dto.TipsType == 2)
  6352. {
  6353. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6354. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6355. }
  6356. else if (dto.TipsType == 3)
  6357. {
  6358. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6359. return Ok(JsonView(true, "查询成功!", airData.Data));
  6360. }
  6361. return Ok(JsonView(false));
  6362. }
  6363. /// <summary>
  6364. /// 团组模块 - 出入境国家费用标准 List
  6365. /// </summary>
  6366. /// <returns></returns>
  6367. [HttpPost]
  6368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6369. public async Task<IActionResult> PostNationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6370. {
  6371. Stopwatch sw = new Stopwatch();
  6372. sw.Start();
  6373. RefAsync<int> total = 0;
  6374. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6375. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6376. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6377. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6378. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6379. .Select((ntf, sd, u) => new
  6380. {
  6381. Id = ntf.Id,
  6382. Area = $"{ntf.Country}-{ntf.City}",
  6383. Currency = ntf.Currency,
  6384. CurrencyCode = sd.Name,
  6385. CurrencyName = sd.Remark,
  6386. RoomCost = ntf.RoomCost,
  6387. FoodCost = ntf.FoodCost,
  6388. PublicCost = ntf.PublicCost,
  6389. LastUpdateUserId = ntf.LastUpdateUserId,
  6390. LastUpdateUserName = u.CnName,
  6391. LastUpdateTime = ntf.LastUpdateTime,
  6392. })
  6393. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6394. sw.Stop();
  6395. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6396. }
  6397. #endregion
  6398. #region 签证费用录入
  6399. /// <summary>
  6400. /// 根据diid查询签证费用列表
  6401. /// </summary>
  6402. /// <param name="dto"></param>
  6403. /// <returns></returns>
  6404. [HttpPost]
  6405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6406. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6407. {
  6408. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6409. if (groupData.Code != 0)
  6410. {
  6411. return Ok(JsonView(false, groupData.Msg));
  6412. }
  6413. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6414. }
  6415. /// <summary>
  6416. /// 根据签证费用Id查询单条数据及c表数据
  6417. /// </summary>
  6418. /// <param name="dto"></param>
  6419. /// <returns></returns>
  6420. [HttpPost]
  6421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6422. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6423. {
  6424. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6425. if (groupData.Code != 0)
  6426. {
  6427. return Ok(JsonView(false, groupData.Msg));
  6428. }
  6429. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6430. }
  6431. /// <summary>
  6432. /// 签证费用删除
  6433. /// </summary>
  6434. /// <param name="dto"></param>
  6435. /// <returns></returns>
  6436. [HttpPost]
  6437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6438. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6439. {
  6440. _sqlSugar.BeginTran();
  6441. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6442. if (!res)
  6443. {
  6444. _sqlSugar.RollbackTran();
  6445. return Ok(JsonView(false, "删除失败"));
  6446. }
  6447. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6448. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6449. .SetColumns(a => new Grp_CreditCardPayment()
  6450. {
  6451. IsDel = 1,
  6452. DeleteUserId = dto.DeleteUserId,
  6453. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6454. })
  6455. .ExecuteCommand();
  6456. if (resSub < 1)
  6457. {
  6458. _sqlSugar.RollbackTran();
  6459. return Ok(JsonView(false, "删除失败"));
  6460. }
  6461. _sqlSugar.CommitTran();
  6462. return Ok(JsonView(true, "删除成功!"));
  6463. }
  6464. /// <summary>
  6465. /// 签证费用录入下拉框初始化
  6466. /// </summary>
  6467. /// <returns></returns>
  6468. [HttpPost]
  6469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6470. public async Task<IActionResult> VisaPriceAddSelect()
  6471. {
  6472. //支付方式
  6473. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6474. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6475. //币种
  6476. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6477. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6478. //乘客类型
  6479. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6480. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6481. //卡类型
  6482. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6483. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6484. //代办费类型
  6485. var agencyFeeTypeData = new List<dynamic>() {
  6486. new { id = 0 , Text = "未选择" },
  6487. new { id = 1 , Text = "小公务" },
  6488. new { id = 2 , Text = "大公务" },
  6489. };
  6490. //签证费用标准国家Data
  6491. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  6492. var data = new
  6493. {
  6494. Payment = _Payment,
  6495. CurrencyList = _CurrencyList,
  6496. PassengerType = _PassengerType,
  6497. BankCard = _BankCard,
  6498. AgencyFeeType = agencyFeeTypeData,
  6499. CountryFeeData = visaCountryFeeData
  6500. };
  6501. return Ok(JsonView(true, "查询成功!", data));
  6502. }
  6503. /// <summary>
  6504. /// 签证费用录入操作(Status:1.新增,2.修改)
  6505. /// </summary>
  6506. /// <param name="dto"></param>
  6507. /// <returns></returns>
  6508. [HttpPost]
  6509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6510. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6511. {
  6512. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6513. if (groupData.Code != 0)
  6514. {
  6515. return Ok(JsonView(false, groupData.Msg));
  6516. }
  6517. #region 应用推送
  6518. try
  6519. {
  6520. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6521. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6522. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6523. //2024-10-21 新增LZ UID
  6524. var userIds = new List<int>() { 21 };
  6525. string title = $"系统通知";
  6526. string content = "";
  6527. var diId = dto.DiId;
  6528. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6529. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6530. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6531. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6532. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6533. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  6534. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6535. }
  6536. catch (Exception ex)
  6537. {
  6538. }
  6539. #endregion
  6540. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6541. }
  6542. #endregion
  6543. #region 签证提成录入
  6544. /// <summary>
  6545. /// 签证提成录入
  6546. /// 基础数据
  6547. /// </summary>
  6548. /// <param name="_dto"></param>
  6549. /// <returns></returns>
  6550. [HttpGet]
  6551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6552. public async Task<IActionResult> VisaCommissionInit()
  6553. {
  6554. return Ok(await _visaCommissionRep.Init());
  6555. }
  6556. /// <summary>
  6557. /// 签证提成录入
  6558. /// Item
  6559. /// </summary>
  6560. /// <param name="_dto"></param>
  6561. /// <returns></returns>
  6562. [HttpPost]
  6563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6564. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6565. {
  6566. var validator = new VisaCommissionItemDtoValidator();
  6567. var validatorRes = await validator.ValidateAsync(_dto);
  6568. if (!validatorRes.IsValid)
  6569. {
  6570. StringBuilder sb = new StringBuilder();
  6571. foreach (var item in validatorRes.Errors)
  6572. {
  6573. sb.AppendLine(item.ErrorMessage);
  6574. }
  6575. return Ok(JsonView(false, sb.ToString()));
  6576. }
  6577. return Ok(await _visaCommissionRep.Item(_dto));
  6578. }
  6579. /// <summary>
  6580. /// 签证提成录入
  6581. /// Save
  6582. /// </summary>
  6583. /// <param name="_dto"></param>
  6584. /// <returns></returns>
  6585. [HttpPost]
  6586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6587. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6588. {
  6589. //参数验证
  6590. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6591. foreach (var item in _dto.Items)
  6592. {
  6593. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6594. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6595. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6596. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6597. }
  6598. return Ok(await _visaCommissionRep.Save(_dto));
  6599. }
  6600. /// <summary>
  6601. /// 签证提成录入
  6602. /// Create
  6603. /// </summary>
  6604. /// <param name="_dto"></param>
  6605. /// <returns></returns>
  6606. [HttpPost]
  6607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6608. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6609. {
  6610. var validator = new VisaCommissionCreateDtoValidator();
  6611. var validatorRes = await validator.ValidateAsync(_dto);
  6612. if (!validatorRes.IsValid)
  6613. {
  6614. StringBuilder sb = new StringBuilder();
  6615. foreach (var item in validatorRes.Errors)
  6616. {
  6617. sb.AppendLine(item.ErrorMessage);
  6618. }
  6619. return Ok(JsonView(false, sb.ToString()));
  6620. }
  6621. return Ok(await _visaCommissionRep.Create(_dto));
  6622. }
  6623. /// <summary>
  6624. /// 签证提成录入
  6625. /// Put(编辑)
  6626. /// </summary>
  6627. /// <param name="id"></param>
  6628. /// <param name="_dto"></param>
  6629. /// <returns></returns>
  6630. [HttpPut]
  6631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6632. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6633. {
  6634. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6635. var validator = new VisaCommissionCreateDtoValidator();
  6636. var validatorRes = await validator.ValidateAsync(_dto);
  6637. if (!validatorRes.IsValid)
  6638. {
  6639. StringBuilder sb = new StringBuilder();
  6640. foreach (var item in validatorRes.Errors)
  6641. {
  6642. sb.AppendLine(item.ErrorMessage);
  6643. }
  6644. return Ok(JsonView(false, sb.ToString()));
  6645. }
  6646. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6647. }
  6648. /// <summary>
  6649. /// 签证提成录入
  6650. /// Del
  6651. /// </summary>
  6652. /// <param name="id"></param>
  6653. /// <param name="currUserId"></param>
  6654. /// <returns></returns>
  6655. [HttpPost]
  6656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6657. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6658. {
  6659. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6660. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6661. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6662. }
  6663. #endregion
  6664. #region op费用录入
  6665. /// <summary>
  6666. /// 根据diid查询op费用列表
  6667. /// </summary>
  6668. /// <param name="dto"></param>
  6669. /// <returns></returns>
  6670. [HttpPost]
  6671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6672. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6673. {
  6674. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6675. if (groupData.Code != 0)
  6676. {
  6677. return Ok(JsonView(false, groupData.Msg));
  6678. }
  6679. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6680. }
  6681. /// <summary>
  6682. /// 根据op费用Id查询单条数据及c表数据
  6683. /// </summary>
  6684. /// <param name="dto"></param>
  6685. /// <returns></returns>
  6686. [HttpPost]
  6687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6688. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6689. {
  6690. try
  6691. {
  6692. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6693. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6694. var data = new
  6695. {
  6696. CarTouristGuideGround = _groupData,
  6697. CreditCardPayment = _creditCardPayment
  6698. };
  6699. return Ok(JsonView(true, "查询成功!", data));
  6700. }
  6701. catch (Exception ex)
  6702. {
  6703. return Ok(JsonView(false, "程序错误!"));
  6704. }
  6705. }
  6706. /// <summary>
  6707. /// op费用删除
  6708. /// </summary>
  6709. /// <param name="dto"></param>
  6710. /// <returns></returns>
  6711. [HttpPost]
  6712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6713. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6714. {
  6715. try
  6716. {
  6717. _sqlSugar.BeginTran();
  6718. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6719. if (!res)
  6720. {
  6721. return Ok(JsonView(false, "删除失败"));
  6722. }
  6723. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6724. {
  6725. IsDel = 1,
  6726. DeleteUserId = dto.DeleteUserId,
  6727. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6728. }).ExecuteCommandAsync();
  6729. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6730. {
  6731. IsDel = 1,
  6732. DeleteUserId = dto.DeleteUserId,
  6733. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6734. }).ExecuteCommandAsync();
  6735. #region 删除超支相关数据
  6736. //删除导入的超支数据
  6737. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6738. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6739. {
  6740. IsDel = 1,
  6741. DeleteUserId = dto.DeleteUserId,
  6742. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6743. }).ExecuteCommand();
  6744. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6745. {
  6746. IsDel = 1,
  6747. DeleteUserId = dto.DeleteUserId,
  6748. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6749. }).ExecuteCommand();
  6750. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6751. {
  6752. IsDel = 1,
  6753. DeleteUserId = dto.DeleteUserId,
  6754. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6755. }).ExecuteCommand();
  6756. #endregion
  6757. _sqlSugar.CommitTran();
  6758. return Ok(JsonView(true, "删除成功!"));
  6759. }
  6760. catch (Exception ex)
  6761. {
  6762. _sqlSugar.RollbackTran();
  6763. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6764. }
  6765. }
  6766. /// <summary>
  6767. /// op费用录入操作(Status:1.新增,2.修改)
  6768. /// </summary>
  6769. /// <param name="dto"></param>
  6770. /// <returns></returns>
  6771. [HttpPost]
  6772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6773. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6774. {
  6775. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6776. if (groupData.Code != 0)
  6777. {
  6778. return Ok(JsonView(false, groupData.Msg));
  6779. }
  6780. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6781. }
  6782. /// <summary>
  6783. /// 填写费用详细页面初始化绑定
  6784. /// </summary>
  6785. /// <param name="dto"></param>
  6786. /// <returns></returns>
  6787. [HttpPost]
  6788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6789. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6790. {
  6791. try
  6792. {
  6793. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6794. if (groupData.Code != 0)
  6795. {
  6796. return Ok(JsonView(false, groupData.Msg));
  6797. }
  6798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6799. }
  6800. catch (Exception ex)
  6801. {
  6802. return Ok(JsonView(false, ex.Message));
  6803. }
  6804. }
  6805. /// <summary>
  6806. /// 根据op费用Id查询详细数据
  6807. /// </summary>
  6808. /// <param name="dto"></param>
  6809. /// <returns></returns>
  6810. [HttpPost]
  6811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6812. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6813. {
  6814. try
  6815. {
  6816. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6817. if (groupData.Code != 0)
  6818. {
  6819. return Ok(JsonView(false, groupData.Msg));
  6820. }
  6821. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6822. }
  6823. catch (Exception ex)
  6824. {
  6825. return Ok(JsonView(false, ex.Message));
  6826. }
  6827. }
  6828. /// <summary>
  6829. /// OP费用录入填写详情
  6830. /// </summary>
  6831. /// <param name="dto"></param>
  6832. /// <returns></returns>
  6833. [HttpPost]
  6834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6835. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6836. {
  6837. try
  6838. {
  6839. #region 参数校验
  6840. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6841. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6842. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6843. #endregion
  6844. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6845. if (groupData.Code != 0)
  6846. {
  6847. return Ok(JsonView(false, groupData.Msg));
  6848. }
  6849. //自动审核
  6850. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6851. #region 应用推送
  6852. try
  6853. {
  6854. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6855. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6856. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6857. //2024-10-21 新增LZ UID
  6858. var userIds = new List<int>() { 21 };
  6859. string title = $"系统通知";
  6860. var diId = dto.DiId;
  6861. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6862. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6863. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  6864. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6865. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  6866. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6867. }
  6868. catch (Exception ex)
  6869. {
  6870. }
  6871. #endregion
  6872. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6873. }
  6874. catch (Exception ex)
  6875. {
  6876. return Ok(JsonView(false, ex.Message));
  6877. }
  6878. }
  6879. /// <summary>
  6880. /// 获取三公详细所有城市
  6881. /// </summary>
  6882. /// <returns></returns>
  6883. [HttpGet]
  6884. public IActionResult OpCarCityResult()
  6885. {
  6886. var jw = JsonView(false);
  6887. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6888. {
  6889. x.Id,
  6890. x.Country,
  6891. x.City,
  6892. }).ToList();
  6893. if (data.Count > 0)
  6894. {
  6895. jw = JsonView(true, "获取成功!", data);
  6896. }
  6897. else
  6898. {
  6899. jw.Msg = "城市数据为空!";
  6900. jw.Data = new string[0];
  6901. }
  6902. return Ok(jw);
  6903. }
  6904. /// <summary>
  6905. /// 导出地接费用明细
  6906. /// </summary>
  6907. /// <param name="dto"></param>
  6908. /// <returns></returns>
  6909. [HttpPost]
  6910. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6911. {
  6912. var jw = JsonView(false);
  6913. if (dto.Diid < 1)
  6914. {
  6915. jw.Msg = "请输入正确的diid!";
  6916. return Ok(jw);
  6917. }
  6918. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6919. if (group == null)
  6920. {
  6921. jw.Msg = "未找到团组信息!";
  6922. return Ok(jw);
  6923. }
  6924. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6925. if (localGuideArr.Count == 0)
  6926. {
  6927. jw.Msg = "该团组暂无地接信息!";
  6928. return Ok(jw);
  6929. }
  6930. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6931. var overspendSoure = new Dictionary<int, int>
  6932. {
  6933. { 91, 982 }, //车
  6934. { 92 , 1059} ,//导游
  6935. { 994 , 1073}, //翻译
  6936. { 988 , 1074 }, //早餐
  6937. { 93 , 1075 }, //午餐
  6938. { 989 , 1076 }, //晚餐
  6939. };
  6940. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6941. foreach (var groupArr in localGroup)
  6942. {
  6943. var keyValue = groupArr.Key;
  6944. if (int.TryParse(keyValue, out int cityid))
  6945. {
  6946. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6947. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6948. }
  6949. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6950. foreach (var item in groupArr)
  6951. {
  6952. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6953. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6954. new Grp_CarTouristGuideGroundReservationsContentExtend
  6955. {
  6956. Count = a.Count,
  6957. CreateTime = a.CreateTime,
  6958. CreateUserId = a.CreateUserId,
  6959. CTGGRId = a.CTGGRId,
  6960. Currency = a.Currency,
  6961. DatePrice = a.DatePrice,
  6962. DeleteTime = a.DeleteTime,
  6963. DeleteUserId = a.DeleteUserId,
  6964. DiId = a.DiId,
  6965. Id = a.Id,
  6966. IsDel = a.IsDel,
  6967. Price = a.Price,
  6968. PriceContent = a.PriceContent,
  6969. Remark = a.Remark,
  6970. SId = a.SId,
  6971. SidName = b.Name,
  6972. Units = a.Units,
  6973. }
  6974. ).ToList();
  6975. if (content.Count > 0)
  6976. {
  6977. contentArr.Add(content);
  6978. }
  6979. }
  6980. //open excel
  6981. //set excel
  6982. //save excel
  6983. try
  6984. {
  6985. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6986. IWorkbook workbook;
  6987. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6988. {
  6989. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6990. }
  6991. else
  6992. {
  6993. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6994. }
  6995. ISheet sheet = workbook.GetSheetAt(0);
  6996. var rowStartIndex = 2;
  6997. var clounmCount = 10;
  6998. var initStyleRow = sheet.GetRow(2);
  6999. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7000. //var overspendArrDetail =
  7001. var existsId = new List<CarCompare>();
  7002. var lastElem = arr.Last();
  7003. var thisSid = -1;
  7004. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7005. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7006. {
  7007. Name = "未知币种!",
  7008. Remark = "未知币种!",
  7009. };
  7010. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7011. Action cloneRowFn = () =>
  7012. {
  7013. rowStartIndex++;
  7014. var cloneRow = sheet.CreateRow(rowStartIndex);
  7015. // 复制样式
  7016. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7017. {
  7018. ICell sourceCell = initStyleRow.GetCell(i);
  7019. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7020. // 确保单元格存在样式
  7021. if (sourceCell.CellStyle != null)
  7022. {
  7023. targetCell.CellStyle = sourceCell.CellStyle;
  7024. }
  7025. }
  7026. };
  7027. var mergeRow = () =>
  7028. {
  7029. for (int i = 2; i < sheet.LastRowNum; i++)
  7030. {
  7031. var row = sheet.GetRow(i);
  7032. var cellFirst = row.GetCell(0);
  7033. var thisIndex = i + 1;
  7034. while (thisIndex < sheet.LastRowNum)
  7035. {
  7036. var nextRow = sheet.GetRow(thisIndex);
  7037. var nextCellFirst = nextRow.GetCell(0);
  7038. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7039. {
  7040. thisIndex++;
  7041. }
  7042. else
  7043. {
  7044. break;
  7045. }
  7046. }
  7047. thisIndex--;
  7048. if (thisIndex != i)
  7049. {
  7050. //合并row
  7051. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7052. i, // 起始行索引(0-based)
  7053. thisIndex, // 结束行索引(0-based)
  7054. 0, // 起始列索引(0-based)
  7055. 0 // 结束列索引(0-based)
  7056. );
  7057. sheet.AddMergedRegion(cellRangeAddress);
  7058. i = thisIndex;
  7059. }
  7060. }
  7061. };
  7062. var chaoshiNumber = 0;
  7063. var totalNumber = 0.00M;
  7064. string lastStr = "";
  7065. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7066. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7067. {
  7068. b.IsAuditGM,
  7069. x.Id,
  7070. x.Area,
  7071. b.PayPercentage,
  7072. b.PayMoney,
  7073. }).ToList();
  7074. string yesPayment = "", noPayment = "";
  7075. foreach (var item in queryCarArrByCityAndDiid)
  7076. {
  7077. if (item.IsAuditGM == 1)
  7078. {
  7079. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7080. }
  7081. else
  7082. {
  7083. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7084. }
  7085. }
  7086. lastStr = yesPayment + noPayment;
  7087. foreach (var item in arr)
  7088. {
  7089. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  7090. {
  7091. if (thisSid != item.SId)
  7092. {
  7093. if (thisSid == -1)
  7094. {
  7095. thisSid = item.SId;
  7096. }
  7097. else
  7098. {
  7099. //合并小计行
  7100. //创建合并区域的实例
  7101. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7102. rowStartIndex, // 起始行索引(0-based)
  7103. rowStartIndex, // 结束行索引(0-based)
  7104. 0, // 起始列索引(0-based)
  7105. 3 // 结束列索引(0-based)
  7106. );
  7107. sheet.AddMergedRegion(cellRangeAddress);
  7108. var CellStyle = workbook.CreateCellStyle();
  7109. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7110. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7111. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7112. for (int i = 0; i <= clounmCount; i++)
  7113. {
  7114. if (i > 6)
  7115. {
  7116. var CellStyle1 = workbook.CreateCellStyle();
  7117. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7118. IFont Font = workbook.CreateFont(); // 创建字体
  7119. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7120. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7121. CellStyle1.SetFont(Font);
  7122. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7123. }
  7124. else
  7125. {
  7126. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7127. }
  7128. }
  7129. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7130. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7131. //超时合计
  7132. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7133. //超时数
  7134. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7135. //超时合计费用
  7136. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7137. thisSid = item.SId;
  7138. cloneRowFn();
  7139. chaoshiNumber = 0;
  7140. totalNumber = 0;
  7141. }
  7142. }
  7143. IRow row = sheet.GetRow(rowStartIndex);
  7144. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7145. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  7146. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  7147. if (isOpenOverspendSoure)
  7148. {
  7149. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7150. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  7151. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  7152. }
  7153. for (int i = 0; i <= clounmCount; i++)
  7154. {
  7155. var cell = row.GetCell(i);
  7156. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  7157. if (cell == null)
  7158. {
  7159. cell = row.CreateCell(i);
  7160. }
  7161. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  7162. fontRed.CloneStyleFrom(cell.CellStyle);
  7163. IFont Font = workbook.CreateFont(); // 创建字体
  7164. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  7165. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7166. fontRed.SetFont(Font);
  7167. byte[] rgb = new byte[3] { 255, 242, 204 };
  7168. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  7169. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  7170. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  7171. if (workbook is XSSFWorkbook)
  7172. {
  7173. BackgroundColor255_242_204.FillForegroundColor = 0;
  7174. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  7175. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  7176. }
  7177. else
  7178. {
  7179. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  7180. }
  7181. if (i == 1 || i > 6)
  7182. {
  7183. if (i > 6)
  7184. {
  7185. fontRed.FillForegroundColor = 0;
  7186. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  7187. fontRed.FillPattern = FillPattern.SolidForeground;
  7188. }
  7189. cell.CellStyle = fontRed;
  7190. }
  7191. if (i > 2 && i < 7)
  7192. {
  7193. cell.CellStyle = BackgroundColor255_242_204;
  7194. }
  7195. cell.SetCellValue(setCellValue); //写入单元格
  7196. }
  7197. if (overspendSoure.ContainsKey(thisSid))
  7198. {
  7199. var overspendId = overspendSoure[thisSid];
  7200. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7201. }
  7202. cloneRowFn();
  7203. existsId.Add(new CarCompare
  7204. {
  7205. DataPrice = item.DatePrice.ObjToDate(),
  7206. Sid = item.SId
  7207. });
  7208. }
  7209. if (item.Equals(lastElem))
  7210. {
  7211. //合并小计行
  7212. //创建合并区域的实例
  7213. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7214. rowStartIndex, // 起始行索引(0-based)
  7215. rowStartIndex, // 结束行索引(0-based)
  7216. 0, // 起始列索引(0-based)
  7217. 3 // 结束列索引(0-based)
  7218. );
  7219. sheet.AddMergedRegion(cellRangeAddress);
  7220. var CellStyle = workbook.CreateCellStyle();
  7221. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7222. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7223. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7224. for (int i = 0; i <= clounmCount; i++)
  7225. {
  7226. if (i > 6)
  7227. {
  7228. var CellStyle1 = workbook.CreateCellStyle();
  7229. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7230. IFont Font = workbook.CreateFont(); // 创建字体
  7231. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7232. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7233. CellStyle1.SetFont(Font);
  7234. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7235. }
  7236. else
  7237. {
  7238. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7239. }
  7240. }
  7241. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7242. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7243. //超时合计
  7244. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7245. //超时数
  7246. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7247. //超时合计费用
  7248. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7249. cloneRowFn();
  7250. // 创建合并区域的实例
  7251. cellRangeAddress = new CellRangeAddress(
  7252. rowStartIndex, // 起始行索引(0-based)
  7253. rowStartIndex, // 结束行索引(0-based)
  7254. 0, // 起始列索引(0-based)
  7255. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  7256. );
  7257. // 添加合并区域
  7258. sheet.AddMergedRegion(cellRangeAddress);
  7259. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  7260. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  7261. }
  7262. }
  7263. mergeRow();
  7264. // 保存修改后的Excel文件到新文件
  7265. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  7266. // new FileStream(newFilePath, FileMode.CreateNew)
  7267. using (var stream = new MemoryStream())
  7268. {
  7269. workbook.Write(stream, true);
  7270. stream.Flush();
  7271. stream.Seek(0, SeekOrigin.Begin);
  7272. MemoryStream memoryStream = new MemoryStream();
  7273. stream.CopyTo(memoryStream);
  7274. memoryStream.Seek(0, SeekOrigin.Begin);
  7275. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  7276. }
  7277. workbook.Close();
  7278. workbook.Dispose();
  7279. }
  7280. catch (Exception ex)
  7281. {
  7282. jw.Msg = "出现异常!" + ex.Message;
  7283. return Ok(jw);
  7284. }
  7285. }
  7286. if (Zips.Count > 0)
  7287. {
  7288. IOOperatorHelper io = new IOOperatorHelper();
  7289. var byts = io.ConvertZipStream(Zips);
  7290. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  7291. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  7292. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  7293. }
  7294. else
  7295. {
  7296. jw.Msg = "暂无生成文件!";
  7297. }
  7298. return Ok(jw);
  7299. }
  7300. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  7301. {
  7302. string outStr = string.Empty;
  7303. switch (i)
  7304. {
  7305. case 0:
  7306. outStr = arr[0].SidName;
  7307. break;
  7308. case 1:
  7309. outStr = arr[0].DataPriceStr;
  7310. break;
  7311. case 2:
  7312. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  7313. break;
  7314. case 4:
  7315. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  7316. break;
  7317. case 7:
  7318. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7319. {
  7320. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  7321. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  7322. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  7323. }
  7324. break;
  7325. case 8:
  7326. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7327. {
  7328. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  7329. }
  7330. break;
  7331. case 9:
  7332. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7333. {
  7334. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  7335. }
  7336. break;
  7337. case 10:
  7338. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7339. {
  7340. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  7341. }
  7342. break;
  7343. }
  7344. return outStr;
  7345. }
  7346. #region OP行程单
  7347. /// <summary>
  7348. /// OP行程单初始化
  7349. /// </summary>
  7350. /// <param name="dto"></param>
  7351. /// <returns></returns>
  7352. [HttpPost]
  7353. public IActionResult InitOpTravel(InitOpTravelDto dto)
  7354. {
  7355. var jw = JsonView(false);
  7356. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  7357. var group = groupList.First();
  7358. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  7359. if (group == null)
  7360. {
  7361. jw.Msg = "暂无团组!";
  7362. return Ok(jw);
  7363. }
  7364. group = groupList.Find(x => x.Id == diid);
  7365. if (group == null)
  7366. {
  7367. jw.Msg = "请输入正确的团组ID!";
  7368. return Ok(jw);
  7369. }
  7370. string city = string.Empty;
  7371. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  7372. if (blackCode.Count > 0)
  7373. {
  7374. var black = blackCode.First();
  7375. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  7376. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  7377. if (blackSp.Length > 0)
  7378. {
  7379. try
  7380. {
  7381. var cityArrCode = new List<string>(20);
  7382. foreach (var item in blackSp)
  7383. {
  7384. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  7385. var IndexSelect = itemSp[2];
  7386. var cityArrCodeLength = cityArrCode.Count - 1;
  7387. var startCity = IndexSelect.Substring(0, 3);
  7388. if (cityArrCodeLength > 0)
  7389. {
  7390. var arrEndCity = cityArrCode[cityArrCodeLength];
  7391. if (arrEndCity != startCity)
  7392. {
  7393. cityArrCode.Add(startCity.ToUpper());
  7394. }
  7395. }
  7396. else
  7397. {
  7398. cityArrCode.Add(startCity.ToUpper());
  7399. }
  7400. var endCity = IndexSelect.Substring(3, 3);
  7401. cityArrCode.Add(endCity.ToUpper());
  7402. }
  7403. var cityThree = string.Empty;
  7404. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  7405. cityThree = cityThree.TrimEnd(',');
  7406. if (string.IsNullOrWhiteSpace(cityThree))
  7407. {
  7408. throw new
  7409. Exception("error");
  7410. }
  7411. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7412. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7413. foreach (var item in cityArrCode)
  7414. {
  7415. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7416. if (find != null)
  7417. {
  7418. city += find.City + "/";
  7419. }
  7420. else
  7421. {
  7422. city += item + "三字码未收入/";
  7423. }
  7424. }
  7425. city = city.TrimEnd('/');
  7426. }
  7427. catch (Exception e)
  7428. {
  7429. city = "黑屏代码格式不正确!";
  7430. }
  7431. }
  7432. }
  7433. else
  7434. {
  7435. city = "未录入黑屏代码";
  7436. }
  7437. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7438. {
  7439. Date = x.Date,
  7440. Days = x.Days,
  7441. Diffgroup = x.Diffgroup,
  7442. Diid = x.Diid,
  7443. Traffic_First = x.Traffic_First,
  7444. Traffic_Second = x.Traffic_Second,
  7445. Trip = x.Trip,
  7446. WeekDay = x.WeekDay,
  7447. Id = x.Id
  7448. }).ToList();
  7449. jw.Data = new
  7450. {
  7451. groupList = groupList.Select(x => new
  7452. {
  7453. x.Id,
  7454. x.TeamName,
  7455. x.TourCode
  7456. }).ToList(),
  7457. groupInfo = new
  7458. {
  7459. group.VisitDays,
  7460. group.TourCode,
  7461. group.VisitPNumber,
  7462. group.TeamName,
  7463. city
  7464. },
  7465. OpTravelList
  7466. };
  7467. jw.Code = 200;
  7468. jw.Msg = "操作成功!";
  7469. return Ok(jw);
  7470. }
  7471. /// <summary>
  7472. /// 删除团组行程单
  7473. /// </summary>
  7474. /// <returns></returns>
  7475. [HttpPost]
  7476. public IActionResult DelTravel(DelOpTravelDto dto)
  7477. {
  7478. var jw = JsonView(false);
  7479. if (dto.UserId <= 0 || dto.Diid <= 0)
  7480. {
  7481. jw.Msg = "请输入正确的参数!";
  7482. return Ok(jw);
  7483. }
  7484. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7485. .SetColumns(x => new Grp_TravelList
  7486. {
  7487. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7488. DeleteUserId = dto.UserId,
  7489. IsDel = 1,
  7490. }).ExecuteCommand();
  7491. jw = JsonView(true);
  7492. return Ok(jw);
  7493. }
  7494. /// <summary>
  7495. /// 行程单保存
  7496. /// </summary>
  7497. /// <returns></returns>
  7498. [HttpPost]
  7499. public IActionResult TravelSave(TravelSaveDto dto)
  7500. {
  7501. var jw = JsonView(false);
  7502. if (dto.Arr.Count > 0)
  7503. {
  7504. try
  7505. {
  7506. _sqlSugar.BeginTran();
  7507. foreach (var item in dto.Arr)
  7508. {
  7509. if (item.Id == 0)
  7510. {
  7511. throw new Exception("请传入正确的Id");
  7512. }
  7513. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7514. .SetColumns(x => new Grp_TravelList
  7515. {
  7516. Trip = item.Trip
  7517. }).ExecuteCommand();
  7518. }
  7519. _sqlSugar.CommitTran();
  7520. jw = JsonView(true);
  7521. }
  7522. catch (Exception ex)
  7523. {
  7524. _sqlSugar.RollbackTran();
  7525. jw.Msg = "程序异常!" + ex.Message;
  7526. }
  7527. }
  7528. else
  7529. {
  7530. jw.Msg = "请传入正确的参数!";
  7531. }
  7532. return Ok(jw);
  7533. }
  7534. /// <summary>
  7535. /// 导出行程单
  7536. /// </summary>
  7537. /// <param name="dto"></param>
  7538. /// <returns></returns>
  7539. [HttpPost]
  7540. public IActionResult ExportTravel(ExportTravelDto dto)
  7541. {
  7542. var jw = JsonView(false);
  7543. jw.Data = "";
  7544. int diid = 0;
  7545. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7546. if (Find == null)
  7547. {
  7548. jw.Msg = "请选择正确的团组!";
  7549. return Ok(jw);
  7550. }
  7551. else
  7552. {
  7553. diid = Find.Id;
  7554. }
  7555. //数据源
  7556. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7557. DataTable dtBlack = null;
  7558. try
  7559. {
  7560. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7561. }
  7562. catch (Exception)
  7563. {
  7564. jw.Msg = "机票黑屏代码有误!";
  7565. return Ok(jw);
  7566. }
  7567. string CityStr = string.Empty;
  7568. if (dtBlack.Rows.Count == 0)
  7569. {
  7570. jw.Msg = "机票黑屏代码有误!";
  7571. return Ok(jw);
  7572. }
  7573. else
  7574. {
  7575. foreach (DataRow row in dtBlack.Rows)
  7576. {
  7577. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7578. {
  7579. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7580. return Ok(jw);
  7581. }
  7582. }
  7583. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7584. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7585. }
  7586. //创建数据源Table
  7587. DataTable dtSource = new DataTable();
  7588. dtSource.Columns.Add("Days", typeof(string));
  7589. dtSource.Columns.Add("Date", typeof(string));
  7590. dtSource.Columns.Add("Week", typeof(string));
  7591. dtSource.Columns.Add("Traffic", typeof(string));
  7592. dtSource.Columns.Add("Trip", typeof(string));
  7593. //获取数据,放到datatable
  7594. foreach (var item in _travelList)
  7595. {
  7596. DataRow dr = dtSource.NewRow();
  7597. dr["Days"] = item.Days;
  7598. dr["Date"] = item.Date;
  7599. dr["Week"] = item.WeekDay;
  7600. dr["Traffic"] = item.Traffic_First
  7601. + "\r\n"
  7602. + item.Traffic_Second;
  7603. dr["Trip"] = item.Trip;
  7604. dtSource.Rows.Add(dr);
  7605. }
  7606. Dictionary<string, string> dic = new Dictionary<string, string>();
  7607. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7608. dic.Add("City", CityStr);
  7609. dic.Add("Days", Find.VisitDays.ToString());
  7610. dic.Add("DeleCode", Find.TourCode);
  7611. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7612. //模板路径
  7613. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7614. //载入模板
  7615. Document doc = null;
  7616. DocumentBuilder builder = null;
  7617. try
  7618. {
  7619. //载入模板
  7620. doc = new Document(tempPath);
  7621. builder = new DocumentBuilder(doc);
  7622. }
  7623. catch (Exception)
  7624. {
  7625. jw.Msg = "模板位置不存在!";
  7626. return Ok(jw);
  7627. }
  7628. foreach (var key in dic.Keys)
  7629. {
  7630. Bookmark bookmark = doc.Range.Bookmarks[key];
  7631. if (bookmark != null)
  7632. {
  7633. builder.MoveToBookmark(key);
  7634. builder.Write(dic[key]);
  7635. }
  7636. }
  7637. //获取word里所有表格
  7638. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7639. //获取所填表格的序数
  7640. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7641. try
  7642. {
  7643. //循环赋值
  7644. for (int i = 0; i < dtSource.Rows.Count; i++)
  7645. {
  7646. builder.MoveToCell(0, i + 1, 0, 0);
  7647. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7648. builder.MoveToCell(0, i + 1, 1, 0);
  7649. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7650. builder.MoveToCell(0, i + 1, 2, 0);
  7651. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7652. var trip = dtSource.Rows[i]["Trip"].ToString();
  7653. builder.MoveToCell(0, i + 1, 3, 0);
  7654. builder.Write(trip);
  7655. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7656. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7657. // 获取特定索引的段落
  7658. Paragraph paragraph = (Paragraph)paragraphs[0];
  7659. Run run = paragraph.Runs[0];
  7660. Aspose.Words.Font font = run.Font;
  7661. font.Name = "黑体";
  7662. //设置双休红色
  7663. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7664. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7665. paragraph = (Paragraph)paragraphs[1];
  7666. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7667. {
  7668. run = paragraph.Runs[0];
  7669. font = run.Font;
  7670. font.Color = Color.Red;
  7671. }
  7672. }
  7673. }
  7674. catch (Exception ex)
  7675. {
  7676. }
  7677. //删除多余行
  7678. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7679. {
  7680. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7681. }
  7682. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7683. if (!Directory.Exists(savePath))
  7684. {
  7685. try
  7686. {
  7687. Directory.CreateDirectory(savePath);
  7688. }
  7689. catch
  7690. {
  7691. }
  7692. }
  7693. string path = savePath + Find.TeamName + "出访日程";
  7694. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7695. try
  7696. {
  7697. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7698. string postfix = ".docx";
  7699. if (dto.IsPDF == 1)
  7700. {
  7701. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7702. postfix = ".pdf";
  7703. }
  7704. doc.Save(path + postfix, saveFormat);
  7705. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7706. }
  7707. catch (Exception)
  7708. {
  7709. jw = JsonView(false);
  7710. }
  7711. return Ok(jw);
  7712. }
  7713. /// <summary>
  7714. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7715. /// </summary>
  7716. /// <param name="num"></param>
  7717. /// <returns></returns>
  7718. string GetNum(string num)
  7719. {
  7720. string str = "";
  7721. switch (num)
  7722. {
  7723. case "1":
  7724. str = "一";
  7725. break;
  7726. case "2":
  7727. str = "二";
  7728. break;
  7729. case "3":
  7730. str = "三";
  7731. break;
  7732. case "4":
  7733. str = "四";
  7734. break;
  7735. case "5":
  7736. str = "五";
  7737. break;
  7738. case "6":
  7739. str = "六";
  7740. break;
  7741. case "7":
  7742. str = "七";
  7743. break;
  7744. case "8":
  7745. str = "八";
  7746. break;
  7747. case "9":
  7748. str = "九";
  7749. break;
  7750. case "10":
  7751. str = "十";
  7752. break;
  7753. case "11":
  7754. str = "十一";
  7755. break;
  7756. case "12":
  7757. str = "十二";
  7758. break;
  7759. case "一":
  7760. str = "1";
  7761. break;
  7762. case "二":
  7763. str = "2";
  7764. break;
  7765. case "三":
  7766. str = "3";
  7767. break;
  7768. case "四":
  7769. str = "4";
  7770. break;
  7771. case "五":
  7772. str = "5";
  7773. break;
  7774. case "六":
  7775. str = "6";
  7776. break;
  7777. case "七":
  7778. str = "7";
  7779. break;
  7780. case "八":
  7781. str = "8";
  7782. break;
  7783. case "九":
  7784. str = "9";
  7785. break;
  7786. case "十":
  7787. str = "10";
  7788. break;
  7789. case "十一":
  7790. str = "11";
  7791. break;
  7792. case "十二":
  7793. str = "12";
  7794. break;
  7795. }
  7796. return str;
  7797. }
  7798. #endregion
  7799. #endregion
  7800. #region 团组成本
  7801. /// <summary>
  7802. /// 团组成本数据初始化
  7803. /// </summary>
  7804. /// <param name="dto"></param>
  7805. /// <returns></returns>
  7806. [HttpPost]
  7807. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7808. {
  7809. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7810. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7811. WHEN COUNT(*) >= 0 THEN 'True'
  7812. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7813. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7814. ").ToList(); //团组列表
  7815. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7816. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7817. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7818. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7819. if (groupinfoValue != null)
  7820. {
  7821. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7822. var spArr = new string[1] { countryArr };
  7823. if (countryArr.Contains("|"))
  7824. {
  7825. spArr = countryArr.Split("|");
  7826. }
  7827. else if (countryArr.Contains("、"))
  7828. {
  7829. spArr = countryArr.Split("、");
  7830. }
  7831. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7832. {
  7833. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7834. if (dbQueryCountry != null)
  7835. {
  7836. visaCountryInfoArr.Add(dbQueryCountry);
  7837. }
  7838. }
  7839. }
  7840. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7841. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7842. var create = _GroupCostRepository.
  7843. CreateGroupCostByBlackCode(dto.Diid);
  7844. if (groupCost.Count == 0 && create.Code == 0)
  7845. {
  7846. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7847. }
  7848. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7849. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7850. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7851. groupCostMap = groupCostMap.Select(x =>
  7852. {
  7853. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7854. {
  7855. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7856. }
  7857. return x;
  7858. }).ToList();
  7859. //GroupCostParameter.Add(new
  7860. // Grp_GroupCostParameter());
  7861. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7862. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7863. return Ok(JsonView(new
  7864. {
  7865. groupList,
  7866. groupInfo,
  7867. groupChecks,
  7868. groupCost = groupCostMap,
  7869. hotelNumber,
  7870. GroupCostParameter = GroupCostParameterMap,
  7871. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7872. {
  7873. x.VisaCountry,
  7874. x.VisaPrice,
  7875. x.Id,
  7876. }).ToList(),
  7877. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7878. blackCodeIsTrue = create.Code == 0 ? true : false,
  7879. hotelIsTrue = hotelIsTrue,
  7880. }));
  7881. }
  7882. /// <summary>
  7883. /// 团组成本信息保存
  7884. /// </summary>
  7885. /// <param name="dto"></param>
  7886. /// <returns></returns>
  7887. [HttpPost]
  7888. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7889. {
  7890. if (dto.Diid <= 0 || dto.Userid <= 0)
  7891. {
  7892. return Ok(JsonView(false));
  7893. }
  7894. JsonView jw = null;
  7895. bool isTrue = false;
  7896. #region 复制团组成本
  7897. //if (dto.Diid == 2581)
  7898. //{
  7899. // dto.Diid = 2599;
  7900. // dto.CheckBoxs.ForEach(x =>
  7901. // {
  7902. // x.Diid = 2599;
  7903. // });
  7904. // dto.GroupCosts.ForEach(x =>
  7905. // {
  7906. // x.Diid = 2599;
  7907. // });
  7908. // dto.CostTypeHotelNumbers.ForEach(x =>
  7909. // {
  7910. // x.Diid = 2599;
  7911. // });
  7912. // dto.GroupCostParameters.ForEach(x =>
  7913. // {
  7914. // x.DiId = 2599;
  7915. // });
  7916. //}
  7917. #endregion
  7918. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7919. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7920. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7921. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7922. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7923. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7924. try
  7925. {
  7926. _sqlSugar.BeginTran();
  7927. isTrue = await _GroupCostRepository.
  7928. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7929. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7930. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7931. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7932. _sqlSugar.CommitTran();
  7933. jw = JsonView(true, "保存成功!", isTrue);
  7934. }
  7935. catch (Exception)
  7936. {
  7937. _sqlSugar.RollbackTran();
  7938. jw = JsonView(false);
  7939. }
  7940. return Ok(jw);
  7941. }
  7942. /// <summary>
  7943. /// 司兼导数据
  7944. /// </summary>
  7945. /// <param name="dto"></param>
  7946. /// <returns></returns>
  7947. [HttpPost]
  7948. public IActionResult GetCarGuides(CarGuidesDto dto)
  7949. {
  7950. JsonView jw = null;
  7951. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7952. jw = JsonView(true, "获取成功!", Data);
  7953. return Ok(jw);
  7954. }
  7955. /// <summary>
  7956. /// 导游数据
  7957. /// </summary>
  7958. /// <param name="dto"></param>
  7959. /// <returns></returns>
  7960. [HttpPost]
  7961. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7962. {
  7963. JsonView jw = null;
  7964. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7965. // 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
  7966. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7967. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7968. jw = JsonView(true, "获取成功!", Data);
  7969. return Ok(jw);
  7970. }
  7971. /// <summary>
  7972. /// 成本车数据
  7973. /// </summary>
  7974. /// <param name="dto"></param>
  7975. /// <returns></returns>
  7976. [HttpPost]
  7977. public IActionResult GetCarInfo(CarGuidesDto dto)
  7978. {
  7979. JsonView jw = null;
  7980. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7981. jw = JsonView(true, "获取成功!", Data);
  7982. return Ok(jw);
  7983. }
  7984. /// <summary>
  7985. /// 景点数据
  7986. /// </summary>
  7987. /// <param name="dto"></param>
  7988. /// <returns></returns>
  7989. [HttpPost]
  7990. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7991. {
  7992. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7993. return Ok(JsonView(true, "获取成功!", Data));
  7994. }
  7995. /// <summary>
  7996. /// 成本通知
  7997. /// </summary>
  7998. /// <param name="dto"></param>
  7999. /// <returns></returns>
  8000. [HttpPost]
  8001. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8002. {
  8003. if (dto.Diid < 0)
  8004. {
  8005. return Ok(JsonView(false));
  8006. }
  8007. JsonView jw = null;
  8008. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8009. if (GroupCostParameter != null)
  8010. {
  8011. int IsShare = 0;
  8012. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8013. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8014. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8015. string msg = string.Empty;
  8016. if (isTrue)
  8017. {
  8018. if (IsShare == 0)
  8019. {
  8020. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8021. }
  8022. else
  8023. {
  8024. #region 企微通知对应岗位用户
  8025. try
  8026. {
  8027. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8028. }
  8029. catch (Exception ex)
  8030. {
  8031. }
  8032. #endregion
  8033. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8034. }
  8035. jw = JsonView(isTrue, msg, new { IsShare });
  8036. }
  8037. else
  8038. {
  8039. msg = "修改失败!";
  8040. jw = JsonView(isTrue, msg);
  8041. }
  8042. }
  8043. else
  8044. {
  8045. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8046. }
  8047. return Ok(jw);
  8048. }
  8049. /// <summary>
  8050. /// 导出报价单
  8051. /// </summary>
  8052. /// <param name="dto"></param>
  8053. /// <returns></returns>
  8054. [HttpPost]
  8055. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8056. {
  8057. if (dto.Diid == 0)
  8058. {
  8059. return Ok(JsonView(false, "请传递团组id"));
  8060. }
  8061. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8062. if (deleInfo.Code != 0)
  8063. {
  8064. return Ok(JsonView(false, "团组信息查询失败!"));
  8065. }
  8066. var di = deleInfo.Data as DelegationInfoWebView;
  8067. if (di != null)
  8068. {
  8069. di.TeamName = di.TeamName.Replace("|", "、");
  8070. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8071. //文件名
  8072. string strFileName = di.TeamName + "-收款账单.doc";
  8073. //获取模板
  8074. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  8075. //载入模板
  8076. Document doc = new Document(tmppath);
  8077. decimal TotalPrice = 0.00M;
  8078. string itemStr = string.Empty;
  8079. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  8080. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8081. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8082. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  8083. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  8084. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  8085. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  8086. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  8087. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  8088. foreach (var cost in groupCostType)
  8089. {
  8090. var List = cost.ToList();
  8091. if (cost.Key == "A")
  8092. {
  8093. foreach (var ListItem in List)
  8094. {
  8095. if (ListItem.number > 0)
  8096. {
  8097. if (ListItem.code.Contains("TBR"))
  8098. {
  8099. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8100. }
  8101. else
  8102. {
  8103. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8104. }
  8105. TotalPrice += (ListItem.number * ListItem.price);
  8106. }
  8107. }
  8108. }
  8109. else
  8110. {
  8111. itemStr = itemStr.Insert(0, "A段\r\n");
  8112. itemStr += "B段\r\n";
  8113. foreach (var ListItem in List)
  8114. {
  8115. if (ListItem.number > 0)
  8116. {
  8117. if (ListItem.code.Contains("TBR"))
  8118. {
  8119. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8120. }
  8121. else
  8122. {
  8123. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8124. }
  8125. TotalPrice += (ListItem.number * ListItem.price);
  8126. }
  8127. }
  8128. }
  8129. }
  8130. #region 替换Word模板书签内容
  8131. Dictionary<string, string> marks = new Dictionary<string, string>();
  8132. marks.Add("To", di.ClientUnit);//付款方
  8133. marks.Add("ToTel", di.TellPhone);//付款方电话
  8134. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  8135. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  8136. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  8137. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  8138. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  8139. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  8140. marks.Add("PayItemContent", itemStr);//详细信息
  8141. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  8142. #endregion
  8143. ////注
  8144. //if (doc.Range.Bookmarks["Attention"] != null)
  8145. //{
  8146. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  8147. // mark.Text = frList[0].Attention;
  8148. //}
  8149. foreach (var item in marks.Keys)
  8150. {
  8151. if (doc.Range.Bookmarks[item] != null)
  8152. {
  8153. Bookmark mark = doc.Range.Bookmarks[item];
  8154. mark.Text = marks[item];
  8155. }
  8156. }
  8157. byte[] bytes = null;
  8158. using (MemoryStream stream = new MemoryStream())
  8159. {
  8160. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8161. bytes = stream.ToArray();
  8162. }
  8163. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  8164. return Ok(JsonView(true, "", new
  8165. {
  8166. Data = bytes,
  8167. strFileName,
  8168. }));
  8169. }
  8170. else
  8171. {
  8172. return Ok(JsonView(false, "团组信息不存在!"));
  8173. }
  8174. }
  8175. /// <summary>
  8176. /// 导出团组成本
  8177. /// </summary>
  8178. /// <param name="dto"></param>
  8179. /// <returns></returns>
  8180. [HttpPost]
  8181. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  8182. {
  8183. var jw = JsonView(false);
  8184. if (dto.Diid == 0)
  8185. {
  8186. return Ok(JsonView(false, "请传递团组id"));
  8187. }
  8188. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8189. if (deleInfo.Code != 0)
  8190. {
  8191. return Ok(JsonView(false, "团组信息查询失败!"));
  8192. }
  8193. var di = deleInfo.Data as DelegationInfoWebView;
  8194. if (di == null)
  8195. {
  8196. return Ok(JsonView(false, "团组信息查询失败!"));
  8197. }
  8198. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  8199. WorkbookDesigner designer = new WorkbookDesigner();
  8200. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  8201. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  8202. for (int i = 0; i < List_GC.Count; i++)
  8203. {
  8204. GroupCost_Excel gc = new GroupCost_Excel();
  8205. gc.Id = List_GC[i].Id;
  8206. gc.Diid = List_GC[i].Diid.ToString();
  8207. gc.DAY = List_GC[i].DAY;
  8208. string week = "";
  8209. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  8210. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  8211. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  8212. gc.ITIN = List_GC[i].ITIN;
  8213. gc.CarType = List_GC[i].CarType;
  8214. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  8215. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  8216. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  8217. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  8218. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  8219. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  8220. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  8221. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  8222. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  8223. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  8224. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  8225. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  8226. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  8227. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  8228. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  8229. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  8230. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  8231. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  8232. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  8233. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  8234. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  8235. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  8236. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  8237. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  8238. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  8239. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  8240. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  8241. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  8242. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  8243. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  8244. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  8245. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  8246. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  8247. List_GC1.Add(gc);
  8248. }
  8249. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  8250. dt.TableName = "TB";
  8251. //报表标题等不用dt的值
  8252. designer.SetDataSource("TeamName", dto.title.TeamName);
  8253. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  8254. designer.SetDataSource("Tax", dto.title.Tax);
  8255. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  8256. designer.SetDataSource("Currency", dto.title.Currency);
  8257. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  8258. designer.SetDataSource("Rate", dto.title.Rate);
  8259. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  8260. var Aparams = hotels.Find(x => x.Type == "Default");
  8261. if (Aparams == null)
  8262. {
  8263. return Ok(jw);
  8264. }
  8265. //酒店数量
  8266. var txtSGRNumber = Aparams.SGR.ToString();
  8267. var txtTBRNumber = Aparams.TBR.ToString();
  8268. var txtJSESNumber = Aparams.JSES.ToString();
  8269. var txtSUITENumbe = Aparams.SUITE.ToString();
  8270. if (dto.costType == "B")
  8271. {
  8272. Aparams = hotels.Find(x => x.Type == "A");
  8273. var Bparams = hotels.Find(x => x.Type == "B");
  8274. if (Aparams == null || Bparams == null)
  8275. {
  8276. return Ok(jw);
  8277. }
  8278. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  8279. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  8280. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  8281. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  8282. }
  8283. designer.SetDataSource("SGRNumber", txtSGRNumber);
  8284. designer.SetDataSource("TBRNumber", txtTBRNumber);
  8285. designer.SetDataSource("JSESNumber", txtJSESNumber);
  8286. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  8287. var ws = designer.Workbook.Worksheets[0];
  8288. int Row = List_GC.Count;
  8289. int startIndex = 11;
  8290. int HideRows = 0;
  8291. List<int> hideRowsList = new List<int>();
  8292. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  8293. #region A段left数据
  8294. var left = dto.leftInfo.Find(x => x.Type == "A");
  8295. if (left == null)
  8296. {
  8297. return Ok(jw);
  8298. }
  8299. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  8300. if (leftBindData != null)
  8301. {
  8302. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  8303. designer.SetDataSource("VisaRS", leftBindData.rs);
  8304. designer.SetDataSource("VisaXS", leftBindData.xs);
  8305. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8306. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8307. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8308. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8309. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8310. }
  8311. else
  8312. {
  8313. hideRowsList.Add(Row + startIndex + HideRows);
  8314. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8315. }
  8316. HideRows += 2;
  8317. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  8318. if (leftBindData != null)
  8319. {
  8320. designer.SetDataSource("BXDRCB", leftBindData.cb);
  8321. designer.SetDataSource("BXRS", leftBindData.rs);
  8322. designer.SetDataSource("BXXS", leftBindData.xs);
  8323. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8324. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8325. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8326. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8327. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8328. }
  8329. else
  8330. {
  8331. hideRowsList.Add(Row + startIndex + HideRows);
  8332. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8333. }
  8334. HideRows += 2;
  8335. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8336. if (leftBindData != null)
  8337. {
  8338. designer.SetDataSource("HSDRCB", leftBindData.cb);
  8339. designer.SetDataSource("HSRS", leftBindData.rs);
  8340. designer.SetDataSource("HSXS", leftBindData.xs);
  8341. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8342. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8343. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8344. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8345. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8346. }
  8347. else
  8348. {
  8349. hideRowsList.Add(Row + startIndex + HideRows);
  8350. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8351. }
  8352. HideRows += 2;
  8353. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8354. if (leftBindData != null)
  8355. {
  8356. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  8357. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  8358. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  8359. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8360. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8361. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8362. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8363. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8364. }
  8365. else
  8366. {
  8367. hideRowsList.Add(Row + startIndex + HideRows);
  8368. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8369. }
  8370. HideRows += 2;
  8371. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8372. if (leftBindData != null)
  8373. {
  8374. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  8375. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  8376. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  8377. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8378. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8379. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8380. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8381. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8382. }
  8383. else
  8384. {
  8385. hideRowsList.Add(Row + startIndex + HideRows);
  8386. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8387. }
  8388. HideRows += 2;
  8389. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8390. if (leftBindData != null)
  8391. {
  8392. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  8393. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  8394. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  8395. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8396. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8397. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8398. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8399. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8400. }
  8401. else
  8402. {
  8403. hideRowsList.Add(Row + startIndex + HideRows);
  8404. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8405. }
  8406. HideRows += 2;
  8407. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8408. if (leftBindData != null)
  8409. {
  8410. ////TBR
  8411. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8412. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8413. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8414. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8415. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8416. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8417. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8418. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8419. }
  8420. else
  8421. {
  8422. hideRowsList.Add(Row + startIndex + HideRows);
  8423. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8424. }
  8425. HideRows += 2;
  8426. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8427. if (leftBindData != null)
  8428. {
  8429. ////SGR
  8430. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8431. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8432. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8433. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8434. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8435. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8436. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8437. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8438. }
  8439. else
  8440. {
  8441. hideRowsList.Add(Row + startIndex + HideRows);
  8442. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8443. }
  8444. HideRows += 2;
  8445. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8446. if (leftBindData != null)
  8447. {
  8448. ////JS/ES
  8449. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8450. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8451. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8452. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8453. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8454. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8455. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8456. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8457. }
  8458. else
  8459. {
  8460. hideRowsList.Add(Row + startIndex + HideRows);
  8461. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8462. }
  8463. HideRows += 2;
  8464. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8465. if (leftBindData != null)
  8466. {
  8467. ////SUITE
  8468. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8469. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8470. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8471. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8472. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8473. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8474. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8475. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8476. }
  8477. else
  8478. {
  8479. hideRowsList.Add(Row + startIndex + HideRows);
  8480. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8481. }
  8482. HideRows += 2;
  8483. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8484. if (leftBindData != null)
  8485. {
  8486. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8487. designer.SetDataSource("DJRS", leftBindData.rs);
  8488. designer.SetDataSource("DJXS", leftBindData.xs);
  8489. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8490. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8491. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8492. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8493. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8494. }
  8495. else
  8496. {
  8497. hideRowsList.Add(Row + startIndex + HideRows);
  8498. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8499. }
  8500. HideRows += 2;
  8501. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8502. if (leftBindData != null)
  8503. {
  8504. designer.SetDataSource("HCPCB", leftBindData.cb);
  8505. designer.SetDataSource("HCPRS", leftBindData.rs);
  8506. designer.SetDataSource("HCPXS", leftBindData.xs);
  8507. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8508. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8509. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8510. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8511. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8512. }
  8513. else
  8514. {
  8515. hideRowsList.Add(Row + startIndex + HideRows);
  8516. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8517. }
  8518. HideRows += 2;
  8519. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8520. if (leftBindData != null)
  8521. {
  8522. designer.SetDataSource("CPCB", leftBindData.cb);
  8523. designer.SetDataSource("CPRS", leftBindData.rs);
  8524. designer.SetDataSource("CPXS", leftBindData.xs);
  8525. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8526. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8527. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8528. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8529. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8530. }
  8531. else
  8532. {
  8533. hideRowsList.Add(Row + startIndex + HideRows);
  8534. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8535. }
  8536. HideRows += 2;
  8537. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8538. if (leftBindData != null)
  8539. {
  8540. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8541. designer.SetDataSource("GWRS", leftBindData.rs);
  8542. designer.SetDataSource("GWXS", leftBindData.xs);
  8543. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8544. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8545. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8546. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8547. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8548. }
  8549. else
  8550. {
  8551. hideRowsList.Add(Row + startIndex + HideRows);
  8552. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8553. }
  8554. HideRows += 2;
  8555. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8556. if (leftBindData != null)
  8557. {
  8558. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8559. designer.SetDataSource("LYJRS", leftBindData.rs);
  8560. designer.SetDataSource("LYJXS", leftBindData.xs);
  8561. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8562. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8563. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8564. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8565. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8566. }
  8567. else
  8568. {
  8569. hideRowsList.Add(Row + startIndex + HideRows);
  8570. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8571. }
  8572. #endregion
  8573. #region A段Right信息
  8574. var right = dto.rightInfo.Find(x => x.Type == "A");
  8575. if (right == null)
  8576. {
  8577. return Ok(jw);
  8578. }
  8579. HideRows += 4;
  8580. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8581. if (rightBindData != null)
  8582. {
  8583. //经济舱 + 双人间 TBR
  8584. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8585. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8586. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8587. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8588. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8589. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8590. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8591. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8592. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8593. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8594. }
  8595. else
  8596. {
  8597. hideRowsList.Add(Row + startIndex + HideRows);
  8598. }
  8599. HideRows += 2;
  8600. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8601. if (rightBindData != null)
  8602. {
  8603. //经济舱 + 单人间 SGR
  8604. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8605. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8606. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8607. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8608. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8609. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8610. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8611. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8612. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8613. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8614. }
  8615. else
  8616. {
  8617. hideRowsList.Add(Row + startIndex + HideRows);
  8618. }
  8619. HideRows += 2;
  8620. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8621. if (rightBindData != null)
  8622. {
  8623. //公务舱 + 单人间 SGR
  8624. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8625. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8626. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8627. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8628. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8629. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8630. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8631. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8632. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8633. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8634. }
  8635. else
  8636. {
  8637. hideRowsList.Add(Row + startIndex + HideRows);
  8638. }
  8639. HideRows += 2;
  8640. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8641. if (rightBindData != null)
  8642. {
  8643. //公务舱 + 小套房 JSES
  8644. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8645. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8646. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8647. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8648. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8649. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8650. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8651. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8652. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8653. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8654. }
  8655. else
  8656. {
  8657. hideRowsList.Add(Row + startIndex + HideRows);
  8658. }
  8659. HideRows += 2;
  8660. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8661. if (rightBindData != null)
  8662. {
  8663. //公务舱 + 小套房 JSES
  8664. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8665. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8666. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8667. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8668. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8669. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8670. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8671. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8672. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8673. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8674. }
  8675. else
  8676. {
  8677. hideRowsList.Add(Row + startIndex + HideRows);
  8678. }
  8679. HideRows += 2;
  8680. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8681. if (rightBindData != null)
  8682. {
  8683. //经济舱 + 大套房
  8684. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8685. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8686. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8687. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8688. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8689. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8690. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8691. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8692. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8693. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8694. }
  8695. else
  8696. {
  8697. hideRowsList.Add(Row + startIndex + HideRows);
  8698. }
  8699. HideRows += 2;
  8700. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8701. if (rightBindData != null)
  8702. {
  8703. //头等舱 + 小套房 JSES
  8704. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8705. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8706. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8707. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8708. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8709. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8710. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8711. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8712. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8713. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8714. }
  8715. else
  8716. {
  8717. hideRowsList.Add(Row + startIndex + HideRows);
  8718. }
  8719. HideRows += 2;
  8720. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8721. if (rightBindData != null)
  8722. {
  8723. //头等舱 + 大套房
  8724. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8725. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8726. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8727. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8728. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8729. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8730. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8731. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8732. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8733. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8734. }
  8735. else
  8736. {
  8737. hideRowsList.Add(Row + startIndex + HideRows);
  8738. }
  8739. #endregion
  8740. #region B段标题清空
  8741. designer.SetDataSource("CostBDRCB", "");
  8742. designer.SetDataSource("CostBRS", "");
  8743. designer.SetDataSource("CostBXS", "");
  8744. designer.SetDataSource("CostBZCB", "");
  8745. designer.SetDataSource("CostBDRBJ", "");
  8746. designer.SetDataSource("CostBZBJ", "");
  8747. designer.SetDataSource("CostBDRLR", "");
  8748. designer.SetDataSource("CostBZLR", "");
  8749. designer.SetDataSource("CostBDRCBOM", "");
  8750. designer.SetDataSource("CostBRSOM", "");
  8751. designer.SetDataSource("CostBZCBOM", "");
  8752. designer.SetDataSource("CostBDRBJOM", "");
  8753. designer.SetDataSource("CostBZBJOM", "");
  8754. designer.SetDataSource("CostBDRLROM", "");
  8755. designer.SetDataSource("CostBZLROM", "");
  8756. #endregion
  8757. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8758. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8759. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8760. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8761. designer.SetDataSource("DJName", "地接(CNY)");
  8762. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8763. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8764. designer.SetDataSource("GWName", "公务(CNY)");
  8765. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8766. designer.SetDataSource("LYJName", "零用金(CNY)");
  8767. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8768. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8769. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8770. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8771. designer.SetDataSource("BXName", "保险(CNY)");
  8772. designer.SetDataSource("VisaName", "签证(CNY)");
  8773. #region B段基本数据
  8774. if (dto.costType == "B")
  8775. {
  8776. left = dto.leftInfo.Find(x => x.Type == "B");
  8777. if (left == null)
  8778. {
  8779. return Ok(jw);
  8780. }
  8781. #region B段left数据
  8782. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8783. if (leftBindData != null)
  8784. {
  8785. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8786. designer.SetDataSource("BHSRS", leftBindData.rs);
  8787. designer.SetDataSource("BHSXS", leftBindData.xs);
  8788. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8789. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8790. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8791. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8792. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8793. }
  8794. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8795. if (leftBindData != null)
  8796. {
  8797. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8798. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8799. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8800. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8801. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8802. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8803. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8804. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8805. }
  8806. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8807. if (leftBindData != null)
  8808. {
  8809. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8810. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8811. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8812. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8813. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8814. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8815. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8816. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8817. }
  8818. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8819. if (leftBindData != null)
  8820. {
  8821. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8822. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8823. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8824. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8825. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8826. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8827. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8828. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8829. }
  8830. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8831. if (leftBindData != null)
  8832. {
  8833. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8834. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8835. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8836. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8837. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8838. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8839. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8840. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8841. }
  8842. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8843. if (leftBindData != null)
  8844. {
  8845. designer.SetDataSource("BCPCB", leftBindData.cb);
  8846. designer.SetDataSource("BCPRS", leftBindData.rs);
  8847. designer.SetDataSource("BCPXS", leftBindData.xs);
  8848. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8849. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8850. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8851. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8852. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8853. }
  8854. //TBR
  8855. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8856. if (leftBindData != null)
  8857. {
  8858. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8859. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8860. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8861. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8862. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8863. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8864. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8865. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8866. }
  8867. //SGR
  8868. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8869. if (leftBindData != null)
  8870. {
  8871. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8872. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8873. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8874. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8875. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8876. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8877. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8878. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8879. }
  8880. //JS/ES
  8881. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8882. if (leftBindData != null)
  8883. {
  8884. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8885. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8886. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8887. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8888. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8889. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8890. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8891. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8892. }
  8893. //SUITE
  8894. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8895. if (leftBindData != null)
  8896. {
  8897. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8898. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8899. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8900. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8901. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8902. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8903. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8904. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8905. }
  8906. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8907. if (leftBindData != null)
  8908. {
  8909. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8910. designer.SetDataSource("BDJRS", leftBindData.rs);
  8911. designer.SetDataSource("BDJXS", leftBindData.xs);
  8912. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8913. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8914. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8915. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8916. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8917. }
  8918. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8919. if (leftBindData != null)
  8920. {
  8921. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8922. designer.SetDataSource("BGWRS", leftBindData.rs);
  8923. designer.SetDataSource("BGWXS", leftBindData.xs);
  8924. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8925. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8926. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8927. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8928. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8929. }
  8930. #region 优化方案
  8931. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8932. //excelBind.Add("零用金", new {
  8933. //cb="",
  8934. //rs="",
  8935. //xs ="",
  8936. //zcb = "",
  8937. //});
  8938. #endregion
  8939. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8940. if (leftBindData != null)
  8941. {
  8942. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8943. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8944. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8945. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8946. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8947. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8948. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8949. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8950. }
  8951. #endregion
  8952. #region B段Right信息
  8953. right = dto.rightInfo.Find(x => x.Type == "B");
  8954. if (right == null)
  8955. {
  8956. return Ok(jw);
  8957. }
  8958. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8959. if (rightBindData != null)
  8960. {
  8961. //经济舱 + 双人间 TBR
  8962. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8963. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8964. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8965. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8966. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8967. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8968. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8969. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8970. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8971. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8972. }
  8973. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8974. if (rightBindData != null)
  8975. {
  8976. //经济舱 + 单人间 SGR
  8977. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8978. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8979. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8980. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8981. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8982. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8983. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8984. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8985. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8986. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8987. }
  8988. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8989. if (rightBindData != null)
  8990. {
  8991. //公务舱 + 单人间 SGR
  8992. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8993. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8994. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8995. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8996. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8997. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8998. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8999. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9000. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9001. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9002. }
  9003. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9004. if (rightBindData != null)
  9005. {
  9006. //公务舱 + 小套房 JSES
  9007. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9008. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9009. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9010. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9011. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9012. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9013. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9014. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9015. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9016. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9017. }
  9018. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9019. if (rightBindData != null)
  9020. {
  9021. //公务舱 + 小套房 JSES
  9022. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9023. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9024. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9025. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9026. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9027. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9028. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9029. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9030. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9031. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9032. }
  9033. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9034. if (rightBindData != null)
  9035. {
  9036. //经济舱 + 大套房
  9037. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9038. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9039. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9040. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9041. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9042. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9043. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9044. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9045. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9046. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9047. }
  9048. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9049. if (rightBindData != null)
  9050. {
  9051. //头等舱 + 小套房 JSES
  9052. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9053. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9054. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9055. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9056. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9057. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9058. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9059. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9060. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9061. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9062. }
  9063. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9064. if (rightBindData != null)
  9065. {
  9066. //头等舱 + 大套房
  9067. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9068. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9069. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9070. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9071. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9072. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9073. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9074. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9075. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9076. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9077. }
  9078. #endregion
  9079. #region 标题
  9080. designer.SetDataSource("CostBDRCB", "单人成本");
  9081. designer.SetDataSource("CostBRS", "人数");
  9082. designer.SetDataSource("CostBXS", "系数");
  9083. designer.SetDataSource("CostBZCB", "总成本");
  9084. designer.SetDataSource("CostBDRBJ", "单人报价");
  9085. designer.SetDataSource("CostBZBJ", "总报价");
  9086. designer.SetDataSource("CostBDRLR", "单人利润");
  9087. designer.SetDataSource("CostBZLR", "总利润");
  9088. designer.SetDataSource("CostBDRCBOM", "单人成本");
  9089. designer.SetDataSource("CostBRSOM", "人数");
  9090. designer.SetDataSource("CostBZCBOM", "总成本");
  9091. designer.SetDataSource("CostBDRBJOM", "单人报价");
  9092. designer.SetDataSource("CostBZBJOM", "总报价");
  9093. designer.SetDataSource("CostBDRLROM", "单人利润");
  9094. designer.SetDataSource("CostBZLROM", "总利润");
  9095. #endregion
  9096. }
  9097. #endregion
  9098. designer.SetDataSource("TzZCB2", TzZCB2);
  9099. designer.SetDataSource("TzZBJ2", TzZBJ2);
  9100. designer.SetDataSource("TzZLR2", TzZLR2);
  9101. string[] dataSourceKeys = new string[]
  9102. {
  9103. "VF",
  9104. "TGS",
  9105. "TGOF",
  9106. "TGM",
  9107. "TGA",
  9108. "TGTF",
  9109. "TGEF",
  9110. "CFM",
  9111. "CFOF",
  9112. "B",
  9113. "L",
  9114. "D",
  9115. "TBR",
  9116. "SGR",
  9117. "JSES",
  9118. "Suite",
  9119. "TV",
  9120. "1L",
  9121. "IF",
  9122. "EF",
  9123. "BRF",
  9124. "TE",
  9125. "TGT",
  9126. "DRVT",
  9127. "PC",
  9128. "TLF",
  9129. "ECT"
  9130. };
  9131. foreach (var item in dataSourceKeys)
  9132. {
  9133. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  9134. if (find != null)
  9135. {
  9136. designer.SetDataSource(item, find.text);
  9137. }
  9138. else
  9139. {
  9140. designer.SetDataSource(item, 0);
  9141. }
  9142. }
  9143. designer.SetDataSource(dt);
  9144. //根据数据源处理生成报表内容
  9145. designer.Process();
  9146. designer.Workbook.Worksheets[0].Name = "清单";
  9147. Worksheet sheet = designer.Workbook.Worksheets[0];
  9148. foreach (var Rowindex in hideRowsList)
  9149. {
  9150. ws.Cells.HideRows(Rowindex, 2);
  9151. }
  9152. byte[] bytes = null;
  9153. string strFileName = di.TeamName + "-团组-成本.xls";
  9154. using (MemoryStream stream = new MemoryStream())
  9155. {
  9156. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  9157. bytes = stream.ToArray();
  9158. }
  9159. return Ok(JsonView(true, "", new
  9160. {
  9161. Data = bytes,
  9162. strFileName,
  9163. }));
  9164. }
  9165. /// <summary>
  9166. /// 导出客户报表
  9167. /// </summary>
  9168. /// <returns></returns>
  9169. [HttpPost]
  9170. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  9171. {
  9172. var jw = JsonView(false);
  9173. if (dto.Diid == 0)
  9174. {
  9175. return Ok(JsonView(false, "请传递团组id"));
  9176. }
  9177. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9178. if (deleInfo.Code != 0)
  9179. {
  9180. return Ok(JsonView(false, "团组信息查询失败!"));
  9181. }
  9182. var di = deleInfo.Data as DelegationInfoWebView;
  9183. if (di == null)
  9184. {
  9185. return Ok(JsonView(false, "团组信息查询失败!"));
  9186. }
  9187. //文件名
  9188. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  9189. //获取模板
  9190. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  9191. //载入模板
  9192. Document doc = new Document(tmppath);
  9193. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  9194. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  9195. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  9196. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  9197. var AParameter = ParameterList.Find(x => x.CostType == "A");
  9198. var BParameter = ParameterList.Find(x => x.CostType == "B");
  9199. if (AParameter == null)
  9200. {
  9201. return Ok(JsonView(false, "系数不存在!"));
  9202. }
  9203. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  9204. , TzAirDesc, TzZCost;
  9205. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  9206. = TzAirDesc = TzZCost = string.Empty;
  9207. TzNumber = AParameter.CostTypenumber.ToString();
  9208. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  9209. CarGuides1 = dto.CarGuides1;
  9210. Meal = dto.Meal;
  9211. SubsidizedMeals = dto.SubsidizedMeals;
  9212. NightRepair = dto.NightRepair;
  9213. AttractionsTickets = dto.AttractionsTickets;
  9214. MiscellaneousFees = dto.MiscellaneousFees;
  9215. ATip = dto.ATip;
  9216. TzHotelDesc = "";
  9217. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  9218. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  9219. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  9220. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  9221. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  9222. TzAirDesc = "";
  9223. TzZCost = dto.TzZCost;
  9224. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  9225. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  9226. var index = 1;
  9227. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  9228. foreach (var item in TzHotelDescArr)
  9229. {
  9230. if (AinfoArr != null)
  9231. {
  9232. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9233. if (Ainfo != null)
  9234. {
  9235. if (int.Parse(Ainfo.rs) <= 0)
  9236. {
  9237. continue;
  9238. }
  9239. var hotelText = string.Empty;
  9240. switch (item)
  9241. {
  9242. case "SGR":
  9243. hotelText = "单人间";
  9244. break;
  9245. case "JSES":
  9246. hotelText = "小套房";
  9247. break;
  9248. case "SUITE":
  9249. hotelText = "套房";
  9250. break;
  9251. case "TBR":
  9252. hotelText = "双人间";
  9253. break;
  9254. }
  9255. if (item != "TBR")
  9256. {
  9257. 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";
  9258. }
  9259. else
  9260. {
  9261. 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";
  9262. }
  9263. index++;
  9264. }
  9265. }
  9266. }
  9267. index = 1;
  9268. foreach (var item in TzAirDescArr)
  9269. {
  9270. if (AinfoArr != null)
  9271. {
  9272. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9273. if (Ainfo != null)
  9274. {
  9275. if (int.Parse(Ainfo.rs) <= 0)
  9276. {
  9277. continue;
  9278. }
  9279. 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";
  9280. index++;
  9281. }
  9282. }
  9283. }
  9284. if (dto.costType == "B")
  9285. {
  9286. if (BParameter == null)
  9287. {
  9288. return Ok(JsonView(false, "B段系数不存在!"));
  9289. }
  9290. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  9291. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  9292. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  9293. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  9294. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  9295. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  9296. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  9297. foreach (var item in TzHotelDescArr)
  9298. {
  9299. if (AinfoArr != null)
  9300. {
  9301. TzHotelDesc += "B段信息 \r\n";
  9302. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9303. if (Ainfo != null)
  9304. {
  9305. if (int.Parse(Ainfo.rs) <= 0)
  9306. {
  9307. continue;
  9308. }
  9309. var hotelText = string.Empty;
  9310. switch (item)
  9311. {
  9312. case "SGR":
  9313. hotelText = "单人间";
  9314. break;
  9315. case "JSES":
  9316. hotelText = "小套房";
  9317. break;
  9318. case "SUITE":
  9319. hotelText = "套房";
  9320. break;
  9321. case "TBR":
  9322. hotelText = "双人间";
  9323. break;
  9324. }
  9325. if (item != "TBR")
  9326. {
  9327. 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";
  9328. }
  9329. else
  9330. {
  9331. 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";
  9332. }
  9333. index++;
  9334. }
  9335. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  9336. }
  9337. }
  9338. index = 1;
  9339. foreach (var item in TzAirDescArr)
  9340. {
  9341. if (AinfoArr != null)
  9342. {
  9343. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9344. if (Ainfo != null)
  9345. {
  9346. if (int.Parse(Ainfo.rs) <= 0)
  9347. {
  9348. continue;
  9349. }
  9350. 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";
  9351. index++;
  9352. }
  9353. }
  9354. }
  9355. }
  9356. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  9357. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  9358. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  9359. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  9360. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  9361. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  9362. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  9363. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  9364. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  9365. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  9366. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  9367. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  9368. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  9369. DickeyValue.Add("Visa", Visa); // 签证单人报价
  9370. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  9371. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  9372. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  9373. DickeyValue.Add("TzZCost", TzZCost);
  9374. foreach (var key in DickeyValue.Keys)
  9375. {
  9376. if (doc.Range.Bookmarks[key] != null)
  9377. {
  9378. Bookmark mark = doc.Range.Bookmarks[key];
  9379. mark.Text = DickeyValue[key];
  9380. }
  9381. }
  9382. byte[] bytes = null;
  9383. string strFileName = di.TeamName + "-客户报价.doc";
  9384. using (MemoryStream stream = new MemoryStream())
  9385. {
  9386. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9387. bytes = stream.ToArray();
  9388. }
  9389. return Ok(JsonView(true, "", new
  9390. {
  9391. Data = bytes,
  9392. strFileName,
  9393. }));
  9394. }
  9395. /// <summary>
  9396. /// 团组成本 各模块(酒店,地接,机票)成本提示
  9397. /// </summary>
  9398. /// <param name="dto"></param>
  9399. /// <returns></returns>
  9400. [HttpPost]
  9401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9402. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  9403. {
  9404. try
  9405. {
  9406. #region 参数验证
  9407. if (dto.DiId < 0)
  9408. {
  9409. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9410. }
  9411. List<int> cTableIds = new List<int>() {
  9412. 76 ,//酒店预订
  9413. 77 ,//行程
  9414. 79 ,//车/导游地接
  9415. 80 ,//签证
  9416. 81 ,//邀请/公务活
  9417. 82 ,//团组客户保险
  9418. 85 ,//机票预订
  9419. 98 ,//其他款项
  9420. 285 ,//收款退还
  9421. 751 ,//酒店早餐
  9422. 1015 // 超支费用
  9423. };
  9424. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9425. {
  9426. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9427. }
  9428. #endregion
  9429. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9430. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9431. if (_GroupCostParameters.Count <= 0)
  9432. {
  9433. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9434. }
  9435. if (_GroupCostParameters[0].IsShare == 0)
  9436. {
  9437. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9438. }
  9439. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9440. //处理date为空问题
  9441. if (_GroupCosts.Count > 0)
  9442. {
  9443. for (int i = 0; i < _GroupCosts.Count; i++)
  9444. {
  9445. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9446. {
  9447. if (i > 0)
  9448. {
  9449. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9450. }
  9451. }
  9452. }
  9453. }
  9454. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9455. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9456. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9457. string currCode = "";
  9458. #region currCode 验证
  9459. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9460. if (isInt)
  9461. {
  9462. var currData = currDatas.Find(it => it.Id == intCurrency);
  9463. if (currData != null)
  9464. {
  9465. currCode = currData.Name;
  9466. }
  9467. }
  9468. else
  9469. {
  9470. currCode = _GroupCostParameters[0].Currency.Trim();
  9471. }
  9472. #endregion
  9473. //op,酒店单段模式存储
  9474. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9475. {
  9476. CurrencyCode = currCode,
  9477. Rate = _GroupCostParameters[0].Rate,
  9478. CostType = _GroupCostParameters[0].CostType,
  9479. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9480. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9481. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9482. };
  9483. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9484. if (_GroupCostParameters.Count == 2)
  9485. {
  9486. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9487. }
  9488. foreach (var item in _GroupCostParameters)
  9489. {
  9490. decimal _rate = 1;
  9491. decimal _rate1 = item.Rate;
  9492. decimal _scale = 1;
  9493. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9494. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9495. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9496. //if (userInfo != null)
  9497. //{
  9498. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9499. // {
  9500. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9501. // {
  9502. // _scale = 1.00M;
  9503. // }
  9504. // }
  9505. //}
  9506. #endregion
  9507. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9508. {
  9509. CurrencyCode = currCode,
  9510. Rate = _rate1,
  9511. CostType = item.CostType,
  9512. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9513. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9514. CostTypeNumber = item.CostTypenumber
  9515. };
  9516. if (_GroupCostParameters.Count > 1)
  9517. {
  9518. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9519. }
  9520. else
  9521. {
  9522. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9523. }
  9524. if (dto.CTable == 79)//
  9525. {
  9526. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9527. modulePromptInfo.TotalCost = item.DJCB;
  9528. }
  9529. List<string> costTypes = new List<string>() { "A", "B" };
  9530. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9531. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9532. if (_GroupCostsDuplicates.Count() == 1)
  9533. {
  9534. _GroupCostsTypeData = _GroupCosts;
  9535. }
  9536. else
  9537. {
  9538. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9539. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9540. }
  9541. /*
  9542. * 76 酒店预订
  9543. * 77 行程
  9544. * 79 车/导游地接
  9545. * 80 签证
  9546. * 81 邀请/公务活动
  9547. * 82 团组客户保险
  9548. * 85 机票预订
  9549. * 98 其他款项
  9550. * 285 收款退还
  9551. * 751 酒店早餐
  9552. * 1015 超支费用
  9553. */
  9554. switch (dto.CTable)
  9555. {
  9556. case 76: // 酒店预订
  9557. _ModuleSubPromptInfo.AddRange(
  9558. _GroupCostsTypeData.Select(it => new
  9559. {
  9560. it.DAY,
  9561. it.Date,
  9562. it.ACCON,
  9563. it.ITIN,
  9564. it.SGR,
  9565. it.TBR,
  9566. it.JS_ES,
  9567. it.Suite
  9568. })
  9569. );
  9570. break;
  9571. case 79: // 车/导游地接
  9572. _ModuleSubPromptInfo.AddRange(
  9573. _GroupCostsTypeData.Select(it => new
  9574. {
  9575. Date = it.Date, //日期
  9576. CarFee = it.CarCost * _rate * _scale, //车费用
  9577. CarType = it.CarType, //车型
  9578. DriverFee = it.CFS * _rate * _scale, //司机工资
  9579. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9580. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9581. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9582. GuideFee = it.TGS * _rate * _scale, //导游费用
  9583. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9584. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9585. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9586. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9587. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9588. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9589. Breakfast = it.B * _rate * _scale, //早餐费
  9590. Lunch = it.L * _rate * _scale, //午餐费
  9591. Dinner = it.D * _rate * _scale, //晚餐费
  9592. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9593. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9594. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9595. TicketFee = it.EF * _rate * _scale, //门票费
  9596. TicketRemark = it.EFR, //门票费描述
  9597. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9598. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9599. SpentCash = it.PC * _rate * _scale, //零用金
  9600. LeadersFee = it.TLF * _rate * _scale, //领队费
  9601. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9602. })
  9603. );
  9604. break;
  9605. case 85: // 机票
  9606. List<dynamic> datas = new List<dynamic>();
  9607. datas.Add(
  9608. new
  9609. {
  9610. AirType = "经济舱",
  9611. AirNum = item.JJCRS,
  9612. AirDRCB = item.JJCCB,
  9613. AirZCB = (item.JJCRS * item.JJCCB)
  9614. }
  9615. );
  9616. datas.Add(
  9617. new
  9618. {
  9619. AirType = "公务舱",
  9620. AirNum = item.GWCRS,
  9621. AirDRCB = item.GWCCB,
  9622. AirZCB = (item.GWCRS * item.GWCCB)
  9623. }
  9624. );
  9625. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9626. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9627. modulePromptInfo.Data = new
  9628. {
  9629. airFeeData = datas,
  9630. airInitData = initDatas
  9631. };
  9632. _ModulePromptInfos.Add(modulePromptInfo);
  9633. break;
  9634. default:
  9635. break;
  9636. }
  9637. }
  9638. if (dto.CTable != 85)
  9639. {
  9640. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9641. _ModulePromptInfos.Add(_ModulePromptInfo);
  9642. }
  9643. _view.ModulePromptInfos = _ModulePromptInfos;
  9644. return Ok(JsonView(true, "操作成功!", _view));
  9645. }
  9646. catch (Exception ex)
  9647. {
  9648. return Ok(JsonView(false, ex.Message));
  9649. }
  9650. }
  9651. /// <summary>
  9652. /// 根据黑屏代码重新生成行程
  9653. /// </summary>
  9654. /// <param name="dto"></param>
  9655. /// <returns></returns>
  9656. [HttpPost]
  9657. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9658. {
  9659. var jw = JsonView(false);
  9660. var Create = _GroupCostRepository.
  9661. CreateGroupCostByBlackCode(dto.Diid);
  9662. jw.Msg = Create.Msg;
  9663. if (Create.Code == 0)
  9664. {
  9665. jw.Code = 200;
  9666. jw.Data = new
  9667. {
  9668. groupCost = Create.Data,
  9669. blackCodeIsTrue = true
  9670. };
  9671. }
  9672. else
  9673. {
  9674. jw.Code = 400;
  9675. jw.Data = new
  9676. {
  9677. groupCost = Create.Data,
  9678. blackCodeIsTrue = false,
  9679. };
  9680. }
  9681. return Ok(jw);
  9682. }
  9683. /// <summary>
  9684. /// 成本获取OP历史车费用
  9685. /// </summary>
  9686. /// <param name="dto"></param>
  9687. /// <returns></returns>
  9688. [HttpPost]
  9689. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9690. {
  9691. var jw = JsonView(false);
  9692. try
  9693. {
  9694. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9695. //获取现有所有车的数据
  9696. if (!dto.Param.IsNullOrWhiteSpace())
  9697. {
  9698. string sql = $@"
  9699. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9700. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9701. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9702. 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
  9703. AND gctggr.ServiceEndTime is not NULL
  9704. ORDER by gctggrc.id DESC
  9705. ";
  9706. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9707. var numeberResult = await Task.Run(() =>
  9708. {
  9709. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9710. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9711. return numberArr;
  9712. });
  9713. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9714. foreach (var item in numeberResult)
  9715. {
  9716. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9717. {
  9718. Country = "数据异常!",
  9719. City = string.Empty,
  9720. };
  9721. item.Area = find.Country + " " + find.City;
  9722. }
  9723. dbResult.AddRange(numeberResult);
  9724. if (dto.Param.Contains("、"))
  9725. {
  9726. var sp = dto.Param.Split("、");
  9727. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9728. .Where(x =>
  9729. {
  9730. return System.Array.Exists(sp, e =>
  9731. {
  9732. bool where = false;
  9733. if (x.Area != null)
  9734. {
  9735. where = x.Area.Contains(e);
  9736. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9737. {
  9738. return false;
  9739. }
  9740. }
  9741. if (x.PriceName != null && !where)
  9742. {
  9743. where = x.PriceName.Contains(e);
  9744. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9745. {
  9746. return false;
  9747. }
  9748. }
  9749. return where;
  9750. });
  9751. }).ToList();
  9752. }
  9753. else
  9754. {
  9755. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9756. .Where(x =>
  9757. {
  9758. bool where = false;
  9759. if (x.Area != null)
  9760. {
  9761. where = x.Area.Contains(dto.Param);
  9762. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9763. {
  9764. return false;
  9765. }
  9766. }
  9767. if (x.PriceName != null && !where)
  9768. {
  9769. where = x.PriceName.Contains(dto.Param);
  9770. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9771. {
  9772. return false;
  9773. }
  9774. }
  9775. return where;
  9776. }
  9777. )
  9778. .ToList();
  9779. }
  9780. }
  9781. var view = dbResult.Select(x =>
  9782. {
  9783. decimal dp = 0.00M;
  9784. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9785. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9786. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9787. {
  9788. if (startB && endB)
  9789. {
  9790. var timesp = endD.Subtract(startD);
  9791. if ((timesp.Days + 1) != 0)
  9792. {
  9793. dp = x.Price / (timesp.Days + 1);
  9794. }
  9795. }
  9796. }
  9797. else
  9798. {
  9799. dp = x.Price;
  9800. }
  9801. return new
  9802. {
  9803. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9804. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9805. x.Area,
  9806. x.id,
  9807. price = x.Price.ToString("F2"),
  9808. x.PriceName,
  9809. x.PriceContent,
  9810. x.TeamName,
  9811. x.DatePrice,
  9812. dayPrice = dp.ToString("F2"),
  9813. };
  9814. }).OrderByDescending(x => x.id).ToList();
  9815. jw = JsonView(true, "获取成功!", view);
  9816. }
  9817. catch (Exception e)
  9818. {
  9819. jw = JsonView(false, e.Message);
  9820. }
  9821. return Ok(jw);
  9822. }
  9823. #endregion
  9824. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9825. /// <summary>
  9826. /// 酒店预订
  9827. /// 酒店费用列表 根据团组Id查询
  9828. /// </summary>
  9829. /// <param name="_dto"></param>
  9830. /// <returns></returns>
  9831. [HttpPost]
  9832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9833. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9834. {
  9835. #region 参数验证
  9836. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9837. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9838. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9839. #region 团组操作权限验证 76 酒店预定模块
  9840. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9841. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9842. #endregion
  9843. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9844. #region 页面操作权限验证
  9845. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9846. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9847. #endregion
  9848. #endregion
  9849. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9850. }
  9851. /// <summary>
  9852. /// 酒店预订
  9853. /// 基础数据
  9854. /// </summary>
  9855. /// <param name="_dto"></param>
  9856. /// <returns></returns>
  9857. [HttpPost]
  9858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9859. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9860. {
  9861. #region 参数验证
  9862. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9863. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9864. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9865. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9866. #region 页面操作权限验证
  9867. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9868. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9869. #endregion
  9870. #region 团组操作权限验证 76 酒店预定模块
  9871. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9872. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9873. #endregion
  9874. #endregion
  9875. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9876. }
  9877. /// <summary>
  9878. /// 酒店预订
  9879. /// 创建 入住卷号码
  9880. /// </summary>
  9881. /// <param name="_dto"></param>
  9882. /// <returns></returns>
  9883. [HttpPost]
  9884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9885. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9886. {
  9887. #region 参数验证
  9888. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9889. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9890. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9891. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9892. #region 页面操作权限验证
  9893. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9894. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9895. #endregion
  9896. #region 团组操作权限验证 76 酒店预定模块
  9897. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9898. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9899. #endregion
  9900. #endregion
  9901. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9902. if (data.Code != 0)
  9903. {
  9904. return Ok(JsonView(false, data.Msg));
  9905. }
  9906. return Ok(JsonView(true, data.Msg, data.Data));
  9907. }
  9908. /// <summary>
  9909. /// 酒店预订
  9910. /// 详情
  9911. /// </summary>
  9912. /// <param name="_dto"></param>
  9913. /// <returns></returns>
  9914. [HttpPost]
  9915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9916. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9917. {
  9918. #region 参数验证
  9919. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9920. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9921. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9922. #region 团组操作权限验证 76 酒店预定模块
  9923. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9924. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9925. #endregion
  9926. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9927. #region 页面操作权限验证
  9928. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9929. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9930. #endregion
  9931. #endregion
  9932. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9933. }
  9934. /// <summary>
  9935. /// 酒店预订
  9936. /// Add Or Edit
  9937. /// </summary>
  9938. /// <param name="_dto"></param>
  9939. /// <returns></returns>
  9940. [HttpPost]
  9941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9942. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9943. {
  9944. #region 参数验证
  9945. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9946. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9947. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9948. #region 团组操作权限验证 76 酒店预定模块
  9949. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9950. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9951. #endregion
  9952. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9953. #region 页面操作权限验证
  9954. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9955. if (_dto.Id == 0) // Add
  9956. {
  9957. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9958. }
  9959. else if (_dto.Id > 1) // Edit
  9960. {
  9961. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9962. }
  9963. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9964. #endregion
  9965. #endregion
  9966. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9967. if (_view.Code != 200)
  9968. {
  9969. return Ok(_view);
  9970. }
  9971. #region 应用推送
  9972. try
  9973. {
  9974. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9975. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9976. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9977. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  9978. //2024-10-21 新增LZ UID
  9979. var userIds = new List<int>() { 21 };
  9980. string title = $"费用审核";
  9981. var diId = _dto.DiId;
  9982. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9983. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9984. string content = "";
  9985. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9986. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9987. try
  9988. {
  9989. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  9990. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  9991. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  9992. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  9993. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  9994. }
  9995. catch (Exception ex )
  9996. {
  9997. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  9998. }
  9999. }
  10000. catch (Exception ex)
  10001. {
  10002. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  10003. }
  10004. try
  10005. {
  10006. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10007. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10008. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10009. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10010. //自动审核
  10011. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  10012. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  10013. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  10014. //2024-10-21 新增LZ UID
  10015. var userIds = new List<int>() { 21 };
  10016. string title = $"系统通知";
  10017. var diId = _dto.DiId;
  10018. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10019. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10020. string content = "";
  10021. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10022. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10023. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10024. }
  10025. catch (Exception ex)
  10026. {
  10027. }
  10028. #endregion
  10029. return Ok(_view);
  10030. }
  10031. /// <summary>
  10032. /// 酒店自动审核测试
  10033. /// Add Or Edit
  10034. /// </summary>
  10035. /// <param name="_dto"></param>
  10036. /// <returns></returns>
  10037. [HttpPost]
  10038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10039. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  10040. {
  10041. #region 应用推送
  10042. try
  10043. {
  10044. //自动审核
  10045. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  10046. }
  10047. catch (Exception ex)
  10048. {
  10049. return Ok(JsonView(false, "操作失败"));
  10050. }
  10051. #endregion
  10052. return Ok(JsonView(false, "操作成功"));
  10053. }
  10054. /// <summary>
  10055. /// 酒店预订
  10056. /// Del
  10057. /// </summary>
  10058. /// <param name="_dto"></param>
  10059. /// <returns></returns>
  10060. [HttpPost]
  10061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10062. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  10063. {
  10064. #region 参数验证
  10065. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10066. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10067. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10068. #region 团组操作权限验证 76 酒店预定模块
  10069. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10070. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10071. #endregion
  10072. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10073. #region 页面操作权限验证
  10074. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10075. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10076. #endregion
  10077. #endregion
  10078. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  10079. }
  10080. /// <summary>
  10081. /// 酒店预订
  10082. /// 生成VOUCHER
  10083. /// 2024.05.06 之前版本
  10084. /// </summary>
  10085. /// <param name="_dto"></param>
  10086. /// <returns></returns>
  10087. [HttpPost]
  10088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10089. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  10090. {
  10091. try
  10092. {
  10093. #region 参数验证
  10094. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10095. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10096. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10097. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  10098. #region 团组操作权限验证 76 酒店预定模块
  10099. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10100. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10101. #endregion
  10102. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10103. #region 页面操作权限验证
  10104. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10105. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10106. #endregion
  10107. #endregion
  10108. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  10109. //判断数据是否完整
  10110. if (hr != null)
  10111. {
  10112. if (!string.IsNullOrEmpty(hr.DetermineNo))
  10113. {
  10114. string strFileName = "HotelStatement/";
  10115. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10116. if (dele != null)
  10117. strFileName += dele.TourCode;
  10118. //载入模板
  10119. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  10120. Document doc = new Document(sss);
  10121. DocumentBuilder builder = new DocumentBuilder(doc);
  10122. #region 替换Word模板书签内容
  10123. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  10124. //入住卷预定号码
  10125. if (doc.Range.Bookmarks["VNO"] != null)
  10126. {
  10127. Bookmark mark = doc.Range.Bookmarks["VNO"];
  10128. mark.Text = hr.CheckNumber;
  10129. }
  10130. //酒店时间
  10131. if (doc.Range.Bookmarks["Date"] != null)
  10132. {
  10133. Bookmark mark = doc.Range.Bookmarks["Date"];
  10134. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  10135. }
  10136. //团号
  10137. if (doc.Range.Bookmarks["TNo"] != null)
  10138. {
  10139. Bookmark mark = doc.Range.Bookmarks["TNo"];
  10140. mark.Text = dele.TourCode;
  10141. }
  10142. //预定号码
  10143. if (doc.Range.Bookmarks["BookingId"] != null)
  10144. {
  10145. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  10146. mark.Text = hr.ReservationsNo;
  10147. }
  10148. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  10149. {
  10150. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  10151. mark.Text = hr.DetermineNo;
  10152. }
  10153. //酒店城市
  10154. if (doc.Range.Bookmarks["City"] != null)
  10155. {
  10156. Bookmark mark = doc.Range.Bookmarks["City"];
  10157. mark.Text = hr.City;
  10158. }
  10159. //酒店名称
  10160. if (doc.Range.Bookmarks["HName"] != null)
  10161. {
  10162. Bookmark mark = doc.Range.Bookmarks["HName"];
  10163. mark.Text = hr.HotelName;
  10164. }
  10165. //酒店地址
  10166. if (doc.Range.Bookmarks["Address"] != null)
  10167. {
  10168. Bookmark mark = doc.Range.Bookmarks["Address"];
  10169. mark.Text = hr.HotelAddress;
  10170. }
  10171. //酒店电话
  10172. if (doc.Range.Bookmarks["Tel"] != null)
  10173. {
  10174. Bookmark mark = doc.Range.Bookmarks["Tel"];
  10175. mark.Text = hr.HotelTel;
  10176. }
  10177. //酒店传真
  10178. if (doc.Range.Bookmarks["Fax"] != null)
  10179. {
  10180. Bookmark mark = doc.Range.Bookmarks["Fax"];
  10181. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  10182. {
  10183. mark.Text = hr.HotelFax;
  10184. }
  10185. }
  10186. //入住时间
  10187. if (doc.Range.Bookmarks["CIn"] != null)
  10188. {
  10189. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  10190. Bookmark mark = doc.Range.Bookmarks["CIn"];
  10191. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  10192. }
  10193. //退房时间
  10194. if (doc.Range.Bookmarks["COut"] != null)
  10195. {
  10196. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  10197. Bookmark mark = doc.Range.Bookmarks["COut"];
  10198. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  10199. }
  10200. //客户名称
  10201. if (doc.Range.Bookmarks["GName"] != null)
  10202. {
  10203. string guestName = "";
  10204. string[] clients = new string[] { };
  10205. if (hr.GuestName.Contains(","))
  10206. {
  10207. clients = hr.GuestName.Split(",");
  10208. }
  10209. else
  10210. {
  10211. clients = new string[] { hr.GuestName };
  10212. }
  10213. List<int> clientIds_int = new List<int>();
  10214. if (clients.Length > 0)
  10215. {
  10216. foreach (var item in clients)
  10217. {
  10218. if (item.IsNumeric())
  10219. {
  10220. clientIds_int.Add(int.Parse(item));
  10221. }
  10222. }
  10223. }
  10224. if (clientIds_int.Count > 0)
  10225. {
  10226. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  10227. foreach (var client in _clientDatas)
  10228. {
  10229. //男
  10230. if (client.Sex == 0) guestName += $"Mr.";
  10231. //女
  10232. else if (client.Sex == 1) guestName += $"Ms.";
  10233. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  10234. {
  10235. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  10236. }
  10237. //guestName += $"{client.Pinyin},";
  10238. }
  10239. if (guestName.Length > 0)
  10240. {
  10241. guestName = guestName.Substring(0, guestName.Length - 1);
  10242. }
  10243. }
  10244. else
  10245. {
  10246. guestName = hr.GuestName;
  10247. }
  10248. Bookmark mark = doc.Range.Bookmarks["GName"];
  10249. mark.Text = guestName;
  10250. }
  10251. //房间介绍
  10252. if (doc.Range.Bookmarks["ROOM"] != null)
  10253. {
  10254. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  10255. mark.Text = hr.RoomExplanation;
  10256. }
  10257. //报价描述
  10258. if (doc.Range.Bookmarks["NOTE"] != null)
  10259. {
  10260. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  10261. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  10262. if (ss != null)
  10263. mark.Text = ss.Name;
  10264. }
  10265. //入住时间
  10266. if (doc.Range.Bookmarks["CheckIn"] != null)
  10267. {
  10268. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  10269. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  10270. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10271. }
  10272. //退房时间
  10273. if (doc.Range.Bookmarks["CheckOut"] != null)
  10274. {
  10275. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  10276. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  10277. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  10278. }
  10279. //日期
  10280. if (doc.Range.Bookmarks["DT"] != null)
  10281. {
  10282. Bookmark mark = doc.Range.Bookmarks["DT"];
  10283. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  10284. }
  10285. //名称
  10286. if (doc.Range.Bookmarks["VName"] != null)
  10287. {
  10288. Bookmark mark = doc.Range.Bookmarks["VName"];
  10289. mark.Text = hr.HotelName;
  10290. }
  10291. //号码
  10292. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  10293. {
  10294. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  10295. mark.Text = hr.CheckNumber;
  10296. }
  10297. #endregion
  10298. strFileName += "VOUCHER.doc";
  10299. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10300. doc.Save(fileDir);
  10301. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10302. return Ok(JsonView(true, "操作成功!", Url));
  10303. }
  10304. else
  10305. {
  10306. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  10307. }
  10308. }
  10309. else
  10310. {
  10311. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  10312. }
  10313. }
  10314. catch (Exception ex)
  10315. {
  10316. return Ok(JsonView(false, ex.Message));
  10317. }
  10318. }
  10319. /// <summary>
  10320. /// 酒店预订
  10321. /// 生成VOUCHER
  10322. /// 2024.05.06 之后版本
  10323. /// </summary>
  10324. /// <param name="_dto"></param>
  10325. /// <returns></returns>
  10326. [HttpPost]
  10327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10328. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  10329. {
  10330. #region 参数验证
  10331. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10332. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10333. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10334. #region 团组操作权限验证 76 酒店预定模块
  10335. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10336. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10337. #endregion
  10338. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10339. #region 页面操作权限验证
  10340. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10341. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10342. #endregion
  10343. #endregion
  10344. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10345. //判断数据是否完整
  10346. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10347. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10348. string strFileName = "HotelStatement/";
  10349. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10350. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  10351. #region 数据处理
  10352. List<int> guestIds = new List<int>();
  10353. int index = 0;
  10354. foreach (var item in hrDtas)
  10355. {
  10356. if (item.GuestName.Contains(","))
  10357. {
  10358. string[] guestIdArr = item.GuestName.Split(',');
  10359. foreach (var guestIdStr in guestIdArr)
  10360. {
  10361. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  10362. if (guestBool)
  10363. {
  10364. guestIds.Add(guestId);
  10365. }
  10366. }
  10367. }
  10368. else guestNames += item.GuestName;
  10369. var voucherInfo = new HotelVoucherInfoView()
  10370. {
  10371. HotelName = item.HotelName,
  10372. CheckInDate = item.CheckInDate,
  10373. CheckOutDate = item.CheckOutDate,
  10374. ConfirmationNumber = item.DetermineNo.Trim(),
  10375. RoomType = item.RoomExplanation
  10376. };
  10377. vouchers.Add(voucherInfo);
  10378. }
  10379. if (guestIds.Count > 0)
  10380. {
  10381. guestIds = guestIds.Distinct().ToList();
  10382. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  10383. if (guestDatas.Count > 0)
  10384. {
  10385. guestNames = "";
  10386. foreach (var guest in guestDatas)
  10387. {
  10388. string guestName = "";
  10389. if (guest.Sex == 0) guestName += @"MR.";
  10390. else if (guest.Sex == 1) guestName += @"MS.";
  10391. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10392. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10393. guestNames += @$"{guestName.Trim()}、";
  10394. }
  10395. if (guestNames.Length > 0)
  10396. {
  10397. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10398. }
  10399. }
  10400. }
  10401. #endregion
  10402. //载入模板
  10403. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  10404. Document doc = new Document(sss);
  10405. DocumentBuilder builder = new DocumentBuilder(doc);
  10406. if (doc.Range.Bookmarks["GuestName"] != null)
  10407. {
  10408. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  10409. mark.Text = guestNames;
  10410. }
  10411. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10412. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  10413. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  10414. for (int i = 1; i <= vouchers.Count; i++)
  10415. {
  10416. HotelVoucherInfoView hviv = vouchers[i - 1];
  10417. builder.MoveToCell(0, i, 0, 0);
  10418. builder.Write(hviv.HotelName);
  10419. builder.MoveToCell(0, i, 1, 0);
  10420. builder.Write(hviv.CheckInDate);
  10421. builder.MoveToCell(0, i, 2, 0);
  10422. builder.Write(hviv.CheckOutDate);
  10423. builder.MoveToCell(0, i, 3, 0);
  10424. builder.Write(hviv.RoomType);
  10425. builder.MoveToCell(0, i, 4, 0);
  10426. builder.Write(hviv.ConfirmationNumber);
  10427. }
  10428. //删除多余行
  10429. int currRowIndex = vouchers.Count + 1;
  10430. int delRows = 21 - currRowIndex;
  10431. if (delRows > 0)
  10432. {
  10433. for (int i = 0; i < delRows; i++)
  10434. {
  10435. table.Rows.RemoveAt(currRowIndex);
  10436. //cultivateRowIndex++;
  10437. }
  10438. }
  10439. strFileName += "VOUCHER.docx";
  10440. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10441. doc.Save(fileDir);
  10442. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10443. return Ok(JsonView(true, "操作成功!", Url));
  10444. }
  10445. /// <summary>
  10446. /// 酒店预订
  10447. /// 生成VOUCHER 批量生成
  10448. /// New
  10449. /// </summary>
  10450. /// <param name="_dto"></param>
  10451. /// <returns></returns>
  10452. [HttpPost]
  10453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10454. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10455. {
  10456. #region 参数验证
  10457. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10458. if (_dto.PageId < 1) _dto.PageId = 28;
  10459. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10460. #region 团组操作权限验证 76 酒店预定模块
  10461. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10462. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10463. #endregion
  10464. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10465. #region 页面操作权限验证
  10466. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10467. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10468. #endregion
  10469. #endregion
  10470. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10471. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10472. .OrderBy(x => x.CheckInDate)
  10473. .ToListAsync();
  10474. //判断数据是否完整
  10475. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10476. string strFileName = "HotelStatement/";
  10477. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10478. if (dele != null)
  10479. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10480. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10481. for (int i = 0; i < hrDtas.Count; i++)
  10482. {
  10483. string guestNames = string.Empty;
  10484. List<int> guestIds = new List<int>();
  10485. var item = hrDtas[i];
  10486. //处理客户姓名
  10487. if (item.GuestName.Contains(","))
  10488. {
  10489. string[] guestIdArr = item.GuestName.Split(',');
  10490. foreach (var guestIdStr in guestIdArr)
  10491. if (int.TryParse(guestIdStr, out int guestId))
  10492. guestIds.Add(guestId);
  10493. }
  10494. else
  10495. {
  10496. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10497. if (guestIdBool)
  10498. {
  10499. guestIds.Add(guestId);
  10500. }
  10501. //NaN
  10502. if (item.GuestName.Contains("NaN"))
  10503. {
  10504. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10505. }
  10506. }
  10507. if (guestIds.Count > 0)
  10508. {
  10509. guestIds = guestIds.Distinct().ToList();
  10510. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10511. if (guestDatas1.Count > 0)
  10512. {
  10513. guestNames = "";
  10514. foreach (var guest in guestDatas1)
  10515. {
  10516. string guestName = "";
  10517. if (guest.Sex == 0) guestName += @"MR.";
  10518. else if (guest.Sex == 1) guestName += @"MS.";
  10519. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10520. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10521. guestNames += @$"{guestName.Trim()}、";
  10522. }
  10523. if (guestNames.Length > 0)
  10524. {
  10525. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10526. }
  10527. }
  10528. }
  10529. //if (!string.IsNullOrEmpty(guestNames))
  10530. //{
  10531. hrDtas[i].GuestName = guestNames;
  10532. //}
  10533. }
  10534. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10535. Document doc = new Document();
  10536. DocumentBuilder builder = new DocumentBuilder(doc);
  10537. try
  10538. {
  10539. builder.MoveToDocumentStart();
  10540. foreach (var item in hrDtas)
  10541. {
  10542. //标题
  10543. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10544. builder.ParagraphFormat.LineSpacing = 1;
  10545. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10546. builder.ParagraphFormat.Style.Font.Size = 9;
  10547. builder.ParagraphFormat.Style.Font.Bold = true;
  10548. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10549. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10550. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10551. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10552. builder.ParagraphFormat.LineSpacing = 1;
  10553. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10554. builder.ParagraphFormat.Style.Font.Size = 9;
  10555. builder.ParagraphFormat.Style.Font.Bold = true;
  10556. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10557. builder.StartTable();
  10558. // 设置边框颜色
  10559. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10560. //设置边框样式
  10561. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10562. //表格
  10563. #region 第一行
  10564. builder.InsertCell();
  10565. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10566. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10567. //builder.CellFormat.AllowAutoFit = false;
  10568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10569. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10570. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10571. builder.CellFormat.WrapText = true; //自动换行
  10572. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10573. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10574. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10575. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10576. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10577. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10578. builder.Write("TOUR NO:");
  10579. builder.InsertCell();
  10580. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10581. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10582. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10583. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10584. builder.ParagraphFormat.Style.Font.Bold = false;
  10585. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10586. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10587. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10588. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10589. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10590. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10591. builder.Write($"{dele?.TourCode ?? "-"}");
  10592. builder.InsertCell();
  10593. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10594. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10595. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10596. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10597. builder.ParagraphFormat.Style.Font.Bold = false;
  10598. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10599. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10600. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10601. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10602. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10603. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10604. builder.Write($"CITY:");
  10605. builder.InsertCell();
  10606. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10607. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10608. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10609. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10610. builder.ParagraphFormat.Style.Font.Bold = false;
  10611. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10612. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10613. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10614. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10615. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10616. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10617. builder.Write($"{item.City}");
  10618. builder.EndRow();
  10619. #endregion
  10620. #region 第二行
  10621. builder.InsertCell();
  10622. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10623. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10624. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10625. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10626. builder.ParagraphFormat.Style.Font.Bold = false;
  10627. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10628. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10629. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10630. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10631. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10632. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10633. builder.Write("CONFIRMATION NO:");
  10634. builder.InsertCell();
  10635. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10636. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10637. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10638. builder.ParagraphFormat.Style.Font.Bold = false;
  10639. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10640. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10641. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10642. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10643. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10644. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10645. builder.CellFormat.VerticalMerge = CellMerge.None;
  10646. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10647. builder.Write($"{item.DetermineNo}");
  10648. builder.InsertCell();
  10649. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10650. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10651. builder.InsertCell();
  10652. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10653. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10654. builder.EndRow();
  10655. #endregion
  10656. #region 第三行
  10657. builder.InsertCell();
  10658. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10659. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10660. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10661. builder.ParagraphFormat.Style.Font.Bold = false;
  10662. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10663. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10664. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10665. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10666. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10667. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10668. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10669. builder.Write($"HOTEL NAME:");
  10670. builder.InsertCell();
  10671. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10672. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10673. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10674. builder.ParagraphFormat.Style.Font.Bold = false;
  10675. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10676. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10677. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10678. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10679. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10680. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10681. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10682. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10683. builder.Write($"{item.HotelName}");
  10684. builder.InsertCell();
  10685. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10686. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10687. builder.InsertCell();
  10688. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10689. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10690. builder.EndRow();
  10691. #endregion
  10692. #region 第四行
  10693. builder.InsertCell();
  10694. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10695. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10696. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10697. builder.ParagraphFormat.Style.Font.Bold = false;
  10698. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10699. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10700. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10701. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10702. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10703. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10704. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10705. builder.Write($"HOTEL ADDRESS:");
  10706. builder.InsertCell();
  10707. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10708. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10709. builder.ParagraphFormat.Style.Font.Size = 8;
  10710. builder.ParagraphFormat.Style.Font.Bold = false;
  10711. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10712. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10713. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10714. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10715. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10716. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10717. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10718. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10719. builder.Write($"{item.HotelAddress}");
  10720. builder.InsertCell();
  10721. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10722. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10723. builder.InsertCell();
  10724. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10725. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10726. builder.EndRow();
  10727. #endregion
  10728. #region 第五行
  10729. builder.InsertCell();
  10730. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10731. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10732. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10733. builder.ParagraphFormat.Style.Font.Bold = false;
  10734. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10735. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10736. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10737. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10738. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10739. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10740. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10741. builder.Write("TEL:");
  10742. builder.InsertCell();
  10743. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10744. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10745. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10746. builder.ParagraphFormat.Style.Font.Bold = false;
  10747. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10748. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10749. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10750. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10751. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10752. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10753. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10754. builder.Write($"{item.HotelTel}");
  10755. builder.InsertCell();
  10756. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10757. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10758. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10759. builder.ParagraphFormat.Style.Font.Bold = false;
  10760. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10761. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10762. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10763. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10764. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10765. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10766. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10767. builder.Write($"FAX:");
  10768. builder.InsertCell();
  10769. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10770. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10771. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10772. builder.ParagraphFormat.Style.Font.Bold = false;
  10773. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10774. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10775. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10776. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10777. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10778. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10779. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10780. builder.Write($"{item.HotelFax}");
  10781. builder.EndRow();
  10782. #endregion
  10783. #region 第六行
  10784. builder.InsertCell();
  10785. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10786. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10787. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10788. builder.ParagraphFormat.Style.Font.Bold = false;
  10789. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10790. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10791. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10792. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10793. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10794. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10795. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10796. builder.Write("CHECK IN:");
  10797. builder.InsertCell();
  10798. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10799. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10800. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10801. builder.ParagraphFormat.Style.Font.Bold = false;
  10802. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10803. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10804. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10805. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10806. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10807. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10808. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10809. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10810. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10811. builder.Write($"{checkInStr}");
  10812. builder.InsertCell();
  10813. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10814. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10815. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10816. builder.ParagraphFormat.Style.Font.Bold = false;
  10817. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10818. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10819. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10820. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10821. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10822. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10823. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10824. builder.Write($"CHECK OUT:");
  10825. builder.InsertCell();
  10826. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10827. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10828. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10829. builder.ParagraphFormat.Style.Font.Bold = false;
  10830. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10831. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10832. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10833. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10834. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10835. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10836. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10837. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10838. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10839. builder.Write($"{checkOutStr}");
  10840. builder.EndRow();
  10841. #endregion
  10842. #region 第七行
  10843. builder.InsertCell();
  10844. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10845. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10846. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10847. builder.ParagraphFormat.Style.Font.Bold = false;
  10848. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10849. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10850. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10851. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10852. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10853. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10854. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10855. builder.Write($"GUEST NAME:");
  10856. builder.InsertCell();
  10857. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10858. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10859. builder.ParagraphFormat.Style.Font.Size = 8;
  10860. builder.ParagraphFormat.Style.Font.Bold = false;
  10861. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10862. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10863. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10864. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10865. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10866. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10867. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10868. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10869. builder.Write($"{item.GuestName}");
  10870. builder.InsertCell();
  10871. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10872. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10873. builder.InsertCell();
  10874. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10875. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10876. builder.EndRow();
  10877. #endregion
  10878. #region 第八行
  10879. builder.InsertCell();
  10880. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10881. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10882. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10883. builder.ParagraphFormat.Style.Font.Bold = false;
  10884. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10885. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10886. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10887. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10888. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10889. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10890. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10891. builder.Write($"ROOM TYPE:");
  10892. builder.InsertCell();
  10893. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10894. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10895. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10896. builder.ParagraphFormat.Style.Font.Bold = false;
  10897. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10898. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10899. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10900. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10901. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10902. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10903. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10904. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10905. builder.Write($"{item.RoomExplanation}");
  10906. builder.InsertCell();
  10907. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10908. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10909. builder.InsertCell();
  10910. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10911. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10912. builder.EndRow();
  10913. #endregion
  10914. #region 第九行
  10915. builder.InsertCell();
  10916. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10917. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10918. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10919. builder.ParagraphFormat.Style.Font.Bold = false;
  10920. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10921. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10922. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10923. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10924. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10925. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10926. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10927. builder.Write($"NOTE:");
  10928. builder.InsertCell();
  10929. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10930. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10931. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10932. builder.ParagraphFormat.Style.Font.Bold = false;
  10933. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10934. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10935. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10936. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10937. 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.");
  10938. builder.InsertCell();
  10939. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10940. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10941. builder.InsertCell();
  10942. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10943. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10944. builder.EndRow();
  10945. #endregion
  10946. builder.EndTable();
  10947. //换行
  10948. builder.Writeln("");
  10949. builder.Writeln("");
  10950. }
  10951. #region 获取文档中的所有表格 设置文字自适应
  10952. // 获取文档中的所有表格。
  10953. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10954. {
  10955. // 遍历表格中的所有行。
  10956. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10957. {
  10958. foreach (Cell cell in row.Cells)
  10959. {
  10960. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10961. cellFormat.Width = 0;
  10962. }
  10963. }
  10964. }
  10965. #endregion
  10966. #region 设置页眉
  10967. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10968. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10969. if (System.IO.File.Exists(voucherHeaderPath))
  10970. {
  10971. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10972. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10973. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10974. Shape shape = builder.InsertImage(imageBytes);
  10975. // 调整图片位置
  10976. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10977. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10978. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10979. shape.Left = 0; // 将图片距离页面左边缘的距离
  10980. shape.Width = 81; // 设置图片宽度
  10981. shape.Height = 36; // 设置图片高度
  10982. }
  10983. //靠右
  10984. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10985. //// 设置页脚上下边距
  10986. //builder.PageSetup.HeaderDistance = 42;
  10987. // 添加页眉线
  10988. Aspose.Words.Border borderHeader = null;
  10989. try
  10990. {
  10991. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10992. }
  10993. catch (Exception e)
  10994. {
  10995. // TODO Auto-generated catch block
  10996. //e.printStackTrace();
  10997. }
  10998. borderHeader.Shadow = true;
  10999. borderHeader.DistanceFromText = 2;
  11000. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  11001. #endregion
  11002. }
  11003. catch (Exception ex)
  11004. {
  11005. }
  11006. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11007. doc.Save(fileDir);
  11008. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11009. return Ok(JsonView(true, "操作成功!", Url));
  11010. }
  11011. /// <summary>
  11012. /// 酒店预订
  11013. /// 生成 预定成本 Excel
  11014. /// </summary>
  11015. /// <param name="_dto"></param>
  11016. /// <returns></returns>
  11017. [HttpPost]
  11018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11019. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  11020. {
  11021. #region 参数验证
  11022. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  11023. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  11024. if (!vadalitorRes.IsValid)
  11025. {
  11026. var errors = new StringBuilder();
  11027. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  11028. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  11029. }
  11030. #region 团组操作权限验证 76 酒店预定模块
  11031. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11032. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11033. #endregion
  11034. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11035. #region 页面操作权限验证
  11036. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11037. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11038. #endregion
  11039. #endregion
  11040. decimal _rate = 1.00M;
  11041. string _currency = string.Empty;
  11042. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  11043. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11044. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  11045. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11046. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  11047. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  11048. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  11049. if (_GroupCostParameter == null)
  11050. {
  11051. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  11052. bool isIntType = int.TryParse(_currency, out int currId);
  11053. if (isIntType)
  11054. {
  11055. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  11056. }
  11057. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  11058. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  11059. if (currInfo == null)
  11060. {
  11061. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  11062. }
  11063. else _rate = currInfo.Rate;
  11064. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  11065. {
  11066. _rate = _GroupCostParameter.Rate;
  11067. }
  11068. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11069. string strFileName = "HotelStatement/";
  11070. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11071. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  11072. var rateDatas = new List<dynamic>();
  11073. #region 数据处理
  11074. foreach (var item in hrDtas)
  11075. {
  11076. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  11077. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  11078. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  11079. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  11080. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  11081. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  11082. {
  11083. continue;
  11084. }
  11085. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  11086. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  11087. string singleRoomFeeStr = string.Empty,
  11088. doubleRoomFeeStr = string.Empty,
  11089. suiteRoomFeeStr = string.Empty,
  11090. otherRoomFeeStr = string.Empty,
  11091. payMoneyStr = string.Empty,
  11092. cardPriceStr = string.Empty;
  11093. if (roomCurr.Equals("CNY"))
  11094. {
  11095. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  11096. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11097. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11098. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11099. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11100. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  11101. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  11102. }
  11103. else
  11104. {
  11105. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11106. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11107. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11108. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11109. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  11110. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  11111. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  11112. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  11113. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  11114. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  11115. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  11116. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  11117. if (ccpPaymentCurrency.Equals("CNY"))
  11118. {
  11119. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  11120. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  11121. }
  11122. else
  11123. {
  11124. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  11125. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  11126. }
  11127. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  11128. if (hotelcardPriceCurrency.Equals("CNY"))
  11129. {
  11130. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  11131. }
  11132. else
  11133. {
  11134. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  11135. }
  11136. }
  11137. string breakfastPriceStr = string.Empty,
  11138. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  11139. governmentRentStr = string.Empty,
  11140. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  11141. cityTaxStr = string.Empty,
  11142. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  11143. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  11144. if (!string.IsNullOrEmpty(breakfastCurrency1))
  11145. {
  11146. if (breakfastCurrency1.Equals("CNY"))
  11147. {
  11148. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  11149. }
  11150. else
  11151. {
  11152. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  11153. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  11154. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  11155. }
  11156. }
  11157. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  11158. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  11159. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  11160. {
  11161. if (governmentRentCurrency.Equals("CNY"))
  11162. {
  11163. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  11164. }
  11165. else
  11166. {
  11167. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  11168. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  11169. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  11170. }
  11171. }
  11172. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  11173. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  11174. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  11175. {
  11176. if (cityTaxStrCurrency1.Equals("CNY"))
  11177. {
  11178. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  11179. }
  11180. else
  11181. {
  11182. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  11183. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  11184. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  11185. }
  11186. }
  11187. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  11188. int payDId = roomInfo?.PayDId ?? 0;
  11189. pcfds.Add(new HotelReservations_PCFD_View()
  11190. {
  11191. City = item.City,
  11192. HotelName = item.HotelName,
  11193. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  11194. // SingleRoomCount = item.SingleRoomCount,
  11195. SingleRoomPrice = singleRoomFeeStr,
  11196. // DoubleRoomCount = item.DoubleRoomCount,
  11197. DoubleRoomPrice = doubleRoomFeeStr,
  11198. //SuiteRoomCount = item.SuiteRoomCount,
  11199. SuiteRoomPrice = suiteRoomFeeStr,
  11200. OtherRoomPrice = otherRoomFeeStr,
  11201. //OtherRoomCount = item.OtherRoomCount,
  11202. BreakfastPrice = breakfastPriceStr,
  11203. GovernmentRent = governmentRentStr,
  11204. CityTax = cityTaxStr,
  11205. RoomExplanation = item.RoomExplanation,
  11206. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11207. PayTime = roomInfo?.ConsumptionDate,
  11208. BankNo = roomInfo?.BankNo,
  11209. PayMoney = payMoneyStr,
  11210. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11211. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11212. CardPrice = cardPriceStr,
  11213. Remark = ccpInfo.Remark
  11214. });
  11215. }
  11216. #endregion
  11217. //载入模板
  11218. WorkbookDesigner designer = new WorkbookDesigner();
  11219. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11220. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11221. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11222. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11223. var rateDatas1 = rateDatas.Distinct();
  11224. var rateStr = string.Empty;
  11225. foreach (var item in rateDatas1)
  11226. {
  11227. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  11228. }
  11229. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  11230. designer.SetDataSource("Opertor", userInfo.CnName);
  11231. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11232. dt.TableName = "ViewMyHotelReservations";
  11233. designer.SetDataSource(dt);
  11234. designer.Process();
  11235. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11236. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11237. designer.Workbook.Save(serverPath);
  11238. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11239. #region 删除指定行
  11240. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11241. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11242. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11243. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11244. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11245. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11246. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11247. cssIndex = dt.Columns["CityTax"].Ordinal,
  11248. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11249. remarkIndex = dt.Columns["Remark"].Ordinal;
  11250. //删除指定列
  11251. foreach (DataRow item in dt.Rows)
  11252. {
  11253. string singleStr = item["SingleRoomPrice"].ToString();
  11254. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11255. if (containsDigitButNotZero1) singleDel = false;
  11256. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11257. string doubleStr = item["DoubleRoomPrice"].ToString();
  11258. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11259. if (containsDigitButNotZero2) doubleDel = false;
  11260. string suiteStr = item["SuiteRoomPrice"].ToString();
  11261. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11262. if (containsDigitButNotZero3) suiteDel = false;
  11263. string otherStr = item["OtherRoomPrice"].ToString();
  11264. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11265. if (containsDigitButNotZero4) otherDel = false;
  11266. string zcStr = item["BreakfastPrice"].ToString();
  11267. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11268. if (containsDigitButNotZero5) zcDel = false;
  11269. string dsStr = item["GovernmentRent"].ToString();
  11270. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11271. if (containsDigitButNotZero6) dsDel = false;
  11272. string cssStr = item["CityTax"].ToString();
  11273. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11274. if (containsDigitButNotZero7) cssDel = false;
  11275. string cpStr = item["ConsumptionPatterns"].ToString();
  11276. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11277. string remarkStr = item["Remark"].ToString();
  11278. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11279. }
  11280. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11281. DeleteColumn(serverPath, cpIndex, cpDel);
  11282. DeleteColumn(serverPath, dsIndex, dsDel);
  11283. DeleteColumn(serverPath, cssIndex, cssDel);
  11284. DeleteColumn(serverPath, zcIndex, zcDel);
  11285. DeleteColumn(serverPath, otherIndex, otherDel);
  11286. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11287. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11288. DeleteColumn(serverPath, singleIndex, singleDel);
  11289. #endregion
  11290. //只保留第一个表格
  11291. DeleteSheet(serverPath);
  11292. return Ok(JsonView(true, "操作成功", url = rst));
  11293. }
  11294. else
  11295. {
  11296. _currency = _GroupCostParameter.Currency;
  11297. bool isIntType = int.TryParse(_currency, out int currId);
  11298. if (isIntType)
  11299. {
  11300. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  11301. }
  11302. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  11303. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  11304. if (currInfo == null)
  11305. {
  11306. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  11307. }
  11308. if (!_currency.ToUpper().Equals("CNY"))
  11309. {
  11310. _rate = _GroupCostParameter.Rate;
  11311. }
  11312. _rate = currInfo.Rate;
  11313. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11314. string strFileName = "HotelStatement/";
  11315. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11316. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  11317. #region 数据处理
  11318. foreach (var item in hrDtas)
  11319. {
  11320. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  11321. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  11322. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  11323. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  11324. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  11325. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  11326. string singleRoomFeeStr = string.Empty,
  11327. doubleRoomFeeStr = string.Empty,
  11328. suiteRoomFeeStr = string.Empty,
  11329. otherRoomFeeStr = string.Empty,
  11330. payMoneyStr = string.Empty,
  11331. cardPriceStr = string.Empty;
  11332. if (roomCurr.Equals(_currency))
  11333. {
  11334. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  11335. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  11336. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  11337. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  11338. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  11339. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  11340. }
  11341. else
  11342. {
  11343. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11344. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11345. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11346. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11347. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  11348. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  11349. }
  11350. string breakfastPriceStr = string.Empty,
  11351. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  11352. governmentRentStr = string.Empty,
  11353. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  11354. cityTaxStrStr = string.Empty,
  11355. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  11356. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  11357. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  11358. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  11359. int payDId = roomInfo?.PayDId ?? 0;
  11360. pcfds.Add(new HotelReservations_PCFD_View()
  11361. {
  11362. City = item.City,
  11363. HotelName = item.HotelName,
  11364. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  11365. // SingleRoomCount = item.SingleRoomCount,
  11366. SingleRoomPrice = singleRoomFeeStr,
  11367. // DoubleRoomCount = item.DoubleRoomCount,
  11368. DoubleRoomPrice = doubleRoomFeeStr,
  11369. //SuiteRoomCount = item.SuiteRoomCount,
  11370. SuiteRoomPrice = suiteRoomFeeStr,
  11371. OtherRoomPrice = otherRoomFeeStr,
  11372. //OtherRoomCount = item.OtherRoomCount,
  11373. BreakfastPrice = breakfastPriceStr,
  11374. GovernmentRent = governmentRentStr,
  11375. CityTax = cityTaxStrStr,
  11376. RoomExplanation = item.RoomExplanation,
  11377. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11378. PayTime = roomInfo?.ConsumptionDate,
  11379. BankNo = roomInfo?.BankNo,
  11380. PayMoney = payMoneyStr,
  11381. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11382. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11383. CardPrice = cardPriceStr,
  11384. Remark = ccpInfo.Remark
  11385. });
  11386. }
  11387. #endregion
  11388. //载入模板
  11389. WorkbookDesigner designer = new WorkbookDesigner();
  11390. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11391. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11392. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11393. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11394. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  11395. designer.SetDataSource("Opertor", userInfo.CnName);
  11396. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11397. dt.TableName = "ViewMyHotelReservations";
  11398. designer.SetDataSource(dt);
  11399. designer.Process();
  11400. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11401. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11402. designer.Workbook.Save(serverPath);
  11403. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11404. #region 删除指定行
  11405. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11406. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11407. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11408. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11409. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11410. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11411. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11412. cssIndex = dt.Columns["CityTax"].Ordinal,
  11413. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11414. remarkIndex = dt.Columns["Remark"].Ordinal;
  11415. //删除指定列
  11416. foreach (DataRow item in dt.Rows)
  11417. {
  11418. string singleStr = item["SingleRoomPrice"].ToString();
  11419. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11420. if (containsDigitButNotZero1) singleDel = false;
  11421. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11422. string doubleStr = item["DoubleRoomPrice"].ToString();
  11423. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11424. if (containsDigitButNotZero2) doubleDel = false;
  11425. string suiteStr = item["SuiteRoomPrice"].ToString();
  11426. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11427. if (containsDigitButNotZero3) suiteDel = false;
  11428. string otherStr = item["OtherRoomPrice"].ToString();
  11429. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11430. if (containsDigitButNotZero4) otherDel = false;
  11431. string zcStr = item["BreakfastPrice"].ToString();
  11432. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11433. if (containsDigitButNotZero5) zcDel = false;
  11434. string dsStr = item["GovernmentRent"].ToString();
  11435. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11436. if (containsDigitButNotZero6) dsDel = false;
  11437. string cssStr = item["CityTax"].ToString();
  11438. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11439. if (containsDigitButNotZero7) cssDel = false;
  11440. string cpStr = item["ConsumptionPatterns"].ToString();
  11441. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11442. string remarkStr = item["Remark"].ToString();
  11443. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11444. }
  11445. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11446. DeleteColumn(serverPath, cpIndex, cpDel);
  11447. DeleteColumn(serverPath, dsIndex, dsDel);
  11448. DeleteColumn(serverPath, cssIndex, cssDel);
  11449. DeleteColumn(serverPath, zcIndex, zcDel);
  11450. DeleteColumn(serverPath, otherIndex, otherDel);
  11451. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11452. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11453. DeleteColumn(serverPath, singleIndex, singleDel);
  11454. #endregion
  11455. //只保留第一个表格
  11456. DeleteSheet(serverPath);
  11457. return Ok(JsonView(true, "操作成功", url = rst));
  11458. }
  11459. return Ok(JsonView(false));
  11460. }
  11461. /// <summary>
  11462. /// 删除指定列
  11463. /// </summary>
  11464. /// <param name="file"></param>
  11465. /// <param name="columnIndex"></param>
  11466. /// <param name="isDel"></param>
  11467. private void DeleteColumn(string file, int columnIndex, bool isDel)
  11468. {
  11469. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11470. //wb.Save(file);
  11471. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  11472. if (sheet1 != null)
  11473. {
  11474. if (isDel)
  11475. {
  11476. Cells cells = sheet1.Cells;
  11477. cells.DeleteColumn(columnIndex);
  11478. }
  11479. }
  11480. wb.Save(file);
  11481. }
  11482. /// <summary>
  11483. /// 删除sheet
  11484. /// </summary>
  11485. /// <param name="file"></param>
  11486. /// <param name="sheetName"></param>
  11487. private void DeleteSheet(string file, string sheetName = "")
  11488. {
  11489. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11490. //wb.Save(file);
  11491. List<string> sheets = new List<string>();
  11492. foreach (var item in wb.Worksheets)
  11493. {
  11494. sheets.Add(item.Name);
  11495. }
  11496. if (sheets.Count > 0)
  11497. {
  11498. sheets.RemoveAt(0);//不删除第一个sheet
  11499. foreach (var item in sheets)
  11500. {
  11501. wb.Worksheets.RemoveAt(item);
  11502. }
  11503. }
  11504. wb.Save(file);
  11505. }
  11506. /// <summary>
  11507. /// 酒店预订
  11508. /// 确认单
  11509. /// </summary>
  11510. /// <param name="_dto"></param>
  11511. /// <returns></returns>
  11512. [HttpPost]
  11513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11514. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  11515. {
  11516. try
  11517. {
  11518. #region 参数验证
  11519. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11520. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11521. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11522. #region 团组操作权限验证 76 酒店预定模块
  11523. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11524. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11525. #endregion
  11526. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11527. #region 页面操作权限验证
  11528. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11529. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11530. #endregion
  11531. #endregion
  11532. //团组信息
  11533. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  11534. //酒店数据
  11535. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  11536. if (listhoteldata.Count < 0)
  11537. {
  11538. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  11539. }
  11540. //利datatable存储
  11541. DataTable dt = new DataTable();
  11542. dt.Columns.Add("CheckInDate", typeof(string));
  11543. dt.Columns.Add("City", typeof(string));
  11544. dt.Columns.Add("Hotel", typeof(string));
  11545. dt.Columns.Add("Room", typeof(string));
  11546. for (int i = 0; i < listhoteldata.Count; i++)
  11547. {
  11548. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  11549. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  11550. while (dayStart < dayEnd)
  11551. {
  11552. string temp = "";
  11553. DataRow row = dt.NewRow();
  11554. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  11555. row["City"] = listhoteldata[i].City;
  11556. row["Hotel"] = listhoteldata[i].HotelName;
  11557. if (listhoteldata[i].SingleRoomCount > 0)
  11558. {
  11559. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  11560. }
  11561. if (listhoteldata[i].DoubleRoomCount > 0)
  11562. {
  11563. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  11564. }
  11565. if (listhoteldata[i].SuiteRoomCount > 0)
  11566. {
  11567. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  11568. }
  11569. if (listhoteldata[i].OtherRoomCount > 0)
  11570. {
  11571. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  11572. }
  11573. row["Room"] = temp;
  11574. dt.Rows.Add(row);
  11575. dayStart = dayStart.AddDays(1);
  11576. }
  11577. }
  11578. Dictionary<string, string> dic = new Dictionary<string, string>();
  11579. dic.Add("Dele", di.TeamName);
  11580. dic.Add("City", di.VisitCountry);
  11581. //模板路径
  11582. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  11583. //载入模板
  11584. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  11585. DocumentBuilder builder = new DocumentBuilder(doc);
  11586. foreach (var key in dic.Keys)
  11587. {
  11588. builder.MoveToBookmark(key);
  11589. builder.Write(dic[key]);
  11590. }
  11591. //获取word里所有表格
  11592. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11593. //获取所填表格的序数
  11594. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11595. var rowStart = tableOne.Rows[0]; //获取第1行
  11596. //循环赋值
  11597. for (int i = 0; i < dt.Rows.Count; i++)
  11598. {
  11599. builder.MoveToCell(0, i + 1, 0, 0);
  11600. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  11601. builder.MoveToCell(0, i + 1, 1, 0);
  11602. builder.Write(dt.Rows[i]["City"].ToString());
  11603. builder.MoveToCell(0, i + 1, 2, 0);
  11604. builder.Write(dt.Rows[i]["Hotel"].ToString());
  11605. builder.MoveToCell(0, i + 1, 3, 0);
  11606. builder.Write(dt.Rows[i]["Room"].ToString());
  11607. }
  11608. //删除多余行
  11609. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  11610. {
  11611. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  11612. }
  11613. string strFileName = di.TeamName + "酒店确认单.doc";
  11614. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  11615. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  11616. return Ok(JsonView(true, "成功", url));
  11617. }
  11618. catch (Exception ex)
  11619. {
  11620. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  11621. }
  11622. }
  11623. #endregion
  11624. #region 团组状态
  11625. /// <summary>
  11626. /// 团组状态列表 Page
  11627. /// </summary>
  11628. /// <param name="dto">团组列表请求dto</param>
  11629. /// <returns></returns>
  11630. [HttpPost]
  11631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11632. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  11633. {
  11634. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11635. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  11636. {
  11637. string sqlWhere = string.Empty;
  11638. if (dto.IsSure == 0) //未完成
  11639. {
  11640. sqlWhere += string.Format(@" And IsSure = 0");
  11641. }
  11642. else if (dto.IsSure == 1) //已完成
  11643. {
  11644. sqlWhere += string.Format(@" And IsSure = 1");
  11645. }
  11646. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  11647. {
  11648. string tj = dto.SearchCriteria;
  11649. 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}%')",
  11650. tj, tj, tj, tj, tj);
  11651. }
  11652. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  11653. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  11654. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  11655. From (
  11656. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  11657. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  11658. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  11659. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  11660. From Grp_DelegationInfo gdi
  11661. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  11662. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  11663. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  11664. Where gdi.IsDel = 0 {0}
  11665. ) temp ", sqlWhere);
  11666. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  11667. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  11668. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  11669. }
  11670. else
  11671. {
  11672. return Ok(JsonView(false, "查询失败"));
  11673. }
  11674. }
  11675. /// <summary>
  11676. /// 团组状态
  11677. /// 设置操作完成
  11678. /// </summary>
  11679. /// <param name="dto">团组列表请求dto</param>
  11680. /// <returns></returns>
  11681. [HttpPost]
  11682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11683. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  11684. {
  11685. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11686. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  11687. {
  11688. Id = dto.Id,
  11689. IsSure = 1
  11690. };
  11691. var result = await _sqlSugar.Updateable(_DelegationInfo)
  11692. .UpdateColumns(it => new { it.IsSure })
  11693. .WhereColumns(it => new { it.Id })
  11694. .ExecuteCommandAsync();
  11695. if (result > 0)
  11696. {
  11697. return Ok(JsonView(true, "操作完成!"));
  11698. }
  11699. return Ok(JsonView(false, "操作失败!"));
  11700. }
  11701. #endregion
  11702. #region 保险费用录入
  11703. /// <summary>
  11704. /// 根据团组Id查询保险费用列表
  11705. /// </summary>
  11706. /// <param name="dto"></param>
  11707. /// <returns></returns>
  11708. [HttpPost]
  11709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11710. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11711. {
  11712. Result groupData = await _customersRep.CustomersByDiId(dto);
  11713. if (groupData.Code != 0)
  11714. {
  11715. return Ok(JsonView(false, groupData.Msg));
  11716. }
  11717. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11718. }
  11719. /// <summary>
  11720. /// 根据保险费用Id查询保险费用详细
  11721. /// </summary>
  11722. /// <param name="dto"></param>
  11723. /// <returns></returns>
  11724. [HttpPost]
  11725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11726. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11727. {
  11728. try
  11729. {
  11730. Result groupData = await _customersRep.CustomersById(dto);
  11731. if (groupData.Code != 0)
  11732. {
  11733. return Ok(JsonView(false, groupData.Msg));
  11734. }
  11735. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11736. }
  11737. catch (Exception ex)
  11738. {
  11739. return Ok(JsonView(false, ex.Message));
  11740. }
  11741. }
  11742. /// <summary>
  11743. /// 保险费用录入页面初始化绑定
  11744. /// </summary>
  11745. /// <param name="dto"></param>
  11746. /// <returns></returns>
  11747. [HttpPost]
  11748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11749. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11750. {
  11751. try
  11752. {
  11753. Result groupData = await _customersRep.CustomersInitialize(dto);
  11754. if (groupData.Code != 0)
  11755. {
  11756. return Ok(JsonView(false, groupData.Msg));
  11757. }
  11758. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11759. }
  11760. catch (Exception ex)
  11761. {
  11762. return Ok(JsonView(false, ex.Message));
  11763. }
  11764. }
  11765. /// <summary>
  11766. /// 保险费用操作(Status:1.新增,2.修改)
  11767. /// </summary>
  11768. /// <param name="dto"></param>
  11769. /// <returns></returns>
  11770. [HttpPost]
  11771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11772. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11773. {
  11774. Result groupData = await _customersRep.OpCustomers(dto);
  11775. if (groupData.Code != 0)
  11776. {
  11777. return Ok(JsonView(false, groupData.Msg));
  11778. }
  11779. #region 应用推送
  11780. try
  11781. {
  11782. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11783. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11784. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11785. //2024-10-21 新增LZ UID
  11786. var userIds = new List<int>() { 21 };
  11787. string title = $"系统通知";
  11788. var diId = dto.DiId;
  11789. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11790. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11791. string content = "";
  11792. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11793. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11794. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11795. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11796. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11797. }
  11798. catch (Exception ex)
  11799. {
  11800. }
  11801. #endregion
  11802. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11803. }
  11804. /// <summary>
  11805. /// 保险文件上传
  11806. /// </summary>
  11807. /// <param name="file"></param>
  11808. /// <returns></returns>
  11809. [HttpPost]
  11810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11811. public async Task<IActionResult> UploadCus(IFormFile file)
  11812. {
  11813. try
  11814. {
  11815. if (file != null)
  11816. {
  11817. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11818. //文件名称
  11819. string projectFileName = file.FileName;
  11820. //上传的文件的路径
  11821. string filePath = "";
  11822. if (!Directory.Exists(fileDir))
  11823. {
  11824. Directory.CreateDirectory(fileDir);
  11825. }
  11826. //上传的文件的路径
  11827. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11828. using (FileStream fs = System.IO.File.Create(filePath))
  11829. {
  11830. file.CopyTo(fs);
  11831. fs.Flush();
  11832. }
  11833. return Ok(JsonView(true, "上传成功!", projectFileName));
  11834. }
  11835. else
  11836. {
  11837. return Ok(JsonView(false, "上传失败!"));
  11838. }
  11839. }
  11840. catch (Exception ex)
  11841. {
  11842. return Ok(JsonView(false, "程序错误!"));
  11843. throw;
  11844. }
  11845. }
  11846. /// <summary>
  11847. /// 保险删除指定文件
  11848. /// </summary>
  11849. /// <param name="dto"></param>
  11850. /// <returns></returns>
  11851. [HttpPost]
  11852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11853. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11854. {
  11855. try
  11856. {
  11857. string filePath = "";
  11858. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11859. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11860. //int id = 0;
  11861. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11862. // 删除该文件
  11863. try
  11864. {
  11865. System.IO.File.Delete(filePath);
  11866. 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()
  11867. {
  11868. Attachment = "",
  11869. }).ExecuteCommandAsync();
  11870. if (result != 0)
  11871. {
  11872. return Ok(JsonView(true, "成功!"));
  11873. }
  11874. else
  11875. {
  11876. return Ok(JsonView(false, "失败!"));
  11877. }
  11878. }
  11879. catch (Exception)
  11880. {
  11881. 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()
  11882. {
  11883. Attachment = "",
  11884. }).ExecuteCommandAsync();
  11885. if (result != 0)
  11886. {
  11887. return Ok(JsonView(true, "成功!"));
  11888. }
  11889. else
  11890. {
  11891. return Ok(JsonView(false, "失败!"));
  11892. }
  11893. }
  11894. }
  11895. catch (Exception ex)
  11896. {
  11897. return Ok(JsonView(false, "程序错误!"));
  11898. throw;
  11899. }
  11900. }
  11901. /// <summary>
  11902. /// 保险费用操作(删除)
  11903. /// </summary>
  11904. /// <param name="dto"></param>
  11905. /// <returns></returns>
  11906. [HttpPost]
  11907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11908. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11909. {
  11910. try
  11911. {
  11912. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11913. if (!res)
  11914. {
  11915. return Ok(JsonView(false, "删除失败"));
  11916. }
  11917. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11918. {
  11919. IsDel = 1,
  11920. DeleteUserId = dto.DeleteUserId,
  11921. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11922. }).ExecuteCommandAsync();
  11923. return Ok(JsonView(true, "删除成功!"));
  11924. }
  11925. catch (Exception ex)
  11926. {
  11927. return Ok(JsonView(false, "程序错误!"));
  11928. throw;
  11929. }
  11930. }
  11931. #endregion
  11932. #region 接团客户名单 PageId 104
  11933. /// <summary>
  11934. /// 接团客户名单
  11935. /// 迁移数据(慎用!)
  11936. /// </summary>
  11937. /// <param name="dto"></param>
  11938. /// <returns></returns>
  11939. [HttpPost]
  11940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11941. public async Task<IActionResult> PostTourClientListChange()
  11942. {
  11943. try
  11944. {
  11945. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11946. //var groupClinetData1
  11947. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11948. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11949. int updateCount = 0;
  11950. if (oldOAClientList.Count > 0)
  11951. {
  11952. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11953. _sqlSugar.BeginTran();
  11954. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11955. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11956. foreach (var item in oldOAClientList)
  11957. {
  11958. int comId = 0;
  11959. string format = "yyyy-MM-dd HH:mm:ss";
  11960. string data11 = "1990-01-01 00:00";
  11961. var data1 = IsValidDate(item.OPdate, format);
  11962. if (data1) data11 = item.OPdate;
  11963. //客户公司验证
  11964. if (!string.IsNullOrEmpty(item.Company))
  11965. {
  11966. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11967. if (clientComInfo == null) // add
  11968. {
  11969. var addInfo = new Crm_CustomerCompany()
  11970. {
  11971. CompanyAbbreviation = "",
  11972. CompanyFullName = item.Company,
  11973. Address = "",
  11974. PostCodes = "",
  11975. LastedOpUserId = item.OPer,
  11976. LastedOpDt = Convert.ToDateTime(data11),
  11977. CreateUserId = item.OPer,
  11978. CreateTime = Convert.ToDateTime(data11),
  11979. IsDel = 0
  11980. };
  11981. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11982. if (comId1 > 0) comId = comId1;
  11983. }
  11984. else comId = clientComInfo.Id;
  11985. }
  11986. //客户人员验证
  11987. int clientId = 0;
  11988. string name = item.LastName + item.Name;
  11989. if (!string.IsNullOrEmpty(name))
  11990. {
  11991. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11992. if (clientInfo == null)
  11993. {
  11994. DateTime? dateTime = null;
  11995. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11996. if (isDt) dateTime = birthDayDt;
  11997. var addInfo1 = new Crm_DeleClient()
  11998. {
  11999. CrmCompanyId = comId,
  12000. DiId = -1,
  12001. LastName = item.LastName,
  12002. FirstName = item.Name,
  12003. OldName = "",
  12004. Pinyin = item.Pinyin,
  12005. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  12006. Marriage = 0,
  12007. Phone = item.Phone,
  12008. Job = item.Job,
  12009. BirthDay = dateTime
  12010. };
  12011. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  12012. if (clientId1 > 0) clientId = clientId1;
  12013. }
  12014. else clientId = clientInfo.Id;
  12015. }
  12016. if (clientId < 1)
  12017. {
  12018. continue;
  12019. }
  12020. int airType = 0;
  12021. if (item.AirType == "超经舱") airType = 459;
  12022. else if (item.AirType == "公务舱") airType = 458;
  12023. else if (item.AirType == "经济舱") airType = 460;
  12024. else if (item.AirType == "其他") airType = 565;
  12025. else if (item.AirType == "头等舱") airType = 457;
  12026. var _TourClientListEntity = new Grp_TourClientList()
  12027. {
  12028. DiId = item.Diid,
  12029. ClientId = clientId,
  12030. CreateUserId = item.OPer,
  12031. CreateTime = Convert.ToDateTime(data11),
  12032. Remark = item.Remark,
  12033. IsDel = item.Isdel,
  12034. ShippingSpaceTypeId = airType,
  12035. ShippingSpaceSpecialNeeds = item.AirRemark,
  12036. HotelSpecialNeeds = item.RoomType
  12037. };
  12038. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  12039. if (_TourClientList > 0)
  12040. {
  12041. updateCount++;
  12042. }
  12043. }
  12044. _sqlSugar.CommitTran();
  12045. }
  12046. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  12047. }
  12048. catch (Exception ex)
  12049. {
  12050. _sqlSugar.RollbackTran();
  12051. return Ok(JsonView(false, ex.Message));
  12052. }
  12053. return Ok(JsonView(true));
  12054. }
  12055. private bool IsValidDate(string dateString, string format)
  12056. {
  12057. DateTime dateValue;
  12058. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  12059. return valid;
  12060. }
  12061. /// <summary>
  12062. /// 接团客户名单
  12063. /// 根据团组Id查询List
  12064. /// </summary>
  12065. /// <param name="dto"></param>
  12066. /// <returns></returns>
  12067. [HttpPost]
  12068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12069. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  12070. {
  12071. #region 参数验证
  12072. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  12073. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  12074. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  12075. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12076. #region 页面操作权限验证
  12077. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12078. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12079. #endregion
  12080. #endregion
  12081. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  12082. if (viewData.Code != 0)
  12083. {
  12084. return Ok(JsonView(false, viewData.Msg));
  12085. }
  12086. return Ok(JsonView(viewData.Data));
  12087. }
  12088. /// <summary>
  12089. /// 接团客户名单
  12090. /// 基础数据 Init
  12091. /// </summary>
  12092. /// <param name="_dto"></param>
  12093. /// <returns></returns>
  12094. [HttpPost]
  12095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12096. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  12097. {
  12098. #region 参数验证
  12099. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12100. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12101. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12102. #region 页面操作权限验证
  12103. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12104. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12105. #endregion
  12106. #endregion
  12107. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  12108. }
  12109. /// <summary>
  12110. /// 接团客户名单
  12111. /// 根据 Id查询 Details
  12112. /// </summary>
  12113. /// <param name="_dto"></param>
  12114. /// <returns></returns>
  12115. [HttpPost]
  12116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12117. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  12118. {
  12119. #region 参数验证
  12120. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12121. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12122. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  12123. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12124. #region 页面操作权限验证
  12125. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12126. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12127. #endregion
  12128. #endregion
  12129. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  12130. if (viewData.Code != 0)
  12131. {
  12132. return Ok(JsonView(false, viewData.Msg));
  12133. }
  12134. return Ok(JsonView(viewData.Data));
  12135. }
  12136. /// <summary>
  12137. /// 接团客户名单
  12138. /// Add Or Edit
  12139. /// </summary>
  12140. /// <param name="_dto"></param>
  12141. /// <returns></returns>
  12142. [HttpPost]
  12143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12144. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  12145. {
  12146. #region 参数验证
  12147. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12148. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12149. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  12150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12151. #region 页面操作权限验证
  12152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12153. if (_dto.Id == 0) //添加
  12154. {
  12155. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12156. }
  12157. else if (_dto.Id >= 0) //修改
  12158. {
  12159. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  12160. }
  12161. #endregion
  12162. #endregion
  12163. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  12164. if (viewData.Code != 0)
  12165. {
  12166. return Ok(JsonView(false, viewData.Msg));
  12167. }
  12168. return Ok(JsonView(true));
  12169. }
  12170. /// <summary>
  12171. /// 接团客户名单
  12172. /// AddMultiple(添加多个)
  12173. /// </summary>
  12174. /// <param name="_dto"></param>
  12175. /// <returns></returns>
  12176. [HttpPost]
  12177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12178. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  12179. {
  12180. #region 参数验证
  12181. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12182. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12183. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12184. #region 页面操作权限验证
  12185. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12186. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12187. #endregion
  12188. #endregion
  12189. var viewData = await _tourClientListRep._AddMultiple(_dto);
  12190. if (viewData.Code != 0)
  12191. {
  12192. return Ok(JsonView(false, viewData.Msg));
  12193. }
  12194. return Ok(JsonView(true));
  12195. }
  12196. /// <summary>
  12197. /// 接团客户名单
  12198. /// Del
  12199. /// </summary>
  12200. /// <param name="_dto"></param>
  12201. /// <returns></returns>
  12202. [HttpPost]
  12203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12204. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  12205. {
  12206. #region 参数验证
  12207. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12208. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12209. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12210. #region 页面操作权限验证
  12211. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12212. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12213. #endregion
  12214. #endregion
  12215. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  12216. if (viewData.Code != 0)
  12217. {
  12218. return Ok(JsonView(false, viewData.Msg));
  12219. }
  12220. return Ok(JsonView(true));
  12221. }
  12222. /// <summary>
  12223. /// 接团客户名单
  12224. /// 文件下载 客户名单
  12225. /// </summary>
  12226. /// <param name="_dto"></param>
  12227. /// <returns></returns>
  12228. [HttpPost]
  12229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12230. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  12231. {
  12232. #region 参数验证
  12233. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12234. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12235. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  12236. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12237. #region 页面操作权限验证
  12238. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12239. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12240. #endregion
  12241. #endregion
  12242. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  12243. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  12244. From Grp_TourClientList tcl
  12245. Left Join
  12246. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  12247. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  12248. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  12249. From Crm_DeleClient dc
  12250. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  12251. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  12252. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  12253. Where dc.IsDel = 0) temp
  12254. On temp.DcId =tcl.ClientId
  12255. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  12256. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  12257. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  12258. //载入模板
  12259. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  12260. if (_dto.Language == 1)
  12261. {
  12262. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  12263. }
  12264. //载入模板
  12265. var doc = new Document(tempPath);
  12266. DocumentBuilder builder = new DocumentBuilder(doc);
  12267. //获取word里所有表格
  12268. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12269. //获取所填表格的序数
  12270. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12271. var rowStart = tableOne.Rows[0]; //获取第1行
  12272. if (_dto.Language == 0)
  12273. {
  12274. //循环赋值
  12275. for (int i = 0; i < DcList.Count; i++)
  12276. {
  12277. builder.MoveToCell(0, i + 1, 0, 0);
  12278. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  12279. builder.MoveToCell(0, i + 1, 1, 0);
  12280. int sex = DcList[i].Sex;
  12281. string sexStr = string.Empty;
  12282. if (sex == 0) sexStr = "男";
  12283. else if (sex == 1) sexStr = "女";
  12284. else sexStr = "未设置";
  12285. builder.Write(sexStr);
  12286. builder.MoveToCell(0, i + 1, 2, 0);
  12287. string birthDay = DcList[i].BirthDay;
  12288. string birthDayStr = string.Empty;
  12289. if (!string.IsNullOrEmpty(birthDay))
  12290. {
  12291. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  12292. }
  12293. builder.Write(birthDayStr);
  12294. builder.MoveToCell(0, i + 1, 3, 0);
  12295. string company = "";
  12296. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12297. {
  12298. company = DcList[i].CompanyFullName.ToString();
  12299. }
  12300. builder.Write(company);
  12301. builder.MoveToCell(0, i + 1, 4, 0);
  12302. builder.Write(DcList[i].Job);
  12303. }
  12304. }
  12305. else if (_dto.Language == 1)
  12306. {
  12307. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  12308. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  12309. List<string> transArrayStr = new List<string>();
  12310. string transStrRes1 = "";
  12311. for (int i = 0; i < DcList.Count; i++)
  12312. {
  12313. var dc = DcList[i];
  12314. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  12315. if (dc.Job.Equals("暂无")) dc.Job = "-";
  12316. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  12317. if (DcList.Count - 1 == i) transStrRes1 += str1;
  12318. else transStrRes1 += $"{str1}|";
  12319. }
  12320. //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";
  12321. string transStrRes = "";
  12322. if (transStrRes1.Length > 0)
  12323. {
  12324. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  12325. }
  12326. //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
  12327. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  12328. //List<string> transArray = new List<string> { };
  12329. List<TranslateInfo> transArray = new List<TranslateInfo>();
  12330. if (transStrRes.Contains("|"))
  12331. {
  12332. string[] transArray1 = transStrRes.Split('|');
  12333. if (transArray1.Length > 0)
  12334. {
  12335. foreach (var item in transArray1)
  12336. {
  12337. if (item.Contains("&"))
  12338. {
  12339. string[] transArray2 = item.Split('&');
  12340. int index = 0;
  12341. string companyName = "", job = "";
  12342. if (transArray2.Length > 0)
  12343. {
  12344. bool success = int.TryParse(transArray2[0].Trim(), out index);
  12345. if (1 < transArray2.Length) companyName = transArray2[1];
  12346. if (2 < transArray2.Length) job = transArray2[2];
  12347. }
  12348. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  12349. }
  12350. }
  12351. }
  12352. }
  12353. //循环赋值
  12354. for (int i = 0; i < DcList.Count; i++)
  12355. {
  12356. string PYName = "";
  12357. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  12358. {
  12359. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  12360. string PY_First = DcList[i].Pinyin.Split('/')[1];
  12361. PYName = PY_First + " " + PY_Last;
  12362. }
  12363. else
  12364. {
  12365. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  12366. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  12367. PYName = PY_First + " " + PY_Last;
  12368. }
  12369. builder.MoveToCell(0, i + 1, 0, 0);
  12370. builder.Write(PYName);
  12371. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  12372. builder.MoveToCell(0, i + 1, 1, 0);
  12373. builder.Write(sex);
  12374. DateTime birthDt;
  12375. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  12376. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  12377. builder.MoveToCell(0, i + 1, 2, 0);
  12378. builder.Write(birthday);
  12379. string company = string.Empty, job = string.Empty;
  12380. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  12381. if (dcTransInfo != null)
  12382. {
  12383. company = dcTransInfo.CompanyName;
  12384. job = dcTransInfo.Job;
  12385. }
  12386. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12387. {
  12388. //查询对照表
  12389. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  12390. if (tempCec != null)
  12391. {
  12392. company = tempCec.enName;
  12393. }
  12394. //翻译
  12395. else
  12396. {
  12397. }
  12398. }
  12399. builder.MoveToCell(0, i + 1, 3, 0);
  12400. builder.Write(company);
  12401. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  12402. {
  12403. //查询对照表
  12404. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  12405. if (tempPec != null)
  12406. {
  12407. job = tempPec.enName;
  12408. }
  12409. //翻译
  12410. else
  12411. {
  12412. }
  12413. }
  12414. builder.MoveToCell(0, i + 1, 4, 0);
  12415. builder.Write(job);
  12416. }
  12417. }
  12418. //删除多余行
  12419. while (tableOne.Rows.Count > DcList.Count + 1)
  12420. {
  12421. tableOne.Rows.RemoveAt(DcList.Count + 1);
  12422. }
  12423. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  12424. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  12425. doc.Save(fileDir);
  12426. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  12427. return Ok(JsonView(true, "操作成功!", Url));
  12428. }
  12429. private class TranslateInfo
  12430. {
  12431. public int Index { get; set; }
  12432. public string CompanyName { get; set; }
  12433. public string Job { get; set; }
  12434. }
  12435. #endregion
  12436. #region 团组倒推表
  12437. /// <summary>
  12438. /// 倒推表基础数据
  12439. /// Init
  12440. /// </summary>
  12441. /// <param name="dto"></param>
  12442. /// <returns></returns>
  12443. [HttpPost]
  12444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12445. public async Task<IActionResult> PostInvertedListInit()
  12446. {
  12447. var viewData = await _invertedListRep._Init();
  12448. if (viewData.Code != 0)
  12449. {
  12450. return Ok(JsonView(false, viewData.Msg));
  12451. }
  12452. return Ok(JsonView(viewData.Data));
  12453. }
  12454. /// <summary>
  12455. /// 倒推表
  12456. /// Info
  12457. /// </summary>
  12458. /// <param name="dto"></param>
  12459. /// <returns></returns>
  12460. [HttpPost]
  12461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12462. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  12463. {
  12464. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  12465. if (viewData.Code != 0)
  12466. {
  12467. return Ok(JsonView(false, viewData.Msg));
  12468. }
  12469. return Ok(JsonView(viewData.Data));
  12470. }
  12471. /// <summary>
  12472. /// 倒推表
  12473. /// Create
  12474. /// </summary>
  12475. /// <param name="dto"></param>
  12476. /// <returns></returns>
  12477. [HttpPost]
  12478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12479. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  12480. {
  12481. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  12482. if (viewData.Code != 0)
  12483. {
  12484. return Ok(JsonView(false, viewData.Msg));
  12485. }
  12486. return Ok(JsonView(viewData.Data));
  12487. }
  12488. /// <summary>
  12489. /// 倒推表
  12490. /// Update
  12491. /// </summary>
  12492. /// <param name="dto"></param>
  12493. /// <returns></returns>
  12494. [HttpPost]
  12495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12496. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  12497. {
  12498. var viewData = await _invertedListRep._Update(dto);
  12499. if (viewData.Code != 0)
  12500. {
  12501. return Ok(JsonView(false, viewData.Msg));
  12502. }
  12503. return Ok(JsonView(viewData.Data));
  12504. }
  12505. /// <summary>
  12506. /// 倒推表
  12507. /// File Download
  12508. /// </summary>
  12509. /// <param name="dto"></param>
  12510. /// <returns></returns>
  12511. [HttpPost]
  12512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12513. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  12514. {
  12515. var info2 = await _invertedListRep._Info(1, dto.DiId);
  12516. if (info2.Code != 0)
  12517. {
  12518. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  12519. }
  12520. var info1 = info2.Data as InvertedListInfoView;
  12521. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  12522. string teamName = "";
  12523. if (info != null) teamName = info.TeamName;
  12524. //载入模板
  12525. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  12526. DocumentBuilder builder = new DocumentBuilder(doc);
  12527. //利用键值对存放数据
  12528. Dictionary<string, string> dic = new Dictionary<string, string>();
  12529. dic.Add("TeamName", teamName);
  12530. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  12531. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  12532. dic.Add("BPRemark", info1.ApprovalDataRemark);
  12533. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  12534. dic.Add("SQRemark", info1.ApprovalRemark);
  12535. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  12536. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  12537. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  12538. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  12539. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  12540. dic.Add("QZRemark", info1.VisaInformationRemark);
  12541. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  12542. dic.Add("SQQZRemark", info1.SendVisaRemark);
  12543. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  12544. dic.Add("CQRemark", info1.IssueVisaRemark);
  12545. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  12546. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  12547. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  12548. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  12549. #region 填充word模板书签内容
  12550. foreach (var key in dic.Keys)
  12551. {
  12552. builder.MoveToBookmark(key);
  12553. builder.Write(dic[key]);
  12554. }
  12555. #endregion
  12556. var fileDir = AppSettingsHelper.Get("WordBasePath");
  12557. string fileName = $"{teamName}团出行准备流程表.doc";
  12558. string filePath = fileDir + $@"InvertedList/{fileName}";
  12559. doc.Save(filePath);
  12560. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  12561. return Ok(JsonView(true, "操作成功!", Url));
  12562. }
  12563. #endregion
  12564. #region 三公签证费用(签证费、代办费)
  12565. /// <summary>
  12566. /// 三公签证费用(签证费、代办费)
  12567. /// List
  12568. /// </summary>
  12569. /// <returns></returns>
  12570. [HttpPost]
  12571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12572. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  12573. {
  12574. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  12575. if (_view.Code != 0)
  12576. {
  12577. return Ok(JsonView(false, _view.Msg));
  12578. }
  12579. return Ok(JsonView(true, "操作成功!", _view.Data));
  12580. }
  12581. /// <summary>
  12582. /// 三公签证费用(签证费、代办费)
  12583. /// Add Or Update
  12584. /// </summary>
  12585. /// <returns></returns>
  12586. [HttpPost]
  12587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12588. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  12589. {
  12590. var _view = await _visaFeeInfoRep._Update(_dto);
  12591. if (_view.Code != 0)
  12592. {
  12593. return Ok(JsonView(false, _view.Msg));
  12594. }
  12595. return Ok(JsonView(true, _view.Msg));
  12596. }
  12597. #endregion
  12598. #region 酒店询价
  12599. /// <summary>
  12600. /// 酒店询价
  12601. /// Init
  12602. /// </summary>
  12603. /// <param name="dto"></param>
  12604. /// <returns></returns>
  12605. [HttpPost]
  12606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12607. public async Task<IActionResult> PostHotelInquiryInit()
  12608. {
  12609. var res = await _hotelInquiryRep._Init();
  12610. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12611. return Ok(JsonView(true, res.Msg, res.Data));
  12612. }
  12613. /// <summary>
  12614. /// 酒店询价
  12615. /// page Item
  12616. /// </summary>
  12617. /// <param name="_dto"></param>
  12618. /// <returns></returns>
  12619. [HttpPost]
  12620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12621. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  12622. {
  12623. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  12624. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12625. var view = res.Data as PageDataViewBase;
  12626. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  12627. }
  12628. /// <summary>
  12629. /// 酒店询价
  12630. /// info
  12631. /// </summary>
  12632. /// <param name="_dto"></param>
  12633. /// <returns></returns>
  12634. [HttpPost]
  12635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12636. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  12637. {
  12638. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  12639. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12640. return Ok(JsonView(true, res.Msg, res.Data));
  12641. }
  12642. /// <summary>
  12643. /// 酒店询价
  12644. /// Add Or Edit
  12645. /// </summary>
  12646. /// <param name="_dto"></param>
  12647. /// <returns></returns>
  12648. [HttpPost]
  12649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12650. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  12651. {
  12652. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  12653. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12654. return Ok(JsonView(true, res.Msg, res.Data));
  12655. }
  12656. /// <summary>
  12657. /// 酒店询价
  12658. /// Del
  12659. /// </summary>
  12660. /// <param name="_dto"></param>
  12661. /// <returns></returns>
  12662. [HttpPost]
  12663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12664. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  12665. {
  12666. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  12667. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12668. return Ok(JsonView(true, res.Msg, res.Data));
  12669. }
  12670. #endregion
  12671. #region 下载匹配op行程单
  12672. /// <summary>
  12673. /// 匹配op行程单
  12674. /// Init
  12675. /// </summary>
  12676. /// <param name="dto">团组列表请求dto</param>
  12677. /// <returns></returns>
  12678. [HttpPost]
  12679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12680. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  12681. {
  12682. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12683. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12684. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  12685. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  12686. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  12687. .Where(it => it.IsDel == 0)
  12688. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  12689. .OrderByDescending(it => it.CreateUserId)
  12690. .ToList();
  12691. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  12692. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12693. var diids = groupInfos.Select(it => it.Id).ToList();
  12694. List<string> countrys = new List<string>();
  12695. foreach (var item in country)
  12696. {
  12697. var data = _groupRepository.FormartTeamName(item);
  12698. var dataArray = _groupRepository.GroupSplitCountry(data);
  12699. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12700. }
  12701. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12702. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12703. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12704. foreach (var item in areaItem)
  12705. {
  12706. string areaStr = item.Value;
  12707. if (!string.IsNullOrEmpty(areaStr))
  12708. {
  12709. string[] str1 = areaStr.Split("-");
  12710. if (str1.Length > 0)
  12711. {
  12712. areaArray.AddRange(str1);
  12713. }
  12714. }
  12715. }
  12716. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12717. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12718. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12719. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12720. .ToList();
  12721. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12722. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12723. .Where(it => countriesIds.Contains(it.Id))
  12724. .Select(it => new { it.Id, Name = it.Name_CN })
  12725. .ToList();
  12726. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12727. .Select(it => it.TeamName).ToList();
  12728. stopwatch.Stop();
  12729. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12730. }
  12731. ///// <summary>
  12732. ///// 匹配op行程单
  12733. ///// Init 查询区域数据
  12734. ///// </summary>
  12735. ///// <param name="dto">团组列表请求dto</param>
  12736. ///// <returns></returns>
  12737. //[HttpPost]
  12738. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12739. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12740. //{
  12741. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12742. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12743. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12744. // if (string.IsNullOrEmpty(countriesDataStr))
  12745. // {
  12746. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12747. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12748. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12749. // }
  12750. // else
  12751. // {
  12752. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12753. // }
  12754. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12755. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12756. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12757. // List<dynamic> childList = new List<dynamic>();
  12758. // int parentId = dto.CountriesId;
  12759. // if (provinceData.Count > 1)
  12760. // {
  12761. // foreach (var item1 in provinceData)
  12762. // {
  12763. // List<dynamic> childList1 = new List<dynamic>();
  12764. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12765. // foreach (var item2 in citiesData1)
  12766. // {
  12767. // List<dynamic> childList2 = new List<dynamic>();
  12768. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12769. // foreach (var item3 in countiesData1)
  12770. // {
  12771. // childList2.Add(new
  12772. // {
  12773. // id = item3.Id,
  12774. // parentId = item2.Id,
  12775. // level = "district",
  12776. // name = item3.Name_CN,
  12777. // });
  12778. // }
  12779. // childList1.Add(new
  12780. // {
  12781. // id = item2.Id,
  12782. // parentId = item1.Id,
  12783. // level = "city",
  12784. // name = item2.Name_CN,
  12785. // childList = childList2
  12786. // });
  12787. // }
  12788. // childList.Add(new
  12789. // {
  12790. // id = item1.Id,
  12791. // parentId = parentId,
  12792. // level = "province",
  12793. // name = item1.Name_CN,
  12794. // childList = childList1
  12795. // });
  12796. // }
  12797. // //城市
  12798. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12799. // foreach (var item2 in citiesData2)
  12800. // {
  12801. // List<dynamic> childList22 = new List<dynamic>();
  12802. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12803. // foreach (var item3 in countiesData1)
  12804. // {
  12805. // childList22.Add(new
  12806. // {
  12807. // id = item3.Id,
  12808. // parentId = item2.Id,
  12809. // level = "district",
  12810. // name = item3.Name_CN,
  12811. // });
  12812. // }
  12813. // childList.Add(new
  12814. // {
  12815. // id = item2.Id,
  12816. // parentId = parentId,
  12817. // level = "city",
  12818. // name = item2.Name_CN,
  12819. // childList = childList22
  12820. // });
  12821. // }
  12822. // }
  12823. // else
  12824. // {
  12825. // foreach (var item2 in citiesData)
  12826. // {
  12827. // string cname = item2.Name_CN;
  12828. // List<dynamic> childList1 = new List<dynamic>();
  12829. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12830. // foreach (var item3 in countiesData1)
  12831. // {
  12832. // childList1.Add(new
  12833. // {
  12834. // Id = item3.Id,
  12835. // parentId = item2.Id,
  12836. // level = "district",
  12837. // name = item3.Name_CN
  12838. // });
  12839. // }
  12840. // childList.Add(new
  12841. // {
  12842. // id = item2.Id,
  12843. // parentId = parentId,
  12844. // level = "city",
  12845. // name = item2.Name_CN,
  12846. // childList = childList1
  12847. // });
  12848. // }
  12849. // }
  12850. // stopwatch.Stop();
  12851. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12852. //}
  12853. /// <summary>
  12854. /// 匹配op行程单
  12855. /// 接团信息列表 Page
  12856. /// </summary>
  12857. /// <param name="dto">团组列表请求dto</param>
  12858. /// <returns></returns>
  12859. [HttpPost]
  12860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12861. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12862. {
  12863. var swatch = new Stopwatch();
  12864. swatch.Start();
  12865. #region 参数验证
  12866. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12867. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12868. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12869. #region 页面操作权限验证
  12870. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12871. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12872. #endregion
  12873. #endregion
  12874. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12875. {
  12876. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12877. string sqlWhere = "";
  12878. if (!string.IsNullOrEmpty(dto.Country))
  12879. {
  12880. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12881. }
  12882. if (!string.IsNullOrEmpty(dto.Area))
  12883. {
  12884. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12885. }
  12886. if (!string.IsNullOrEmpty(dto.TeamName))
  12887. {
  12888. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12889. }
  12890. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12891. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12892. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12893. swatch.Stop();
  12894. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12895. }
  12896. else
  12897. {
  12898. return Ok(JsonView(false, "查询失败"));
  12899. }
  12900. }
  12901. /// <summary>
  12902. /// 匹配op行程单
  12903. /// 行程单下载
  12904. /// </summary>
  12905. /// <param name="dto">团组列表请求dto</param>
  12906. /// <returns></returns>
  12907. [HttpPost]
  12908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12909. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12910. {
  12911. #region 参数验证
  12912. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12913. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12914. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12915. #region 页面操作权限验证
  12916. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12917. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12918. #endregion
  12919. #endregion
  12920. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12921. {
  12922. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12923. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12924. }
  12925. else
  12926. {
  12927. return Ok(JsonView(false, "下载失败!"));
  12928. }
  12929. }
  12930. #endregion
  12931. #region 国家信息 数据 注释
  12932. //[HttpPost]
  12933. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12934. //{
  12935. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12936. // foreach (var item in dto)
  12937. // {
  12938. // infos.Add(new Grp_GroupsTaskAssignment()
  12939. // {
  12940. // DIId = item,
  12941. // CTId = 82,
  12942. // UId = 248,
  12943. // IsEnable = 1,
  12944. // CreateUserId = 233,
  12945. // CreateTime = DateTime.Now,
  12946. // IsDel = 0
  12947. // });
  12948. // infos.Add(new Grp_GroupsTaskAssignment()
  12949. // {
  12950. // DIId = item,
  12951. // CTId = 82,
  12952. // UId = 286,
  12953. // IsEnable = 1,
  12954. // CreateUserId = 233,
  12955. // CreateTime = DateTime.Now,
  12956. // IsDel = 0
  12957. // });
  12958. // }
  12959. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12960. // return Ok("操作成功");
  12961. //}
  12962. //public class paramJsonDto
  12963. //{
  12964. // public List<CountriesInfo> str { get; set; }
  12965. //}
  12966. //[HttpPost]
  12967. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12968. //{
  12969. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12970. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12971. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12972. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12973. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12974. // _sqlSugar.BeginTran();
  12975. // int countitiesIndex = 0;
  12976. // foreach (var item in dto.str)
  12977. // {
  12978. // dynamic data = item.c;
  12979. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12980. // if (data != null)
  12981. // {
  12982. // countitiesIndex++;
  12983. // foreach (var item1 in data)
  12984. // {
  12985. // string cnname = item1.cn;
  12986. // string enname = item1.en;
  12987. // Sys_Cities provinceInfo = new Sys_Cities()
  12988. // {
  12989. // CountriesId = countriesId,
  12990. // Name_CN = cnname,
  12991. // Name_EN = enname,
  12992. // ParentId = 0,
  12993. // IsCapital = 1,
  12994. // CreateUserId = 208,
  12995. // CreateTime = DateTime.Now,
  12996. // IsDel = 0
  12997. // };
  12998. // if (item1.lv == "province") //省份
  12999. // {
  13000. // provinceInfo.Level = 1;
  13001. // int provinceId = 0;
  13002. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  13003. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  13004. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  13005. // var data1 = item1.c;
  13006. // foreach (var item2 in data1)
  13007. // {
  13008. // if (item2.lv == "city")
  13009. // {
  13010. // string citycnname = item2.cn;
  13011. // string cityenname = item2.en;
  13012. // Sys_Cities cityInfo = new Sys_Cities()
  13013. // {
  13014. // CountriesId = countriesId,
  13015. // ParentId = provinceId,
  13016. // Level = 2,
  13017. // Name_CN = citycnname,
  13018. // Name_EN = cityenname,
  13019. // IsCapital = 1,
  13020. // CreateUserId = 208,
  13021. // CreateTime = DateTime.Now,
  13022. // IsDel = 0
  13023. // };
  13024. // if (item2.c != null)
  13025. // {
  13026. // int cityId = 0;
  13027. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  13028. // if (citiesInfo != null) cityId = citiesInfo.Id;
  13029. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  13030. // foreach (var item3 in item2.c)
  13031. // {
  13032. // if (item3.lv == "district")
  13033. // {
  13034. // var districtInfo = new Sys_Cities()
  13035. // {
  13036. // CountriesId = countriesId,
  13037. // Name_CN = item3.cn,
  13038. // Name_EN = item3.en,
  13039. // Level = 3,
  13040. // ParentId = cityId,
  13041. // IsCapital = 1,
  13042. // CreateUserId = 208,
  13043. // CreateTime = DateTime.Now,
  13044. // IsDel = 0
  13045. // };
  13046. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  13047. // //{
  13048. // districts.Add(districtInfo);
  13049. // //}
  13050. // }
  13051. // }
  13052. // }
  13053. // else
  13054. // {
  13055. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  13056. // //{
  13057. // cities.Add(cityInfo);
  13058. // //}
  13059. // }
  13060. // }
  13061. // }
  13062. // }
  13063. // else if (item1.lv == "city")//城市
  13064. // {
  13065. // provinceInfo.Level = 2;
  13066. // if (item1.c != null)
  13067. // {
  13068. // int cityId = 0;
  13069. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  13070. // if (citiesInfo != null) cityId = citiesInfo.Id;
  13071. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  13072. // foreach (var item3 in item1.c)
  13073. // {
  13074. // if (item3.lv == "district")
  13075. // {
  13076. // var districtInfo = new Sys_Cities()
  13077. // {
  13078. // CountriesId = countriesId,
  13079. // Name_CN = item3.cn,
  13080. // Name_EN = item3.en,
  13081. // Level = 3,
  13082. // ParentId = cityId,
  13083. // IsCapital = 1,
  13084. // CreateUserId = 208,
  13085. // CreateTime = DateTime.Now,
  13086. // IsDel = 0
  13087. // };
  13088. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  13089. // //{
  13090. // districts.Add(districtInfo);
  13091. // //}
  13092. // }
  13093. // }
  13094. // }
  13095. // else
  13096. // {
  13097. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  13098. // //{
  13099. // cities.Add(provinceInfo);
  13100. // //}
  13101. // }
  13102. // }
  13103. // }
  13104. // }
  13105. // }
  13106. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  13107. // cities = cities.Distinct().ToList();
  13108. // districts = districts.Distinct().ToList();
  13109. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  13110. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  13111. // cities.AddRange(districts);
  13112. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  13113. // //_sqlSugar.RollbackTran();
  13114. // _sqlSugar.CommitTran();
  13115. // return Ok(JsonView(false, "操作成功!"));
  13116. //}
  13117. //[HttpPost]
  13118. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  13119. //{
  13120. // List<CountitiesInfo> infos = dto.MyProperty;
  13121. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  13122. // _sqlSugar.BeginTran();
  13123. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  13124. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  13125. // foreach (var item in infos)
  13126. // {
  13127. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  13128. // if (countryInfo != null)
  13129. // {
  13130. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  13131. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  13132. // if (cityInfo1 != null)
  13133. // {
  13134. // cityInfo1.IsCapital = 0;
  13135. // cityInfos.Add(cityInfo1);
  13136. // }
  13137. // }
  13138. // }
  13139. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  13140. // .UpdateColumns(it => it.IsCapital)
  13141. // .WhereColumns(it => it.Id)
  13142. // .ExecuteCommand();
  13143. // //_sqlSugar.RollbackTran();
  13144. // _sqlSugar.CommitTran();
  13145. // return Ok(JsonView(false, "操作成功!"));
  13146. //}
  13147. //public class CounrtiesDto
  13148. //{
  13149. // public List<CountitiesInfo> MyProperty { get; set; }
  13150. //}
  13151. //public class CountitiesInfo
  13152. //{
  13153. // /// <summary>
  13154. // /// 圣约翰
  13155. // /// </summary>
  13156. // public string capital_name_chinese { get; set; }
  13157. // /// <summary>
  13158. // ///
  13159. // /// </summary>
  13160. // public string capital_name { get; set; }
  13161. // /// <summary>
  13162. // ///
  13163. // /// </summary>
  13164. // public string country_type { get; set; }
  13165. // /// <summary>
  13166. // /// 安提瓜和巴布达
  13167. // /// </summary>
  13168. // public string country_name_chinese { get; set; }
  13169. // /// <summary>
  13170. // /// 安提瓜和巴布达
  13171. // /// </summary>
  13172. // public string country_name_chinese_short { get; set; }
  13173. // /// <summary>
  13174. // /// 安提瓜和巴布达
  13175. // /// </summary>
  13176. // public string country_name_chinese_UN { get; set; }
  13177. // /// <summary>
  13178. // ///
  13179. // /// </summary>
  13180. // public string country_name_english_abbreviation { get; set; }
  13181. // /// <summary>
  13182. // ///
  13183. // /// </summary>
  13184. // public string country_name_english_formal { get; set; }
  13185. // /// <summary>
  13186. // ///
  13187. // /// </summary>
  13188. // public string country_name_english_UN { get; set; }
  13189. // /// <summary>
  13190. // ///
  13191. // /// </summary>
  13192. // public string continent_name { get; set; }
  13193. // /// <summary>
  13194. // ///
  13195. // /// </summary>
  13196. // public string subregion_name { get; set; }
  13197. // /// <summary>
  13198. // ///
  13199. // /// </summary>
  13200. // public string country_code2 { get; set; }
  13201. // /// <summary>
  13202. // ///
  13203. // /// </summary>
  13204. // public string country_code3 { get; set; }
  13205. // /// <summary>
  13206. // ///
  13207. // /// </summary>
  13208. // public string phone_code { get; set; }
  13209. //}
  13210. //public class CountriesInfo : BasicInfo
  13211. //{
  13212. // public List<CitiesInfo> c { get; set; }
  13213. //}
  13214. //public class CitiesInfo : BasicInfo
  13215. //{
  13216. // public List<AreaInfo> c { get; set; }
  13217. //}
  13218. //public class AreaInfo : BasicInfo
  13219. //{
  13220. // public List<AreaInfo> c { get; set; }
  13221. //}
  13222. //public class BasicInfo
  13223. //{
  13224. // public string code { get; set; }
  13225. // public string cn { get; set; }
  13226. // public string lv { get; set; }
  13227. // public string en { get; set; }
  13228. //}
  13229. #endregion
  13230. #region 查看邀请方
  13231. /// <summary>
  13232. /// 查看邀请方
  13233. /// 邀请方信息 Init
  13234. /// </summary>
  13235. /// <param name="dto"></param>
  13236. /// <returns></returns>
  13237. [HttpPost]
  13238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13239. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  13240. {
  13241. string sqlWhere = string.Empty;
  13242. if (!string.IsNullOrEmpty(dto.Search))
  13243. {
  13244. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  13245. }
  13246. string sql = string.Format($@"Select
  13247. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  13248. Id,
  13249. UnitName
  13250. From Res_InvitationOfficialActivityData
  13251. Where IsDel = 0
  13252. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  13253. RefAsync<int> total = 0;
  13254. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13255. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  13256. }
  13257. /// <summary>
  13258. /// 查看邀请方
  13259. /// 国家信息 Init
  13260. /// </summary>
  13261. /// <param name="dto"></param>
  13262. /// <returns></returns>
  13263. [HttpPost]
  13264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13265. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  13266. {
  13267. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  13268. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13269. var diids = groupInfos.Select(it => it.Id).ToList();
  13270. List<string> countrys = new List<string>();
  13271. foreach (var item in country)
  13272. {
  13273. var data = _groupRepository.FormartTeamName(item);
  13274. var dataArray = _groupRepository.GroupSplitCountry(data);
  13275. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13276. }
  13277. countrys = countrys.Distinct().ToList();
  13278. for (int i = 0; i < countrys.Count; i++)
  13279. {
  13280. string item = countrys[i];
  13281. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  13282. {
  13283. countrys.Remove(item);
  13284. i--;
  13285. }
  13286. }
  13287. RefAsync<int> total = 0;
  13288. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  13289. .Where(it => countrys.Contains(it.Name_CN))
  13290. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  13291. .Select(it => new { id = it.Id, name = it.Name_CN })
  13292. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13293. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  13294. }
  13295. /// <summary>
  13296. /// 查看邀请方
  13297. /// 城市信息 Init
  13298. /// </summary>
  13299. /// <param name="dto"></param>
  13300. /// <returns></returns>
  13301. [HttpPost]
  13302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13303. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  13304. {
  13305. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  13306. RefAsync<int> total = 0;
  13307. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  13308. .Where(it => it.CountriesId == dto.CountiesId)
  13309. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  13310. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  13311. .Select(it => new { id = it.Id, name = it.Name_CN })
  13312. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13313. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  13314. }
  13315. /// <summary>
  13316. /// 查看邀请方
  13317. /// 团组名称 Init
  13318. /// </summary>
  13319. /// <param name="dto"></param>
  13320. /// <returns></returns>
  13321. [HttpPost]
  13322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13323. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  13324. {
  13325. var watch = new Stopwatch();
  13326. watch.Start();
  13327. RefAsync<int> total = 0;
  13328. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  13329. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  13330. .Where((oa, di) => oa.IsDel == 0)
  13331. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  13332. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  13333. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  13334. .Distinct()
  13335. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13336. watch.Stop();
  13337. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  13338. }
  13339. /// <summary>
  13340. /// 查看邀请方
  13341. /// 团组 & 邀请方信息
  13342. /// </summary>
  13343. /// <param name="dto"></param>
  13344. /// <returns></returns>
  13345. [HttpPost]
  13346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13347. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  13348. {
  13349. var watch = new Stopwatch();
  13350. watch.Start();
  13351. RefAsync<int> total = 0;
  13352. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  13353. .AS("Grp_DelegationInfo")
  13354. .Includes(x => x.InvitingInfos)
  13355. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  13356. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  13357. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  13358. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  13359. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  13360. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  13361. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13362. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  13363. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  13364. infos.ForEach(x =>
  13365. {
  13366. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  13367. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  13368. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  13369. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  13370. });
  13371. watch.Stop();
  13372. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  13373. }
  13374. #endregion
  13375. #region 报批行程
  13376. /// <summary>
  13377. /// 报批行程初始化
  13378. /// </summary>
  13379. /// <param name="dto"></param>
  13380. /// <returns></returns>
  13381. [HttpPost]
  13382. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  13383. {
  13384. const int chiNumber = 5;
  13385. var jw = JsonView(false);
  13386. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  13387. var group = groupList.First();
  13388. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13389. group = groupList.First(x => x.Id == diid);
  13390. if (group == null)
  13391. {
  13392. jw.Msg = "暂无团组!";
  13393. return Ok(jw);
  13394. }
  13395. var data = new
  13396. {
  13397. groupList = groupList.Select(x => new
  13398. {
  13399. x.TeamName,
  13400. x.Id
  13401. }),
  13402. content = new ArrayList(),
  13403. groupInfo = new
  13404. {
  13405. group.VisitDays,
  13406. group.TourCode,
  13407. group.VisitPNumber,
  13408. group.TeamName,
  13409. group.Id,
  13410. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  13411. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  13412. },
  13413. };
  13414. var resultArr = new ArrayList();
  13415. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  13416. if (content.Count == 0)
  13417. {
  13418. var stay = "-";
  13419. var cityPath = "-";
  13420. //添加城市路径以及住宿地
  13421. //黑屏代码数据
  13422. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13423. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13424. {
  13425. jw = JsonView(true, "黑屏代码有误!", data);
  13426. return Ok(jw);
  13427. }
  13428. foreach (DataRow row in dtBlack.Rows)
  13429. {
  13430. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13431. {
  13432. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  13433. return Ok(jw);
  13434. }
  13435. }
  13436. //黑屏代码获取时间区间
  13437. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13438. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13439. _sqlSugar.BeginTran();
  13440. for (int i = 0; i < timeArr.Count; i++)
  13441. {
  13442. stay = "-";
  13443. cityPath = "-";
  13444. DateTime NewData = DateTime.Parse(timeArr[i]);
  13445. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13446. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13447. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13448. if (tbSelect.Length > 0)
  13449. {
  13450. List<string> threeCodeStr = new List<string>();
  13451. foreach (var item in tbSelect)
  13452. {
  13453. var threeCode = item["Three"].ToString() ?? "";
  13454. if (threeCode.Length == 6)
  13455. {
  13456. var start = threeCode.Substring(0, 3);
  13457. var end = threeCode.Substring(3, 3);
  13458. if (threeCodeStr.Count == 0)
  13459. {
  13460. threeCodeStr.Add(start);
  13461. threeCodeStr.Add(end);
  13462. }
  13463. else
  13464. {
  13465. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13466. {
  13467. threeCodeStr.Add(end);
  13468. }
  13469. else
  13470. {
  13471. threeCodeStr.Add(start);
  13472. threeCodeStr.Add(end);
  13473. }
  13474. }
  13475. }
  13476. }
  13477. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13478. var last = threeCodeStr.Last();
  13479. foreach (var item in threeCodeStr)
  13480. {
  13481. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13482. if (item.Equals(last))
  13483. {
  13484. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13485. }
  13486. }
  13487. cityPath = cityPath.Trim('-');
  13488. }
  13489. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13490. appro.Diid = diid ?? -1;
  13491. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13492. appro.Id = thisId;
  13493. appro.CreateUserId = dto.UserId;
  13494. appro.CreateTime = DateTime.Now;
  13495. content.Add(appro);
  13496. }
  13497. _sqlSugar.CommitTran();
  13498. }
  13499. foreach (var x in content)
  13500. {
  13501. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  13502. if (chiList.Count < chiNumber)
  13503. {
  13504. for (int i = chiList.Count; i < chiNumber; i++)
  13505. {
  13506. chiList.Add(new Grp_ApprovalTravelDetails());
  13507. }
  13508. }
  13509. resultArr.Add(new
  13510. {
  13511. x.Id,
  13512. x.Date,
  13513. x.Diid,
  13514. chiList = chiList.Select(x1 => new
  13515. {
  13516. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13517. x1.Details,
  13518. x1.ParentId,
  13519. x1.Id
  13520. })
  13521. });
  13522. }
  13523. data = data with
  13524. {
  13525. content = resultArr,
  13526. };
  13527. jw = JsonView(true, "获取成功!", data);
  13528. return Ok(jw);
  13529. }
  13530. /// <summary>
  13531. /// 报批行程删除
  13532. /// </summary>
  13533. /// <param name="dto"></param>
  13534. /// <returns></returns>
  13535. [HttpPost]
  13536. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  13537. {
  13538. var jw = JsonView(false);
  13539. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13540. if (group == null)
  13541. {
  13542. jw.Msg = "团组参数有误!";
  13543. return Ok(jw);
  13544. }
  13545. try
  13546. {
  13547. _sqlSugar.BeginTran();
  13548. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  13549. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  13550. {
  13551. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13552. DeleteUserId = dto.uesrId,
  13553. IsDel = 1
  13554. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  13555. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  13556. {
  13557. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13558. DeleteUserId = dto.uesrId,
  13559. IsDel = 1
  13560. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  13561. _sqlSugar.CommitTran();
  13562. jw = JsonView(true, "删除成功");
  13563. }
  13564. catch (Exception ex)
  13565. {
  13566. jw = JsonView(false, ex.Message);
  13567. }
  13568. return Ok(jw);
  13569. }
  13570. /// <summary>
  13571. /// 报批行程保存
  13572. /// </summary>
  13573. /// <param name="dto"></param>
  13574. /// <returns></returns>
  13575. [HttpPost]
  13576. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  13577. {
  13578. var jw = JsonView(false);
  13579. var Find = dto.Arr.Find(x => x.id == 0);
  13580. if (Find != null)
  13581. {
  13582. jw.Msg = "生成的ID为0!";
  13583. return Ok(jw);
  13584. }
  13585. foreach (var item in dto.Arr)
  13586. {
  13587. foreach (var chi in item.chiList)
  13588. {
  13589. if (chi.parentId == 0)
  13590. {
  13591. chi.parentId = item.id;
  13592. }
  13593. }
  13594. }
  13595. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  13596. _sqlSugar.BeginTran();
  13597. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  13598. {
  13599. var parentIds = dto.Arr.Select(x => x.id).ToList();
  13600. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  13601. {
  13602. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13603. DeleteUserId = dto.UserId,
  13604. IsDel = 1
  13605. }).ExecuteCommand();
  13606. }
  13607. try
  13608. {
  13609. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  13610. {
  13611. CreateTime = DateTime.Now,
  13612. CreateUserId = dto.UserId,
  13613. Details = x.details,
  13614. ParentId = x.parentId,
  13615. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13616. Remark = "",
  13617. IsDel = 0
  13618. }).ToList()).ExecuteCommand();
  13619. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  13620. {
  13621. Id = x.id,
  13622. Details = x.details,
  13623. ParentId = x.parentId,
  13624. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13625. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  13626. {
  13627. Details = x.Details,
  13628. ParentId = x.ParentId,
  13629. Time = x.Time
  13630. }).ExecuteCommand();
  13631. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  13632. {
  13633. Id = x.id,
  13634. Date = x.date,
  13635. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  13636. {
  13637. Date = x.Date
  13638. }).ExecuteCommand();
  13639. _sqlSugar.CommitTran();
  13640. jw = JsonView(true, "保存成功!");
  13641. }
  13642. catch (Exception ex)
  13643. {
  13644. _sqlSugar.RollbackTran();
  13645. jw = JsonView(false, "保存失败!" + ex.Message);
  13646. }
  13647. return Ok(jw);
  13648. }
  13649. /// <summary>
  13650. /// 报批行程生成
  13651. /// </summary>
  13652. /// <param name="dto"></param>
  13653. /// <returns></returns>
  13654. [HttpPost]
  13655. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  13656. {
  13657. var jw = JsonView(false);
  13658. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13659. if (group == null)
  13660. {
  13661. jw.Msg = "暂无该团组!";
  13662. return Ok(jw);
  13663. }
  13664. //黑屏代码数据
  13665. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13666. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13667. {
  13668. jw.Msg = "黑屏代码有误!";
  13669. return Ok(jw);
  13670. }
  13671. foreach (DataRow row in dtBlack.Rows)
  13672. {
  13673. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13674. {
  13675. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  13676. return Ok(jw);
  13677. }
  13678. }
  13679. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13680. var resultArr = new ArrayList();
  13681. if (officialActivitiesArr.Count == 0)
  13682. {
  13683. jw.Msg = "暂无公务出访信息!";
  13684. return Ok(jw);
  13685. }
  13686. try
  13687. {
  13688. _sqlSugar.BeginTran();
  13689. DeleteApprovalJourney(new
  13690. Domain.Dtos.Groups.DeleteApprovalJourney
  13691. {
  13692. Diid = dto.Diid,
  13693. uesrId = dto.Userid
  13694. });
  13695. var stay = "-";
  13696. var cityPath = "-";
  13697. //添加城市路径以及住宿地
  13698. //黑屏代码获取时间区间
  13699. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13700. var empty = "【未收入该三字码!请机票同事录入】";
  13701. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13702. for (int i = 0; i < timeArr.Count; i++)
  13703. {
  13704. stay = "-";
  13705. cityPath = "-";
  13706. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13707. DateTime NewData = DateTime.Parse(timeArr[i]);
  13708. 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();
  13709. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13710. if (tbSelect.Length > 0)
  13711. {
  13712. List<string> threeCodeStr = new List<string>();
  13713. bool isTrade = false;
  13714. string trip = string.Empty;
  13715. var rowLast = tbSelect.Last();
  13716. var rowFirst = tbSelect.First();
  13717. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13718. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13719. var takeOffTime = DateTime.Parse(timeArr[i]);
  13720. var fallToTime = DateTime.Parse(timeArr[i]);
  13721. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13722. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13723. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13724. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13725. foreach (var item in tbSelect)
  13726. {
  13727. var start = string.Empty;
  13728. var end = string.Empty;
  13729. var threeCode = item["Three"].ToString() ?? "";
  13730. if (threeCode.Length == 6)
  13731. {
  13732. start = threeCode.Substring(0, 3);
  13733. end = threeCode.Substring(3, 3);
  13734. if (threeCodeStr.Count == 0)
  13735. {
  13736. threeCodeStr.Add(start);
  13737. threeCodeStr.Add(end);
  13738. }
  13739. else
  13740. {
  13741. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13742. {
  13743. threeCodeStr.Add(end);
  13744. }
  13745. else
  13746. {
  13747. threeCodeStr.Add(start);
  13748. threeCodeStr.Add(end);
  13749. }
  13750. }
  13751. }
  13752. //处理机票信息
  13753. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13754. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13755. if (start_Object == null)
  13756. {
  13757. start_Object = new Res_ThreeCode()
  13758. {
  13759. AirPort = empty,
  13760. AirPort_En = empty,
  13761. City = empty,
  13762. Country = empty,
  13763. Four = empty,
  13764. Three = empty,
  13765. };
  13766. }
  13767. if (end_Object == null)
  13768. {
  13769. end_Object = new Res_ThreeCode()
  13770. {
  13771. AirPort = empty,
  13772. AirPort_En = empty,
  13773. City = empty,
  13774. Country = empty,
  13775. Four = empty,
  13776. Three = empty,
  13777. };
  13778. }
  13779. //机型判断
  13780. string airModel = item["AirModel"].ToString();
  13781. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13782. string flightTime = item["FlightTime"].ToString();
  13783. if (flightTime!.Contains(":"))
  13784. {
  13785. flightTime = flightTime.Replace(":", "小时");
  13786. flightTime += "分钟";
  13787. }
  13788. if (flightTime.Contains("H"))
  13789. {
  13790. flightTime = flightTime.Replace("H", "小时");
  13791. }
  13792. if (flightTime.Contains("M"))
  13793. {
  13794. flightTime = flightTime.Replace("M", "分钟");
  13795. }
  13796. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13797. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13798. {
  13799. flightTime = flightDataTime.Hour > 0
  13800. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13801. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13802. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13803. }
  13804. //航班号
  13805. string flightcode = item["Fliagtcode"].ToString();
  13806. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13807. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13808. if (aircompany == null)
  13809. {
  13810. aircompany = new Res_AirCompany
  13811. {
  13812. CnName = hsEmpty,
  13813. EnName = hsEmpty,
  13814. ShortCode = hsEmpty,
  13815. };
  13816. }
  13817. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13818. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13819. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13820. if (isTrade)
  13821. {
  13822. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13823. }
  13824. else
  13825. {
  13826. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13827. }
  13828. }
  13829. chiarr.Add(new Grp_ApprovalTravelDetails
  13830. {
  13831. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13832. CreateTime = DateTime.Now,
  13833. CreateUserId = dto.Userid,
  13834. ParentId = 0,
  13835. Details = trip
  13836. });
  13837. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13838. var last = threeCodeStr.Last();
  13839. foreach (var item in threeCodeStr)
  13840. {
  13841. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13842. if (item.Equals(last))
  13843. {
  13844. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13845. }
  13846. }
  13847. cityPath = cityPath.Trim('-');
  13848. }
  13849. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13850. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13851. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13852. appro.Diid = dto.Diid;
  13853. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13854. appro.Id = thisId;
  13855. appro.CreateUserId = dto.Userid;
  13856. appro.CreateTime = DateTime.Now;
  13857. foreach (var item in gwinfo)
  13858. {
  13859. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13860. chi.Details = "拜访" + item.Client;
  13861. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13862. {
  13863. chi.Details += "," + item.ReqSample;
  13864. }
  13865. chi.ParentId = thisId;
  13866. chi.Time = item.Time;
  13867. chiarr.Add(chi);
  13868. }
  13869. if (chiarr.Count < 5)
  13870. {
  13871. for (int j = chiarr.Count; j < 5; j++)
  13872. {
  13873. chiarr.Add(new
  13874. Grp_ApprovalTravelDetails());
  13875. }
  13876. }
  13877. resultArr.Add(new
  13878. {
  13879. appro.Id,
  13880. appro.Date,
  13881. appro.Diid,
  13882. chiList = chiarr.Select(x1 => new
  13883. {
  13884. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13885. x1.Details,
  13886. x1.ParentId,
  13887. x1.Id
  13888. })
  13889. });
  13890. }
  13891. _sqlSugar.CommitTran();
  13892. jw = JsonView(true, "生成成功!", resultArr);
  13893. }
  13894. catch (Exception ex)
  13895. {
  13896. jw.Code = 400;
  13897. jw.Msg = "生成失败!" + ex.Message;
  13898. }
  13899. return Ok(jw);
  13900. }
  13901. /// <summary>
  13902. /// 报批行程word导出
  13903. /// </summary>
  13904. /// <param name="dto"></param>
  13905. /// <returns></returns>
  13906. [HttpPost]
  13907. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13908. {
  13909. var jw = JsonView(false);
  13910. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13911. if (group == null)
  13912. {
  13913. jw.Msg = "暂无该团组!";
  13914. return Ok(jw);
  13915. }
  13916. //模板路径
  13917. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13918. //载入模板
  13919. Document doc = new Document(tempPath);
  13920. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13921. //获取所填表格的序数
  13922. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13923. Aspose.Words.Tables.Row titleRowClone = null;
  13924. Aspose.Words.Tables.Row CenterRowClone = null;
  13925. int index = 0;
  13926. int indexChi = 0;
  13927. int SetIndex = 0;
  13928. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13929. //获取数据,放到datatable
  13930. foreach (var item in ApprovalTravelArr)
  13931. {
  13932. if (index > 0)
  13933. {
  13934. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13935. tableOne.AppendChild(titleRowClone);
  13936. }
  13937. var textTime = item.Date;
  13938. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13939. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13940. SetIndex++;
  13941. if (ChiRep.Count > 0)
  13942. {
  13943. foreach (var itemChi in ChiRep)
  13944. {
  13945. var txtTime = itemChi.Time;
  13946. var txtDetail = itemChi.Details;
  13947. if (indexChi > 0)
  13948. {
  13949. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13950. tableOne.AppendChild(CenterRowClone);
  13951. }
  13952. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13953. {
  13954. SetCells(tableOne, doc, SetIndex, 0, "");
  13955. SetCells(tableOne, doc, SetIndex, 1, "");
  13956. indexChi++;
  13957. SetIndex++;
  13958. break;
  13959. }
  13960. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13961. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13962. indexChi++;
  13963. SetIndex++;
  13964. }
  13965. }
  13966. else
  13967. {
  13968. if (indexChi > 0)
  13969. {
  13970. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13971. tableOne.AppendChild(CenterRowClone);
  13972. }
  13973. SetCells(tableOne, doc, SetIndex, 0, "");
  13974. SetCells(tableOne, doc, SetIndex, 1, "");
  13975. indexChi++;
  13976. SetIndex++;
  13977. }
  13978. index++;
  13979. }
  13980. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13981. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13982. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13983. jw.Code = 200;
  13984. jw.Msg = "";
  13985. return Ok(jw);
  13986. }
  13987. private string intToString(int numberVal)
  13988. {
  13989. string numberval = numberVal.ToString();
  13990. Dictionary<char, string> Number = new Dictionary<char, string>();
  13991. Number.Add('1', "一");
  13992. Number.Add('2', "二");
  13993. Number.Add('3', "三");
  13994. Number.Add('4', "四");
  13995. Number.Add('5', "五");
  13996. Number.Add('6', "六");
  13997. Number.Add('7', "七");
  13998. Number.Add('8', "八");
  13999. Number.Add('9', "九");
  14000. string stringNumberVal = string.Empty;
  14001. for (int i = 0; i < numberval.Length; i++)
  14002. {
  14003. if (i == 0)
  14004. {
  14005. stringNumberVal += Number[numberval[i]];
  14006. }
  14007. else if (i >= 1)
  14008. {
  14009. if (numberval[i] == '0')
  14010. {
  14011. stringNumberVal = "十";
  14012. }
  14013. else
  14014. {
  14015. stringNumberVal += "十" + Number[numberval[i]];
  14016. }
  14017. }
  14018. }
  14019. return stringNumberVal;
  14020. }
  14021. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  14022. {
  14023. //获取table中的某个单元格,从0开始
  14024. Cell lshCell = table.Rows[rows].Cells[cells];
  14025. //将单元格中段落移除
  14026. foreach (Node item in lshCell.Paragraphs)
  14027. {
  14028. lshCell.Paragraphs.Remove(item);
  14029. }
  14030. if (val.Contains("\r\n"))
  14031. {
  14032. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  14033. foreach (var item in spArr)
  14034. {
  14035. //新建一个段落
  14036. Paragraph p = new Paragraph(doc);
  14037. var r = new Run(doc, item);
  14038. //把设置的值赋给之前新建的段落
  14039. p.AppendChild(r);
  14040. //将此段落加到单元格内
  14041. lshCell.AppendChild(p);
  14042. }
  14043. }
  14044. else
  14045. {
  14046. //新建一个段落
  14047. Paragraph p = new Paragraph(doc);
  14048. var r = new Run(doc, val);
  14049. //把设置的值赋给之前新建的段落
  14050. p.AppendChild(r);
  14051. //将此段落加到单元格内
  14052. lshCell.AppendChild(p);
  14053. }
  14054. }
  14055. [HttpPost]
  14056. public async Task<IActionResult> ServerHttp(string paramStr)
  14057. {
  14058. paramStr = paramStr.TrimEnd('\'');
  14059. paramStr = paramStr.TrimStart('\'');
  14060. JsonView jw = JsonView(false);
  14061. JObject param = JObject.Parse(paramStr);
  14062. if (!param.ContainsKey("url"))
  14063. {
  14064. jw.Msg = "url null";
  14065. return Ok(jw);
  14066. }
  14067. string url = param["url"]!.ToString();
  14068. var methon = "get";
  14069. Dictionary<string, string> headValues = null;
  14070. string bodyStr = string.Empty;
  14071. if (param.ContainsKey("methon"))
  14072. {
  14073. methon = param["methon"]!.ToString().ToLower();
  14074. }
  14075. if (param.ContainsKey("header"))
  14076. {
  14077. var header = param["header"]!.ToString();
  14078. JObject headerJobject = JObject.Parse(header);
  14079. headValues = new Dictionary<string, string>();
  14080. foreach (JProperty item in headerJobject.Properties())
  14081. {
  14082. var value = item.Value.ToString();
  14083. var head = item.Path;
  14084. headValues.Add(head, value);
  14085. }
  14086. }
  14087. HttpClient client = new HttpClient();
  14088. string responseString = string.Empty;
  14089. StringContent content = null;
  14090. if (headValues != null)
  14091. {
  14092. foreach (var item in headValues.Keys)
  14093. {
  14094. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  14095. {
  14096. if (param.ContainsKey("body"))
  14097. {
  14098. bodyStr = param["body"]!.ToString();
  14099. }
  14100. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  14101. }
  14102. else
  14103. {
  14104. client.DefaultRequestHeaders.Add(item, headValues[item]);
  14105. }
  14106. }
  14107. }
  14108. try
  14109. {
  14110. if (methon == "get")
  14111. {
  14112. responseString = await client.GetStringAsync(url);
  14113. }
  14114. else if (methon == "post")
  14115. {
  14116. var request = new HttpRequestMessage(HttpMethod.Post, url)
  14117. {
  14118. Content = content
  14119. };
  14120. var response = await client.SendAsync(request);
  14121. try
  14122. {
  14123. Stream responseStream = await response.Content.ReadAsStreamAsync();
  14124. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  14125. {
  14126. using (StreamReader reader = new StreamReader(gzipStream))
  14127. {
  14128. responseString = await reader.ReadToEndAsync();
  14129. }
  14130. }
  14131. }
  14132. catch (Exception)
  14133. {
  14134. responseString = await response.Content.ReadAsStringAsync();
  14135. }
  14136. }
  14137. else
  14138. {
  14139. responseString = "methon error";
  14140. }
  14141. jw = JsonView(true, "success", responseString);
  14142. }
  14143. catch (Exception ex)
  14144. {
  14145. jw.Msg = "error " + ex.Message;
  14146. jw.Data = ex.StackTrace;
  14147. }
  14148. finally
  14149. {
  14150. client.Dispose();
  14151. }
  14152. return Ok(jw);
  14153. }
  14154. #endregion
  14155. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  14156. /// <summary>
  14157. /// 团组接待意见调查 - 信息管理
  14158. /// 基础数据(团组)
  14159. /// </summary>
  14160. /// <param name="dto"></param>
  14161. /// <returns></returns>
  14162. [HttpGet]
  14163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14164. public async Task<IActionResult> OpinionaireInit()
  14165. {
  14166. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  14167. .Select(x => new
  14168. {
  14169. x.Id,
  14170. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  14171. })
  14172. .OrderByDescending(x => x.Id)
  14173. .ToListAsync();
  14174. return Ok(JsonView(groupData, groupData.Count));
  14175. }
  14176. /// <summary>
  14177. /// 团组接待意见调查 - 信息管理
  14178. /// 列表
  14179. /// </summary>
  14180. /// <param name="groupId"></param>
  14181. /// <returns></returns>
  14182. [HttpGet("{groupId}")]
  14183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14184. public async Task<IActionResult> OpinionaireManageList(int groupId)
  14185. {
  14186. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14187. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  14188. .Select(x => new
  14189. {
  14190. x.Id,
  14191. x.TourGuideName,
  14192. x.CityName,
  14193. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  14194. x.CreateTime
  14195. })
  14196. .OrderBy(x => x.Id)
  14197. .ToListAsync();
  14198. return Ok(JsonView(data));
  14199. }
  14200. /// <summary>
  14201. /// 团组接待意见调查 - 信息管理
  14202. /// 保存
  14203. /// </summary>
  14204. /// <param name="dto"></param>
  14205. /// <returns></returns>
  14206. [HttpPost]
  14207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14208. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  14209. {
  14210. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  14211. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  14212. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14213. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  14214. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  14215. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  14216. _opinionaireRep.BeginTran();
  14217. if (addData != null && addData.Count > 0)
  14218. {
  14219. foreach (var item in addData)
  14220. {
  14221. item.CreateUserId = currUserInfo.UserId;
  14222. item.DiId = dto.DiId;
  14223. }
  14224. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  14225. }
  14226. if (updData != null && updData.Count > 0)
  14227. {
  14228. var upd = await _opinionaireRep._sqlSugar
  14229. .Updateable(updData)
  14230. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  14231. .WhereColumns(x => new { x.Id })
  14232. .ExecuteCommandAsync();
  14233. }
  14234. _opinionaireRep.CommitTran();
  14235. return Ok(JsonView("操作成功!"));
  14236. }
  14237. /// <summary>
  14238. /// 团组接待意见调查 - 信息管理
  14239. /// 删除
  14240. /// </summary>
  14241. /// <param name="id"></param>
  14242. /// <returns></returns>
  14243. [HttpDelete("{id}")]
  14244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14245. public async Task<IActionResult> OpinionaireManageDel(int id)
  14246. {
  14247. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  14248. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  14249. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  14250. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  14251. if (!del) return Ok(JsonView("操作失败!"));
  14252. return Ok(JsonView("操作成功!"));
  14253. }
  14254. /// <summary>
  14255. /// 团组接待意见调查 - 用户
  14256. /// 列表
  14257. /// </summary>
  14258. /// <param name="id"></param>
  14259. /// <returns></returns>
  14260. [HttpGet("{diId}")]
  14261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14262. public async Task<IActionResult> OpinionaireUserList(int diId)
  14263. {
  14264. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14265. var sql = string.Format(@"
  14266. SELECT
  14267. o.Id,
  14268. o.DiId,
  14269. di.TeamName AS 'GroupName',
  14270. di.VisitPNumber AS 'PeopleNumber',
  14271. di.ClientName AS 'LeadGroup',
  14272. di.VisitCountry AS 'Travel',
  14273. di.VisitDays AS 'Days',
  14274. o.CityName,
  14275. o.TourGuideName,
  14276. o.Catering,
  14277. o.CateringReason,
  14278. o.Stay,
  14279. o.StayReason,
  14280. o.[Route],
  14281. o.RouteReason,
  14282. o.OfficialActivity,
  14283. o.OfficialActivityReason,
  14284. o.TourGuide,
  14285. o.TourGuideReason,
  14286. o.[Translate],
  14287. o.TranslateReason,
  14288. o.Trip,
  14289. o.TripReason,
  14290. o.ESFileName,
  14291. o.SignatureDate,
  14292. o.Remark
  14293. FROM
  14294. Grp_Opinionaire o
  14295. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  14296. WHERE
  14297. o.IsDel = 0
  14298. AND o.DiId = {0}
  14299. ORDER BY
  14300. o.Id ASC", diId);
  14301. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  14302. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  14303. return Ok(JsonView(data));
  14304. }
  14305. /// <summary>
  14306. /// 团组接待意见调查 - 用户
  14307. /// 保存
  14308. /// </summary>
  14309. /// <param name="id"></param>
  14310. /// <returns></returns>
  14311. [HttpPost]
  14312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14313. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  14314. {
  14315. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  14316. foreach (var item in dto)
  14317. {
  14318. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  14319. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  14320. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  14321. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  14322. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  14323. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  14324. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  14325. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  14326. }
  14327. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  14328. if (!Directory.Exists(filePathBase))
  14329. {
  14330. Directory.CreateDirectory(filePathBase);
  14331. }
  14332. #region 上传文件
  14333. var filePaths = new List<string>();
  14334. foreach (var item in dto)
  14335. {
  14336. var file = item.File;
  14337. // 将文件保存到指定位置
  14338. var filePath = Path.Combine(filePathBase, file.FileName);
  14339. using (var stream = new FileStream(filePath, FileMode.Create))
  14340. {
  14341. await file.CopyToAsync(stream);
  14342. }
  14343. //验证文件是否上传成功
  14344. if (!System.IO.File.Exists(filePath))
  14345. {
  14346. foreach (var filePathStr in filePaths)
  14347. {
  14348. System.IO.File.Delete(filePathStr);
  14349. }
  14350. return Ok(JsonView(false, "文件上传失败!"));
  14351. }
  14352. item.ESFileName = file.FileName;
  14353. }
  14354. #endregion
  14355. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  14356. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  14357. .UpdateColumns(x => new
  14358. {
  14359. x.Catering,
  14360. x.CateringReason,
  14361. x.Stay,
  14362. x.StayReason,
  14363. x.Route,
  14364. x.RouteReason,
  14365. x.OfficialActivity,
  14366. x.OfficialActivityReason,
  14367. x.TourGuide,
  14368. x.TourGuideReason,
  14369. x.Translate,
  14370. x.TranslateReason,
  14371. x.Trip,
  14372. x.TripReason,
  14373. x.ESFileName,
  14374. x.SignatureDate,
  14375. x.Remark
  14376. })
  14377. .WhereColumns(x => new { x.Id })
  14378. .ExecuteCommandAsync();
  14379. if (upd < 1)
  14380. {
  14381. foreach (var filePathStr in filePaths)
  14382. {
  14383. System.IO.File.Delete(filePathStr);
  14384. }
  14385. return Ok(JsonView(false));
  14386. }
  14387. return Ok(JsonView(true));
  14388. }
  14389. #endregion
  14390. // /// <summary>
  14391. // ///
  14392. // /// </summary>
  14393. // /// <param name="_dto"></param>
  14394. // /// <returns></returns>
  14395. // [HttpPost]
  14396. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14397. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14398. // {
  14399. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14400. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  14401. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  14402. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14403. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  14404. // dic_psg.Add("客人", 974);
  14405. // dic_psg.Add("司机", 975);
  14406. // dic_psg.Add("导游", 976);
  14407. // dic_psg.Add("公司内部人员", 977);
  14408. // dic_psg.Add("司机/导游/公司内部人员", 978);
  14409. // foreach (var item in list_visa)
  14410. // {
  14411. // Grp_VisaInfo temp = new Grp_VisaInfo();
  14412. // temp.Id = item.Id;
  14413. // temp.DIId = item.DIId;
  14414. // temp.VisaClient = item.VisaClient;
  14415. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  14416. // temp.VisaCurrency = item.VisaCurrency;
  14417. // temp.IsThird = item.IsThird;
  14418. // if (dic_psg.ContainsKey(item.PassengerType))
  14419. // {
  14420. // temp.PassengerType = dic_psg[item.PassengerType];
  14421. // }
  14422. // else {
  14423. // temp.PassengerType = -1;
  14424. // }
  14425. // temp.VisaNumber = item.VisaNumber;
  14426. // temp.VisaFreeNumber = item.VisaFreeNumber;
  14427. // temp.CreateUserId = item.Operators;
  14428. // DateTime dt_ct;
  14429. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  14430. // if (b_ct)
  14431. // {
  14432. // temp.CreateTime = dt_ct;
  14433. // }
  14434. // else
  14435. // {
  14436. // temp.CreateTime = DateTime.Now;
  14437. // }
  14438. // temp.DeleteTime = "";
  14439. // temp.DeleteUserId = 0;
  14440. // temp.Remark = item.Remark;
  14441. // if (string.IsNullOrEmpty(temp.Remark)) {
  14442. // temp.Remark = "";
  14443. // }
  14444. // temp.IsDel = item.IsDel;
  14445. // temp.VisaDescription = item.VisaAttachment;
  14446. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  14447. //([Id]
  14448. // ,[DIId]
  14449. // ,[VisaClient]
  14450. // ,[VisaPrice]
  14451. // ,[VisaCurrency]
  14452. // ,[IsThird]
  14453. // ,[PassengerType]
  14454. // ,[VisaNumber]
  14455. // ,[VisaFreeNumber]
  14456. // ,[CreateUserId]
  14457. // ,[CreateTime]
  14458. // ,[DeleteTime]
  14459. // ,[DeleteUserId]
  14460. // ,[Remark]
  14461. // ,[IsDel]
  14462. // ,[visaDescription])
  14463. // VALUES
  14464. // ({0},{1},'{2}',{3},{4}
  14465. //,{5},{6},{7},{8},{9}
  14466. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  14467. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  14468. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  14469. //);
  14470. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  14471. // }
  14472. // return Ok(JsonView(true, "操作成功!"));
  14473. // }
  14474. /// <summary>
  14475. /// 123132123
  14476. /// </summary>
  14477. /// <param name="_dto"></param>
  14478. /// <returns></returns>
  14479. [HttpPost]
  14480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14481. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14482. {
  14483. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14484. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  14485. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  14486. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14487. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  14488. dicDetail.Add(789, 1034);
  14489. dicDetail.Add(790, 1035);
  14490. dicDetail.Add(791, 1036);
  14491. dicDetail.Add(792, 1037);
  14492. dicDetail.Add(793, 1038);
  14493. dicDetail.Add(794, 1039);
  14494. dicDetail.Add(795, 1040);
  14495. dicDetail.Add(796, 1041);
  14496. dicDetail.Add(797, 1042);
  14497. dicDetail.Add(798, 1043);
  14498. dicDetail.Add(801, 1044);
  14499. dicDetail.Add(802, 1045);
  14500. dicDetail.Add(803, 1046);
  14501. Dictionary<int, int> dic = new Dictionary<int, int>();
  14502. dic.Add(806, 1027);
  14503. dic.Add(807, 1028);
  14504. dic.Add(808, 1029);
  14505. dic.Add(809, 1030);
  14506. dic.Add(810, 1031);
  14507. dic.Add(811, 1032);
  14508. dic.Add(812, 1033);
  14509. foreach (var item in list_visa)
  14510. {
  14511. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  14512. temp.Coefficient = item.coefficient;
  14513. DateTime dtCrt;
  14514. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  14515. if (b1)
  14516. {
  14517. temp.CreateTime = dtCrt;
  14518. }
  14519. else
  14520. {
  14521. temp.CreateTime = DateTime.Now;
  14522. }
  14523. temp.CreateUserId = item.Operators;
  14524. temp.DeleteTime = "";
  14525. temp.DeleteUserId = 0;
  14526. temp.DiId = int.Parse(item.DIID);
  14527. temp.FilePath = item.FilePath;
  14528. temp.IsDel = item.IsDel;
  14529. temp.Price = item.Price;
  14530. temp.PriceCount = 1;
  14531. temp.PriceCurrency = item.Currency;
  14532. int detailId = 0;
  14533. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  14534. {
  14535. detailId = dicDetail[item.PriceTypeDetail];
  14536. }
  14537. temp.PriceDetailType = detailId;
  14538. temp.PriceDt = DateTime.Now;
  14539. temp.PriceName = item.PriceName;
  14540. temp.PriceSum = item.Price;
  14541. int tid = 0;
  14542. if (dic.ContainsKey(item.PriceType))
  14543. {
  14544. tid = dic[item.PriceType];
  14545. }
  14546. temp.PriceType = tid;
  14547. temp.Remark = item.Remark;
  14548. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  14549. }
  14550. return Ok(JsonView(true, "操作成功!"));
  14551. }
  14552. }
  14553. }