GroupsController.cs 770 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569
  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.SS.Format;
  12. using NPOI.SS.Formula.Functions;
  13. using NPOI.SS.UserModel;
  14. using NPOI.SS.Util;
  15. using NPOI.XSSF.UserModel;
  16. using OASystem.API.OAMethodLib;
  17. using OASystem.API.OAMethodLib.APNs;
  18. using OASystem.API.OAMethodLib.File;
  19. using OASystem.API.OAMethodLib.Hub.HubClients;
  20. using OASystem.API.OAMethodLib.Hub.Hubs;
  21. using OASystem.API.OAMethodLib.JuHeAPI;
  22. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Domain.ViewModels.Statistics;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using OfficeOpenXml;
  36. using Org.BouncyCastle.Asn1.Ocsp;
  37. using Quartz.Util;
  38. using SqlSugar;
  39. using SqlSugar.Extensions;
  40. using System.Collections;
  41. using System.Data;
  42. using System.Data.OleDb;
  43. using System.Diagnostics;
  44. using System.Globalization;
  45. using System.IO;
  46. using System.IO.Compression;
  47. using System.Net.Http;
  48. using System.Reflection.PortableExecutable;
  49. using System.Security.Cryptography;
  50. using Ubiety.Dns.Core;
  51. using static NPOI.POIFS.Crypt.CryptoFunctions;
  52. using static OASystem.API.OAMethodLib.JWTHelper;
  53. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  54. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  55. using Bookmark = Aspose.Words.Bookmark;
  56. using Cell = Aspose.Words.Tables.Cell;
  57. using Table = Aspose.Words.Tables.Table;
  58. namespace OASystem.API.Controllers
  59. {
  60. /// <summary>
  61. /// 团组相关
  62. /// </summary>
  63. //[Authorize]
  64. [Route("api/[controller]/[action]")]
  65. public class GroupsController : ControllerBase
  66. {
  67. private readonly ILogger<GroupsController> _logger;
  68. private readonly GrpScheduleRepository _grpScheduleRep;
  69. private readonly IMapper _mapper;
  70. private readonly DelegationInfoRepository _groupRepository;
  71. private readonly TaskAssignmentRepository _taskAssignmentRep;
  72. private readonly AirTicketResRepository _airTicketResRep;
  73. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  74. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  75. private readonly DelegationEnDataRepository _delegationEnDataRep;
  76. private readonly DelegationVisaRepository _delegationVisaRep;
  77. private readonly VisaPriceRepository _visaPriceRep;
  78. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  79. private readonly HotelPriceRepository _hotelPriceRep;
  80. private readonly CustomersRepository _customersRep;
  81. private readonly MessageRepository _message;
  82. private readonly SqlSugarClient _sqlSugar;
  83. private readonly TourClientListRepository _tourClientListRep;
  84. private readonly TeamRateRepository _teamRateRep;
  85. #region 成本相关
  86. private readonly CheckBoxsRepository _checkBoxs;
  87. private readonly GroupCostRepository _GroupCostRepository;
  88. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  89. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  90. #endregion
  91. private readonly SetDataRepository _setDataRep;
  92. private string url;
  93. private string path;
  94. private readonly EnterExitCostRepository _enterExitCostRep;
  95. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  96. private readonly UsersRepository _usersRep;
  97. private readonly IJuHeApiService _juHeApi;
  98. private readonly InvertedListRepository _invertedListRep;
  99. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  100. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  101. private readonly ThreeCodeRepository _threeCodeRepository;
  102. private readonly HotelInquiryRepository _hotelInquiryRep;
  103. private readonly FeeAuditRepository _feeAuditRep;
  104. private readonly VisaCommissionRepository _visaCommissionRep;
  105. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  106. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  107. public GroupsController(
  108. ILogger<GroupsController> logger,
  109. IMapper mapper,
  110. IHubContext<ChatHub, IChatClient> hubContext,
  111. SqlSugarClient sqlSugar,
  112. GrpScheduleRepository grpScheduleRep,
  113. DelegationInfoRepository groupRepository,
  114. TaskAssignmentRepository taskAssignmentRep,
  115. AirTicketResRepository airTicketResRep,
  116. DecreasePaymentsRepository decreasePaymentsRep,
  117. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  118. DelegationEnDataRepository delegationEnDataRep,
  119. EnterExitCostRepository enterExitCostRep,
  120. DelegationVisaRepository delegationVisaRep,
  121. MessageRepository message,
  122. VisaPriceRepository visaPriceRep,
  123. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  124. CheckBoxsRepository checkBoxs,
  125. GroupCostRepository GroupCostRepository,
  126. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  127. GroupCostParameterRepository GroupCostParameterRepository,
  128. HotelPriceRepository hotelPriceRep,
  129. CustomersRepository customersRep,
  130. SetDataRepository setDataRep,
  131. TourClientListRepository tourClientListRep,
  132. TeamRateRepository teamRateRep,
  133. UsersRepository usersRep, IJuHeApiService juHeApi,
  134. InvertedListRepository invertedListRep,
  135. VisaFeeInfoRepository visaFeeInfoRep,
  136. TicketBlackCodeRepository ticketBlackCodeRep,
  137. HotelInquiryRepository hotelInquiryRep,
  138. ThreeCodeRepository threeCodeRepository,
  139. FeeAuditRepository feeAuditRep,
  140. VisaCommissionRepository visaCommissionRep,
  141. ForeignReceivablesRepository ffrRep,
  142. OpinionaireRepository opinionaireRep
  143. )
  144. {
  145. _logger = logger;
  146. _mapper = mapper;
  147. _grpScheduleRep = grpScheduleRep;
  148. _groupRepository = groupRepository;
  149. _taskAssignmentRep = taskAssignmentRep;
  150. _airTicketResRep = airTicketResRep;
  151. _sqlSugar = sqlSugar;
  152. url = AppSettingsHelper.Get("ExcelBaseUrl");
  153. path = AppSettingsHelper.Get("ExcelBasePath");
  154. if (!System.IO.Directory.Exists(path))
  155. {
  156. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  157. }
  158. _decreasePaymentsRep = decreasePaymentsRep;
  159. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  160. _delegationEnDataRep = delegationEnDataRep;
  161. _enterExitCostRep = enterExitCostRep;
  162. _delegationVisaRep = delegationVisaRep;
  163. _message = message;
  164. _visaPriceRep = visaPriceRep;
  165. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  166. _checkBoxs = checkBoxs;
  167. _GroupCostRepository = GroupCostRepository;
  168. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  169. _GroupCostParameterRepository = GroupCostParameterRepository;
  170. _hotelPriceRep = hotelPriceRep;
  171. _customersRep = customersRep;
  172. _setDataRep = setDataRep;
  173. _tourClientListRep = tourClientListRep;
  174. _teamRateRep = teamRateRep;
  175. _hubContext = hubContext;
  176. _usersRep = usersRep;
  177. _juHeApi = juHeApi;
  178. _invertedListRep = invertedListRep;
  179. _visaFeeInfoRep = visaFeeInfoRep;
  180. _ticketBlackCodeRep = ticketBlackCodeRep;
  181. _hotelInquiryRep = hotelInquiryRep;
  182. _threeCodeRepository = threeCodeRepository;
  183. _feeAuditRep = feeAuditRep;
  184. _visaCommissionRep = visaCommissionRep;
  185. _ffrRep = ffrRep;
  186. _opinionaireRep = opinionaireRep;
  187. }
  188. #region 流程管控
  189. /// <summary>
  190. /// 获取团组流程管控信息
  191. /// </summary>
  192. /// <param name="paras">参数Json字符串</param>
  193. /// <returns></returns>
  194. [HttpPost]
  195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  196. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  197. {
  198. if (string.IsNullOrEmpty(_jsonDto.Paras))
  199. {
  200. return Ok(JsonView(false, "参数为空"));
  201. }
  202. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  203. if (_ScheduleDto != null)
  204. {
  205. if (_ScheduleDto.SearchType == 2)//获取列表
  206. {
  207. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  208. return Ok(JsonView(_grpScheduleViewList));
  209. }
  210. else//获取对象
  211. {
  212. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  213. if (_grpScheduleView != null)
  214. {
  215. return Ok(JsonView(_grpScheduleView));
  216. }
  217. }
  218. }
  219. else
  220. {
  221. return Ok(JsonView(false, "参数反序列化失败"));
  222. }
  223. return Ok(JsonView(false, "暂无数据!"));
  224. }
  225. /// <summary>
  226. /// 修改团组流程管控详细表数据
  227. /// </summary>
  228. /// <param name="paras"></param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  232. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  233. {
  234. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  235. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  236. .SetColumns(it => it.Duty == _detail.Duty)
  237. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  238. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  239. .SetColumns(it => it.JobContent == _detail.JobContent)
  240. .SetColumns(it => it.Remark == _detail.Remark)
  241. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  242. .Where(s => s.Id == dto.Id)
  243. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  244. .ExecuteCommandAsync();
  245. if (result > 0)
  246. {
  247. return Ok(JsonView(true, "保存成功!"));
  248. }
  249. return Ok(JsonView(false, "保存失败!"));
  250. }
  251. /// <summary>
  252. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  253. /// </summary>
  254. /// <param name="dto"></param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  259. {
  260. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  261. _detail.IsDel = 1;
  262. _detail.DeleteUserId = dto.Duty;
  263. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  264. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  265. .SetColumns(it => it.IsDel == _detail.IsDel)
  266. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  267. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  268. .Where(it => it.Id == dto.Id)
  269. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  270. //.WhereColumns(s => s.Id == dto.Id)
  271. .ExecuteCommandAsync();
  272. if (result > 0)
  273. {
  274. return Ok(JsonView(true, "删除成功!"));
  275. }
  276. return Ok(JsonView(false, "删除失败!"));
  277. }
  278. /// <summary>
  279. /// 增加团组流程管控详细表数据
  280. /// </summary>
  281. /// <param name="dto"></param>
  282. /// <returns></returns>
  283. [HttpPost]
  284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  285. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  286. {
  287. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  288. if (DateTime.Now < _detail.ExpectBeginDt)
  289. {
  290. _detail.StepStatus = 0;
  291. }
  292. else
  293. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  294. _detail.StepStatus = 1;
  295. }
  296. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  297. if (result > 0)
  298. {
  299. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  300. return Ok(JsonView(true, "添加成功!", _result));
  301. }
  302. return Ok(JsonView(false, "添加失败!"));
  303. }
  304. #endregion
  305. #region 团组基本信息
  306. /// <summary>
  307. /// 接团信息列表
  308. /// </summary>
  309. /// <param name="dto">团组列表请求dto</param>
  310. /// <returns></returns>
  311. [HttpPost]
  312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  313. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  314. {
  315. var groupData = await _groupRepository.GetGroupList(dto);
  316. if (groupData.Code != 0)
  317. {
  318. return Ok(JsonView(false, groupData.Msg));
  319. }
  320. return Ok(JsonView(groupData.Data));
  321. }
  322. /// <summary>
  323. /// 分页查询团组列表
  324. /// </summary>
  325. /// <param name="dto"></param>
  326. /// <returns></returns>
  327. [HttpPost]
  328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  329. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  330. {
  331. var watch = new Stopwatch();
  332. watch.Start();
  333. RefAsync<int> total = 0;
  334. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  335. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  336. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  337. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  338. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  339. .Distinct()
  340. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  341. watch.Stop();
  342. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  343. }
  344. /// <summary>
  345. /// 接团信息列表 Page
  346. /// </summary>
  347. /// <param name="dto">团组列表请求dto</param>
  348. /// <returns></returns>
  349. [HttpPost]
  350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  351. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  352. {
  353. #region 参数验证
  354. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  355. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  356. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  357. #region 页面操作权限验证
  358. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  359. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  360. #endregion
  361. #endregion
  362. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  363. {
  364. string sqlWhere = string.Empty;
  365. if (dto.IsSure == 0) //未完成
  366. {
  367. sqlWhere += string.Format(@" And IsSure = 0");
  368. }
  369. else if (dto.IsSure == 1) //已完成
  370. {
  371. sqlWhere += string.Format(@" And IsSure = 1");
  372. }
  373. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  374. {
  375. string tj = dto.SearchCriteria;
  376. 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}%')",
  377. tj, tj, tj, tj, tj);
  378. }
  379. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  380. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  381. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  382. JietuanOperator,IsSure,CreateTime,IsBid
  383. From (
  384. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  385. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  386. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  387. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  388. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  389. From Grp_DelegationInfo gdi
  390. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  391. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  392. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  393. Where gdi.IsDel = 0 {0}
  394. ) temp", sqlWhere);
  395. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  396. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  397. #region 处理所属部门
  398. /*
  399. * 1.sq 和 gyy 等显示 市场部
  400. * 2.王鸽和主管及张总还有管理员号统一国交部
  401. * 2-1. 4 管理员 ,21 张海麟
  402. */
  403. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  404. List<int> userIds1 = new List<int>() { 4, 21 };
  405. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  406. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  407. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  408. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  409. .ToList();
  410. foreach (var item in _DelegationList)
  411. {
  412. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  413. }
  414. #endregion
  415. var _view = new
  416. {
  417. PageFuncAuth = pageFunAuthView,
  418. Data = _DelegationList
  419. };
  420. return Ok(JsonView(true, "查询成功!", _view, total));
  421. }
  422. else
  423. {
  424. return Ok(JsonView(false, "查询失败"));
  425. }
  426. }
  427. /// <summary>
  428. /// 团组列表
  429. /// </summary>
  430. /// <returns></returns>
  431. [HttpPost]
  432. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  433. {
  434. #region 参数验证
  435. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  436. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  437. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  438. #region 页面操作权限验证
  439. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  440. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  441. #endregion
  442. #endregion
  443. if (dto.PortType != 1 && dto.PortType != 2)
  444. {
  445. return Ok(JsonView(false, "查询失败!"));
  446. }
  447. string orderbyStr = "order by gdi.CreateTime Desc";
  448. string sqlWhere = string.Empty;
  449. if (dto.IsSure == 0) //未完成
  450. {
  451. sqlWhere += string.Format(@" And IsSure = 0");
  452. }
  453. else if (dto.IsSure == 1) //已完成
  454. {
  455. sqlWhere += string.Format(@" And IsSure = 1");
  456. }
  457. //团组类型
  458. if (dto.TeamDid > 0)
  459. {
  460. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  461. }
  462. //团组名称
  463. if (!string.IsNullOrEmpty(dto.TeamName))
  464. {
  465. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  466. }
  467. //客户名称
  468. if (!string.IsNullOrEmpty(dto.ClientName))
  469. {
  470. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  471. }
  472. //客户单位
  473. if (!string.IsNullOrEmpty(dto.ClientUnit))
  474. {
  475. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  476. }
  477. //出访时间
  478. if (!string.IsNullOrEmpty(dto.visitDataTime))
  479. {
  480. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  481. orderbyStr = "order by gdi.VisitDate";
  482. }
  483. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  484. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  485. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  486. JietuanOperator,IsSure,CreateTime
  487. From (
  488. Select row_number() over({0}) as Row_Number,
  489. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  490. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  491. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  492. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  493. From Grp_DelegationInfo gdi
  494. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  495. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  496. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  497. Where gdi.IsDel = 0 {1}
  498. ) temp ", orderbyStr, sqlWhere);
  499. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  500. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  501. #region 处理所属部门
  502. /*
  503. * 1.sq 和 gyy 等显示 市场部
  504. * 2.王鸽和主管及张总还有管理员号统一国交部
  505. * 2-1. 4 管理员 ,21 张海麟
  506. */
  507. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  508. List<int> userIds1 = new List<int>() { 4, 21 };
  509. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  510. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  511. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  512. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  513. .ToList();
  514. foreach (var item in _DelegationList)
  515. {
  516. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  517. }
  518. #endregion
  519. var _view = new
  520. {
  521. PageFuncAuth = pageFunAuthView,
  522. Data = _DelegationList
  523. };
  524. return Ok(JsonView(true, "查询成功!", _view, total));
  525. }
  526. /// <summary>
  527. /// 接团信息详情
  528. /// </summary>
  529. /// <param name="dto">团组info请求dto</param>
  530. /// <returns></returns>
  531. [HttpPost]
  532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  533. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  534. {
  535. var groupData = await _groupRepository.GetGroupInfo(dto);
  536. if (groupData.Code != 0)
  537. {
  538. return Ok(JsonView(false, groupData.Msg));
  539. }
  540. return Ok(JsonView(groupData.Data));
  541. }
  542. /// <summary>
  543. /// 接团信息 编辑添加
  544. /// 基础信息数据源
  545. /// </summary>
  546. /// <param name="dto"></param>
  547. /// <returns></returns>
  548. [HttpPost]
  549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  550. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  551. {
  552. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  553. if (groupData.Code != 0)
  554. {
  555. return Ok(JsonView(false, groupData.Msg));
  556. }
  557. return Ok(JsonView(groupData.Data));
  558. }
  559. /// <summary>
  560. /// 接团信息 操作(增改)
  561. /// </summary>
  562. /// <param name="dto"></param>
  563. /// <returns></returns>
  564. [HttpPost]
  565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  566. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  567. {
  568. try
  569. {
  570. decimal ffrPrice = 0.00M;
  571. DateTime? visitDt = null;
  572. if (dto.Status == 2)
  573. {
  574. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  575. if (groupInfo != null)
  576. {
  577. ffrPrice = groupInfo.PaymentMoney;
  578. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  579. }
  580. }
  581. var groupData = await _groupRepository.GroupOperation(dto);
  582. if (groupData.Code != 0)
  583. {
  584. return Ok(JsonView(false, groupData.Msg));
  585. }
  586. int diId = 0;
  587. //添加时 默认加入团组汇率
  588. if (dto.Status == 1) //添加
  589. {
  590. diId = groupData.Data;
  591. //添加默认币种
  592. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  593. //默认分配权限
  594. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  595. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  596. var _managerIds = new List<int>() { 22, 32, 21 };
  597. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  598. if (userIds.Count > 0)
  599. {
  600. userIds.Add(208);
  601. //创建团组管控
  602. GroupStepForDelegation.CreateWorkStep(diId);
  603. //发送消息
  604. string groupName = dto.TeamName;
  605. string createGroupUser = string.Empty;
  606. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  607. if (userInfo != null) createGroupUser = userInfo.CnName;
  608. string title = $"系统通知";
  609. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  610. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  611. }
  612. //默认创建倒推表
  613. await _invertedListRep._Create(dto.UserId, diId);
  614. }
  615. else if (dto.Status == 2)
  616. {
  617. diId = dto.Id;
  618. }
  619. #region 签证人员团组时间通知
  620. #region 计算出访起止时间
  621. var startTime = new DateTime();
  622. var endTime = new DateTime();
  623. if (DateTime.TryParse(dto.VisitDate, out startTime))
  624. {
  625. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  626. }
  627. #endregion
  628. if (diId > 0)
  629. {
  630. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  631. }
  632. #endregion
  633. #region 团组操作默认添加/修改收款账单
  634. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  635. {
  636. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  637. .Where(x => x.IsDel == 0 &&
  638. x.Diid == diId &&
  639. x.Remark.Equals("预付款")
  640. )
  641. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  642. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  643. .FirstAsync();
  644. ffrInfo = new Fin_ForeignReceivables()
  645. {
  646. Diid = diId,
  647. PriceName = dto.ClientUnit,
  648. Price = dto.PaymentMoney,
  649. Count = 1,
  650. Unit = $"元",
  651. ItemSumPrice = dto.PaymentMoney,
  652. Rate = 1.0000M,
  653. Currency = 836,
  654. AddingWay = 0,
  655. CreateUserId = dto.UserId,
  656. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  657. Remark = $"预付款"
  658. };
  659. if (ffrInfo == null) //Add
  660. {
  661. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  662. }
  663. else //修改
  664. {
  665. await _sqlSugar.Updateable(ffrInfo)
  666. .UpdateColumns(x => new
  667. {
  668. x.PriceName,
  669. x.Price,
  670. x.ItemSumPrice,
  671. x.CreateTime,
  672. x.CreateUserId
  673. })
  674. .WhereColumns(x => x.Id)
  675. .ExecuteCommandAsync();
  676. }
  677. }
  678. #endregion
  679. return Ok(JsonView(true, "操作成功!", diId));
  680. }
  681. catch (Exception ex)
  682. {
  683. Logs("[response]" + JsonConvert.SerializeObject(dto));
  684. Logs(ex.Message);
  685. return Ok(JsonView(false, ex.Message));
  686. }
  687. }
  688. /// <summary>
  689. /// 接团流程操作(增改)
  690. /// 安卓端使用 建团时添加客户名单
  691. /// </summary>
  692. /// <param name="dto"></param>
  693. /// <returns></returns>
  694. [HttpPost]
  695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  696. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  697. {
  698. try
  699. {
  700. #region 参数验证
  701. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  702. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  703. #region 页面操作权限验证
  704. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  705. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  706. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  707. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  708. #endregion
  709. #endregion
  710. _sqlSugar.BeginTran();
  711. decimal ffrPrice = 0.00M;
  712. DateTime? visitDt = null;
  713. if (dto.Status == 2)
  714. {
  715. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  716. if (groupInfo != null)
  717. {
  718. ffrPrice = groupInfo.PaymentMoney;
  719. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  720. }
  721. }
  722. var _dto = new GroupOperationDto();
  723. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  724. var groupData = await _groupRepository.GroupOperation(_dto);
  725. if (groupData.Code != 0)
  726. {
  727. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  728. }
  729. int diId = 0;
  730. //添加时 默认加入团组汇率
  731. if (dto.Status == 1) //添加
  732. {
  733. diId = groupData.Data;
  734. //添加默认币种
  735. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  736. //默认分配权限
  737. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  738. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  739. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  740. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  741. if (userIds.Count > 0)
  742. {
  743. userIds.Add(208);
  744. //创建团组管控
  745. GroupStepForDelegation.CreateWorkStep(diId);
  746. //发送消息
  747. string groupName = dto.TeamName;
  748. string createGroupUser = string.Empty;
  749. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  750. if (userInfo != null) createGroupUser = userInfo.CnName;
  751. string title = $"系统通知";
  752. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  753. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  754. }
  755. #region 应用推送
  756. try
  757. {
  758. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  759. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  760. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  761. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  762. {
  763. List<string> userList = new List<string>() { users.QiyeChatUserId };
  764. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  765. }
  766. }
  767. catch (Exception ex)
  768. {
  769. }
  770. #endregion
  771. //默认创建倒推表
  772. await _invertedListRep._Create(dto.UserId, diId);
  773. }
  774. if (dto.Status == 2)
  775. {
  776. diId = dto.Id;
  777. if (diId == 0)
  778. {
  779. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  780. }
  781. }
  782. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  783. if (viewData.Code != 0)
  784. {
  785. _sqlSugar.RollbackTran();
  786. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  787. }
  788. #region 团组操作默认添加/修改收款账单
  789. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  790. {
  791. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  792. .Where(x => x.IsDel == 0 &&
  793. x.Diid == diId &&
  794. x.Remark.Equals("预付款")
  795. )
  796. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  797. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  798. .FirstAsync();
  799. ffrInfo = new Fin_ForeignReceivables()
  800. {
  801. Diid = diId,
  802. PriceName = dto.ClientUnit,
  803. Price = dto.PaymentMoney,
  804. Count = 1,
  805. Unit = $"元",
  806. ItemSumPrice = dto.PaymentMoney,
  807. Rate = 1.0000M,
  808. Currency = 836,
  809. AddingWay = 0,
  810. CreateUserId = dto.UserId,
  811. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  812. Remark = $"预付款"
  813. };
  814. if (ffrInfo == null) //Add
  815. {
  816. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  817. }
  818. else //修改
  819. {
  820. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  821. .UpdateColumns(x => new
  822. {
  823. x.PriceName,
  824. x.Price,
  825. x.ItemSumPrice,
  826. x.CreateTime,
  827. x.CreateUserId
  828. })
  829. .WhereColumns(x => x.Id)
  830. .ExecuteCommandAsync();
  831. }
  832. }
  833. #endregion
  834. #region 签证人员团组时间通知
  835. #region 计算出访起止时间
  836. var startTime = new DateTime();
  837. var endTime = new DateTime();
  838. if (DateTime.TryParse(dto.VisitDate, out startTime))
  839. {
  840. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  841. }
  842. #endregion
  843. if (diId > 0)
  844. {
  845. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  846. }
  847. #endregion
  848. _sqlSugar.CommitTran();
  849. return Ok(JsonView(true, "添加成功"));
  850. }
  851. catch (Exception ex)
  852. {
  853. _sqlSugar.RollbackTran();
  854. return Ok(JsonView(false, ex.Message));
  855. }
  856. }
  857. /// <summary>
  858. /// 接团信息 操作(删除)
  859. /// </summary>
  860. /// <param name="dto"></param>
  861. /// <returns></returns>
  862. [HttpPost]
  863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  864. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  865. {
  866. try
  867. {
  868. var groupData = await _groupRepository.GroupDel(dto);
  869. if (groupData.Code != 0)
  870. {
  871. return Ok(JsonView(false, groupData.Msg));
  872. }
  873. return Ok(JsonView(true));
  874. }
  875. catch (Exception ex)
  876. {
  877. Logs("[response]" + JsonConvert.SerializeObject(dto));
  878. Logs(ex.Message);
  879. return Ok(JsonView(false, ex.Message));
  880. }
  881. }
  882. /// <summary>
  883. /// 获取团组销售报价号
  884. /// 团组添加时 使用
  885. /// </summary>
  886. /// <returns></returns>
  887. [HttpPost]
  888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  889. public async Task<IActionResult> GetGroupSalesQuoteNo()
  890. {
  891. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  892. if (groupData.Code != 0)
  893. {
  894. return Ok(JsonView(false, groupData.Msg));
  895. }
  896. object salesQuoteNo = new
  897. {
  898. SalesQuoteNo = groupData.Data
  899. };
  900. return Ok(JsonView(salesQuoteNo));
  901. }
  902. /// <summary>
  903. /// 设置确认出团
  904. /// </summary>
  905. /// <param name="dto"></param>
  906. /// <returns></returns>
  907. [HttpPost]
  908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  909. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  910. {
  911. var groupData = await _groupRepository.ConfirmationGroup(dto);
  912. if (groupData.Code != 0)
  913. {
  914. return Ok(JsonView(false, groupData.Msg));
  915. }
  916. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  917. #region OA消息推送
  918. try
  919. {
  920. string groupName = groupInfo.TeamName;
  921. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  922. List<int> userIds = new List<int>();
  923. listUser.ForEach(s => userIds.Add(s.Id));
  924. string title = $"系统通知";
  925. string content = $"团组[{groupName}]已确认出团!";
  926. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  927. }
  928. catch (Exception ex)
  929. {
  930. }
  931. #endregion
  932. #region 应用推送
  933. try
  934. {
  935. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  936. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  937. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  938. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  939. {
  940. List<string> userList = new List<string>() { users.QiyeChatUserId };
  941. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  942. }
  943. }
  944. catch (Exception ex)
  945. {
  946. }
  947. #endregion
  948. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  949. return Ok(JsonView(true, "操作成功!", groupData.Data));
  950. }
  951. /// <summary>
  952. /// 获取团组名称data And 签证国别Data
  953. /// </summary>
  954. /// <param name="dto"></param>
  955. /// <returns></returns>
  956. [HttpPost]
  957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  958. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  959. {
  960. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  961. if (groupData.Code != 0)
  962. {
  963. return Ok(JsonView(false, groupData.Msg));
  964. }
  965. return Ok(JsonView(groupData.Data));
  966. }
  967. /// <summary>
  968. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  969. /// </summary>
  970. /// <returns></returns>
  971. [HttpPost]
  972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  973. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  974. {
  975. try
  976. {
  977. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  978. if (groupData.Code != 0)
  979. {
  980. return Ok(JsonView(false, groupData.Msg));
  981. }
  982. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  983. }
  984. catch (Exception ex)
  985. {
  986. return Ok(JsonView(false, "程序错误!"));
  987. throw;
  988. }
  989. }
  990. /// <summary>
  991. /// 团组清单 Excel
  992. /// </summary>
  993. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  994. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  995. /// <returns></returns>
  996. [HttpGet]
  997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  998. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  999. {
  1000. DateTime _beginDt, _endDt;
  1001. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1002. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1003. if (!beginBool && !endBool)
  1004. {
  1005. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1006. }
  1007. string sql = string.Format(@"
  1008. SELECT
  1009. ROW_NUMBER,
  1010. Id,
  1011. SalesQuoteNo,
  1012. TourCode,
  1013. TeamTypeId,
  1014. TeamType,
  1015. TeamLevId,
  1016. TeamLev,
  1017. TeamName,
  1018. ClientName,
  1019. ClientUnit,
  1020. VisitDate,
  1021. VisitDays,
  1022. VisitPNumber,
  1023. JietuanOperatorId,
  1024. JietuanOperator,
  1025. IsSure,
  1026. CreateTime,
  1027. IsBid
  1028. FROM
  1029. (
  1030. SELECT
  1031. ROW_NUMBER() OVER(
  1032. ORDER BY
  1033. gdi.CreateTime Desc
  1034. ) AS ROW_NUMBER,
  1035. gdi.Id,
  1036. SalesQuoteNo,
  1037. TourCode,
  1038. ssd.Id TeamTypeId,
  1039. ssd.Name TeamType,
  1040. ssd1.Id TeamLevId,
  1041. ssd1.Name TeamLev,
  1042. TeamName,
  1043. ClientName,
  1044. ClientUnit,
  1045. VisitDate,
  1046. VisitDays,
  1047. VisitPNumber,
  1048. JietuanOperator JietuanOperatorId,
  1049. su.CnName JietuanOperator,
  1050. IsSure,
  1051. gdi.CreateTime,
  1052. gdi.IsBid
  1053. FROM
  1054. Grp_DelegationInfo gdi
  1055. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1056. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1057. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1058. WHERE
  1059. gdi.IsDel = 0
  1060. AND gdi.IsBid = 0
  1061. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1062. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1063. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1064. #region 处理所属部门
  1065. /*
  1066. * 1.sq 和 gyy 等显示 市场部
  1067. * 2.王鸽和主管及张总还有管理员号统一国交部
  1068. * 2-1. 4 管理员 ,21 张海麟
  1069. */
  1070. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1071. List<int> userIds1 = new List<int>() { 4, 21 };
  1072. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1073. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1074. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1075. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1076. .ToListAsync();
  1077. foreach (var item in groupList)
  1078. {
  1079. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1080. }
  1081. #endregion
  1082. #region Excel
  1083. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1084. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1085. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1086. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1087. var fileName = $"团组清单({beginDt}{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1088. //载入模板
  1089. WorkbookDesigner designer = new WorkbookDesigner();
  1090. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1091. designer.SetDataSource("Titel", $"团组清单({beginDt}{endDt})");
  1092. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1093. dt.TableName = "GroupList";
  1094. designer.SetDataSource(dt);
  1095. designer.Process();
  1096. if (!Directory.Exists(savePath))
  1097. {
  1098. Directory.CreateDirectory(savePath);
  1099. }
  1100. string serverPath = $"{savePath}{fileName}";
  1101. designer.Workbook.Save(serverPath);
  1102. string rst = $"{servicePath}{ftpPath}{fileName}";
  1103. #endregion
  1104. return Ok(JsonView(true, "操作成功!", rst));
  1105. }
  1106. #endregion
  1107. #region 团组&签证
  1108. /// <summary>
  1109. /// 根据团组Id获取签证客户信息List
  1110. /// </summary>
  1111. /// <param name="dto">请求dto</param>
  1112. /// <returns></returns>
  1113. [HttpPost]
  1114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1115. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1116. {
  1117. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1118. if (groupData.Code != 0)
  1119. {
  1120. return Ok(JsonView(false, groupData.Msg));
  1121. }
  1122. return Ok(JsonView(groupData.Data));
  1123. }
  1124. /// <summary>
  1125. /// IOS获取团组签证拍照上传进度01(团组列表)
  1126. /// </summary>
  1127. /// <param name="dto">请求dto</param>
  1128. /// <returns></returns>
  1129. [HttpPost]
  1130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1131. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1132. {
  1133. if (dto == null)
  1134. {
  1135. return Ok(JsonView(false, "参数为空"));
  1136. }
  1137. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1138. return Ok(JsonView(visaList));
  1139. }
  1140. /// <summary>
  1141. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1142. /// </summary>
  1143. /// <returns></returns>
  1144. [HttpPost]
  1145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1146. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1147. {
  1148. if (dto == null)
  1149. {
  1150. return Ok(JsonView(false, "请求错误:"));
  1151. }
  1152. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1153. return Ok(JsonView(list));
  1154. }
  1155. /// <summary>
  1156. /// IOS获取团组签证拍照上传进度03(相册)
  1157. /// </summary>
  1158. /// <returns></returns>
  1159. [HttpPost]
  1160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1161. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1162. {
  1163. if (dto == null)
  1164. {
  1165. return Ok(JsonView(false, "请求错误:"));
  1166. }
  1167. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1168. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1169. list.ForEach(s => s.url = url);
  1170. return Ok(JsonView(list));
  1171. }
  1172. /// <summary>
  1173. /// IOS获取团组签证拍照上传进度04(图片上传)
  1174. /// </summary>
  1175. /// <param name="dto"></param>
  1176. /// <returns></returns>
  1177. [HttpPost]
  1178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1179. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1180. {
  1181. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1182. //if (!string.IsNullOrEmpty(result))
  1183. //{
  1184. //}
  1185. //else {
  1186. // return Ok(JsonView(false, "上传失败"));
  1187. //}
  1188. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1189. int sucNum = 0;
  1190. try
  1191. {
  1192. foreach (var item in dto.base64DataList)
  1193. {
  1194. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1195. string result = decodeBase64ToImage(item, imageName);
  1196. if (!string.IsNullOrEmpty(result))
  1197. {
  1198. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1199. pic.CreateUserId = dto.CreateUserId;
  1200. pic.PicName = imageName;
  1201. pic.PicPath = result;
  1202. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1203. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1204. if (insertResult > 0)
  1205. {
  1206. sucNum++;
  1207. }
  1208. }
  1209. }
  1210. }
  1211. catch (Exception ex)
  1212. {
  1213. return Ok(JsonView(false, ex.Message));
  1214. }
  1215. string msg = string.Format(@"成功上传{0}张", sucNum);
  1216. return Ok(JsonView(true, msg));
  1217. }
  1218. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1219. {
  1220. string filename = "";//声明一个string类型的相对路径
  1221. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1222. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1223. try//会有异常抛出,try,catch一下
  1224. {
  1225. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1226. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1227. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1228. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1229. //文件名称
  1230. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1231. //上传的文件的路径
  1232. string filePath = "";
  1233. if (!Directory.Exists(fileDir))
  1234. {
  1235. Directory.CreateDirectory(fileDir);
  1236. }
  1237. //上传的文件的路径
  1238. filePath = fileDir + filename;
  1239. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1240. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1241. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1242. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1243. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1244. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1245. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1246. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1247. bitmap.Dispose();
  1248. }
  1249. catch (Exception e)
  1250. {
  1251. string massage = e.Message;
  1252. Logs("IOS图片上传Error:" + massage);
  1253. //filename = e.Message;
  1254. }
  1255. return filename;//返回相对路径
  1256. }
  1257. /// <summary>
  1258. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1259. /// </summary>
  1260. /// <param name="dto"></param>
  1261. /// <returns></returns>
  1262. [HttpPost]
  1263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1264. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1265. {
  1266. if (dto == null)
  1267. {
  1268. return Ok(JsonView(false, "请求错误:"));
  1269. }
  1270. string msg = "参数错误";
  1271. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1272. {
  1273. try
  1274. {
  1275. //_delegationVisaRep.BeginTran();
  1276. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1277. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1278. .Where(s => s.Id == dto.visaProgressCustomerId)
  1279. .ExecuteCommandAsync();
  1280. if (updCount > 0 && dto.publishCode == 1)
  1281. {
  1282. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1283. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1284. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1285. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1286. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1287. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1288. if (groupData == null)
  1289. {
  1290. _delegationVisaRep.RollbackTran();
  1291. }
  1292. string title = string.Format(@"[签证进度更新]");
  1293. string content = string.Format(@"测试文本");
  1294. bool rst = await _message.AddMsg(new MessageDto()
  1295. {
  1296. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1297. IssuerId = dto.publisher,
  1298. Title = title,
  1299. Content = content,
  1300. ReleaseTime = DateTime.Now,
  1301. UIdList = new List<int> {
  1302. 234
  1303. }
  1304. });
  1305. if (rst)
  1306. {
  1307. return Ok(JsonView(true, "发送通知成功"));
  1308. }
  1309. }
  1310. //_delegationVisaRep.CommitTran();
  1311. }
  1312. catch (Exception)
  1313. {
  1314. //_delegationVisaRep.RollbackTran();
  1315. }
  1316. }
  1317. return Ok(JsonView(true, msg));
  1318. }
  1319. #endregion
  1320. #region 团组任务分配
  1321. /// <summary>
  1322. /// 团组任务分配初始化
  1323. /// </summary>
  1324. /// <param name="dto"></param>
  1325. /// <returns></returns>
  1326. [HttpPost]
  1327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1328. public async Task<IActionResult> GetTaskAssignmen()
  1329. {
  1330. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1331. if (groupData.Code != 0)
  1332. {
  1333. return Ok(JsonView(false, groupData.Msg));
  1334. }
  1335. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1336. }
  1337. /// <summary>
  1338. /// 团组任务分配查询
  1339. /// </summary>
  1340. /// <param name="dto"></param>
  1341. /// <returns></returns>
  1342. [HttpPost]
  1343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1344. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1345. {
  1346. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1347. if (groupData.Code != 0)
  1348. {
  1349. return Ok(JsonView(false, groupData.Msg));
  1350. }
  1351. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1352. }
  1353. /// <summary>
  1354. /// 团组任务分配操作
  1355. /// </summary>
  1356. /// <param name="dto"></param>
  1357. /// <returns></returns>
  1358. [HttpPost]
  1359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1360. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1361. {
  1362. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1363. if (groupData.Code != 0)
  1364. {
  1365. return Ok(JsonView(false, groupData.Msg));
  1366. }
  1367. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1368. }
  1369. /// <summary>
  1370. /// 团组任务分配
  1371. /// 批量分配
  1372. /// 查询团组
  1373. /// </summary>
  1374. /// <param name="dto"></param>
  1375. /// <returns></returns>
  1376. [HttpPost]
  1377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1378. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1379. {
  1380. //参数验证
  1381. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1382. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1383. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1384. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1385. }
  1386. /// <summary>
  1387. /// 团组任务分配
  1388. /// 批量分配
  1389. /// </summary>
  1390. /// <param name="dto"></param>
  1391. /// <returns></returns>
  1392. [HttpPost]
  1393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1394. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1395. {
  1396. //参数验证
  1397. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1398. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1399. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1400. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1401. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1402. }
  1403. #endregion
  1404. #region 团组费用审核
  1405. /// <summary>
  1406. /// 费用审核
  1407. /// 团组列表 Page
  1408. /// </summary>
  1409. /// <param name="_dto">团组列表请求dto</param>
  1410. /// <returns></returns>
  1411. [HttpPost]
  1412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1413. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1414. {
  1415. #region 参数验证
  1416. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1417. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1418. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1419. #region 页面操作权限验证
  1420. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1421. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1422. #endregion
  1423. #endregion
  1424. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1425. {
  1426. string sqlWhere = string.Empty;
  1427. if (_dto.IsSure == 0) //未完成
  1428. {
  1429. sqlWhere += string.Format(@" And IsSure = 0");
  1430. }
  1431. else if (_dto.IsSure == 1) //已完成
  1432. {
  1433. sqlWhere += string.Format(@" And IsSure = 1");
  1434. }
  1435. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1436. {
  1437. string tj = _dto.SearchCriteria;
  1438. 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}%')",
  1439. tj, tj, tj, tj, tj);
  1440. }
  1441. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1442. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1443. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1444. From (
  1445. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1446. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1447. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1448. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1449. From Grp_DelegationInfo gdi
  1450. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1451. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1452. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1453. Where gdi.IsDel = 0 {0}
  1454. ) temp ", sqlWhere);
  1455. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1456. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1457. var _view = new
  1458. {
  1459. PageFuncAuth = pageFunAuthView,
  1460. Data = _DelegationList
  1461. };
  1462. return Ok(JsonView(true, "查询成功!", _view, total));
  1463. }
  1464. else
  1465. {
  1466. return Ok(JsonView(false, "查询失败"));
  1467. }
  1468. }
  1469. /// <summary>
  1470. /// 获取团组费用审核
  1471. /// </summary>
  1472. /// <param name="paras">参数Json字符串</param>
  1473. /// <returns></returns>
  1474. [HttpPost]
  1475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1476. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1477. {
  1478. try
  1479. {
  1480. #region 参数验证
  1481. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1482. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1483. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1484. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1485. #region 页面操作权限验证
  1486. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1487. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1488. #endregion
  1489. #endregion
  1490. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1491. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1492. #region 费用清单
  1493. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1494. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1495. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1496. List<Grp_CreditCardPayment> entityList = _groupRepository
  1497. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1498. .Where(exp.ToExpression())
  1499. .ToList();
  1500. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1501. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1502. /*
  1503. * 76://酒店预订
  1504. */
  1505. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1506. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1507. .ToListAsync();
  1508. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1509. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1510. .ToListAsync();
  1511. /*
  1512. * 79://车/导游地接
  1513. */
  1514. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1515. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1516. .ToListAsync();
  1517. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1518. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1519. .ToListAsync();
  1520. /*
  1521. * 80: //签证
  1522. */
  1523. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1524. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1525. .ToListAsync();
  1526. /*
  1527. *81: //邀请/公务活动
  1528. */
  1529. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1530. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1531. .ToListAsync();
  1532. /*
  1533. * 82: //团组客户保险
  1534. */
  1535. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1536. /*
  1537. * Lable = 85 机票预订
  1538. */
  1539. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1540. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1541. .ToListAsync();
  1542. /*
  1543. * 85 机票预定
  1544. */
  1545. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1546. /*
  1547. * 98 其他款项
  1548. */
  1549. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1550. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1551. .ToListAsync();
  1552. /*
  1553. * 285:收款退还
  1554. */
  1555. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1556. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1557. .ToListAsync();
  1558. /*
  1559. * 1015: //超支费用
  1560. */
  1561. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1562. /*
  1563. * 币种信息
  1564. */
  1565. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1566. /*
  1567. * 车/导游地接 费用类型
  1568. */
  1569. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1570. /*
  1571. * 车/导游地接 费用类型
  1572. */
  1573. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1574. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1575. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1576. /*
  1577. * 用户信息
  1578. */
  1579. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1580. /*
  1581. * 费用模块
  1582. */
  1583. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1584. string priceModule = string.Empty;
  1585. if (sdPriceName != null)
  1586. {
  1587. priceModule = sdPriceName.Name;
  1588. }
  1589. /*
  1590. * 成本信息
  1591. */
  1592. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1593. decimal _groupRate = 0.0000M;
  1594. string _groupCurrencyCode = "-";
  1595. if (groupCost != null)
  1596. {
  1597. _groupRate = groupCost.Rate;
  1598. if (int.TryParse(groupCost.Currency, out int _currency))
  1599. {
  1600. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1601. }
  1602. else _groupCurrencyCode = groupCost.Currency;
  1603. }
  1604. string costContentSql = $"Select * From Grp_GroupCost";
  1605. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1606. //处理日期为空的天数
  1607. for (int i = 0; i < groupCostDetails.Count; i++)
  1608. if (i != 0)
  1609. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1610. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1611. /*
  1612. * 处理详情数据
  1613. */
  1614. foreach (var entity in entityList)
  1615. {
  1616. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1617. _detail.Id = entity.Id;
  1618. _detail.PriceName = priceModule;
  1619. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1620. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1621. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1622. //处理金额
  1623. if (entity.CTable == 1015)
  1624. {
  1625. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1626. if (czInfo != null)
  1627. {
  1628. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1629. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1630. }
  1631. }
  1632. /*
  1633. * 应付款金额
  1634. */
  1635. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1636. string PaymentCurrency_WaitPay = "Unknown";
  1637. string hotelCurrncyCode = "Unknown";
  1638. string hotelCurrncyName = "Unknown";
  1639. if (sdPaymentCurrency_WaitPay != null)
  1640. {
  1641. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1642. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1643. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1644. if (hotelCurrncyCode.Equals("CNY"))
  1645. {
  1646. entity.DayRate = 1.0000M;
  1647. }
  1648. }
  1649. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1650. /*
  1651. * 此次付款金额
  1652. */
  1653. decimal CurrPayStr = 0.00M,
  1654. OriginalCurrPay = 0.00M;
  1655. if (entity.PayPercentage == 0)
  1656. {
  1657. if (entity.PayThenMoney != 0)
  1658. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1659. }
  1660. else
  1661. {
  1662. if (entity.PayMoney != 0)
  1663. {
  1664. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1665. }
  1666. }
  1667. if (_dto.Label == 79)
  1668. {
  1669. string original = string.Empty;
  1670. if (hotelCurrncyCode.Equals("CNY"))
  1671. {
  1672. OriginalCurrPay = CurrPayStr;
  1673. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1674. }
  1675. else
  1676. {
  1677. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1678. //760 EUR(7600.00 CNY)
  1679. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1680. }
  1681. }
  1682. else
  1683. {
  1684. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1685. }
  1686. /*
  1687. * 剩余尾款
  1688. */
  1689. decimal BalanceStr = 0;
  1690. if (CurrPayStr != 0)
  1691. {
  1692. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1693. BalanceStr = 0;
  1694. else
  1695. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1696. }
  1697. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1698. /*
  1699. * Bus名称
  1700. */
  1701. _detail.BusName = "待增加";
  1702. /*
  1703. *费用所属
  1704. */
  1705. switch (entity.CTable)
  1706. {
  1707. case 76://酒店预订
  1708. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1709. if (hotelReservations != null)
  1710. {
  1711. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1712. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1713. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1714. string roomFeeStr = "", roomFeestr1 = "";
  1715. //是否比较房型价格
  1716. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1717. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1718. roomFeeStr += $"<br/>";
  1719. if (hotelReservations.SingleRoomPrice > 0)
  1720. {
  1721. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1722. __isSingle = true;
  1723. }
  1724. if (hotelReservations.DoubleRoomPrice > 0)
  1725. {
  1726. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1727. __isDouble = true;
  1728. }
  1729. if (hotelReservations.SuiteRoomPrice > 0)
  1730. {
  1731. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1732. __isSuite = true;
  1733. }
  1734. if (hotelReservations.OtherRoomPrice > 0)
  1735. {
  1736. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1737. __isOther = true;
  1738. }
  1739. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1740. else roomFeeStr += " 0.00 * 0";
  1741. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1742. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1743. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1744. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1745. /*
  1746. * 费用类型
  1747. * 1:房费
  1748. * 2:早餐
  1749. * 3:地税
  1750. * 4:城市税
  1751. * </summary>
  1752. */
  1753. //地税
  1754. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1755. if (governmentRentData != null)
  1756. {
  1757. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1758. governmentRentFee = governmentRentData.Price;
  1759. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1760. if (governmentRentCurrData != null)
  1761. {
  1762. governmentRentCode = governmentRentCurrData.Name;
  1763. governmentRentName = $"({governmentRentCurrData.Remark})";
  1764. }
  1765. }
  1766. //城市税
  1767. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1768. if (cityTaxData != null)
  1769. {
  1770. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1771. cityTaxFee = cityTaxData.Price;
  1772. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1773. if (cityTaxCurrData != null)
  1774. {
  1775. cityTaxCode = cityTaxCurrData.Name;
  1776. cityTaxName = $"({cityTaxCurrData.Remark})";
  1777. }
  1778. }
  1779. //酒店早餐
  1780. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1781. if (breakfastData != null)
  1782. {
  1783. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1784. breakfastFee = breakfastData.Price;
  1785. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1786. if (breakfastCurrData != null)
  1787. {
  1788. breakfastCode = breakfastCurrData.Name;
  1789. breakfastName = $"({breakfastCurrData.Remark})";
  1790. }
  1791. }
  1792. //房间费用
  1793. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1794. if (roomData != null)
  1795. {
  1796. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1797. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1798. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1799. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1800. roomFee = roomData.Price;
  1801. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1802. if (roomCurrData != null)
  1803. {
  1804. roomCode = roomCurrData.Name;
  1805. roomName = $"({roomCurrData.Remark})";
  1806. }
  1807. }
  1808. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1809. string hotelCostStr = "";
  1810. decimal hotelCsotTotal = 0.00M;
  1811. if (groupCost != null)
  1812. {
  1813. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1814. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1815. }
  1816. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1817. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1818. string hotelCost_day = "";
  1819. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1820. foreach (var item in hotelCostDetails1)
  1821. {
  1822. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1823. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1824. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1825. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1826. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1827. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1828. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1829. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1830. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1831. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1832. hotelCost_day += @$"<br/>";
  1833. }
  1834. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1835. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1836. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1837. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1838. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1839. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1840. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1841. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1842. $"房间说明: {hotelReservations.Remark} <br/>" +
  1843. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1844. $"{hotelBreakfastStr}" +
  1845. $"{hotelGovernmentRentStr}" +
  1846. $"{hotelCityTaxStr}";
  1847. _detail.PriceNameContent = hotelReservations.HotelName;
  1848. }
  1849. break;
  1850. case 79://车/导游地接
  1851. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1852. if (touristGuideGroundReservations != null)
  1853. {
  1854. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1855. {
  1856. _detail.BusName = touristGuideGroundReservations.BusName;
  1857. }
  1858. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1859. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1860. //if (isInt)
  1861. //{
  1862. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1863. // if (cityInfo != null)
  1864. // {
  1865. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1866. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1867. // if (carFeeItem != null)
  1868. // {
  1869. // nameContent += $@"({carFeeItem.Name})";
  1870. // }
  1871. // _detail.PriceNameContent = nameContent;
  1872. // }
  1873. //}
  1874. //else
  1875. //{
  1876. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1877. //}
  1878. var touristGuideGroundReservationsContents =
  1879. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1880. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1881. foreach (var item in touristGuideGroundReservationsContents)
  1882. {
  1883. string typeName = "Unknown";
  1884. string carCurrencyCode = "Unknown";
  1885. string carCurrencyName = "Unknown";
  1886. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1887. if (carTypeData != null) typeName = carTypeData.Name;
  1888. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1889. if (currencyData != null)
  1890. {
  1891. carCurrencyCode = currencyData.Name;
  1892. carCurrencyName = currencyData.Remark;
  1893. }
  1894. //op、成本 币种是否一致
  1895. bool IsCurrencyAgreement = false;
  1896. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1897. string opCostStr = string.Empty;
  1898. decimal opCostTypePrice = 0.00M;
  1899. #region 处理成本各项费用
  1900. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1901. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1902. if (opCost.Count > 0)
  1903. {
  1904. switch (item.SId)
  1905. {
  1906. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1907. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1908. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1909. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1910. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1911. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1912. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1913. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1914. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1915. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1916. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1917. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1918. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1919. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1920. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1921. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1922. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1923. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1924. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1925. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1926. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1927. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1928. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1929. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1930. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1931. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1932. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1933. }
  1934. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1935. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1936. }
  1937. #endregion
  1938. string opTypeStr = $"{typeName}{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1939. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1940. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1941. $"{opTypeStr} {opCostStr}<br/>" +
  1942. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1943. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1944. }
  1945. _detail.PriceMsgContent = priceMsg;
  1946. }
  1947. break;
  1948. case 80: //签证
  1949. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1950. if (visaInfo != null)
  1951. {
  1952. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1953. _detail.PriceNameContent = visaInfo.VisaDescription;
  1954. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1955. }
  1956. break;
  1957. case 81: //邀请/公务活动
  1958. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1959. if (_ioa != null)
  1960. {
  1961. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1962. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1963. sendCurrName = "Unknown", //快递费用币种 Name
  1964. sendCurrCode = "Unknown", //快递费用币种 Code
  1965. eventsCurrName = "Unknown", //公务活动费币种 Name
  1966. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1967. translateCurrName = "Unknown", //公务翻译费 Name
  1968. translateCurrCode = "Unknown"; //公务翻译费 Code
  1969. #region 处理费用币种
  1970. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1971. if (inviteCurrData != null)
  1972. {
  1973. inviteCurrName = inviteCurrData.Remark;
  1974. inviteCurrCode = inviteCurrData.Name;
  1975. }
  1976. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1977. if (sendCurrData != null)
  1978. {
  1979. sendCurrName = sendCurrData.Remark;
  1980. sendCurrCode = sendCurrData.Name;
  1981. }
  1982. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1983. if (eventsCurrData != null)
  1984. {
  1985. eventsCurrName = eventsCurrData.Remark;
  1986. eventsCurrCode = eventsCurrData.Name;
  1987. }
  1988. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1989. if (translateCurrData != null)
  1990. {
  1991. translateCurrName = translateCurrData.Remark;
  1992. translateCurrCode = translateCurrData.Name;
  1993. }
  1994. #endregion
  1995. _detail.PriceNameContent = _ioa.InviterArea;
  1996. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1997. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1998. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1999. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2000. $@"备注:" + _ioa.Remark + "<br/>";
  2001. }
  2002. break;
  2003. case 82: //团组客户保险
  2004. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2005. if (customers != null)
  2006. {
  2007. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2008. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2009. }
  2010. break;
  2011. case 85: //机票预订
  2012. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2013. if (jpRes != null)
  2014. {
  2015. string FlightsDescription = jpRes.FlightsDescription;
  2016. string PriceDescription = jpRes.PriceDescription;
  2017. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2018. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2019. }
  2020. break;
  2021. case 98://其他款项
  2022. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2023. if (gdpRes != null)
  2024. {
  2025. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2026. _detail.PriceNameContent = gdpRes.PriceName;
  2027. }
  2028. break;
  2029. case 285://收款退还
  2030. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2031. if (refundAndOtherMoney != null)
  2032. {
  2033. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2034. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2035. }
  2036. break;
  2037. case 751://酒店早餐
  2038. break;
  2039. case 1015://超支费用
  2040. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2041. if (groupExtraCost != null)
  2042. {
  2043. _detail.PriceNameContent = groupExtraCost.PriceName;
  2044. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2045. }
  2046. break;
  2047. default:
  2048. break;
  2049. }
  2050. /*
  2051. * 申请人
  2052. */
  2053. string operatorName = " - ";
  2054. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2055. if (_opUser != null)
  2056. {
  2057. operatorName = _opUser.CnName;
  2058. }
  2059. _detail.OperatorName = operatorName;
  2060. /*
  2061. * 审核人
  2062. */
  2063. string auditOperatorName = "Unknown";
  2064. if (entity.AuditGMOperate == 0)
  2065. auditOperatorName = " - ";
  2066. else if (entity.AuditGMOperate == 4)
  2067. auditOperatorName = "自动审核";
  2068. else
  2069. {
  2070. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2071. if (_adUser != null)
  2072. {
  2073. auditOperatorName = _adUser.CnName;
  2074. }
  2075. }
  2076. _detail.AuditOperatorName = auditOperatorName;
  2077. /*
  2078. * 超预算比例
  2079. */
  2080. string overBudgetStr = "";
  2081. if (entity.ExceedBudget == -1)
  2082. overBudgetStr = sdPriceName.Name + "尚无预算";
  2083. else if (entity.ExceedBudget == 0)
  2084. {
  2085. if (entity.CTable == 76 || entity.CTable == 79)
  2086. {
  2087. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2088. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2089. }
  2090. else
  2091. {
  2092. overBudgetStr = "未超预算";
  2093. }
  2094. }
  2095. else
  2096. overBudgetStr = entity.ExceedBudget.ToString("P");
  2097. _detail.OverBudget = overBudgetStr;
  2098. /*
  2099. * 已审核金额
  2100. */
  2101. decimal auditFee = 0.00M;
  2102. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2103. /*
  2104. * 费用总计
  2105. */
  2106. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2107. {
  2108. CurrencyId = entity.PaymentCurrency,
  2109. CurrencyName = PaymentCurrency_WaitPay,
  2110. AmountPayable = entity.PayMoney,
  2111. ThisPayment = OriginalCurrPay,
  2112. BalancePayment = BalanceStr,
  2113. AuditedFunds = auditFee
  2114. });
  2115. _detail.IsAuditGM = entity.IsAuditGM;
  2116. detailList.Add(_detail);
  2117. }
  2118. #endregion
  2119. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2120. /*
  2121. * 下方描述处理
  2122. */
  2123. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2124. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2125. if (ccpCurrencyPrice != null)
  2126. {
  2127. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2128. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2129. }
  2130. else
  2131. {
  2132. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2133. }
  2134. string amountPayableStr = string.Format(@"应付款总金额: ");
  2135. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2136. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2137. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2138. foreach (var item in nonDuplicat)
  2139. {
  2140. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2141. if (strs.Count > 0)
  2142. {
  2143. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2144. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2145. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2146. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2147. //单独处理此次付款金额
  2148. if (item.CurrencyId == 836) //人民币
  2149. {
  2150. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2151. }
  2152. else
  2153. {
  2154. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2155. }
  2156. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2157. //单独处理已审核费用
  2158. if (item.CurrencyId == 836) //人民币
  2159. {
  2160. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2161. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2162. }
  2163. else
  2164. {
  2165. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2166. }
  2167. }
  2168. }
  2169. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2170. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2171. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2172. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2173. var _view1 = new
  2174. {
  2175. PageFuncAuth = pageFunAuthView,
  2176. Data = _view
  2177. };
  2178. return Ok(JsonView(_view1));
  2179. }
  2180. catch (Exception ex)
  2181. {
  2182. return Ok(JsonView(false, ex.Message));
  2183. }
  2184. }
  2185. /// <summary>
  2186. /// 费用审核
  2187. /// 修改团组费用审核状态
  2188. /// </summary>
  2189. /// <param name="_dto">参数Json字符串</param>
  2190. /// <returns></returns>
  2191. [HttpPost]
  2192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2193. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2194. {
  2195. #region 参数验证
  2196. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2197. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2198. #endregion
  2199. #region 页面操作权限验证
  2200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2201. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2202. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2203. #endregion
  2204. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2205. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2206. DateTime dtNow = DateTime.Now;
  2207. _groupRepository.BeginTran();
  2208. int rst = 0;
  2209. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2210. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2211. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2212. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2213. List<dynamic> msgDatas = new List<dynamic>();
  2214. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2215. foreach (var item in idList)
  2216. {
  2217. int CreditId = int.Parse(item);
  2218. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2219. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2220. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2221. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2222. .Where(s => s.Id == CreditId)
  2223. .ExecuteCommandAsync();
  2224. if (result < 1)
  2225. {
  2226. rst = -1;
  2227. _groupRepository.RollbackTran();
  2228. return Ok(JsonView(false, "操作失败并回滚!"));
  2229. }
  2230. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2231. if (creditData != null)
  2232. {
  2233. #region 应用通知配置
  2234. try
  2235. {
  2236. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2237. }
  2238. catch (Exception ex)
  2239. {
  2240. }
  2241. #endregion
  2242. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2243. string groupNameStr = string.Empty;
  2244. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2245. if (groupData != null) groupNameStr = groupData.TeamName;
  2246. string creditTypeStr = string.Empty;
  2247. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2248. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2249. string creditCurrency = string.Empty;
  2250. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2251. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2252. if (creditCurrency.Equals("CNY"))
  2253. {
  2254. creditData.DayRate = 1.0000M;
  2255. }
  2256. if (creditData.PayPercentage == 0.00M)
  2257. {
  2258. creditData.PayPercentage = 100M;
  2259. }
  2260. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2261. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2262. string msgContent = "";
  2263. if (creditCurrency.Equals("CNY"))
  2264. {
  2265. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2266. }
  2267. else
  2268. {
  2269. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2270. }
  2271. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2272. }
  2273. }
  2274. if (rst == 0)
  2275. {
  2276. _groupRepository.CommitTran();
  2277. foreach (var item in msgDatas)
  2278. {
  2279. //发送消息
  2280. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2281. }
  2282. #region 应用推送
  2283. try
  2284. {
  2285. foreach (var ccpId in dic_ccp_user.Keys)
  2286. {
  2287. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2288. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2289. }
  2290. }
  2291. catch (Exception)
  2292. {
  2293. }
  2294. #endregion
  2295. return Ok(JsonView(true, "操作成功!"));
  2296. }
  2297. return Ok(JsonView(false, "操作失败!"));
  2298. }
  2299. #endregion
  2300. #region 机票费用录入
  2301. /// <summary>
  2302. /// 机票录入当前登录人可操作团组
  2303. /// </summary>
  2304. /// <param name="dto"></param>
  2305. /// <returns></returns>
  2306. [HttpPost]
  2307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2308. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2309. {
  2310. try
  2311. {
  2312. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2313. if (groupData.Code != 0)
  2314. {
  2315. return Ok(JsonView(false, groupData.Msg));
  2316. }
  2317. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2318. }
  2319. catch (Exception ex)
  2320. {
  2321. return Ok(JsonView(false, "程序错误!"));
  2322. throw;
  2323. }
  2324. }
  2325. /// <summary>
  2326. /// 机票费用录入列表
  2327. /// </summary>
  2328. /// <param name="dto"></param>
  2329. /// <returns></returns>
  2330. [HttpPost]
  2331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2332. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2333. {
  2334. try
  2335. {
  2336. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2337. if (groupData.Code != 0)
  2338. {
  2339. return Ok(JsonView(false, groupData.Msg));
  2340. }
  2341. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2342. }
  2343. catch (Exception ex)
  2344. {
  2345. return Ok(JsonView(false, ex.Message));
  2346. throw;
  2347. }
  2348. }
  2349. /// <summary>
  2350. /// 根据id查询费用录入信息
  2351. /// </summary>
  2352. /// <param name="dto"></param>
  2353. /// <returns></returns>
  2354. [HttpPost]
  2355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2356. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2357. {
  2358. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2359. if (groupData.Code != 0)
  2360. {
  2361. return Ok(JsonView(false, groupData.Msg));
  2362. }
  2363. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2364. }
  2365. /// <summary>
  2366. /// 机票费用录入操作(Status:1.新增,2.修改)
  2367. /// </summary>
  2368. /// <param name="dto"></param>
  2369. /// <returns></returns>
  2370. [HttpPost]
  2371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2372. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2373. {
  2374. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2375. if (groupData.Code != 0)
  2376. {
  2377. return Ok(JsonView(false, groupData.Msg));
  2378. }
  2379. #region 应用推送
  2380. try
  2381. {
  2382. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2383. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2384. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2385. //2024-10-21 新增LZ UID
  2386. var userIds = new List<int>() { 21 };
  2387. string title = $"系统通知";
  2388. string content = "";
  2389. var diId = dto.AirTicketResOpData.DiId;
  2390. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2391. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2392. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2393. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2394. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2395. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content);
  2396. }
  2397. catch (Exception ex)
  2398. {
  2399. }
  2400. #endregion
  2401. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2402. }
  2403. /// <summary>
  2404. /// 根据舱位类型查询接团客户名单信息
  2405. /// </summary>
  2406. /// <param name="dto"></param>
  2407. /// <returns></returns>
  2408. [HttpPost]
  2409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2410. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2411. {
  2412. try
  2413. {
  2414. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2415. if (crm_Groups.Count != 0)
  2416. {
  2417. List<dynamic> Customer = new List<dynamic>();
  2418. foreach (var item in crm_Groups)
  2419. {
  2420. var data = new
  2421. {
  2422. Id = item.Id,
  2423. Pinyin = item.Pinyin,
  2424. Name = item.LastName + item.FirstName
  2425. };
  2426. Customer.Add(data);
  2427. }
  2428. return Ok(JsonView(true, "查询成功!", Customer));
  2429. }
  2430. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2431. }
  2432. catch (Exception ex)
  2433. {
  2434. return Ok(JsonView(false, "程序错误!"));
  2435. throw;
  2436. }
  2437. }
  2438. /// <summary>
  2439. /// 根据团号获取客户信息
  2440. /// </summary>
  2441. /// <param name="dto"></param>
  2442. /// <returns></returns>
  2443. [HttpPost]
  2444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2445. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2446. {
  2447. var jw = JsonView(false);
  2448. if (dto.DIID < 1)
  2449. {
  2450. jw.Msg += "请输入正确的diid";
  2451. return Ok(jw);
  2452. }
  2453. var arr = getSimplClientList(dto.DIID);
  2454. jw = JsonView(true, "获取成功!", arr);
  2455. return Ok(jw);
  2456. }
  2457. private List<SimplClientInfo> getSimplClientList(int diId)
  2458. {
  2459. 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);
  2460. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2461. return arr;
  2462. }
  2463. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2464. {
  2465. string result = origin;
  2466. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2467. {
  2468. string[] temparr = origin.Split(',');
  2469. string fistrStr = temparr[0];
  2470. int count = temparr.Count();
  2471. int tempId;
  2472. bool success = int.TryParse(fistrStr, out tempId);
  2473. if (success)
  2474. {
  2475. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2476. if (tempInfo != null)
  2477. {
  2478. if (count > 1)
  2479. {
  2480. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2481. }
  2482. else
  2483. {
  2484. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2485. }
  2486. }
  2487. }
  2488. }
  2489. return result;
  2490. }
  2491. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2492. {
  2493. string result = origin;
  2494. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2495. {
  2496. string[] temparr = origin.Split(',');
  2497. result = "";
  2498. foreach (var item in temparr)
  2499. {
  2500. int tempId;
  2501. bool success = int.TryParse(item, out tempId);
  2502. if (success)
  2503. {
  2504. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2505. if (tempInfo != null)
  2506. {
  2507. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2508. }
  2509. }
  2510. }
  2511. }
  2512. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2513. return result;
  2514. }
  2515. /// <summary>
  2516. /// 机票费用录入,删除
  2517. /// </summary>
  2518. /// <param name="dto"></param>
  2519. /// <returns></returns>
  2520. [HttpPost]
  2521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2522. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2523. {
  2524. try
  2525. {
  2526. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2527. if (res)
  2528. {
  2529. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2530. {
  2531. IsDel = 1,
  2532. DeleteUserId = dto.DeleteUserId,
  2533. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2534. }).ExecuteCommandAsync();
  2535. return Ok(JsonView(true, "删除成功!"));
  2536. }
  2537. return Ok(JsonView(false, "删除失败!"));
  2538. }
  2539. catch (Exception ex)
  2540. {
  2541. return Ok(JsonView(false, "程序错误!"));
  2542. throw;
  2543. }
  2544. }
  2545. /// <summary>
  2546. /// 导出机票录入报表
  2547. /// </summary>
  2548. /// <param name="dto"></param>
  2549. /// <returns></returns>
  2550. [HttpPost]
  2551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2552. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2553. {
  2554. try
  2555. {
  2556. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2557. if (groupData.Code != 0)
  2558. {
  2559. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2560. }
  2561. else
  2562. {
  2563. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2564. if (AirTicketReservations.Count != 0)
  2565. {
  2566. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2567. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2568. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2569. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2570. WorkbookDesigner designer = new WorkbookDesigner();
  2571. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2572. decimal countCost = 0;
  2573. foreach (var item in AirTicketReservations)
  2574. {
  2575. #region 处理客人姓名
  2576. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2577. item.ClientName = clientNames;
  2578. #endregion
  2579. if (item.BankType == "其他")
  2580. {
  2581. item.BankNo = "--";
  2582. }
  2583. else
  2584. {
  2585. if (!string.IsNullOrEmpty(item.BankType))
  2586. {
  2587. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2588. }
  2589. }
  2590. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2591. item.Price = System.Decimal.Round(item.Price, 2);
  2592. countCost += Convert.ToDecimal(item.Price);
  2593. }
  2594. designer.SetDataSource("Export", AirTicketReservations);
  2595. designer.SetDataSource("ExportDiCode", diCode);
  2596. designer.SetDataSource("ExportDiName", diName);
  2597. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2598. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2599. designer.Process();
  2600. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2601. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2602. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2603. return Ok(JsonView(true, "成功", url = rst));
  2604. }
  2605. else
  2606. {
  2607. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2608. }
  2609. }
  2610. }
  2611. catch (Exception ex)
  2612. {
  2613. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2614. throw;
  2615. }
  2616. }
  2617. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2618. /// <summary>
  2619. /// 行程单导出
  2620. /// </summary>
  2621. /// <param name="dto"></param>
  2622. /// <returns></returns>
  2623. [HttpPost]
  2624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2625. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2626. {
  2627. try
  2628. {
  2629. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2630. if (groupData.Code != 0)
  2631. {
  2632. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2633. }
  2634. else
  2635. {
  2636. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2637. if (dto.Language == "CN")
  2638. {
  2639. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2640. DocumentBuilder builder = new DocumentBuilder(doc);
  2641. int tableIndex = 0;//表格索引
  2642. //得到文档中的第一个表格
  2643. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2644. foreach (var item in _AirTicketReservations)
  2645. {
  2646. #region 处理固定数据
  2647. string[] FlightsCode = item.FlightsCode.Split('/');
  2648. if (FlightsCode.Length != 0)
  2649. {
  2650. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2651. if (_AirCompany != null)
  2652. {
  2653. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2654. }
  2655. else
  2656. {
  2657. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2658. }
  2659. }
  2660. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2661. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2662. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2663. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2664. string name = "";
  2665. foreach (string clientName in nameArray)
  2666. {
  2667. if (!name.Contains(clientName))
  2668. {
  2669. name += clientName + ",";
  2670. }
  2671. }
  2672. if (!string.IsNullOrWhiteSpace(name))
  2673. {
  2674. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2675. }
  2676. else
  2677. {
  2678. table.Range.Bookmarks["ClientName"].Text = "--";
  2679. }
  2680. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2681. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2682. table.Range.Bookmarks["JointTicket"].Text = "--";
  2683. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2684. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2685. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2686. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2687. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2688. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2689. #endregion
  2690. #region 循环数据处理
  2691. List<AirInfo> airs = new List<AirInfo>();
  2692. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2693. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2694. for (int i = 0; i < FlightsCode.Length; i++)
  2695. {
  2696. AirInfo air = new AirInfo();
  2697. string[] tempstr = DayArray[i]
  2698. .Replace("\r\n", string.Empty)
  2699. .Replace("\\r\\n", string.Empty)
  2700. .TrimStart().TrimEnd()
  2701. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2702. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2703. string starCity = "";
  2704. if (star_Three != null)
  2705. {
  2706. starCity = star_Three.AirPort;
  2707. }
  2708. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2709. string EndCity = "";
  2710. if (End_Three != null)
  2711. {
  2712. EndCity = End_Three.AirPort;
  2713. }
  2714. air.Destination = starCity + "/" + EndCity;
  2715. air.Flight = FlightsCode[i];
  2716. air.SeatingClass = item.CTypeName;
  2717. string dateTime = tempstr[2];
  2718. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2719. air.FlightDate = DateTemp;
  2720. air.DepartureTime = tempstr[5];
  2721. air.LandingTime = tempstr[6];
  2722. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2723. air.TicketStatus = "--";
  2724. air.Luggage = "--";
  2725. air.DepartureTerminal = "--";
  2726. air.LandingTerminal = "--";
  2727. airs.Add(air);
  2728. }
  2729. int row = 13;
  2730. for (int i = 0; i < airs.Count; i++)
  2731. {
  2732. if (airs.Count > 2)
  2733. {
  2734. for (int j = 0; j < airs.Count - 2; j++)
  2735. {
  2736. var CopyRow = table.Rows[12].Clone(true);
  2737. table.Rows.Add(CopyRow);
  2738. }
  2739. }
  2740. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2741. int index = 0;
  2742. foreach (PropertyInfo property in properties)
  2743. {
  2744. string value = property.GetValue(airs[i]).ToString();
  2745. Cell ishcel0 = table.Rows[row].Cells[index];
  2746. Paragraph p = new Paragraph(doc);
  2747. string s = value;
  2748. p.AppendChild(new Run(doc, s));
  2749. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2750. ishcel0.AppendChild(p);
  2751. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2752. index++;
  2753. }
  2754. row++;
  2755. }
  2756. #endregion
  2757. Paragraph lastParagraph = new Paragraph(doc);
  2758. //第一个表格末尾加段落
  2759. table.ParentNode.InsertAfter(lastParagraph, table);
  2760. //复制第一个表格
  2761. Table cloneTable = (Table)table.Clone(true);
  2762. //在文档末尾段落后面加入复制的表格
  2763. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2764. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2765. {
  2766. int rownewsIndex = 13;
  2767. for (int i = 0; i < 2; i++)
  2768. {
  2769. var CopyRow = table.Rows[12].Clone(true);
  2770. table.Rows.RemoveAt(13);
  2771. table.Rows.Add(CopyRow);
  2772. rownewsIndex++;
  2773. }
  2774. }
  2775. else
  2776. {
  2777. table.Rows.RemoveAt(12);
  2778. }
  2779. cloneTable.Rows.RemoveAt(12);
  2780. }
  2781. if (_AirTicketReservations.Count != 0)
  2782. {
  2783. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2784. if (FlightsCode.Length != 0)
  2785. {
  2786. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2787. if (_AirCompany != null)
  2788. {
  2789. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2790. }
  2791. else
  2792. {
  2793. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2794. }
  2795. }
  2796. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2797. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2798. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2799. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2800. string name = "";
  2801. foreach (string clientName in nameArray)
  2802. {
  2803. if (!name.Contains(clientName))
  2804. {
  2805. name += clientName + ",";
  2806. }
  2807. }
  2808. if (!string.IsNullOrWhiteSpace(name))
  2809. {
  2810. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2811. }
  2812. else
  2813. {
  2814. table.Range.Bookmarks["ClientName"].Text = "--";
  2815. }
  2816. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2817. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2818. table.Range.Bookmarks["JointTicket"].Text = "--";
  2819. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2820. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2821. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2822. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2823. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2824. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2825. }
  2826. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2827. //保存合并后的文档
  2828. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2829. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2830. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2831. return Ok(JsonView(true, "成功!", rst));
  2832. }
  2833. else
  2834. {
  2835. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2836. DocumentBuilder builder = new DocumentBuilder(doc);
  2837. int tableIndex = 0;//表格索引
  2838. //得到文档中的第一个表格
  2839. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2840. List<string> texts = new List<string>();
  2841. foreach (var item in _AirTicketReservations)
  2842. {
  2843. string[] FlightsCode = item.FlightsCode.Split('/');
  2844. if (FlightsCode.Length != 0)
  2845. {
  2846. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2847. if (_AirCompany != null)
  2848. {
  2849. if (!transDic.ContainsKey(_AirCompany.CnName))
  2850. {
  2851. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2852. }
  2853. }
  2854. else
  2855. {
  2856. if (!transDic.ContainsKey("--"))
  2857. {
  2858. transDic.Add("--", "--");
  2859. }
  2860. }
  2861. }
  2862. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2863. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2864. string name = "";
  2865. foreach (string clientName in nameArray)
  2866. {
  2867. name += clientName + ",";
  2868. }
  2869. if (!texts.Contains(name))
  2870. {
  2871. texts.Add(name);
  2872. }
  2873. List<AirInfo> airs = new List<AirInfo>();
  2874. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2875. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2876. for (int i = 0; i < FlightsCode.Length; i++)
  2877. {
  2878. AirInfo air = new AirInfo();
  2879. string[] tempstr = DayArray[i]
  2880. .Replace("\r\n", string.Empty)
  2881. .Replace("\\r\\n", string.Empty)
  2882. .TrimStart().TrimEnd()
  2883. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2884. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2885. if (star_Three != null)
  2886. {
  2887. if (!transDic.ContainsKey(star_Three.AirPort))
  2888. {
  2889. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2890. }
  2891. }
  2892. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2893. if (End_Three != null)
  2894. {
  2895. if (!transDic.ContainsKey(End_Three.AirPort))
  2896. {
  2897. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2898. }
  2899. }
  2900. if (!texts.Contains(item.CTypeName))
  2901. {
  2902. texts.Add(item.CTypeName);
  2903. }
  2904. }
  2905. }
  2906. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2907. if (transData.Count > 0)
  2908. {
  2909. foreach (TranslateResult item in transData)
  2910. {
  2911. if (!transDic.ContainsKey(item.Query))
  2912. {
  2913. transDic.Add(item.Query, item.Translation);
  2914. }
  2915. }
  2916. }
  2917. foreach (var item in _AirTicketReservations)
  2918. {
  2919. #region 处理固定数据
  2920. string[] FlightsCode = item.FlightsCode.Split('/');
  2921. if (FlightsCode.Length != 0)
  2922. {
  2923. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2924. if (_AirCompany != null)
  2925. {
  2926. string str = "--";
  2927. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2928. if (!string.IsNullOrEmpty(translateResult))
  2929. {
  2930. str = translateResult;
  2931. str = _airTicketResRep.Processing(str);
  2932. }
  2933. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2934. }
  2935. else
  2936. {
  2937. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2938. }
  2939. }
  2940. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2941. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2942. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2943. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2944. string names = "";
  2945. foreach (string clientName in nameArray)
  2946. {
  2947. names += clientName + ",";
  2948. }
  2949. if (!string.IsNullOrWhiteSpace(names))
  2950. {
  2951. string str = "--";
  2952. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2953. if (!string.IsNullOrEmpty(translateResult))
  2954. {
  2955. str = translateResult;
  2956. str = _airTicketResRep.Processing(str);
  2957. }
  2958. table.Range.Bookmarks["ClientName"].Text = str;
  2959. }
  2960. else
  2961. {
  2962. table.Range.Bookmarks["ClientName"].Text = "--";
  2963. }
  2964. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2965. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2966. table.Range.Bookmarks["JointTicket"].Text = "--";
  2967. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2968. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2969. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2970. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2971. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2972. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2973. #endregion
  2974. #region 循环数据处理
  2975. List<AirInfo> airs = new List<AirInfo>();
  2976. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2977. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2978. for (int i = 0; i < FlightsCode.Length; i++)
  2979. {
  2980. AirInfo air = new AirInfo();
  2981. string[] tempstr = DayArray[i]
  2982. .Replace("\r\n", string.Empty)
  2983. .Replace("\\r\\n", string.Empty)
  2984. .TrimStart().TrimEnd()
  2985. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2986. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2987. string starCity = "";
  2988. if (star_Three != null)
  2989. {
  2990. string str2 = "--";
  2991. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2992. if (!string.IsNullOrEmpty(translateResult2))
  2993. {
  2994. str2 = translateResult2;
  2995. str2 = _airTicketResRep.Processing(str2);
  2996. }
  2997. starCity = str2;
  2998. }
  2999. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3000. string EndCity = "";
  3001. if (End_Three != null)
  3002. {
  3003. string str1 = "--";
  3004. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3005. if (!string.IsNullOrEmpty(translateResult1))
  3006. {
  3007. str1 = translateResult1;
  3008. str1 = _airTicketResRep.Processing(str1);
  3009. }
  3010. EndCity = str1;
  3011. }
  3012. air.Destination = starCity + "/" + EndCity;
  3013. air.Flight = FlightsCode[i];
  3014. string str = "--";
  3015. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3016. if (!string.IsNullOrEmpty(translateResult))
  3017. {
  3018. str = translateResult;
  3019. str = _airTicketResRep.Processing(str);
  3020. }
  3021. air.SeatingClass = str;
  3022. string dateTime = tempstr[2];
  3023. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3024. air.FlightDate = DateTemp;
  3025. air.DepartureTime = tempstr[5];
  3026. air.LandingTime = tempstr[6];
  3027. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3028. air.TicketStatus = "--";
  3029. air.Luggage = "--";
  3030. air.DepartureTerminal = "--";
  3031. air.LandingTerminal = "--";
  3032. airs.Add(air);
  3033. }
  3034. int row = 13;
  3035. for (int i = 0; i < airs.Count; i++)
  3036. {
  3037. if (airs.Count > 2)
  3038. {
  3039. for (int j = 0; j < airs.Count - 2; j++)
  3040. {
  3041. var CopyRow = table.Rows[12].Clone(true);
  3042. table.Rows.Add(CopyRow);
  3043. }
  3044. }
  3045. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3046. int index = 0;
  3047. foreach (PropertyInfo property in properties)
  3048. {
  3049. string value = property.GetValue(airs[i]).ToString();
  3050. Cell ishcel0 = table.Rows[row].Cells[index];
  3051. Paragraph p = new Paragraph(doc);
  3052. string s = value;
  3053. p.AppendChild(new Run(doc, s));
  3054. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3055. ishcel0.AppendChild(p);
  3056. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3057. //ishcel0.CellFormat.VerticalAlignment=
  3058. index++;
  3059. }
  3060. row++;
  3061. }
  3062. #endregion
  3063. Paragraph lastParagraph = new Paragraph(doc);
  3064. //第一个表格末尾加段落
  3065. table.ParentNode.InsertAfter(lastParagraph, table);
  3066. //复制第一个表格
  3067. Table cloneTable = (Table)table.Clone(true);
  3068. //在文档末尾段落后面加入复制的表格
  3069. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3070. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3071. {
  3072. int rownewsIndex = 13;
  3073. for (int i = 0; i < 2; i++)
  3074. {
  3075. var CopyRow = table.Rows[12].Clone(true);
  3076. table.Rows.RemoveAt(13);
  3077. table.Rows.Add(CopyRow);
  3078. rownewsIndex++;
  3079. }
  3080. }
  3081. else
  3082. {
  3083. table.Rows.RemoveAt(12);
  3084. }
  3085. cloneTable.Rows.RemoveAt(12);
  3086. }
  3087. if (_AirTicketReservations.Count != 0)
  3088. {
  3089. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3090. if (FlightsCode.Length != 0)
  3091. {
  3092. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3093. if (_AirCompany != null)
  3094. {
  3095. string str = "--";
  3096. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3097. if (!string.IsNullOrEmpty(translateResult))
  3098. {
  3099. str = translateResult;
  3100. str = _airTicketResRep.Processing(str);
  3101. }
  3102. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3103. }
  3104. else
  3105. {
  3106. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3107. }
  3108. }
  3109. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3110. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3111. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3112. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3113. string names = "";
  3114. foreach (string clientName in nameArray)
  3115. {
  3116. names += clientName + ",";
  3117. }
  3118. if (!string.IsNullOrWhiteSpace(names))
  3119. {
  3120. string str = "--";
  3121. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3122. if (!string.IsNullOrEmpty(translateResult))
  3123. {
  3124. str = translateResult;
  3125. str = _airTicketResRep.Processing(str);
  3126. }
  3127. table.Range.Bookmarks["ClientName"].Text = str;
  3128. }
  3129. else
  3130. {
  3131. table.Range.Bookmarks["ClientName"].Text = "--";
  3132. }
  3133. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3134. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3135. table.Range.Bookmarks["JointTicket"].Text = "--";
  3136. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3137. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3138. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3139. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3140. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3141. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3142. }
  3143. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3144. //保存合并后的文档
  3145. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3146. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3147. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3148. return Ok(JsonView(true, "成功!", rst));
  3149. }
  3150. }
  3151. }
  3152. catch (Exception ex)
  3153. {
  3154. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3155. throw;
  3156. }
  3157. }
  3158. #endregion
  3159. #region 团组增减款项 --> 其他款项
  3160. /// <summary>
  3161. /// 团组增减款项下拉框绑定
  3162. /// </summary>
  3163. /// <param name="dto"></param>
  3164. /// <returns></returns>
  3165. [HttpPost]
  3166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3167. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3168. {
  3169. #region 参数验证
  3170. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3171. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3172. #endregion
  3173. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3174. }
  3175. /// <summary>
  3176. /// 根据团组Id查询团组增减款项
  3177. /// </summary>
  3178. /// <param name="dto"></param>
  3179. /// <returns></returns>
  3180. [HttpPost]
  3181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3182. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3183. {
  3184. #region 参数验证
  3185. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3186. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3187. #endregion
  3188. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3189. }
  3190. /// <summary>
  3191. /// 团组增减款项操作(Status:1.新增,2.修改)
  3192. /// </summary>
  3193. /// <param name="dto"></param>
  3194. /// <returns></returns>
  3195. [HttpPost]
  3196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3197. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3198. {
  3199. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3200. if (groupData.Code != 200)
  3201. {
  3202. return Ok(JsonView(false, groupData.Msg));
  3203. }
  3204. #region 应用推送
  3205. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3206. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3207. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3208. //自动审核
  3209. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3210. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3211. //2024-10-21 新增LZ UID
  3212. var userIds = new List<int>() { 21 };
  3213. string title = $"系统通知";
  3214. string content = "";
  3215. var diId = dto.DiId;
  3216. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3217. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3218. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3219. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3220. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3221. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3222. #endregion
  3223. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3224. }
  3225. /// <summary>
  3226. /// 团组增减款项操作 删除
  3227. /// </summary>
  3228. /// <param name="dto"></param>
  3229. /// <returns></returns>
  3230. [HttpPost]
  3231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3232. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3233. {
  3234. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3235. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3236. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3237. if (res.Code == 0)
  3238. {
  3239. return Ok(JsonView(true, "删除成功!"));
  3240. }
  3241. return Ok(JsonView(false, "删除失败!"));
  3242. }
  3243. /// <summary>
  3244. /// 根据团组增减款项Id查询
  3245. /// </summary>
  3246. /// <param name="dto"></param>
  3247. /// <returns></returns>
  3248. [HttpPost]
  3249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3250. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3251. {
  3252. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3253. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3254. }
  3255. /// <summary>
  3256. /// 查询供应商名称
  3257. /// </summary>
  3258. /// <param name="dto"></param>
  3259. /// <returns></returns>
  3260. [HttpPost]
  3261. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3262. {
  3263. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3264. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3265. ?? new List<Grp_DecreasePayments>();
  3266. dbResult = dbResult.Distinct(new
  3267. ProductComparer()).ToList();
  3268. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3269. {
  3270. x.Id,
  3271. x.SupplierAddress,
  3272. x.SupplierArea,
  3273. x.SupplierContact,
  3274. x.SupplierContactNumber,
  3275. x.SupplierEmail,
  3276. x.SupplierName,
  3277. x.SupplierSocialAccount,
  3278. x.SupplierTypeId,
  3279. }).ToList());
  3280. return Ok(jw);
  3281. }
  3282. /// <summary>
  3283. /// 团组增减款项 OTA匹配
  3284. /// </summary>
  3285. /// <param name="file"></param>
  3286. /// <returns></returns>
  3287. [HttpPost]
  3288. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3289. {
  3290. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3291. string fileName = file.FileName;
  3292. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3293. {
  3294. return Ok(JsonView(false, "请上传Excel文件!"));
  3295. }
  3296. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3297. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3298. if (!Directory.Exists(path))
  3299. {
  3300. Directory.CreateDirectory(path);
  3301. }
  3302. var filePath = @$"{path}/{fileName}";
  3303. //保存文件
  3304. using (FileStream fs = System.IO.File.Create(filePath))
  3305. {
  3306. file.CopyTo(fs);
  3307. fs.Flush();
  3308. }
  3309. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3310. //读取ExcelFile
  3311. DataTable dt = ConvertExcelToDataTable(filePath);
  3312. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3313. dt.TableName = "TB";
  3314. //修改table列名
  3315. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3316. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3317. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3318. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3319. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3320. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3321. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3322. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3323. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3324. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3325. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3326. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3327. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3328. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3329. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3330. var otaOrderNos = new List<string>();
  3331. foreach (DataRow item in dt.Rows)
  3332. {
  3333. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3334. }
  3335. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3336. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3337. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3338. .Select((dp, di) => new
  3339. {
  3340. dp.PriceName,
  3341. dp.OTAOrderNo,
  3342. dp.FeeTotal,
  3343. di.TeamName,
  3344. })
  3345. .ToListAsync();
  3346. foreach (DataRow item in dt.Rows)
  3347. {
  3348. var otaOrderNo = item["OTAOrderNo"].ToString();
  3349. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3350. if (oaData == null) continue;
  3351. item["GroupName"] = oaData.TeamName;
  3352. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3353. }
  3354. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3355. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3356. List<DataTable> datas = new List<DataTable>();
  3357. datas.Add(dt);
  3358. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3359. return Ok(JsonView(true, "操作成功", new { url = url }));
  3360. }
  3361. #region
  3362. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3363. {
  3364. // 创建Workbook对象
  3365. Workbook workbook = new Workbook(excelFilePath);
  3366. // 获取第一个工作表
  3367. Worksheet worksheet = workbook.Worksheets[0];
  3368. // 将工作表转换为DataTable
  3369. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3370. return dataTable;
  3371. }
  3372. #endregion
  3373. #endregion
  3374. #region 文件上传、删除
  3375. /// <summary>
  3376. /// region 文件上传 可以带参数
  3377. /// </summary>
  3378. /// <param name="file"></param>
  3379. /// <returns></returns>
  3380. [HttpPost]
  3381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3382. public async Task<IActionResult> UploadProject(IFormFile file)
  3383. {
  3384. //var TypeName = Request.Headers["TypeName"].ToString();
  3385. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3386. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3387. ////文件名称
  3388. //string projectFileName = file.FileName;
  3389. ////上传的文件的路径
  3390. //string filePath = $"{fileDir}/{projectFileName}";
  3391. //if (TypeName == "A")//A代表团组增减款项
  3392. //{
  3393. // filePath = fileDir + $@"\团组增减款项相关文件";
  3394. // if (!Directory.Exists(filePath))
  3395. // {
  3396. // Directory.CreateDirectory(filePath);
  3397. // }
  3398. // //上传的文件的路径
  3399. // filePath += $@"\{projectFileName}";
  3400. //}
  3401. //else if (TypeName == "B")//B代表商邀相关文件
  3402. //{
  3403. // //上传的文件的路径
  3404. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3405. // if (!Directory.Exists(filePath))
  3406. // {
  3407. // Directory.CreateDirectory(filePath);
  3408. // }
  3409. // //上传的文件的路径
  3410. // filePath = $@"\{projectFileName}";
  3411. //}
  3412. //try
  3413. //{
  3414. // using (FileStream fs = System.IO.File.Create(filePath))
  3415. // {
  3416. // file.CopyTo(fs);
  3417. // fs.Flush();
  3418. // }
  3419. //}
  3420. //catch (Exception ex)
  3421. //{
  3422. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3423. //}
  3424. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3425. try
  3426. {
  3427. var TypeName = Request.Headers["TypeName"].ToString();
  3428. if (file != null)
  3429. {
  3430. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3431. //文件名称
  3432. string projectFileName = file.FileName;
  3433. //上传的文件的路径
  3434. string filePath = $"{fileDir}/{projectFileName}";
  3435. if (TypeName == "A")//A代表团组增减款项
  3436. {
  3437. if (!Directory.Exists(fileDir))
  3438. {
  3439. Directory.CreateDirectory(fileDir);
  3440. }
  3441. //上传的文件的路径
  3442. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3443. }
  3444. else if (TypeName == "B")//B代表商邀相关文件
  3445. {
  3446. if (!Directory.Exists(fileDir))
  3447. {
  3448. Directory.CreateDirectory(fileDir);
  3449. }
  3450. //上传的文件的路径
  3451. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3452. }
  3453. using (FileStream fs = System.IO.File.Create(filePath))
  3454. {
  3455. file.CopyTo(fs);
  3456. fs.Flush();
  3457. }
  3458. return Ok(JsonView(true, "上传成功!", projectFileName));
  3459. }
  3460. else
  3461. {
  3462. return Ok(JsonView(false, "上传失败!"));
  3463. }
  3464. }
  3465. catch (Exception ex)
  3466. {
  3467. return Ok(JsonView(false, "程序错误!"));
  3468. }
  3469. }
  3470. /// <summary>
  3471. /// 删除指定文件
  3472. /// </summary>
  3473. /// <param name="dto"></param>
  3474. /// <returns></returns>
  3475. [HttpPost]
  3476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3477. public async Task<IActionResult> DelFile(DelFileDto dto)
  3478. {
  3479. try
  3480. {
  3481. var TypeName = Request.Headers["TypeName"].ToString();
  3482. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3483. string filePath = "";
  3484. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3485. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3486. int id = 0;
  3487. if (TypeName == "A")
  3488. {
  3489. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3490. // 删除该文件
  3491. System.IO.File.Delete(filePath);
  3492. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3493. .Where(a => a.Id == dto.Id)
  3494. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3495. .ExecuteCommandAsync();
  3496. }
  3497. else if (TypeName == "B")
  3498. {
  3499. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3500. // 删除该文件
  3501. System.IO.File.Delete(filePath);
  3502. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3503. if (info != null)
  3504. {
  3505. string[] files = new string[] { };
  3506. if (!string.IsNullOrEmpty(info.Attachment))
  3507. {
  3508. try
  3509. {
  3510. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3511. }
  3512. catch (Exception)
  3513. {
  3514. files = new List<string>() { info.Attachment }.ToArray();
  3515. }
  3516. }
  3517. if (files.Length > 0)
  3518. {
  3519. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3520. string filePath2 = string.Empty;
  3521. if (files1.Length > 0)
  3522. {
  3523. filePath2 = JsonConvert.SerializeObject(files1);
  3524. }
  3525. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3526. .Where(a => a.Id == dto.Id)
  3527. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3528. .ExecuteCommandAsync();
  3529. }
  3530. }
  3531. }
  3532. if (id != 0)
  3533. {
  3534. return Ok(JsonView(true, "成功!"));
  3535. }
  3536. else
  3537. {
  3538. return Ok(JsonView(false, "失败!"));
  3539. }
  3540. }
  3541. catch (Exception ex)
  3542. {
  3543. return Ok(JsonView(false, "程序错误!"));
  3544. throw;
  3545. }
  3546. }
  3547. /// <summary>
  3548. /// 文件上传多个文件 可以带参数
  3549. /// </summary>
  3550. /// <param name="file"></param>
  3551. /// <returns></returns>
  3552. [HttpPost]
  3553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3554. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3555. {
  3556. try
  3557. {
  3558. var TypeName = Request.Headers["TypeName"].ToString();
  3559. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3560. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3561. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3562. var filePahts = new List<string>();
  3563. foreach (var file in files)
  3564. {
  3565. //文件名称
  3566. string projectFileName = file.FileName;
  3567. //上传的文件的路径
  3568. string filePath = $"{fileDir}/{projectFileName}";
  3569. if (TypeName == "A")//A代表团组增减款项
  3570. {
  3571. if (!Directory.Exists(fileDir))
  3572. {
  3573. Directory.CreateDirectory(fileDir);
  3574. }
  3575. //上传的文件的路径
  3576. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3577. }
  3578. else if (TypeName == "B")//B代表商邀相关文件
  3579. {
  3580. if (!Directory.Exists(fileDir))
  3581. {
  3582. Directory.CreateDirectory(fileDir);
  3583. }
  3584. //上传的文件的路径
  3585. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3586. }
  3587. using (FileStream fs = System.IO.File.Create(filePath))
  3588. {
  3589. file.CopyTo(fs);
  3590. fs.Flush();
  3591. }
  3592. filePahts.Add(projectFileName);
  3593. }
  3594. return Ok(JsonView(true, "上传成功!", filePahts));
  3595. }
  3596. catch (Exception ex)
  3597. {
  3598. return Ok(JsonView(false, "程序错误!"));
  3599. }
  3600. }
  3601. #endregion
  3602. #region 商邀费用录入
  3603. /// <summary>
  3604. /// 根据团组Id查询商邀费用列表
  3605. /// </summary>
  3606. /// <param name="dto"></param>
  3607. /// <returns></returns>
  3608. [HttpPost]
  3609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3610. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3611. {
  3612. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3613. if (groupData.Code != 0)
  3614. {
  3615. return Ok(JsonView(false, groupData.Msg));
  3616. }
  3617. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3618. }
  3619. /// <summary>
  3620. /// 商邀费用列表
  3621. /// 下载文件
  3622. /// </summary>
  3623. /// <param name="dto"></param>
  3624. /// <returns></returns>
  3625. [HttpGet("{id}")]
  3626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3627. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3628. {
  3629. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3630. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3631. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3632. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3633. var filePaths = new List<string>();
  3634. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3635. try
  3636. {
  3637. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3638. }
  3639. catch (Exception ex)
  3640. {
  3641. filePaths.Add(info.Attachment);
  3642. }
  3643. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3644. for (int i = 0; i < filePaths.Count; i++)
  3645. {
  3646. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3647. }
  3648. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3649. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3650. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3651. {
  3652. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3653. {
  3654. foreach (string filePath in filePaths)
  3655. {
  3656. if (System.IO.File.Exists(filePath))
  3657. {
  3658. // 获取文件名
  3659. string fileName = Path.GetFileName(filePath);
  3660. // 将文件添加到ZIP归档中
  3661. zipArchive.CreateEntryFromFile(filePath, fileName);
  3662. }
  3663. }
  3664. }
  3665. }
  3666. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3667. }
  3668. /// <summary>
  3669. /// 商邀费用 Info Page 基础数据源
  3670. /// </summary>
  3671. /// <param name="dto"></param>
  3672. /// <returns></returns>
  3673. [HttpPost]
  3674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3675. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3676. {
  3677. try
  3678. {
  3679. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3680. if (groupData.Code != 0)
  3681. {
  3682. return Ok(JsonView(false, groupData.Msg));
  3683. }
  3684. return Ok(JsonView(true, "操作成功", groupData.Data));
  3685. }
  3686. catch (Exception ex)
  3687. {
  3688. return Ok(JsonView(false, ex.Message));
  3689. throw;
  3690. }
  3691. }
  3692. /// <summary>
  3693. /// 根据商邀费用ID查询C表和商邀费用数据
  3694. /// </summary>
  3695. /// <param name="dto"></param>
  3696. /// <returns></returns>
  3697. [HttpPost]
  3698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3699. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3700. {
  3701. try
  3702. {
  3703. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3704. if (groupData.Code != 0)
  3705. {
  3706. return Ok(JsonView(false, groupData.Msg));
  3707. }
  3708. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3709. }
  3710. catch (Exception ex)
  3711. {
  3712. return Ok(JsonView(false, ex.Message));
  3713. throw;
  3714. }
  3715. }
  3716. /// <summary>
  3717. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3718. /// </summary>
  3719. /// <param name="dto"></param>
  3720. /// <returns></returns>
  3721. [HttpPost]
  3722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3723. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3724. {
  3725. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3726. if (groupData.Code != 0)
  3727. {
  3728. return Ok(JsonView(false, groupData.Msg));
  3729. }
  3730. #region 应用推送
  3731. try
  3732. {
  3733. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3734. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3735. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3736. //2024-10-21 新增LZ UID
  3737. var userIds = new List<int>() { 21 };
  3738. string title = $"系统通知";
  3739. string content = "";
  3740. var diId = dto.DiId;
  3741. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3742. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3743. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3744. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3745. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3746. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content);
  3747. }
  3748. catch (Exception ex)
  3749. {
  3750. }
  3751. #endregion
  3752. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3753. }
  3754. /// <summary>
  3755. /// 商邀删除
  3756. /// </summary>
  3757. /// <param name="dto"></param>
  3758. /// <returns></returns>
  3759. [HttpPost]
  3760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3761. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3762. {
  3763. try
  3764. {
  3765. _sqlSugar.BeginTran();
  3766. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3767. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3768. {
  3769. IsDel = 1,
  3770. DeleteUserId = dto.DeleteUserId,
  3771. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3772. })
  3773. .Where(it => it.Id == dto.Id)
  3774. .ExecuteCommand();
  3775. if (res1 > 0)
  3776. {
  3777. int _diId = 0;
  3778. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3779. if (_ioaInfo != null)
  3780. {
  3781. _diId = _ioaInfo.DiId;
  3782. }
  3783. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3784. .SetColumns(a => new Grp_CreditCardPayment()
  3785. {
  3786. IsDel = 1,
  3787. DeleteUserId = dto.DeleteUserId,
  3788. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3789. })
  3790. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3791. .ExecuteCommand();
  3792. if (res2 > 0)
  3793. {
  3794. _sqlSugar.CommitTran();
  3795. return Ok(JsonView(true, "删除成功!"));
  3796. }
  3797. }
  3798. _sqlSugar.RollbackTran();
  3799. return Ok(JsonView(false, "删除失败"));
  3800. }
  3801. catch (Exception ex)
  3802. {
  3803. _sqlSugar.RollbackTran();
  3804. return Ok(JsonView(false, ex.Message));
  3805. }
  3806. }
  3807. /// <summary>
  3808. /// 团组模块文件上传
  3809. /// </summary>
  3810. /// <param name="dto"></param>
  3811. /// <returns></returns>
  3812. [HttpPost]
  3813. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3814. {
  3815. var jw = JsonView(false);
  3816. long M = 1024 * 1024;
  3817. if (dto.Files == null || dto.Files.Count == 0)
  3818. {
  3819. jw.Msg = "无文件信息!";
  3820. return Ok(jw);
  3821. }
  3822. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3823. {
  3824. jw.Msg = "文件大小超过20M!";
  3825. return Ok(jw);
  3826. }
  3827. //var nameSp = dto.File.FileName.Split(".");
  3828. //if (nameSp.Length < 2)
  3829. //{
  3830. // jw.Msg = "拓展名称有误!";
  3831. // return Ok(jw);
  3832. //}
  3833. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3834. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3835. //{
  3836. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3837. // return Ok(jw);
  3838. //}
  3839. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3840. if (Ctable == null)
  3841. {
  3842. jw.Msg = "Ctable指向有误!";
  3843. return Ok(jw);
  3844. }
  3845. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3846. if (groupInfo == null)
  3847. {
  3848. jw.Msg = "团组信息不存在!";
  3849. return Ok(jw);
  3850. }
  3851. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3852. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3853. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3854. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3855. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3856. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3857. try
  3858. {
  3859. if (!Directory.Exists(fileBase))
  3860. {
  3861. Directory.CreateDirectory(fileBase);
  3862. }
  3863. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3864. foreach (var fileStream in dto.Files)
  3865. {
  3866. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3867. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3868. {
  3869. Cid = dto.Cid,
  3870. CreateTime = DateTime.Now,
  3871. CreateUserId = dto.Userid,
  3872. Ctable = dto.Ctable,
  3873. Diid = dto.Diid,
  3874. IsDel = 0,
  3875. FilePath = saveFilePath,
  3876. FileName = fileStream.FileName
  3877. };
  3878. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3879. {
  3880. fileStream.CopyTo(fs);
  3881. fs.Flush();
  3882. }
  3883. saveArr.Add(file);
  3884. }
  3885. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3886. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3887. jw = JsonView(true, "保存成功!", new
  3888. {
  3889. count = addResult,
  3890. filesName = saveArr.Select(x => x.FileName)
  3891. });
  3892. }
  3893. catch (Exception ex)
  3894. {
  3895. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3896. {
  3897. count = 0,
  3898. filesName = new string[0],
  3899. });
  3900. }
  3901. return Ok(jw);
  3902. }
  3903. /// <summary>
  3904. /// 查询各模块已保存文件
  3905. /// </summary>
  3906. /// <param name="dto"></param>
  3907. /// <returns></returns>
  3908. [HttpPost]
  3909. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3910. {
  3911. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3912. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3913. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3914. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3915. {
  3916. expression = Expressionable.Create<Grp_GroupModelFile>()
  3917. .And(x => visaIds.Contains(x.CreateUserId));
  3918. }
  3919. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3920. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3921. .Where(expression.ToExpression())
  3922. .ToList();
  3923. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3924. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3925. {
  3926. x.FileName,
  3927. x.Id,
  3928. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3929. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3930. })));
  3931. }
  3932. /// <summary>
  3933. /// 下载该团组下的所有文件
  3934. /// </summary>
  3935. /// <param name="dto"></param>
  3936. /// <returns></returns>
  3937. [HttpPost]
  3938. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3939. {
  3940. var jw = JsonView(false);
  3941. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3942. if (groupInfo == null)
  3943. {
  3944. jw.Msg = "团组信息不存在!";
  3945. return Ok(jw);
  3946. }
  3947. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3948. var isModule = Convert.ToBoolean(dto.isModule);
  3949. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3950. IOOperatorHelper io = new IOOperatorHelper();
  3951. if (isModule)
  3952. {
  3953. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3954. foreach (var moduleArr in moduleGroup)
  3955. {
  3956. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3957. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3958. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3959. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3960. foreach (var item in moduleArr)
  3961. {
  3962. if (System.IO.File.Exists(item.FilePath))
  3963. {
  3964. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3965. {
  3966. byte[] bytes = new byte[fileStream.Length];
  3967. fileStream.Read(bytes, 0, bytes.Length);
  3968. fileStream.Close();
  3969. Stream stream = new MemoryStream(bytes);
  3970. chiZips.Add(item.FileName, stream);
  3971. }
  3972. }
  3973. }
  3974. if (chiZips.Count > 0)
  3975. {
  3976. var byts = io.ConvertZipStream(chiZips);
  3977. Stream stream = new MemoryStream(byts);
  3978. Zips.Add(key.Name + "_.zip", stream);
  3979. }
  3980. }
  3981. }
  3982. else
  3983. {
  3984. foreach (var item in dbQuery)
  3985. {
  3986. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3987. {
  3988. byte[] bytes = new byte[fileStream.Length];
  3989. fileStream.Read(bytes, 0, bytes.Length);
  3990. fileStream.Close();
  3991. Stream stream = new MemoryStream(bytes);
  3992. while (Zips.Keys.Contains(item.FileName))
  3993. {
  3994. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3995. }
  3996. Zips.Add(item.FileName, stream);
  3997. }
  3998. }
  3999. }
  4000. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4001. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4002. if (Zips.Count > 0)
  4003. {
  4004. var byts = io.ConvertZipStream(Zips);
  4005. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4006. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4007. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4008. }
  4009. else
  4010. {
  4011. jw.Msg = "暂无生成文件!";
  4012. }
  4013. return Ok(jw);
  4014. }
  4015. /// <summary>
  4016. /// 下载该团组下此模块的所有文件
  4017. /// </summary>
  4018. /// <param name="dto"></param>
  4019. /// <returns></returns>
  4020. [HttpPost]
  4021. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4022. {
  4023. var jw = JsonView(false);
  4024. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4025. if (groupInfo == null)
  4026. {
  4027. jw.Msg = "团组信息不存在!";
  4028. return Ok(jw);
  4029. }
  4030. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4031. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4032. && x.IsDel == 0);
  4033. if (key == null)
  4034. {
  4035. jw.Msg = "Ctable指向错误!";
  4036. return Ok(jw);
  4037. }
  4038. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4039. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4040. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4041. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4042. IOOperatorHelper io = new IOOperatorHelper();
  4043. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4044. foreach (var item in dbQuery)
  4045. {
  4046. if (System.IO.File.Exists(item.FilePath))
  4047. {
  4048. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4049. {
  4050. byte[] bytes = new byte[fileStream.Length];
  4051. fileStream.Read(bytes, 0, bytes.Length);
  4052. fileStream.Close();
  4053. Stream stream = new MemoryStream(bytes);
  4054. while (Zips.Keys.Contains(item.FileName))
  4055. {
  4056. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4057. }
  4058. Zips.Add(item.FileName, stream);
  4059. }
  4060. }
  4061. }
  4062. if (Zips.Count > 0)
  4063. {
  4064. var byts = io.ConvertZipStream(Zips);
  4065. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4066. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4067. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4068. }
  4069. else
  4070. {
  4071. jw.Msg = "暂无生成文件!";
  4072. }
  4073. return Ok(jw);
  4074. }
  4075. /// <summary>
  4076. /// 删除该团组下的指定文件
  4077. /// </summary>
  4078. /// <param name="dto"></param>
  4079. /// <returns></returns>
  4080. [HttpPost]
  4081. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4082. {
  4083. var jw = JsonView(false);
  4084. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4085. if (sing == null)
  4086. {
  4087. jw.Msg = "暂无";
  4088. return Ok(jw);
  4089. }
  4090. if (System.IO.File.Exists(sing.FilePath))
  4091. {
  4092. try
  4093. {
  4094. System.IO.File.Delete(sing.FilePath);
  4095. }
  4096. catch (Exception ex)
  4097. {
  4098. jw.Msg = "删除失败!" + ex.Message;
  4099. return Ok(jw);
  4100. }
  4101. }
  4102. sing.IsDel = 1;
  4103. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4104. sing.DeleteUserId = dto.UserId;
  4105. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4106. jw = JsonView(true, "删除成功!");
  4107. return Ok(jw);
  4108. }
  4109. #endregion
  4110. #region 团组英文资料
  4111. /// <summary>
  4112. /// 查询团组英文所有资料
  4113. /// </summary>
  4114. /// <param name="dto"></param>
  4115. /// <returns></returns>
  4116. [HttpPost]
  4117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4118. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4119. {
  4120. try
  4121. {
  4122. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4123. if (groupData.Code != 0)
  4124. {
  4125. return Ok(JsonView(false, groupData.Msg));
  4126. }
  4127. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4128. }
  4129. catch (Exception ex)
  4130. {
  4131. return Ok(JsonView(false, "程序错误!"));
  4132. throw;
  4133. }
  4134. }
  4135. /// <summary>
  4136. /// 团组英文资料操作(Status:1.新增,2.修改)
  4137. /// </summary>
  4138. /// <param name="dto"></param>
  4139. /// <returns></returns>
  4140. [HttpPost]
  4141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4142. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4143. {
  4144. try
  4145. {
  4146. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4147. if (groupData.Code != 0)
  4148. {
  4149. return Ok(JsonView(false, groupData.Msg));
  4150. }
  4151. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4152. }
  4153. catch (Exception ex)
  4154. {
  4155. return Ok(JsonView(false, "程序错误!"));
  4156. throw;
  4157. }
  4158. }
  4159. /// <summary>
  4160. /// 团组英文资料Id查询数据
  4161. /// </summary>
  4162. /// <param name="dto"></param>
  4163. /// <returns></returns>
  4164. [HttpPost]
  4165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4166. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4167. {
  4168. try
  4169. {
  4170. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4171. if (_DelegationEnData != null)
  4172. {
  4173. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4174. }
  4175. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4176. }
  4177. catch (Exception ex)
  4178. {
  4179. return Ok(JsonView(false, "程序错误!"));
  4180. throw;
  4181. }
  4182. }
  4183. /// <summary>
  4184. /// 团组英文资料删除
  4185. /// </summary>
  4186. /// <param name="dto"></param>
  4187. /// <returns></returns>
  4188. [HttpPost]
  4189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4190. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4191. {
  4192. try
  4193. {
  4194. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4195. if (!res)
  4196. {
  4197. return Ok(JsonView(false, "删除失败"));
  4198. }
  4199. return Ok(JsonView(true, "删除成功!"));
  4200. }
  4201. catch (Exception ex)
  4202. {
  4203. return Ok(JsonView(false, "程序错误!"));
  4204. throw;
  4205. }
  4206. }
  4207. #endregion
  4208. #region 导出邀请函
  4209. /// <summary>
  4210. /// 导出邀请函页面初始化
  4211. /// </summary>
  4212. /// <param name="dto"></param>
  4213. /// <returns></returns>
  4214. [HttpPost]
  4215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4216. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4217. {
  4218. try
  4219. {
  4220. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4221. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4222. if (dto.DiId == 0)
  4223. {
  4224. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4225. }
  4226. else
  4227. {
  4228. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4229. }
  4230. return Ok(JsonView(true, "查询成功!", new
  4231. {
  4232. deleClient = crm_Deles,
  4233. delegations = grp_Delegations
  4234. }));
  4235. }
  4236. catch (Exception ex)
  4237. {
  4238. return Ok(JsonView(false, "程序错误!"));
  4239. throw;
  4240. }
  4241. }
  4242. /// <summary>
  4243. /// 导出邀请函
  4244. /// </summary>
  4245. /// <param name="dto"></param>
  4246. /// <returns></returns>
  4247. [HttpPost]
  4248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4249. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4250. {
  4251. #region 参数验证
  4252. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4253. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4254. #endregion
  4255. try
  4256. {
  4257. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4258. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4259. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4260. From Grp_TourClientList tcl
  4261. Left Join
  4262. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4263. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4264. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4265. From Crm_DeleClient dc
  4266. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4267. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4268. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4269. Where dc.IsDel = 0) temp
  4270. On temp.DcId =tcl.ClientId
  4271. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4272. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4273. List<string> texts = new List<string>();
  4274. if (datas.Count != 0)
  4275. {
  4276. foreach (TourClientListDetailsView item in datas)
  4277. {
  4278. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4279. {
  4280. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4281. }
  4282. else
  4283. {
  4284. string name = item.LastName + item.FirstName;
  4285. texts.Add(name);
  4286. }
  4287. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4288. {
  4289. if (!transDic.ContainsKey(item.Job))
  4290. {
  4291. texts.Add(item.Job);
  4292. }
  4293. }
  4294. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4295. {
  4296. texts.Add(item.CompanyFullName);
  4297. }
  4298. }
  4299. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4300. if (transData.Count > 0)
  4301. {
  4302. foreach (TranslateResult item in transData)
  4303. {
  4304. if (!transDic.ContainsKey(item.Query))
  4305. {
  4306. transDic.Add(item.Query, item.Translation);
  4307. }
  4308. }
  4309. }
  4310. List<GuestList> list = new List<GuestList>();
  4311. foreach (TourClientListDetailsView dele in datas)
  4312. {
  4313. GuestList guestList = new GuestList();
  4314. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4315. {
  4316. guestList.Name = dele.Pinyin;
  4317. }
  4318. else
  4319. {
  4320. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4321. guestList.Name = Name;
  4322. }
  4323. if (dele.Sex == 0)
  4324. {
  4325. guestList.Sex = "Male";
  4326. }
  4327. else if (dele.Sex == 1)
  4328. {
  4329. guestList.Sex = "Female";
  4330. }
  4331. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4332. if (!string.IsNullOrEmpty(dele.Job))
  4333. {
  4334. guestList.Job = dele.Job;
  4335. }
  4336. list.Add(guestList);
  4337. }
  4338. //载入模板
  4339. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4340. DocumentBuilder builder = new DocumentBuilder(doc);
  4341. //获取word里所有表格
  4342. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4343. //获取所填表格的序数
  4344. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4345. var rowStart = tableOne.Rows[0]; //获取第1行
  4346. //循环赋值
  4347. for (int i = 0; i < list.Count; i++)
  4348. {
  4349. builder.MoveToCell(0, i + 1, 0, 0);
  4350. builder.Write(list[i].Name.ToString());
  4351. builder.MoveToCell(0, i + 1, 1, 0);
  4352. builder.Write(list[i].Sex.ToString());
  4353. builder.MoveToCell(0, i + 1, 2, 0);
  4354. builder.Write(list[i].DOB.ToString());
  4355. builder.MoveToCell(0, i + 1, 3, 0);
  4356. builder.Write(list[i].Job.ToString());
  4357. }
  4358. //删除多余行
  4359. while (tableOne.Rows.Count > list.Count + 1)
  4360. {
  4361. tableOne.Rows.RemoveAt(list.Count + 1);
  4362. }
  4363. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4364. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4365. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4366. doc.Save(filePath);
  4367. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4368. return Ok(JsonView(true, "操作成功!", Url));
  4369. }
  4370. else
  4371. {
  4372. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4373. }
  4374. }
  4375. catch (Exception ex)
  4376. {
  4377. return Ok(JsonView(false, ex.Message));
  4378. throw;
  4379. }
  4380. }
  4381. #endregion
  4382. #region 团组经理模块 出入境费用
  4383. ///// <summary>
  4384. ///// 团组模块 - 出入境费用
  4385. ///// </summary>
  4386. ///// <returns></returns>
  4387. //[HttpPost]
  4388. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4389. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4390. //{
  4391. // try
  4392. // {
  4393. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4394. // if (data.Code != 0)
  4395. // {
  4396. // return Ok(JsonView(false, data.Msg));
  4397. // }
  4398. // return Ok(JsonView(true, "查询成功!"));
  4399. // }
  4400. // catch (Exception ex)
  4401. // {
  4402. // return Ok(JsonView(false, ex.Message));
  4403. // throw;
  4404. // }
  4405. //}
  4406. /// <summary>
  4407. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4408. /// </summary>
  4409. /// <returns></returns>
  4410. [HttpPost]
  4411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4412. public async Task<IActionResult> SetDayAndCostAreaChange()
  4413. {
  4414. try
  4415. {
  4416. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4417. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4418. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4419. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4420. foreach (var item in unite) //处理交集数据
  4421. {
  4422. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4423. }
  4424. foreach (var item in merge) //处理差集数据
  4425. {
  4426. int nationalTravelFeeId = 0;
  4427. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4428. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4429. else
  4430. {
  4431. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4432. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4433. }
  4434. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4435. }
  4436. //只更新dayAndCost 的 nationalTravelFeeId;
  4437. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4438. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4439. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4440. }
  4441. catch (Exception ex)
  4442. {
  4443. return Ok(JsonView(false, ex.Message));
  4444. throw;
  4445. }
  4446. }
  4447. /// <summary>
  4448. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4449. /// </summary>
  4450. /// <returns></returns>
  4451. [HttpPost]
  4452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4453. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4454. {
  4455. try
  4456. {
  4457. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4458. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4459. //SetDataInfoView
  4460. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4461. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4462. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4463. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4464. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4465. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4466. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4467. //默认币种显示
  4468. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4469. {
  4470. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4471. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4472. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4473. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4474. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4475. };
  4476. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4477. if (_currencyRate.Count > 0)
  4478. {
  4479. foreach (var item in _currencyInfos)
  4480. {
  4481. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4482. if (rateInfo != null)
  4483. {
  4484. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4485. rate1 *= 1.035M;
  4486. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4487. }
  4488. }
  4489. }
  4490. return Ok(JsonView(true, "查询成功!", new
  4491. {
  4492. GroupNameData = groupNameData.Data,
  4493. CurrencyData = _CurrencyData,
  4494. WordTypeData = _WordTypeData,
  4495. ExcelTypeData = _ExcelTypeData,
  4496. CurrencyInit = _currencyInfos
  4497. }));
  4498. }
  4499. catch (Exception ex)
  4500. {
  4501. return Ok(JsonView(false, ex.Message));
  4502. throw;
  4503. }
  4504. }
  4505. /// <summary>
  4506. /// 团组模块 - 出入境费用
  4507. /// 实时汇率 tips
  4508. /// 签证费用 tips
  4509. /// </summary>
  4510. /// <returns></returns>
  4511. [HttpPost]
  4512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4513. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4514. {
  4515. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4516. //默认币种显示
  4517. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4518. {
  4519. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4520. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4521. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4522. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4523. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4524. };
  4525. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4526. List<dynamic> reteInfos = new List<dynamic>();
  4527. if (_currencyRate.Count > 0)
  4528. {
  4529. foreach (var item in _currencyInfos)
  4530. {
  4531. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4532. if (rateInfo != null)
  4533. {
  4534. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4535. decimal rate1 = item.Rate;
  4536. rate1 *= 1.03M;
  4537. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4538. reteInfos.Add(new
  4539. {
  4540. currCode = item.CurrencyCode,
  4541. currName = item.CurrencyName,
  4542. rate = rate2,
  4543. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4544. });
  4545. }
  4546. }
  4547. }
  4548. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4549. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4550. return Ok(JsonView(true, "查询成功!", new
  4551. {
  4552. //GroupNameData = groupNameData.Data,
  4553. visaData = visaData.Data,
  4554. airData = airData.Data,
  4555. reteInfos = reteInfos
  4556. }));
  4557. }
  4558. /// <summary>
  4559. /// 团组模块 - 出入境费用 - Info
  4560. /// </summary>
  4561. /// <returns></returns>
  4562. [HttpPost]
  4563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4564. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4565. {
  4566. try
  4567. {
  4568. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4569. if (data.Code != 0)
  4570. {
  4571. return Ok(JsonView(false, data.Msg));
  4572. }
  4573. return Ok(JsonView(true, "查询成功!", data.Data));
  4574. }
  4575. catch (Exception ex)
  4576. {
  4577. return Ok(JsonView(false, ex.Message));
  4578. }
  4579. }
  4580. /// <summary>
  4581. /// 团组模块 - 出入境费用 - Add And Update
  4582. /// </summary>
  4583. /// <returns></returns>
  4584. [HttpPost]
  4585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4586. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4587. {
  4588. try
  4589. {
  4590. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4591. if (dto.DayOtherPriceData.Any())
  4592. {
  4593. var inserList = dto.DayOtherPriceData
  4594. .Where(x => x.Id == 0)
  4595. .Select(x => new Grp_DayOtherPrice
  4596. {
  4597. Cost = x.Cost,
  4598. Id = x.Id,
  4599. CreateTime = DateTime.Now,
  4600. CreateUserId = dto.UserId,
  4601. Currency = x.Currency,
  4602. Diid = x.DiId,
  4603. Index = x.Index,
  4604. IsDel = 0,
  4605. SetDataId = x.SetDataId,
  4606. SubTotal = x.SubTotal
  4607. })
  4608. .ToList();
  4609. var updateList = dto.DayOtherPriceData
  4610. .Where(x => x.Id != 0)
  4611. .Select(x => new Grp_DayOtherPrice
  4612. {
  4613. Cost = x.Cost,
  4614. Id = x.Id,
  4615. CreateTime = DateTime.Now,
  4616. CreateUserId = dto.UserId,
  4617. Currency = x.Currency,
  4618. Diid = x.DiId,
  4619. Index = x.Index,
  4620. IsDel = 0,
  4621. SetDataId = x.SetDataId,
  4622. SubTotal = x.SubTotal,
  4623. })
  4624. .ToList();
  4625. //添加
  4626. _sqlSugar.BeginTran();
  4627. if (inserList.Any())
  4628. {
  4629. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4630. }
  4631. if (updateList.Any())
  4632. {
  4633. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4634. }
  4635. _sqlSugar.CommitTran();
  4636. }
  4637. if (data.Code != 0)
  4638. {
  4639. return Ok(JsonView(false, data.Msg));
  4640. }
  4641. //生成默认文件pdf并且通知人员
  4642. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4643. {
  4644. DiId = dto.DiId,
  4645. ExportType = 1,
  4646. SubTypeId = 1005
  4647. }, "pdf");
  4648. //发送通知
  4649. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4650. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4651. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4652. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4653. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4654. //汇率信息记录
  4655. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4656. return Ok(JsonView(true, data.Msg, data.Data));
  4657. }
  4658. catch (Exception ex)
  4659. {
  4660. return Ok(JsonView(false, ex.Message));
  4661. }
  4662. }
  4663. /// <summary>
  4664. /// 团组模块 - 出入境费用 - Confirm 费用
  4665. /// </summary>
  4666. /// <returns></returns>
  4667. [HttpPost]
  4668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4669. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4670. {
  4671. //TODO:测试完毕需把对应的用户ID更改
  4672. //1、数据表添加字段
  4673. //2、更改字段接口()
  4674. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4675. //3、确认成功 给财务发送消息
  4676. if (_view.Code == 200)
  4677. {
  4678. if (dto.Type == 1)
  4679. {
  4680. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4681. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4682. }
  4683. }
  4684. return Ok(_view);
  4685. }
  4686. /// <summary>
  4687. /// 团组模块 - 出入境费用 - File downlaod
  4688. /// </summary>
  4689. /// <param name="dto"></param>
  4690. /// <returns></returns>
  4691. [HttpPost]
  4692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4693. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4694. {
  4695. try
  4696. {
  4697. if (dto.DiId < 1)
  4698. {
  4699. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4700. }
  4701. if (dto.ExportType < 1)
  4702. {
  4703. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4704. }
  4705. if (dto.SubTypeId < 1)
  4706. {
  4707. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4708. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4709. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4710. 3 团组成员名单 1 团组成员名单", ""));
  4711. }
  4712. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4713. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4714. if (_EnterExitCosts == null)
  4715. {
  4716. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4717. }
  4718. //数据源
  4719. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4720. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4721. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4722. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4723. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4724. .LeftJoin<Sys_SetData>((x,a)=> a.IsDel == 0 && a.Id == x.SetDataId)
  4725. .LeftJoin<Sys_SetData>((x, a, b) => a.IsDel == 0 && a.Id == x.Currency)
  4726. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4727. .Select((x, a, b) => new
  4728. {
  4729. x.Index,
  4730. itemName = a.Name,
  4731. CurrencyStr = b.Name,
  4732. x.Cost,
  4733. x.SubTotal,
  4734. })
  4735. .OrderBy((x) => x.Index)
  4736. .ToList();
  4737. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4738. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4739. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4740. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4741. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4742. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4743. .Select((tcl, dc, cc) => new
  4744. {
  4745. Name = dc.LastName + dc.FirstName,
  4746. Sex = dc.Sex,
  4747. Birthday = dc.BirthDay,
  4748. Company = cc.CompanyFullName,
  4749. Job = dc.Job
  4750. })
  4751. .ToList();
  4752. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4753. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4754. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4755. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4756. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4757. if (dto.ExportType == 1) //明细表
  4758. {
  4759. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4760. {
  4761. //获取模板
  4762. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4763. //载入模板
  4764. Document doc = new Document(tempPath);
  4765. DocumentBuilder builder = new DocumentBuilder(doc);
  4766. //利用键值对存放数据
  4767. Dictionary<string, string> dic = new Dictionary<string, string>();
  4768. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4769. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4770. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4771. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4772. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4773. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4774. //境内费用(其他费用)
  4775. if (_EnterExitCosts.ChoiceOne == 1)
  4776. {
  4777. string row1_1 = "";
  4778. if (_EnterExitCosts.Visa > 0)
  4779. {
  4780. //insidePayTotal += _EnterExitCosts.Visa;
  4781. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4782. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4783. {
  4784. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4785. }
  4786. }
  4787. string row1_2 = "";
  4788. if (_EnterExitCosts.YiMiao > 0)
  4789. {
  4790. //insidePayTotal += _EnterExitCosts.YiMiao;
  4791. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4792. }
  4793. if (_EnterExitCosts.HeSuan > 0)
  4794. {
  4795. //insidePayTotal += _EnterExitCosts.HeSuan;
  4796. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4797. }
  4798. if (_EnterExitCosts.Service > 0)
  4799. {
  4800. //insidePayTotal += _EnterExitCosts.Service;
  4801. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4802. }
  4803. string row1_3 = "";
  4804. if (_EnterExitCosts.Safe > 0)
  4805. {
  4806. //insidePayTotal += _EnterExitCosts.Safe;
  4807. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4808. }
  4809. if (_EnterExitCosts.Ticket > 0)
  4810. {
  4811. //insidePayTotal += _EnterExitCosts.Ticket;
  4812. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4813. }
  4814. string row1 = "";
  4815. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4816. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4817. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4818. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4819. dic.Add("Row1Str", row1);
  4820. }
  4821. string airTotalStr = string.Empty,
  4822. airPriceStr = string.Empty;
  4823. //经济舱
  4824. if (_EnterExitCosts.SumJJC == 1)
  4825. {
  4826. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4827. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4828. }
  4829. //公务舱
  4830. if (_EnterExitCosts.SumGWC == 1)
  4831. {
  4832. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4833. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4834. }
  4835. //头等舱
  4836. if (_EnterExitCosts.SumTDC == 1)
  4837. {
  4838. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4839. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4840. }
  4841. dic.Add("AirTotalStr", airTotalStr);
  4842. dic.Add("AirPriceStr", airPriceStr);
  4843. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4844. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4845. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4846. int table1Row = 0,
  4847. table2Row = 0,
  4848. table3Row = 0,
  4849. table4Row = 0,
  4850. table5Row = 0;
  4851. //住宿费
  4852. if (_EnterExitCosts.ChoiceThree == 1)
  4853. {
  4854. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4855. table1Row = dac1.Count;
  4856. #region 填充word表格内容
  4857. for (int i = 0; i < dac1.Count; i++)
  4858. {
  4859. Grp_DayAndCost dac = dac1[i];
  4860. if (dac == null) continue;
  4861. builder.MoveToCell(0, i, 0, 0);
  4862. builder.Write("第" + dac.Days.ToString() + "晚:");
  4863. builder.MoveToCell(0, i, 1, 0);
  4864. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4865. //builder.Write(dac.Place == null ? "" : dac.Place);
  4866. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4867. builder.MoveToCell(0, i, 2, 0);
  4868. builder.Write("费用标准:");
  4869. string curr = "";
  4870. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4871. if (currData != null)
  4872. {
  4873. curr = currData.Name;
  4874. }
  4875. builder.MoveToCell(0, i, 3, 0);
  4876. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4877. builder.MoveToCell(0, i, 4, 0);
  4878. builder.Write("费用小计:");
  4879. builder.MoveToCell(0, i, 5, 0);
  4880. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4881. }
  4882. #endregion
  4883. }
  4884. else dic.Add("SubZS", "0.00");
  4885. //删除多余行
  4886. while (table1.Rows.Count > table1Row)
  4887. {
  4888. table1.Rows.RemoveAt(table1Row);
  4889. }
  4890. //伙食费
  4891. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4892. if (_EnterExitCosts.ChoiceFour == 1)
  4893. {
  4894. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4895. table2Row = dac2.Count;
  4896. #region 填充word表格内容
  4897. for (int i = 0; i < dac2.Count; i++)
  4898. {
  4899. Grp_DayAndCost dac = dac2[i];
  4900. if (dac == null) continue;
  4901. builder.MoveToCell(1, i, 0, 0);
  4902. builder.Write("第" + dac.Days.ToString() + "天:");
  4903. builder.MoveToCell(1, i, 1, 0);
  4904. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4905. builder.MoveToCell(1, i, 2, 0);
  4906. builder.Write("费用标准:");
  4907. string curr = "";
  4908. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4909. if (currData != null)
  4910. {
  4911. curr = currData.Name;
  4912. }
  4913. builder.MoveToCell(1, i, 3, 0);
  4914. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4915. builder.MoveToCell(1, i, 4, 0);
  4916. builder.Write("费用小计:");
  4917. builder.MoveToCell(1, i, 5, 0);
  4918. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4919. }
  4920. #endregion
  4921. }
  4922. else dic.Add("SubHS", "0.00");
  4923. //删除多余行
  4924. while (table2.Rows.Count > table2Row)
  4925. {
  4926. table2.Rows.RemoveAt(table2Row);
  4927. }
  4928. //公杂费
  4929. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4930. if (_EnterExitCosts.ChoiceFive == 1)
  4931. {
  4932. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4933. table3Row = dac3.Count;
  4934. #region 填充word表格内容
  4935. for (int i = 0; i < dac3.Count; i++)
  4936. {
  4937. Grp_DayAndCost dac = dac3[i];
  4938. if (dac == null) continue;
  4939. builder.MoveToCell(2, i, 0, 0);
  4940. builder.Write("第" + dac.Days.ToString() + "天:");
  4941. builder.MoveToCell(2, i, 1, 0);
  4942. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4943. builder.MoveToCell(2, i, 2, 0);
  4944. builder.Write("费用标准:");
  4945. string curr = "";
  4946. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4947. if (currData != null)
  4948. {
  4949. curr = currData.Name;
  4950. }
  4951. builder.MoveToCell(2, i, 3, 0);
  4952. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4953. builder.MoveToCell(2, i, 4, 0);
  4954. builder.Write("费用小计:");
  4955. builder.MoveToCell(2, i, 5, 0);
  4956. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4957. }
  4958. //删除多余行
  4959. while (table3.Rows.Count > table3Row)
  4960. {
  4961. table3.Rows.RemoveAt(table3Row);
  4962. }
  4963. #endregion
  4964. }
  4965. else dic.Add("SubGZF", "0.00");
  4966. //删除多余行
  4967. while (table3.Rows.Count > table3Row)
  4968. {
  4969. table3.Rows.RemoveAt(table3Row);
  4970. }
  4971. //培训费
  4972. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4973. if (_EnterExitCosts.ChoiceSix == 1)
  4974. {
  4975. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4976. dic.Add("SubPX", pxStr);
  4977. table4Row = dac4.Count;
  4978. #region 填充word表格内容
  4979. for (int i = 0; i < dac4.Count; i++)
  4980. {
  4981. Grp_DayAndCost dac = dac4[i];
  4982. if (dac == null) continue;
  4983. builder.MoveToCell(3, i, 0, 0);
  4984. builder.Write("第" + dac.Days.ToString() + "天:");
  4985. builder.MoveToCell(3, i, 1, 0);
  4986. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4987. builder.MoveToCell(3, i, 2, 0);
  4988. builder.Write("费用标准:");
  4989. string curr = "";
  4990. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4991. if (currData != null)
  4992. {
  4993. curr = currData.Name;
  4994. }
  4995. builder.MoveToCell(3, i, 3, 0);
  4996. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4997. builder.MoveToCell(3, i, 4, 0);
  4998. builder.Write("费用小计:");
  4999. builder.MoveToCell(3, i, 5, 0);
  5000. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5001. }
  5002. #endregion
  5003. }
  5004. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5005. //删除多余行
  5006. while (table4.Rows.Count > table4Row)
  5007. {
  5008. table4.Rows.RemoveAt(table4Row);
  5009. }
  5010. //其他费用
  5011. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5012. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5013. {
  5014. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5015. dic.Add("titleQi", qtStr);
  5016. table5Row = dac5.Count;
  5017. #region 填充word表格内容
  5018. for (int i = 0; i < dac5.Count; i++)
  5019. {
  5020. var dac = dac5[i];
  5021. if (dac == null) continue;
  5022. builder.MoveToCell(4, i, 0, 0);
  5023. builder.Write("第" + dac.Index.ToString() + "项:");
  5024. builder.MoveToCell(4, i, 1, 0);
  5025. builder.Write(dac.itemName);
  5026. builder.MoveToCell(4, i, 2, 0);
  5027. builder.Write("费用标准:");
  5028. builder.MoveToCell(4, i, 3, 0);
  5029. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5030. builder.MoveToCell(4, i, 4, 0);
  5031. builder.Write("费用小计:");
  5032. builder.MoveToCell(4, i, 5, 0);
  5033. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5034. }
  5035. #endregion
  5036. }
  5037. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5038. //删除多余行
  5039. while (table5.Rows.Count > table5Row)
  5040. {
  5041. table5.Rows.RemoveAt(table5Row);
  5042. }
  5043. //加上其他费用
  5044. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5045. decimal subJJC = 0.00M,
  5046. subGWC = 0.00M,
  5047. subTDC = 0.00M;
  5048. //经济舱
  5049. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5050. //公务舱
  5051. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5052. //头等舱
  5053. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5054. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5055. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5056. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5057. #region 填充word模板书签内容
  5058. foreach (var key in dic.Keys)
  5059. {
  5060. Bookmark bookmark = doc.Range.Bookmarks[key];
  5061. if (bookmark != null)
  5062. {
  5063. builder.MoveToBookmark(key);
  5064. builder.Write(dic[key]);
  5065. }
  5066. }
  5067. #endregion
  5068. //文件名
  5069. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5070. AsposeHelper.removewatermark_v2180();
  5071. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5072. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5073. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5074. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5075. }
  5076. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5077. {
  5078. //获取模板
  5079. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5080. //载入模板
  5081. Document doc = new Document(tempPath);
  5082. DocumentBuilder builder = new DocumentBuilder(doc);
  5083. Dictionary<string, string> dic = new Dictionary<string, string>();
  5084. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5085. {
  5086. List<string> list = new List<string>();
  5087. try
  5088. {
  5089. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5090. foreach (var item in spilitArr)
  5091. {
  5092. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5093. var depCode = spDotandEmpty[2].Substring(0, 3);
  5094. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5095. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5096. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5097. list.Add(depName);
  5098. list.Add(arrName);
  5099. }
  5100. list = list.Distinct().ToList();
  5101. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5102. }
  5103. catch (Exception)
  5104. {
  5105. dic.Add("ReturnCode", "行程录入不正确!");
  5106. }
  5107. }
  5108. else
  5109. {
  5110. dic.Add("ReturnCode", "未录入行程!");
  5111. }
  5112. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5113. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5114. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5115. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5116. {
  5117. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5118. dic.Add("Day", sp.Days.ToString());
  5119. }
  5120. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5121. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5122. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5123. //dic.Add("Names", Names);
  5124. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5125. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5126. decimal dac1totalPrice = 0.00M;
  5127. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5128. foreach (var dac in dac1)
  5129. {
  5130. if (dac.SubTotal == 0.00M)
  5131. {
  5132. continue;
  5133. }
  5134. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5135. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5136. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5137. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5138. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5139. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5140. builder.Write(currency);//币种
  5141. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5142. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5143. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5144. builder.Write("");//人数
  5145. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5146. builder.Write("");//天数
  5147. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5148. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5149. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5150. decimal rate = 0.00M;
  5151. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5152. builder.Write(rate.ToString("#0.0000"));//汇率
  5153. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5154. decimal rbmPrice = dac.SubTotal;
  5155. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5156. accommodationStartIndex++;
  5157. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5158. }
  5159. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5160. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5161. {
  5162. table1.Rows.RemoveAt(i - 1);
  5163. foodandotherStartIndex--;
  5164. }
  5165. if (dac2.Count == dac3.Count)//国家 币种 金额
  5166. {
  5167. for (int i = 0; i < dac2.Count; i++)
  5168. {
  5169. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5170. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5171. }
  5172. }
  5173. decimal dac2totalPrice = 0.00M;
  5174. foreach (var dac in dac2)
  5175. {
  5176. if (dac.SubTotal == 0)
  5177. {
  5178. continue;
  5179. }
  5180. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5181. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5182. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5183. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5184. builder.Write(currency);//币种
  5185. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5186. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5187. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5188. builder.Write("");//人数
  5189. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5190. builder.Write("");//天数
  5191. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5192. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5193. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5194. decimal rate = 0.00M;
  5195. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5196. builder.Write(rate.ToString("#0.0000"));//汇率
  5197. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5198. decimal rbmPrice = dac.SubTotal;
  5199. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5200. foodandotherStartIndex++;
  5201. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5202. }
  5203. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5204. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5205. {
  5206. table1.Rows.RemoveAt(i - 1);
  5207. }
  5208. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5209. string otherFeeStr = "";
  5210. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5211. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5212. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5213. if (otherFeeStr.Length > 0)
  5214. {
  5215. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5216. otherFeeStr = $"({otherFeeStr})";
  5217. dic.Add("OtherFeeStr", otherFeeStr);
  5218. }
  5219. //总计
  5220. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5221. //国际旅费
  5222. string outsideAir = string.Empty;
  5223. string allPriceAir = string.Empty;
  5224. if (_EnterExitCosts.SumJJC == 1)
  5225. {
  5226. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5227. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5228. }
  5229. if (_EnterExitCosts.SumGWC == 1)
  5230. {
  5231. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5232. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5233. }
  5234. if (_EnterExitCosts.SumTDC == 1)
  5235. {
  5236. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5237. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5238. }
  5239. dic.Add("InTravelPrice", $"({outsideAir})");
  5240. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5241. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5242. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5243. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5244. foreach (var key in dic.Keys)
  5245. {
  5246. builder.MoveToBookmark(key);
  5247. builder.Write(dic[key]);
  5248. }
  5249. //模板文件名
  5250. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5251. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5252. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5253. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5254. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5255. }
  5256. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5257. {
  5258. //获取模板
  5259. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5260. //载入模板
  5261. WorkbookDesigner designer = new WorkbookDesigner();
  5262. designer.Workbook = new Workbook(tempPath);
  5263. Dictionary<string, string> dic = new Dictionary<string, string>();
  5264. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5265. {
  5266. List<string> list = new List<string>();
  5267. try
  5268. {
  5269. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5270. foreach (var item in spilitArr)
  5271. {
  5272. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5273. var depCode = spDotandEmpty[2].Substring(0, 3);
  5274. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5275. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5276. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5277. list.Add(depName);
  5278. list.Add(arrName);
  5279. }
  5280. list = list.Distinct().ToList();
  5281. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5282. }
  5283. catch (Exception)
  5284. {
  5285. dic.Add("ReturnCode", "行程录入不正确!");
  5286. }
  5287. }
  5288. else
  5289. {
  5290. dic.Add("ReturnCode", "未录入行程!");
  5291. }
  5292. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5293. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5294. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5295. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5296. {
  5297. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5298. dic.Add("Day", sp.Days.ToString());
  5299. }
  5300. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5301. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5302. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5303. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5304. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5305. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5306. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5307. designer.SetDataSource("Name", Names);
  5308. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5309. designer.SetDataSource("Day", dic["Day"] + "天");
  5310. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5311. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5312. int startIndex = 10;
  5313. const int startIndexcopy = 10;
  5314. if (dac2.Count == dac3.Count)//国家 币种 金额
  5315. {
  5316. for (int i = 0; i < dac2.Count; i++)
  5317. {
  5318. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5319. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5320. }
  5321. }
  5322. DataTable dtdac1 = new DataTable();
  5323. List<string> place = new List<string>();
  5324. dtdac1.Columns.AddRange(new DataColumn[] {
  5325. new DataColumn(){ ColumnName = "city"},
  5326. new DataColumn(){ ColumnName = "curr"},
  5327. new DataColumn(){ ColumnName = "criterion"},
  5328. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5329. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5330. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5331. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5332. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5333. });
  5334. DataTable dtdac2 = new DataTable();
  5335. dtdac2.Columns.AddRange(new DataColumn[] {
  5336. new DataColumn(){ ColumnName = "city"},
  5337. new DataColumn(){ ColumnName = "curr"},
  5338. new DataColumn(){ ColumnName = "criterion"},
  5339. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5340. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5341. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5342. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5343. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5344. });
  5345. dtdac1.TableName = "tb1";
  5346. dtdac2.TableName = "tb2";
  5347. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5348. foreach (var item in dac1)
  5349. {
  5350. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5351. if (place.Contains(item.Place))
  5352. {
  5353. continue;
  5354. }
  5355. DataRow row = dtdac1.NewRow();
  5356. row["city"] = item.Place;
  5357. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5358. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5359. row["curr"] = currency;
  5360. row["rate"] = rate.ToString("#0.0000");
  5361. row["criterion"] = item.Cost.ToString("#0.00");
  5362. row["number"] = 1;
  5363. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5364. //row["costRMB"] = rbmPrice;
  5365. dtdac1.Rows.Add(row);
  5366. place.Add(item.Place);
  5367. }
  5368. place = new List<string>();
  5369. foreach (var item in dac2)
  5370. {
  5371. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5372. if (place.Contains(item.Place))
  5373. {
  5374. continue;
  5375. }
  5376. DataRow row = dtdac2.NewRow();
  5377. row["city"] = item.Place;
  5378. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5379. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5380. row["curr"] = currency;
  5381. row["rate"] = rate.ToString("#0.0000");
  5382. row["criterion"] = item.Cost.ToString("#0.00");
  5383. row["number"] = 1;
  5384. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5385. //row["cost"] = item.SubTotal;
  5386. //row["costRMB"] = rbmPrice;
  5387. dtdac2.Rows.Add(row);
  5388. place.Add(item.Place);
  5389. //dac2totalPrice += rbmPrice;
  5390. }
  5391. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5392. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5393. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5394. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5395. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5396. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5397. string cell4Str1 = string.Empty;
  5398. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5399. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5400. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5401. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5402. string cellStr = $" 5.其他费用(";
  5403. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5404. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5405. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5406. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5407. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5408. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5409. if (cellStr.Length > 8)
  5410. {
  5411. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5412. }
  5413. cellStr += ")";
  5414. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5415. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5416. decimal pxFee = dac4.Sum(it => it.Cost);
  5417. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5418. string celllastStr1 = "";
  5419. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5420. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5421. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5422. celllastStr1 += $",国际旅费 元";
  5423. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5424. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5425. designer.SetDataSource("cell4Str", cell4Str);
  5426. designer.SetDataSource("cellStr", cellStr);
  5427. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5428. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5429. designer.SetDataSource("celllastStr", celllastStr);
  5430. Workbook wb = designer.Workbook;
  5431. var sheet = wb.Worksheets[0];
  5432. //绑定datatable数据集
  5433. designer.SetDataSource(dtdac1);
  5434. designer.SetDataSource(dtdac2);
  5435. designer.Process();
  5436. var rowStart = dtdac1.Rows.Count;
  5437. while (rowStart > 0)
  5438. {
  5439. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5440. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5441. startIndex++;
  5442. rowStart--;
  5443. }
  5444. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5445. startIndex += 1; //总计行
  5446. rowStart = dtdac2.Rows.Count;
  5447. while (rowStart > 0)
  5448. {
  5449. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5450. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5451. startIndex++;
  5452. rowStart--;
  5453. }
  5454. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5455. wb.CalculateFormula(true);
  5456. //模板文件名
  5457. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5458. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5459. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5460. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5461. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5462. }
  5463. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5464. {
  5465. //获取模板
  5466. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5467. //载入模板
  5468. Document doc = new Document(tempPath);
  5469. DocumentBuilder builder = new DocumentBuilder(doc);
  5470. Dictionary<string, string> dic = new Dictionary<string, string>();
  5471. dic.Add("GroupName", _DelegationInfo.TeamName);
  5472. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5473. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5474. string missionLeaderJob = "";//负责人job
  5475. int groupNumber = 0; //团人数
  5476. if (DeleClientList.Count > 0)
  5477. {
  5478. missionLeader = DeleClientList[0]?.Name ?? "";
  5479. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5480. }
  5481. dic.Add("MissionLeader", missionLeader); //团负责人
  5482. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5483. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5484. #region MyRegion
  5485. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5486. //{
  5487. // List<string> list = new List<string>();
  5488. // try
  5489. // {
  5490. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5491. // foreach (var item in spilitArr)
  5492. // {
  5493. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5494. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5495. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5496. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5497. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5498. // list.Add(depName);
  5499. // list.Add(arrName);
  5500. // }
  5501. // list = list.Distinct().ToList();
  5502. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5503. // }
  5504. // catch (Exception)
  5505. // {
  5506. // dic.Add("ReturnCode", "行程录入不正确!");
  5507. // }
  5508. //}
  5509. //else
  5510. //{
  5511. // dic.Add("ReturnCode", "未录入行程!");
  5512. //}
  5513. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5514. dic.Add("ReturnCode", string.Join("、", countrys));
  5515. #endregion
  5516. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5517. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5518. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5519. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5520. //{
  5521. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5522. // dic.Add("Day", sp.Days.ToString());
  5523. //}
  5524. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5525. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5526. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5527. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5528. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5529. //培训人员名单
  5530. int cultivateRowIndex = 7;
  5531. foreach (var item in DeleClientList)
  5532. {
  5533. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5534. builder.Write(item.Name);
  5535. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5536. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5537. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5538. string birthDay = "";
  5539. if (item.Birthday != null)
  5540. {
  5541. DateTime dt = Convert.ToDateTime(item.Birthday);
  5542. birthDay = $"{dt.Year}.{dt.Month}";
  5543. }
  5544. builder.Write(birthDay);
  5545. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5546. builder.Write(item.Company);
  5547. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5548. builder.Write(item.Job);
  5549. cultivateRowIndex++;
  5550. }
  5551. //删除多余行
  5552. //cultivateRowIndex -= 2;
  5553. int delRows = 10 + 7 - cultivateRowIndex;
  5554. if (delRows > 0)
  5555. {
  5556. for (int i = 0; i < delRows; i++)
  5557. {
  5558. table1.Rows.RemoveAt(cultivateRowIndex);
  5559. //cultivateRowIndex++;
  5560. }
  5561. }
  5562. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5563. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5564. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5565. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5566. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5567. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5568. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5569. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5570. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5571. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5572. //其他费用
  5573. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5574. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5575. //其他费用合计
  5576. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5577. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5578. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5579. //公务舱合计
  5580. //国际旅费
  5581. string outsideJJ = "";
  5582. string allPriceJJ = "";
  5583. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5584. {
  5585. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5586. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5587. }
  5588. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5589. {
  5590. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5591. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5592. }
  5593. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5594. {
  5595. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5596. dic.Add("AirFeeTotal", airFeeTotalStr);
  5597. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5598. dic.Add("FeeTotal", feeTotalStr);
  5599. }
  5600. foreach (var key in dic.Keys)
  5601. {
  5602. builder.MoveToBookmark(key);
  5603. builder.Write(dic[key]);
  5604. }
  5605. //模板文件名
  5606. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5607. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5608. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5609. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5610. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5611. }
  5612. }
  5613. else if (dto.ExportType == 2) //表格
  5614. {
  5615. //利用键值对存放数据
  5616. Dictionary<string, string> dic = new Dictionary<string, string>();
  5617. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5618. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5619. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5620. dic.Add("Day", sp.Days.ToString());
  5621. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5622. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5623. {
  5624. //获取模板
  5625. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5626. //载入模板
  5627. Document doc = new Document(tempPath);
  5628. DocumentBuilder builder = new DocumentBuilder(doc);
  5629. dic.Add("TeamName", _DelegationInfo.TeamName);
  5630. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5631. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5632. string missionLeaderName = "",
  5633. missionLeaderJob = "";
  5634. if (DeleClientList.Count > 0)
  5635. {
  5636. missionLeaderName = DeleClientList[0].Name;
  5637. missionLeaderJob = DeleClientList[0].Job;
  5638. }
  5639. dic.Add("MissionLeaderName", missionLeaderName);
  5640. dic.Add("MissionLeaderJob", missionLeaderJob);
  5641. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5642. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5643. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5644. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5645. int rowCount = 10;//总人数行
  5646. int startRowIndex = 7; //起始行
  5647. for (int i = 0; i < DeleClientList.Count; i++)
  5648. {
  5649. builder.MoveToCell(0, startRowIndex, 0, 0);
  5650. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5651. builder.MoveToCell(0, startRowIndex, 1, 0);
  5652. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5653. builder.Write(sex);//性别
  5654. builder.MoveToCell(0, startRowIndex, 2, 0);
  5655. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5656. builder.MoveToCell(0, startRowIndex, 3, 0);
  5657. builder.Write(DeleClientList[i].Company);//工作单位
  5658. builder.MoveToCell(0, startRowIndex, 4, 0);
  5659. builder.Write(DeleClientList[i].Job);//职务及级别
  5660. builder.MoveToCell(0, startRowIndex, 5, 0);
  5661. builder.Write("");//人员属性
  5662. builder.MoveToCell(0, startRowIndex, 6, 0);
  5663. builder.Write("");//上次出国时间
  5664. startRowIndex++;
  5665. }
  5666. int nullRow = rowCount - DeleClientList.Count;//空行
  5667. for (int i = 0; i < nullRow; i++)
  5668. {
  5669. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5670. }
  5671. foreach (var key in dic.Keys)
  5672. {
  5673. builder.MoveToBookmark(key);
  5674. builder.Write(dic[key]);
  5675. }
  5676. //模板文件名
  5677. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5678. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5679. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5680. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5681. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5682. }
  5683. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5684. {
  5685. //获取模板
  5686. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5687. //载入模板
  5688. Document doc = new Document(tempPath);
  5689. DocumentBuilder builder = new DocumentBuilder(doc);
  5690. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5691. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5692. dic.Add("Names", Names);
  5693. int accommodationRows = 12, foodandotherRows = 12;
  5694. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5695. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5696. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5697. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5698. int accommodationStartIndex = 6;
  5699. decimal dac1totalPrice = 0.00M;
  5700. foreach (var dac in dac1)
  5701. {
  5702. if (dac.SubTotal == 0)
  5703. {
  5704. continue;
  5705. }
  5706. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5707. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5708. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5709. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5710. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5711. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5712. builder.Write(currency);//币种
  5713. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5714. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5715. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5716. builder.Write("");//人数
  5717. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5718. builder.Write("");//天数
  5719. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5720. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5721. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5722. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5723. builder.Write(rate.ToString("#0.0000"));//汇率
  5724. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5725. decimal rbmPrice = rate * dac.SubTotal;
  5726. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5727. accommodationStartIndex++;
  5728. dac1totalPrice += rbmPrice;
  5729. }
  5730. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5731. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5732. builder.Write("小计");
  5733. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5734. builder.Write(dac1totalPrice.ToString("#0.00"));
  5735. accommodationStartIndex++;
  5736. int nullRow = accommodationRows - dac1.Count;
  5737. //删除空行
  5738. //if (nullRow > 0)
  5739. //{
  5740. // int rowIndex = accommodationStartIndex;
  5741. // for (int i = 0; i < nullRow; i++)
  5742. // {
  5743. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5744. // row.Remove();
  5745. // rowIndex++;
  5746. // }
  5747. //}
  5748. if (dac2.Count == dac3.Count)//国家 币种 金额
  5749. {
  5750. for (int i = 0; i < dac2.Count; i++)
  5751. {
  5752. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5753. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5754. }
  5755. }
  5756. int foodandotherStartIndex = 19;//
  5757. decimal dac2totalPrice = 0.00M;
  5758. foreach (var dac in dac2)
  5759. {
  5760. if (dac.SubTotal == 0)
  5761. {
  5762. continue;
  5763. }
  5764. //foodandotherStartIndex = 12;
  5765. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5766. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5767. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5768. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5769. builder.Write(currency);//币种
  5770. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5771. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5772. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5773. builder.Write("");//人数
  5774. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5775. builder.Write("");//天数
  5776. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5777. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5778. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5779. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5780. builder.Write(rate.ToString("#0.0000"));//汇率
  5781. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5782. decimal rbmPrice = rate * dac.SubTotal;
  5783. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5784. foodandotherStartIndex++;
  5785. dac2totalPrice += rbmPrice;
  5786. }
  5787. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5788. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5789. //删除空行
  5790. //if (dac2.Count < foodandotherRows)
  5791. //{
  5792. // while (table2.Rows.Count > dac2.Count)
  5793. // {
  5794. // table2.Rows.RemoveAt(dac2.Count);
  5795. // }
  5796. //}
  5797. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5798. string otherFeeStr = "";
  5799. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5800. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5801. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5802. if (otherFeeStr.Length > 0)
  5803. {
  5804. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5805. otherFeeStr = $"({otherFeeStr})";
  5806. dic.Add("OtherFeeStr", otherFeeStr);
  5807. }
  5808. foreach (var key in dic.Keys)
  5809. {
  5810. builder.MoveToBookmark(key);
  5811. builder.Write(dic[key]);
  5812. }
  5813. //模板文件名
  5814. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5815. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5816. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5817. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5818. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5819. }
  5820. }
  5821. else if (dto.ExportType == 3)
  5822. {
  5823. if (dto.SubTypeId == 1) //团组成员名单
  5824. {
  5825. if (DeleClientList.Count < 1)
  5826. {
  5827. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5828. }
  5829. //获取模板
  5830. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5831. //载入模板
  5832. Document doc = new Document(tempPath);
  5833. DocumentBuilder builder = new DocumentBuilder(doc);
  5834. //获取word里所有表格
  5835. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5836. //获取所填表格的序数
  5837. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5838. var rowStart = tableOne.Rows[0]; //获取第1行
  5839. //循环赋值
  5840. for (int i = 0; i < DeleClientList.Count; i++)
  5841. {
  5842. builder.MoveToCell(0, i + 1, 0, 0);
  5843. builder.Write(DeleClientList[i].Name);
  5844. builder.MoveToCell(0, i + 1, 1, 0);
  5845. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5846. builder.Write(sex);
  5847. builder.MoveToCell(0, i + 1, 2, 0);
  5848. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5849. builder.MoveToCell(0, i + 1, 3, 0);
  5850. builder.Write(DeleClientList[i].Company);
  5851. builder.MoveToCell(0, i + 1, 4, 0);
  5852. builder.Write(DeleClientList[i].Job);
  5853. }
  5854. //删除多余行
  5855. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5856. {
  5857. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5858. }
  5859. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5860. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5861. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5862. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5863. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5864. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5865. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5866. }
  5867. }
  5868. return Ok(JsonView(400, "操作失败!", ""));
  5869. }
  5870. catch (Exception ex)
  5871. {
  5872. return Ok(JsonView(400, ex.Message, ""));
  5873. }
  5874. }
  5875. /// <summary>
  5876. /// 获取三公费用标准city
  5877. /// </summary>
  5878. /// <param name="placeData"></param>
  5879. /// <param name="nationalTravelFeeId"></param>
  5880. /// <returns></returns>
  5881. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5882. {
  5883. string _city = string.Empty;
  5884. if (placeData.Count < 1) return _city;
  5885. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5886. if (data == null) return _city;
  5887. string country = data.Country;
  5888. string city = data.City;
  5889. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5890. else _city = city;
  5891. return _city;
  5892. }
  5893. /// <summary>
  5894. /// 团组模块 - 出入境费用 - 明细表导出
  5895. /// </summary>
  5896. /// <returns></returns>
  5897. [HttpPost]
  5898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5899. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5900. {
  5901. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5902. if (data.Code != 0)
  5903. {
  5904. return Ok(JsonView(false, data.Msg));
  5905. }
  5906. return Ok(JsonView(true, data.Msg, data.Data));
  5907. }
  5908. /// <summary>
  5909. /// 团组模块 - 出入境费用 - 一键清空
  5910. /// </summary>
  5911. /// <returns></returns>
  5912. [HttpPost]
  5913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5914. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5915. {
  5916. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5917. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5918. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5919. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5920. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5921. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5922. .SetColumns(x => new Grp_DayOtherPrice
  5923. {
  5924. IsDel = 1,
  5925. DeleteUserId = dto.UserId,
  5926. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5927. })
  5928. .ExecuteCommandAsync();
  5929. if (_view.Code == 0)
  5930. {
  5931. return Ok(JsonView(true, "操作成功"));
  5932. }
  5933. return Ok(JsonView(false, "操作失败"));
  5934. }
  5935. /// <summary>
  5936. /// 团组模块 - 出入境费用 - 子项删除
  5937. /// </summary>
  5938. /// <returns></returns>
  5939. [HttpPost]
  5940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5941. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5942. {
  5943. try
  5944. {
  5945. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5946. if (data.Code != 0)
  5947. {
  5948. return Ok(JsonView(false, data.Msg));
  5949. }
  5950. return Ok(JsonView(true, "操作成功!", data.Data));
  5951. }
  5952. catch (Exception ex)
  5953. {
  5954. return Ok(JsonView(false, ex.Message));
  5955. }
  5956. }
  5957. /// <summary>
  5958. /// 删除三公其他费用
  5959. /// </summary>
  5960. /// <param name="dto"></param>
  5961. /// <returns></returns>
  5962. [HttpPost]
  5963. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  5964. {
  5965. var jw = JsonView(false,"删除失败!");
  5966. var data = new Grp_DayOtherPrice()
  5967. {
  5968. Id = dto.Id,
  5969. IsDel = 1,
  5970. DeleteUserId = dto.DeleteUserId,
  5971. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  5972. };
  5973. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  5974. if (del > 0)
  5975. {
  5976. jw.Code = 200;
  5977. jw.Msg = "删除成功!";
  5978. }
  5979. return Ok(jw);
  5980. }
  5981. /// <summary>
  5982. /// 团组模块 - 出入境国家费用标准 List
  5983. /// </summary>
  5984. /// <returns></returns>
  5985. [HttpPost]
  5986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5987. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5988. {
  5989. try
  5990. {
  5991. Stopwatch sw = new Stopwatch();
  5992. sw.Start();
  5993. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5994. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5995. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5996. Where gntf.Isdel = 0");
  5997. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5998. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5999. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6000. //foreach (var item in nationalTravel)
  6001. //{
  6002. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6003. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6004. // if (otherData != null)
  6005. // {
  6006. // cityData.Remove(otherData);
  6007. // cityData.Add(otherData);
  6008. // }
  6009. // nationalTravelFeeData1.Add(new
  6010. // {
  6011. // Country = item.Country,
  6012. // CityData = cityData
  6013. // });
  6014. //}
  6015. sw.Stop();
  6016. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6017. }
  6018. catch (Exception ex)
  6019. {
  6020. return Ok(JsonView(false, ex.Message));
  6021. throw;
  6022. }
  6023. }
  6024. /// <summary>
  6025. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6026. /// </summary>
  6027. /// <returns></returns>
  6028. [HttpPost]
  6029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6030. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6031. {
  6032. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6033. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6034. List<string> countryData = new List<string>();
  6035. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6036. countryData = countryData.Distinct().ToList();
  6037. List<dynamic> dataSource = new List<dynamic>();
  6038. foreach (var item in countryData)
  6039. {
  6040. List<string> cityData1 = new List<string>();
  6041. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6042. var countryData2 = new
  6043. {
  6044. CountryName = item,
  6045. CityData = cityData1
  6046. };
  6047. dataSource.Add(countryData2);
  6048. }
  6049. return Ok(JsonView(true, "查询成功!", dataSource));
  6050. }
  6051. /// <summary>
  6052. /// 团组模块 - 出入境国家费用标准 Page List
  6053. /// </summary>
  6054. /// <returns></returns>
  6055. [HttpPost]
  6056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6057. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6058. {
  6059. int portId = dto.PortType;
  6060. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6061. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6062. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6063. string whereSql = string.Empty;
  6064. if (!string.IsNullOrEmpty(dto.Country))
  6065. {
  6066. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6067. }
  6068. if (!string.IsNullOrEmpty(dto.City))
  6069. {
  6070. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6071. }
  6072. string pageSql = string.Format(@"Select * From (
  6073. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6074. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6075. From Grp_NationalTravelFee gntf
  6076. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6077. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6078. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6079. RefAsync<int> total = 0;
  6080. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6081. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6082. }
  6083. /// <summary>
  6084. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6085. /// </summary>
  6086. /// <returns></returns>
  6087. [HttpPost]
  6088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6089. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6090. {
  6091. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6092. int portId = dto.PortType;
  6093. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6094. string whereSql = string.Empty;
  6095. if (!string.IsNullOrEmpty(dto.Country))
  6096. {
  6097. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6098. }
  6099. if (!string.IsNullOrEmpty(dto.City))
  6100. {
  6101. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6102. }
  6103. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6104. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6105. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6106. From Grp_NationalTravelFee gntf
  6107. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6108. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6109. Where gntf.Isdel = 0 {0} ", whereSql);
  6110. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6111. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6112. }
  6113. /// <summary>
  6114. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6115. /// </summary>
  6116. /// <returns></returns>
  6117. [HttpPost]
  6118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6119. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6120. {
  6121. try
  6122. {
  6123. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6124. if (data.Code != 0)
  6125. {
  6126. return Ok(JsonView(false, data.Msg));
  6127. }
  6128. return Ok(JsonView(true, "操作成功!", data.Data));
  6129. }
  6130. catch (Exception ex)
  6131. {
  6132. return Ok(JsonView(false, ex.Message));
  6133. }
  6134. }
  6135. /// <summary>
  6136. /// 团组模块 - 出入境国家费用标准 - Del
  6137. /// </summary>
  6138. /// <returns></returns>
  6139. [HttpPost]
  6140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6141. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6142. {
  6143. try
  6144. {
  6145. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6146. {
  6147. Id = dto.Id,
  6148. DeleteUserId = dto.DeleteUserId,
  6149. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6150. IsDel = 1
  6151. };
  6152. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6153. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6154. .WhereColumns(it => new { it.Id })
  6155. .ExecuteCommandAsync();
  6156. if (delStatus <= 0)
  6157. {
  6158. return Ok(JsonView(false, "删除失败!"));
  6159. }
  6160. return Ok(JsonView(true, "操作成功!"));
  6161. }
  6162. catch (Exception ex)
  6163. {
  6164. return Ok(JsonView(false, ex.Message));
  6165. }
  6166. }
  6167. /// <summary>
  6168. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6169. /// 注:Get 请求Headers 加 Token
  6170. /// </summary>
  6171. /// <param name="groupId"></param>
  6172. /// <returns></returns>
  6173. [HttpGet("{groupId}")]
  6174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6175. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6176. {
  6177. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6178. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6179. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6180. data.ForEach(x =>
  6181. {
  6182. x.CreateUserId = _currUserInfo.UserId;
  6183. });
  6184. if (data.Count > 0)
  6185. {
  6186. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6187. if (add > 0)
  6188. {
  6189. return Ok(JsonView(true, "操作成功!"));
  6190. }
  6191. }
  6192. return Ok(JsonView(false, "未操作!"));
  6193. }
  6194. #endregion
  6195. #region 签证费用录入
  6196. /// <summary>
  6197. /// 根据diid查询签证费用列表
  6198. /// </summary>
  6199. /// <param name="dto"></param>
  6200. /// <returns></returns>
  6201. [HttpPost]
  6202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6203. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6204. {
  6205. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6206. if (groupData.Code != 0)
  6207. {
  6208. return Ok(JsonView(false, groupData.Msg));
  6209. }
  6210. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6211. }
  6212. /// <summary>
  6213. /// 根据签证费用Id查询单条数据及c表数据
  6214. /// </summary>
  6215. /// <param name="dto"></param>
  6216. /// <returns></returns>
  6217. [HttpPost]
  6218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6219. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6220. {
  6221. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6222. if (groupData.Code != 0)
  6223. {
  6224. return Ok(JsonView(false, groupData.Msg));
  6225. }
  6226. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6227. }
  6228. /// <summary>
  6229. /// 签证费用删除
  6230. /// </summary>
  6231. /// <param name="dto"></param>
  6232. /// <returns></returns>
  6233. [HttpPost]
  6234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6235. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6236. {
  6237. _sqlSugar.BeginTran();
  6238. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6239. if (!res)
  6240. {
  6241. _sqlSugar.RollbackTran();
  6242. return Ok(JsonView(false, "删除失败"));
  6243. }
  6244. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6245. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6246. .SetColumns(a => new Grp_CreditCardPayment()
  6247. {
  6248. IsDel = 1,
  6249. DeleteUserId = dto.DeleteUserId,
  6250. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6251. })
  6252. .ExecuteCommand();
  6253. if (resSub < 1)
  6254. {
  6255. _sqlSugar.RollbackTran();
  6256. return Ok(JsonView(false, "删除失败"));
  6257. }
  6258. _sqlSugar.CommitTran();
  6259. return Ok(JsonView(true, "删除成功!"));
  6260. }
  6261. /// <summary>
  6262. /// 签证费用录入下拉框初始化
  6263. /// </summary>
  6264. /// <returns></returns>
  6265. [HttpPost]
  6266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6267. public async Task<IActionResult> VisaPriceAddSelect()
  6268. {
  6269. //支付方式
  6270. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6271. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6272. //币种
  6273. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6274. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6275. //乘客类型
  6276. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6277. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6278. //卡类型
  6279. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6280. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6281. //代办费类型
  6282. var agencyFeeTypeData = new List<dynamic>() {
  6283. new { id = 0 , Text = "未选择" },
  6284. new { id = 1 , Text = "小公务" },
  6285. new { id = 2 , Text = "大公务" },
  6286. };
  6287. //签证费用标准国家Data
  6288. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  6289. var data = new
  6290. {
  6291. Payment = _Payment,
  6292. CurrencyList = _CurrencyList,
  6293. PassengerType = _PassengerType,
  6294. BankCard = _BankCard,
  6295. AgencyFeeType = agencyFeeTypeData,
  6296. CountryFeeData = visaCountryFeeData
  6297. };
  6298. return Ok(JsonView(true, "查询成功!", data));
  6299. }
  6300. /// <summary>
  6301. /// 签证费用录入操作(Status:1.新增,2.修改)
  6302. /// </summary>
  6303. /// <param name="dto"></param>
  6304. /// <returns></returns>
  6305. [HttpPost]
  6306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6307. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6308. {
  6309. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6310. if (groupData.Code != 0)
  6311. {
  6312. return Ok(JsonView(false, groupData.Msg));
  6313. }
  6314. #region 应用推送
  6315. try
  6316. {
  6317. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6318. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6319. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6320. //2024-10-21 新增LZ UID
  6321. var userIds = new List<int>() { 21 };
  6322. string title = $"系统通知";
  6323. string content = "";
  6324. var diId = dto.DiId;
  6325. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6326. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6327. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6328. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6329. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6330. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content);
  6331. }
  6332. catch (Exception ex)
  6333. {
  6334. }
  6335. #endregion
  6336. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6337. }
  6338. #endregion
  6339. #region 签证提成录入
  6340. /// <summary>
  6341. /// 签证提成录入
  6342. /// 基础数据
  6343. /// </summary>
  6344. /// <param name="_dto"></param>
  6345. /// <returns></returns>
  6346. [HttpGet]
  6347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6348. public async Task<IActionResult> VisaCommissionInit()
  6349. {
  6350. return Ok(await _visaCommissionRep.Init());
  6351. }
  6352. /// <summary>
  6353. /// 签证提成录入
  6354. /// Item
  6355. /// </summary>
  6356. /// <param name="_dto"></param>
  6357. /// <returns></returns>
  6358. [HttpPost]
  6359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6360. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6361. {
  6362. var validator = new VisaCommissionItemDtoValidator();
  6363. var validatorRes = await validator.ValidateAsync(_dto);
  6364. if (!validatorRes.IsValid)
  6365. {
  6366. StringBuilder sb = new StringBuilder();
  6367. foreach (var item in validatorRes.Errors)
  6368. {
  6369. sb.AppendLine(item.ErrorMessage);
  6370. }
  6371. return Ok(JsonView(false, sb.ToString()));
  6372. }
  6373. return Ok(await _visaCommissionRep.Item(_dto));
  6374. }
  6375. /// <summary>
  6376. /// 签证提成录入
  6377. /// Save
  6378. /// </summary>
  6379. /// <param name="_dto"></param>
  6380. /// <returns></returns>
  6381. [HttpPost]
  6382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6383. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6384. {
  6385. //参数验证
  6386. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6387. foreach (var item in _dto.Items)
  6388. {
  6389. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6390. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6391. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6392. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6393. }
  6394. return Ok(await _visaCommissionRep.Save(_dto));
  6395. }
  6396. /// <summary>
  6397. /// 签证提成录入
  6398. /// Create
  6399. /// </summary>
  6400. /// <param name="_dto"></param>
  6401. /// <returns></returns>
  6402. [HttpPost]
  6403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6404. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6405. {
  6406. var validator = new VisaCommissionCreateDtoValidator();
  6407. var validatorRes = await validator.ValidateAsync(_dto);
  6408. if (!validatorRes.IsValid)
  6409. {
  6410. StringBuilder sb = new StringBuilder();
  6411. foreach (var item in validatorRes.Errors)
  6412. {
  6413. sb.AppendLine(item.ErrorMessage);
  6414. }
  6415. return Ok(JsonView(false, sb.ToString()));
  6416. }
  6417. return Ok(await _visaCommissionRep.Create(_dto));
  6418. }
  6419. /// <summary>
  6420. /// 签证提成录入
  6421. /// Put(编辑)
  6422. /// </summary>
  6423. /// <param name="id"></param>
  6424. /// <param name="_dto"></param>
  6425. /// <returns></returns>
  6426. [HttpPut]
  6427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6428. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6429. {
  6430. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6431. var validator = new VisaCommissionCreateDtoValidator();
  6432. var validatorRes = await validator.ValidateAsync(_dto);
  6433. if (!validatorRes.IsValid)
  6434. {
  6435. StringBuilder sb = new StringBuilder();
  6436. foreach (var item in validatorRes.Errors)
  6437. {
  6438. sb.AppendLine(item.ErrorMessage);
  6439. }
  6440. return Ok(JsonView(false, sb.ToString()));
  6441. }
  6442. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6443. }
  6444. /// <summary>
  6445. /// 签证提成录入
  6446. /// Del
  6447. /// </summary>
  6448. /// <param name="id"></param>
  6449. /// <param name="currUserId"></param>
  6450. /// <returns></returns>
  6451. [HttpPost]
  6452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6453. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6454. {
  6455. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6456. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6457. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6458. }
  6459. #endregion
  6460. #region op费用录入
  6461. /// <summary>
  6462. /// 根据diid查询op费用列表
  6463. /// </summary>
  6464. /// <param name="dto"></param>
  6465. /// <returns></returns>
  6466. [HttpPost]
  6467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6468. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6469. {
  6470. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6471. if (groupData.Code != 0)
  6472. {
  6473. return Ok(JsonView(false, groupData.Msg));
  6474. }
  6475. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6476. }
  6477. /// <summary>
  6478. /// 根据op费用Id查询单条数据及c表数据
  6479. /// </summary>
  6480. /// <param name="dto"></param>
  6481. /// <returns></returns>
  6482. [HttpPost]
  6483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6484. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6485. {
  6486. try
  6487. {
  6488. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6489. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6490. var data = new
  6491. {
  6492. CarTouristGuideGround = _groupData,
  6493. CreditCardPayment = _creditCardPayment
  6494. };
  6495. return Ok(JsonView(true, "查询成功!", data));
  6496. }
  6497. catch (Exception ex)
  6498. {
  6499. return Ok(JsonView(false, "程序错误!"));
  6500. }
  6501. }
  6502. /// <summary>
  6503. /// op费用删除
  6504. /// </summary>
  6505. /// <param name="dto"></param>
  6506. /// <returns></returns>
  6507. [HttpPost]
  6508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6509. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6510. {
  6511. try
  6512. {
  6513. _sqlSugar.BeginTran();
  6514. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6515. if (!res)
  6516. {
  6517. return Ok(JsonView(false, "删除失败"));
  6518. }
  6519. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6520. {
  6521. IsDel = 1,
  6522. DeleteUserId = dto.DeleteUserId,
  6523. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6524. }).ExecuteCommandAsync();
  6525. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6526. {
  6527. IsDel = 1,
  6528. DeleteUserId = dto.DeleteUserId,
  6529. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6530. }).ExecuteCommandAsync();
  6531. #region 删除超支相关数据
  6532. //删除导入的超支数据
  6533. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6534. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6535. {
  6536. IsDel = 1,
  6537. DeleteUserId = dto.DeleteUserId,
  6538. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6539. }).ExecuteCommand();
  6540. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6541. {
  6542. IsDel = 1,
  6543. DeleteUserId = dto.DeleteUserId,
  6544. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6545. }).ExecuteCommand();
  6546. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6547. {
  6548. IsDel = 1,
  6549. DeleteUserId = dto.DeleteUserId,
  6550. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6551. }).ExecuteCommand();
  6552. #endregion
  6553. _sqlSugar.CommitTran();
  6554. return Ok(JsonView(true, "删除成功!"));
  6555. }
  6556. catch (Exception ex)
  6557. {
  6558. _sqlSugar.RollbackTran();
  6559. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6560. }
  6561. }
  6562. /// <summary>
  6563. /// op费用录入操作(Status:1.新增,2.修改)
  6564. /// </summary>
  6565. /// <param name="dto"></param>
  6566. /// <returns></returns>
  6567. [HttpPost]
  6568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6569. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6570. {
  6571. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6572. if (groupData.Code != 0)
  6573. {
  6574. return Ok(JsonView(false, groupData.Msg));
  6575. }
  6576. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6577. }
  6578. /// <summary>
  6579. /// 填写费用详细页面初始化绑定
  6580. /// </summary>
  6581. /// <param name="dto"></param>
  6582. /// <returns></returns>
  6583. [HttpPost]
  6584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6585. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6586. {
  6587. try
  6588. {
  6589. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6590. if (groupData.Code != 0)
  6591. {
  6592. return Ok(JsonView(false, groupData.Msg));
  6593. }
  6594. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6595. }
  6596. catch (Exception ex)
  6597. {
  6598. return Ok(JsonView(false, ex.Message));
  6599. }
  6600. }
  6601. /// <summary>
  6602. /// 根据op费用Id查询详细数据
  6603. /// </summary>
  6604. /// <param name="dto"></param>
  6605. /// <returns></returns>
  6606. [HttpPost]
  6607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6608. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6609. {
  6610. try
  6611. {
  6612. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6613. if (groupData.Code != 0)
  6614. {
  6615. return Ok(JsonView(false, groupData.Msg));
  6616. }
  6617. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6618. }
  6619. catch (Exception ex)
  6620. {
  6621. return Ok(JsonView(false, ex.Message));
  6622. }
  6623. }
  6624. /// <summary>
  6625. /// OP费用录入填写详情
  6626. /// </summary>
  6627. /// <param name="dto"></param>
  6628. /// <returns></returns>
  6629. [HttpPost]
  6630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6631. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6632. {
  6633. try
  6634. {
  6635. #region 参数校验
  6636. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6637. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6638. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6639. #endregion
  6640. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6641. if (groupData.Code != 0)
  6642. {
  6643. return Ok(JsonView(false, groupData.Msg));
  6644. }
  6645. //自动审核
  6646. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6647. #region 应用推送
  6648. try
  6649. {
  6650. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6651. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6652. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6653. //2024-10-21 新增LZ UID
  6654. var userIds = new List<int>() { 21 };
  6655. string title = $"系统通知";
  6656. var diId = dto.DiId;
  6657. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6658. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6659. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  6660. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6661. await APNsTools.iOS_PushNotifications1("051", "OP费用审核", "", content);
  6662. }
  6663. catch (Exception ex)
  6664. {
  6665. }
  6666. #endregion
  6667. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6668. }
  6669. catch (Exception ex)
  6670. {
  6671. return Ok(JsonView(false, ex.Message));
  6672. }
  6673. }
  6674. /// <summary>
  6675. /// 获取三公详细所有城市
  6676. /// </summary>
  6677. /// <returns></returns>
  6678. [HttpGet]
  6679. public IActionResult OpCarCityResult()
  6680. {
  6681. var jw = JsonView(false);
  6682. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6683. {
  6684. x.Id,
  6685. x.Country,
  6686. x.City,
  6687. }).ToList();
  6688. if (data.Count > 0)
  6689. {
  6690. jw = JsonView(true, "获取成功!", data);
  6691. }
  6692. else
  6693. {
  6694. jw.Msg = "城市数据为空!";
  6695. jw.Data = new string[0];
  6696. }
  6697. return Ok(jw);
  6698. }
  6699. /// <summary>
  6700. /// 导出地接费用明细
  6701. /// </summary>
  6702. /// <param name="dto"></param>
  6703. /// <returns></returns>
  6704. [HttpPost]
  6705. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6706. {
  6707. var jw = JsonView(false);
  6708. if (dto.Diid < 1)
  6709. {
  6710. jw.Msg = "请输入正确的diid!";
  6711. return Ok(jw);
  6712. }
  6713. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6714. if (group == null)
  6715. {
  6716. jw.Msg = "未找到团组信息!";
  6717. return Ok(jw);
  6718. }
  6719. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6720. if (localGuideArr.Count == 0)
  6721. {
  6722. jw.Msg = "该团组暂无地接信息!";
  6723. return Ok(jw);
  6724. }
  6725. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6726. var overspendSoure = new Dictionary<int, int>
  6727. {
  6728. { 91, 982 }, //车
  6729. { 92 , 1059} ,//导游
  6730. { 994 , 1073}, //翻译
  6731. { 988 , 1074 }, //早餐
  6732. { 93 , 1075 }, //午餐
  6733. { 989 , 1076 }, //晚餐
  6734. };
  6735. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6736. foreach (var groupArr in localGroup)
  6737. {
  6738. var keyValue = groupArr.Key;
  6739. if (int.TryParse(keyValue, out int cityid))
  6740. {
  6741. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6742. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6743. }
  6744. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6745. foreach (var item in groupArr)
  6746. {
  6747. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6748. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6749. new Grp_CarTouristGuideGroundReservationsContentExtend
  6750. {
  6751. Count = a.Count,
  6752. CreateTime = a.CreateTime,
  6753. CreateUserId = a.CreateUserId,
  6754. CTGGRId = a.CTGGRId,
  6755. Currency = a.Currency,
  6756. DatePrice = a.DatePrice,
  6757. DeleteTime = a.DeleteTime,
  6758. DeleteUserId = a.DeleteUserId,
  6759. DiId = a.DiId,
  6760. Id = a.Id,
  6761. IsDel = a.IsDel,
  6762. Price = a.Price,
  6763. PriceContent = a.PriceContent,
  6764. Remark = a.Remark,
  6765. SId = a.SId,
  6766. SidName = b.Name,
  6767. Units = a.Units,
  6768. }
  6769. ).ToList();
  6770. if (content.Count > 0)
  6771. {
  6772. contentArr.Add(content);
  6773. }
  6774. }
  6775. //open excel
  6776. //set excel
  6777. //save excel
  6778. try
  6779. {
  6780. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6781. IWorkbook workbook;
  6782. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6783. {
  6784. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6785. }
  6786. else
  6787. {
  6788. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6789. }
  6790. ISheet sheet = workbook.GetSheetAt(0);
  6791. var rowStartIndex = 2;
  6792. var clounmCount = 10;
  6793. var initStyleRow = sheet.GetRow(2);
  6794. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6795. //var overspendArrDetail =
  6796. var existsId = new List<CarCompare>();
  6797. var lastElem = arr.Last();
  6798. var thisSid = -1;
  6799. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6800. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6801. {
  6802. Name = "未知币种!",
  6803. Remark = "未知币种!",
  6804. };
  6805. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6806. Action cloneRowFn = () =>
  6807. {
  6808. rowStartIndex++;
  6809. var cloneRow = sheet.CreateRow(rowStartIndex);
  6810. // 复制样式
  6811. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6812. {
  6813. ICell sourceCell = initStyleRow.GetCell(i);
  6814. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6815. // 确保单元格存在样式
  6816. if (sourceCell.CellStyle != null)
  6817. {
  6818. targetCell.CellStyle = sourceCell.CellStyle;
  6819. }
  6820. }
  6821. };
  6822. var mergeRow = () =>
  6823. {
  6824. for (int i = 2; i < sheet.LastRowNum; i++)
  6825. {
  6826. var row = sheet.GetRow(i);
  6827. var cellFirst = row.GetCell(0);
  6828. var thisIndex = i + 1;
  6829. while (thisIndex < sheet.LastRowNum)
  6830. {
  6831. var nextRow = sheet.GetRow(thisIndex);
  6832. var nextCellFirst = nextRow.GetCell(0);
  6833. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6834. {
  6835. thisIndex++;
  6836. }
  6837. else
  6838. {
  6839. break;
  6840. }
  6841. }
  6842. thisIndex--;
  6843. if (thisIndex != i)
  6844. {
  6845. //合并row
  6846. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6847. i, // 起始行索引(0-based)
  6848. thisIndex, // 结束行索引(0-based)
  6849. 0, // 起始列索引(0-based)
  6850. 0 // 结束列索引(0-based)
  6851. );
  6852. sheet.AddMergedRegion(cellRangeAddress);
  6853. i = thisIndex;
  6854. }
  6855. }
  6856. };
  6857. var chaoshiNumber = 0;
  6858. var totalNumber = 0.00M;
  6859. string lastStr = "";
  6860. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6861. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6862. {
  6863. b.IsAuditGM,
  6864. x.Id,
  6865. x.Area,
  6866. b.PayPercentage,
  6867. b.PayMoney,
  6868. }).ToList();
  6869. string yesPayment = "", noPayment = "";
  6870. foreach (var item in queryCarArrByCityAndDiid)
  6871. {
  6872. if (item.IsAuditGM == 1)
  6873. {
  6874. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6875. }
  6876. else
  6877. {
  6878. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6879. }
  6880. }
  6881. lastStr = yesPayment + noPayment;
  6882. foreach (var item in arr)
  6883. {
  6884. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6885. {
  6886. if (thisSid != item.SId)
  6887. {
  6888. if (thisSid == -1)
  6889. {
  6890. thisSid = item.SId;
  6891. }
  6892. else
  6893. {
  6894. //合并小计行
  6895. //创建合并区域的实例
  6896. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6897. rowStartIndex, // 起始行索引(0-based)
  6898. rowStartIndex, // 结束行索引(0-based)
  6899. 0, // 起始列索引(0-based)
  6900. 3 // 结束列索引(0-based)
  6901. );
  6902. sheet.AddMergedRegion(cellRangeAddress);
  6903. var CellStyle = workbook.CreateCellStyle();
  6904. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6905. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6906. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6907. for (int i = 0; i <= clounmCount; i++)
  6908. {
  6909. if (i > 6)
  6910. {
  6911. var CellStyle1 = workbook.CreateCellStyle();
  6912. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6913. IFont Font = workbook.CreateFont(); // 创建字体
  6914. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6915. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6916. CellStyle1.SetFont(Font);
  6917. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6918. }
  6919. else
  6920. {
  6921. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6922. }
  6923. }
  6924. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6925. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6926. //超时合计
  6927. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6928. //超时数
  6929. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6930. //超时合计费用
  6931. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6932. thisSid = item.SId;
  6933. cloneRowFn();
  6934. chaoshiNumber = 0;
  6935. totalNumber = 0;
  6936. }
  6937. }
  6938. IRow row = sheet.GetRow(rowStartIndex);
  6939. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6940. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6941. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6942. if (isOpenOverspendSoure)
  6943. {
  6944. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6945. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6946. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6947. }
  6948. for (int i = 0; i <= clounmCount; i++)
  6949. {
  6950. var cell = row.GetCell(i);
  6951. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6952. if (cell == null)
  6953. {
  6954. cell = row.CreateCell(i);
  6955. }
  6956. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6957. fontRed.CloneStyleFrom(cell.CellStyle);
  6958. IFont Font = workbook.CreateFont(); // 创建字体
  6959. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6960. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6961. fontRed.SetFont(Font);
  6962. byte[] rgb = new byte[3] { 255, 242, 204 };
  6963. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6964. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6965. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6966. if (workbook is XSSFWorkbook)
  6967. {
  6968. BackgroundColor255_242_204.FillForegroundColor = 0;
  6969. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6970. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6971. }
  6972. else
  6973. {
  6974. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6975. }
  6976. if (i == 1 || i > 6)
  6977. {
  6978. if (i > 6)
  6979. {
  6980. fontRed.FillForegroundColor = 0;
  6981. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6982. fontRed.FillPattern = FillPattern.SolidForeground;
  6983. }
  6984. cell.CellStyle = fontRed;
  6985. }
  6986. if (i > 2 && i < 7)
  6987. {
  6988. cell.CellStyle = BackgroundColor255_242_204;
  6989. }
  6990. cell.SetCellValue(setCellValue); //写入单元格
  6991. }
  6992. if (overspendSoure.ContainsKey(thisSid))
  6993. {
  6994. var overspendId = overspendSoure[thisSid];
  6995. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6996. }
  6997. cloneRowFn();
  6998. existsId.Add(new CarCompare
  6999. {
  7000. DataPrice = item.DatePrice.ObjToDate(),
  7001. Sid = item.SId
  7002. });
  7003. }
  7004. if (item.Equals(lastElem))
  7005. {
  7006. //合并小计行
  7007. //创建合并区域的实例
  7008. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7009. rowStartIndex, // 起始行索引(0-based)
  7010. rowStartIndex, // 结束行索引(0-based)
  7011. 0, // 起始列索引(0-based)
  7012. 3 // 结束列索引(0-based)
  7013. );
  7014. sheet.AddMergedRegion(cellRangeAddress);
  7015. var CellStyle = workbook.CreateCellStyle();
  7016. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7017. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7018. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7019. for (int i = 0; i <= clounmCount; i++)
  7020. {
  7021. if (i > 6)
  7022. {
  7023. var CellStyle1 = workbook.CreateCellStyle();
  7024. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7025. IFont Font = workbook.CreateFont(); // 创建字体
  7026. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7027. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7028. CellStyle1.SetFont(Font);
  7029. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7030. }
  7031. else
  7032. {
  7033. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7034. }
  7035. }
  7036. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7037. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7038. //超时合计
  7039. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7040. //超时数
  7041. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7042. //超时合计费用
  7043. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7044. cloneRowFn();
  7045. // 创建合并区域的实例
  7046. cellRangeAddress = new CellRangeAddress(
  7047. rowStartIndex, // 起始行索引(0-based)
  7048. rowStartIndex, // 结束行索引(0-based)
  7049. 0, // 起始列索引(0-based)
  7050. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  7051. );
  7052. // 添加合并区域
  7053. sheet.AddMergedRegion(cellRangeAddress);
  7054. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  7055. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  7056. }
  7057. }
  7058. mergeRow();
  7059. // 保存修改后的Excel文件到新文件
  7060. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  7061. // new FileStream(newFilePath, FileMode.CreateNew)
  7062. using (var stream = new MemoryStream())
  7063. {
  7064. workbook.Write(stream, true);
  7065. stream.Flush();
  7066. stream.Seek(0, SeekOrigin.Begin);
  7067. MemoryStream memoryStream = new MemoryStream();
  7068. stream.CopyTo(memoryStream);
  7069. memoryStream.Seek(0, SeekOrigin.Begin);
  7070. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  7071. }
  7072. workbook.Close();
  7073. workbook.Dispose();
  7074. }
  7075. catch (Exception ex)
  7076. {
  7077. jw.Msg = "出现异常!" + ex.Message;
  7078. return Ok(jw);
  7079. }
  7080. }
  7081. if (Zips.Count > 0)
  7082. {
  7083. IOOperatorHelper io = new IOOperatorHelper();
  7084. var byts = io.ConvertZipStream(Zips);
  7085. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  7086. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  7087. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  7088. }
  7089. else
  7090. {
  7091. jw.Msg = "暂无生成文件!";
  7092. }
  7093. return Ok(jw);
  7094. }
  7095. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  7096. {
  7097. string outStr = string.Empty;
  7098. switch (i)
  7099. {
  7100. case 0:
  7101. outStr = arr[0].SidName;
  7102. break;
  7103. case 1:
  7104. outStr = arr[0].DataPriceStr;
  7105. break;
  7106. case 2:
  7107. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  7108. break;
  7109. case 4:
  7110. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  7111. break;
  7112. case 7:
  7113. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7114. {
  7115. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  7116. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  7117. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  7118. }
  7119. break;
  7120. case 8:
  7121. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7122. {
  7123. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  7124. }
  7125. break;
  7126. case 9:
  7127. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7128. {
  7129. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  7130. }
  7131. break;
  7132. case 10:
  7133. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7134. {
  7135. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  7136. }
  7137. break;
  7138. }
  7139. return outStr;
  7140. }
  7141. #region OP行程单
  7142. /// <summary>
  7143. /// OP行程单初始化
  7144. /// </summary>
  7145. /// <param name="dto"></param>
  7146. /// <returns></returns>
  7147. [HttpPost]
  7148. public IActionResult InitOpTravel(InitOpTravelDto dto)
  7149. {
  7150. var jw = JsonView(false);
  7151. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  7152. var group = groupList.First();
  7153. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  7154. if (group == null)
  7155. {
  7156. jw.Msg = "暂无团组!";
  7157. return Ok(jw);
  7158. }
  7159. group = groupList.Find(x => x.Id == diid);
  7160. if (group == null)
  7161. {
  7162. jw.Msg = "请输入正确的团组ID!";
  7163. return Ok(jw);
  7164. }
  7165. string city = string.Empty;
  7166. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  7167. if (blackCode.Count > 0)
  7168. {
  7169. var black = blackCode.First();
  7170. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  7171. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  7172. if (blackSp.Length > 0)
  7173. {
  7174. try
  7175. {
  7176. var cityArrCode = new List<string>(20);
  7177. foreach (var item in blackSp)
  7178. {
  7179. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  7180. var IndexSelect = itemSp[2];
  7181. var cityArrCodeLength = cityArrCode.Count - 1;
  7182. var startCity = IndexSelect.Substring(0, 3);
  7183. if (cityArrCodeLength > 0)
  7184. {
  7185. var arrEndCity = cityArrCode[cityArrCodeLength];
  7186. if (arrEndCity != startCity)
  7187. {
  7188. cityArrCode.Add(startCity.ToUpper());
  7189. }
  7190. }
  7191. else
  7192. {
  7193. cityArrCode.Add(startCity.ToUpper());
  7194. }
  7195. var endCity = IndexSelect.Substring(3, 3);
  7196. cityArrCode.Add(endCity.ToUpper());
  7197. }
  7198. var cityThree = string.Empty;
  7199. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  7200. cityThree = cityThree.TrimEnd(',');
  7201. if (string.IsNullOrWhiteSpace(cityThree))
  7202. {
  7203. throw new
  7204. Exception("error");
  7205. }
  7206. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7207. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7208. foreach (var item in cityArrCode)
  7209. {
  7210. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7211. if (find != null)
  7212. {
  7213. city += find.City + "/";
  7214. }
  7215. else
  7216. {
  7217. city += item + "三字码未收入/";
  7218. }
  7219. }
  7220. city = city.TrimEnd('/');
  7221. }
  7222. catch (Exception e)
  7223. {
  7224. city = "黑屏代码格式不正确!";
  7225. }
  7226. }
  7227. }
  7228. else
  7229. {
  7230. city = "未录入黑屏代码";
  7231. }
  7232. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7233. {
  7234. Date = x.Date,
  7235. Days = x.Days,
  7236. Diffgroup = x.Diffgroup,
  7237. Diid = x.Diid,
  7238. Traffic_First = x.Traffic_First,
  7239. Traffic_Second = x.Traffic_Second,
  7240. Trip = x.Trip,
  7241. WeekDay = x.WeekDay,
  7242. Id = x.Id
  7243. }).ToList();
  7244. jw.Data = new
  7245. {
  7246. groupList = groupList.Select(x => new
  7247. {
  7248. x.Id,
  7249. x.TeamName,
  7250. x.TourCode
  7251. }).ToList(),
  7252. groupInfo = new
  7253. {
  7254. group.VisitDays,
  7255. group.TourCode,
  7256. group.VisitPNumber,
  7257. group.TeamName,
  7258. city
  7259. },
  7260. OpTravelList
  7261. };
  7262. jw.Code = 200;
  7263. jw.Msg = "操作成功!";
  7264. return Ok(jw);
  7265. }
  7266. /// <summary>
  7267. /// 删除团组行程单
  7268. /// </summary>
  7269. /// <returns></returns>
  7270. [HttpPost]
  7271. public IActionResult DelTravel(DelOpTravelDto dto)
  7272. {
  7273. var jw = JsonView(false);
  7274. if (dto.UserId <= 0 || dto.Diid <= 0)
  7275. {
  7276. jw.Msg = "请输入正确的参数!";
  7277. return Ok(jw);
  7278. }
  7279. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7280. .SetColumns(x => new Grp_TravelList
  7281. {
  7282. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7283. DeleteUserId = dto.UserId,
  7284. IsDel = 1,
  7285. }).ExecuteCommand();
  7286. jw = JsonView(true);
  7287. return Ok(jw);
  7288. }
  7289. /// <summary>
  7290. /// 行程单保存
  7291. /// </summary>
  7292. /// <returns></returns>
  7293. [HttpPost]
  7294. public IActionResult TravelSave(TravelSaveDto dto)
  7295. {
  7296. var jw = JsonView(false);
  7297. if (dto.Arr.Count > 0)
  7298. {
  7299. try
  7300. {
  7301. _sqlSugar.BeginTran();
  7302. foreach (var item in dto.Arr)
  7303. {
  7304. if (item.Id == 0)
  7305. {
  7306. throw new Exception("请传入正确的Id");
  7307. }
  7308. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7309. .SetColumns(x => new Grp_TravelList
  7310. {
  7311. Trip = item.Trip
  7312. }).ExecuteCommand();
  7313. }
  7314. _sqlSugar.CommitTran();
  7315. jw = JsonView(true);
  7316. }
  7317. catch (Exception ex)
  7318. {
  7319. _sqlSugar.RollbackTran();
  7320. jw.Msg = "程序异常!" + ex.Message;
  7321. }
  7322. }
  7323. else
  7324. {
  7325. jw.Msg = "请传入正确的参数!";
  7326. }
  7327. return Ok(jw);
  7328. }
  7329. /// <summary>
  7330. /// 导出行程单
  7331. /// </summary>
  7332. /// <param name="dto"></param>
  7333. /// <returns></returns>
  7334. [HttpPost]
  7335. public IActionResult ExportTravel(ExportTravelDto dto)
  7336. {
  7337. var jw = JsonView(false);
  7338. jw.Data = "";
  7339. int diid = 0;
  7340. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7341. if (Find == null)
  7342. {
  7343. jw.Msg = "请选择正确的团组!";
  7344. return Ok(jw);
  7345. }
  7346. else
  7347. {
  7348. diid = Find.Id;
  7349. }
  7350. //数据源
  7351. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7352. DataTable dtBlack = null;
  7353. try
  7354. {
  7355. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7356. }
  7357. catch (Exception)
  7358. {
  7359. jw.Msg = "机票黑屏代码有误!";
  7360. return Ok(jw);
  7361. }
  7362. string CityStr = string.Empty;
  7363. if (dtBlack.Rows.Count == 0)
  7364. {
  7365. jw.Msg = "机票黑屏代码有误!";
  7366. return Ok(jw);
  7367. }
  7368. else
  7369. {
  7370. foreach (DataRow row in dtBlack.Rows)
  7371. {
  7372. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7373. {
  7374. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7375. return Ok(jw);
  7376. }
  7377. }
  7378. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7379. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7380. }
  7381. //创建数据源Table
  7382. DataTable dtSource = new DataTable();
  7383. dtSource.Columns.Add("Days", typeof(string));
  7384. dtSource.Columns.Add("Date", typeof(string));
  7385. dtSource.Columns.Add("Week", typeof(string));
  7386. dtSource.Columns.Add("Traffic", typeof(string));
  7387. dtSource.Columns.Add("Trip", typeof(string));
  7388. //获取数据,放到datatable
  7389. foreach (var item in _travelList)
  7390. {
  7391. DataRow dr = dtSource.NewRow();
  7392. dr["Days"] = item.Days;
  7393. dr["Date"] = item.Date;
  7394. dr["Week"] = item.WeekDay;
  7395. dr["Traffic"] = item.Traffic_First
  7396. + "\r\n"
  7397. + item.Traffic_Second;
  7398. dr["Trip"] = item.Trip;
  7399. dtSource.Rows.Add(dr);
  7400. }
  7401. Dictionary<string, string> dic = new Dictionary<string, string>();
  7402. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7403. dic.Add("City", CityStr);
  7404. dic.Add("Days", Find.VisitDays.ToString());
  7405. dic.Add("DeleCode", Find.TourCode);
  7406. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7407. //模板路径
  7408. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7409. //载入模板
  7410. Document doc = null;
  7411. DocumentBuilder builder = null;
  7412. try
  7413. {
  7414. //载入模板
  7415. doc = new Document(tempPath);
  7416. builder = new DocumentBuilder(doc);
  7417. }
  7418. catch (Exception)
  7419. {
  7420. jw.Msg = "模板位置不存在!";
  7421. return Ok(jw);
  7422. }
  7423. foreach (var key in dic.Keys)
  7424. {
  7425. Bookmark bookmark = doc.Range.Bookmarks[key];
  7426. if (bookmark != null)
  7427. {
  7428. builder.MoveToBookmark(key);
  7429. builder.Write(dic[key]);
  7430. }
  7431. }
  7432. //获取word里所有表格
  7433. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7434. //获取所填表格的序数
  7435. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7436. try
  7437. {
  7438. //循环赋值
  7439. for (int i = 0; i < dtSource.Rows.Count; i++)
  7440. {
  7441. builder.MoveToCell(0, i + 1, 0, 0);
  7442. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7443. builder.MoveToCell(0, i + 1, 1, 0);
  7444. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7445. builder.MoveToCell(0, i + 1, 2, 0);
  7446. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7447. var trip = dtSource.Rows[i]["Trip"].ToString();
  7448. builder.MoveToCell(0, i + 1, 3, 0);
  7449. builder.Write(trip);
  7450. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7451. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7452. // 获取特定索引的段落
  7453. Paragraph paragraph = (Paragraph)paragraphs[0];
  7454. Run run = paragraph.Runs[0];
  7455. Aspose.Words.Font font = run.Font;
  7456. font.Name = "黑体";
  7457. //设置双休红色
  7458. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7459. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7460. paragraph = (Paragraph)paragraphs[1];
  7461. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7462. {
  7463. run = paragraph.Runs[0];
  7464. font = run.Font;
  7465. font.Color = Color.Red;
  7466. }
  7467. }
  7468. }
  7469. catch (Exception ex)
  7470. {
  7471. }
  7472. //删除多余行
  7473. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7474. {
  7475. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7476. }
  7477. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7478. if (!Directory.Exists(savePath))
  7479. {
  7480. try
  7481. {
  7482. Directory.CreateDirectory(savePath);
  7483. }
  7484. catch
  7485. {
  7486. }
  7487. }
  7488. string path = savePath + Find.TeamName + "出访日程";
  7489. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7490. try
  7491. {
  7492. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7493. string postfix = ".docx";
  7494. if (dto.IsPDF == 1)
  7495. {
  7496. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7497. postfix = ".pdf";
  7498. }
  7499. doc.Save(path + postfix, saveFormat);
  7500. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7501. }
  7502. catch (Exception)
  7503. {
  7504. jw = JsonView(false);
  7505. }
  7506. return Ok(jw);
  7507. }
  7508. /// <summary>
  7509. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7510. /// </summary>
  7511. /// <param name="num"></param>
  7512. /// <returns></returns>
  7513. string GetNum(string num)
  7514. {
  7515. string str = "";
  7516. switch (num)
  7517. {
  7518. case "1":
  7519. str = "一";
  7520. break;
  7521. case "2":
  7522. str = "二";
  7523. break;
  7524. case "3":
  7525. str = "三";
  7526. break;
  7527. case "4":
  7528. str = "四";
  7529. break;
  7530. case "5":
  7531. str = "五";
  7532. break;
  7533. case "6":
  7534. str = "六";
  7535. break;
  7536. case "7":
  7537. str = "七";
  7538. break;
  7539. case "8":
  7540. str = "八";
  7541. break;
  7542. case "9":
  7543. str = "九";
  7544. break;
  7545. case "10":
  7546. str = "十";
  7547. break;
  7548. case "11":
  7549. str = "十一";
  7550. break;
  7551. case "12":
  7552. str = "十二";
  7553. break;
  7554. case "一":
  7555. str = "1";
  7556. break;
  7557. case "二":
  7558. str = "2";
  7559. break;
  7560. case "三":
  7561. str = "3";
  7562. break;
  7563. case "四":
  7564. str = "4";
  7565. break;
  7566. case "五":
  7567. str = "5";
  7568. break;
  7569. case "六":
  7570. str = "6";
  7571. break;
  7572. case "七":
  7573. str = "7";
  7574. break;
  7575. case "八":
  7576. str = "8";
  7577. break;
  7578. case "九":
  7579. str = "9";
  7580. break;
  7581. case "十":
  7582. str = "10";
  7583. break;
  7584. case "十一":
  7585. str = "11";
  7586. break;
  7587. case "十二":
  7588. str = "12";
  7589. break;
  7590. }
  7591. return str;
  7592. }
  7593. #endregion
  7594. #endregion
  7595. #region 团组成本
  7596. /// <summary>
  7597. /// 团组成本数据初始化
  7598. /// </summary>
  7599. /// <param name="dto"></param>
  7600. /// <returns></returns>
  7601. [HttpPost]
  7602. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7603. {
  7604. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7605. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7606. WHEN COUNT(*) >= 0 THEN 'True'
  7607. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7608. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7609. ").ToList(); //团组列表
  7610. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7611. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7612. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7613. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7614. if (groupinfoValue != null)
  7615. {
  7616. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7617. var spArr = new string[1] { countryArr };
  7618. if (countryArr.Contains("|"))
  7619. {
  7620. spArr = countryArr.Split("|");
  7621. }
  7622. else if (countryArr.Contains("、"))
  7623. {
  7624. spArr = countryArr.Split("、");
  7625. }
  7626. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7627. {
  7628. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7629. if (dbQueryCountry != null)
  7630. {
  7631. visaCountryInfoArr.Add(dbQueryCountry);
  7632. }
  7633. }
  7634. }
  7635. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7636. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7637. var create = _GroupCostRepository.
  7638. CreateGroupCostByBlackCode(dto.Diid);
  7639. if (groupCost.Count == 0 && create.Code == 0)
  7640. {
  7641. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7642. }
  7643. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7644. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7645. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7646. groupCostMap = groupCostMap.Select(x =>
  7647. {
  7648. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7649. {
  7650. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7651. }
  7652. return x;
  7653. }).ToList();
  7654. //GroupCostParameter.Add(new
  7655. // Grp_GroupCostParameter());
  7656. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7657. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7658. return Ok(JsonView(new
  7659. {
  7660. groupList,
  7661. groupInfo,
  7662. groupChecks,
  7663. groupCost = groupCostMap,
  7664. hotelNumber,
  7665. GroupCostParameter = GroupCostParameterMap,
  7666. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7667. {
  7668. x.VisaCountry,
  7669. x.VisaPrice,
  7670. x.Id,
  7671. }).ToList(),
  7672. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7673. blackCodeIsTrue = create.Code == 0 ? true : false,
  7674. hotelIsTrue = hotelIsTrue,
  7675. }));
  7676. }
  7677. /// <summary>
  7678. /// 团组成本信息保存
  7679. /// </summary>
  7680. /// <param name="dto"></param>
  7681. /// <returns></returns>
  7682. [HttpPost]
  7683. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7684. {
  7685. if (dto.Diid <= 0 || dto.Userid <= 0)
  7686. {
  7687. return Ok(JsonView(false));
  7688. }
  7689. JsonView jw = null;
  7690. bool isTrue = false;
  7691. #region 复制团组成本
  7692. //if (dto.Diid == 2581)
  7693. //{
  7694. // dto.Diid = 2599;
  7695. // dto.CheckBoxs.ForEach(x =>
  7696. // {
  7697. // x.Diid = 2599;
  7698. // });
  7699. // dto.GroupCosts.ForEach(x =>
  7700. // {
  7701. // x.Diid = 2599;
  7702. // });
  7703. // dto.CostTypeHotelNumbers.ForEach(x =>
  7704. // {
  7705. // x.Diid = 2599;
  7706. // });
  7707. // dto.GroupCostParameters.ForEach(x =>
  7708. // {
  7709. // x.DiId = 2599;
  7710. // });
  7711. //}
  7712. #endregion
  7713. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7714. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7715. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7716. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7717. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7718. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7719. try
  7720. {
  7721. _sqlSugar.BeginTran();
  7722. isTrue = await _GroupCostRepository.
  7723. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7724. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7725. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7726. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7727. _sqlSugar.CommitTran();
  7728. jw = JsonView(true, "保存成功!", isTrue);
  7729. }
  7730. catch (Exception)
  7731. {
  7732. _sqlSugar.RollbackTran();
  7733. jw = JsonView(false);
  7734. }
  7735. return Ok(jw);
  7736. }
  7737. /// <summary>
  7738. /// 司兼导数据
  7739. /// </summary>
  7740. /// <param name="dto"></param>
  7741. /// <returns></returns>
  7742. [HttpPost]
  7743. public IActionResult GetCarGuides(CarGuidesDto dto)
  7744. {
  7745. JsonView jw = null;
  7746. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7747. jw = JsonView(true, "获取成功!", Data);
  7748. return Ok(jw);
  7749. }
  7750. /// <summary>
  7751. /// 导游数据
  7752. /// </summary>
  7753. /// <param name="dto"></param>
  7754. /// <returns></returns>
  7755. [HttpPost]
  7756. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7757. {
  7758. JsonView jw = null;
  7759. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7760. // 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
  7761. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7762. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7763. jw = JsonView(true, "获取成功!", Data);
  7764. return Ok(jw);
  7765. }
  7766. /// <summary>
  7767. /// 成本车数据
  7768. /// </summary>
  7769. /// <param name="dto"></param>
  7770. /// <returns></returns>
  7771. [HttpPost]
  7772. public IActionResult GetCarInfo(CarGuidesDto dto)
  7773. {
  7774. JsonView jw = null;
  7775. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7776. jw = JsonView(true, "获取成功!", Data);
  7777. return Ok(jw);
  7778. }
  7779. /// <summary>
  7780. /// 景点数据
  7781. /// </summary>
  7782. /// <param name="dto"></param>
  7783. /// <returns></returns>
  7784. [HttpPost]
  7785. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7786. {
  7787. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7788. return Ok(JsonView(true, "获取成功!", Data));
  7789. }
  7790. /// <summary>
  7791. /// 成本通知
  7792. /// </summary>
  7793. /// <param name="dto"></param>
  7794. /// <returns></returns>
  7795. [HttpPost]
  7796. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7797. {
  7798. if (dto.Diid < 0)
  7799. {
  7800. return Ok(JsonView(false));
  7801. }
  7802. JsonView jw = null;
  7803. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7804. if (GroupCostParameter != null)
  7805. {
  7806. int IsShare = 0;
  7807. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7808. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7809. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7810. string msg = string.Empty;
  7811. if (isTrue)
  7812. {
  7813. if (IsShare == 0)
  7814. {
  7815. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7816. }
  7817. else
  7818. {
  7819. #region 企微通知对应岗位用户
  7820. try
  7821. {
  7822. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7823. }
  7824. catch (Exception ex)
  7825. {
  7826. }
  7827. #endregion
  7828. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7829. }
  7830. jw = JsonView(isTrue, msg, new { IsShare });
  7831. }
  7832. else
  7833. {
  7834. msg = "修改失败!";
  7835. jw = JsonView(isTrue, msg);
  7836. }
  7837. }
  7838. else
  7839. {
  7840. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7841. }
  7842. return Ok(jw);
  7843. }
  7844. /// <summary>
  7845. /// 导出报价单
  7846. /// </summary>
  7847. /// <param name="dto"></param>
  7848. /// <returns></returns>
  7849. [HttpPost]
  7850. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7851. {
  7852. if (dto.Diid == 0)
  7853. {
  7854. return Ok(JsonView(false, "请传递团组id"));
  7855. }
  7856. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7857. if (deleInfo.Code != 0)
  7858. {
  7859. return Ok(JsonView(false, "团组信息查询失败!"));
  7860. }
  7861. var di = deleInfo.Data as DelegationInfoWebView;
  7862. if (di != null)
  7863. {
  7864. di.TeamName = di.TeamName.Replace("|", "、");
  7865. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7866. //文件名
  7867. string strFileName = di.TeamName + "-收款账单.doc";
  7868. //获取模板
  7869. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7870. //载入模板
  7871. Document doc = new Document(tmppath);
  7872. decimal TotalPrice = 0.00M;
  7873. string itemStr = string.Empty;
  7874. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7875. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7876. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7877. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7878. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7879. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7880. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7881. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7882. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7883. foreach (var cost in groupCostType)
  7884. {
  7885. var List = cost.ToList();
  7886. if (cost.Key == "A")
  7887. {
  7888. foreach (var ListItem in List)
  7889. {
  7890. if (ListItem.number > 0)
  7891. {
  7892. if (ListItem.code.Contains("TBR"))
  7893. {
  7894. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7895. }
  7896. else
  7897. {
  7898. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7899. }
  7900. TotalPrice += (ListItem.number * ListItem.price);
  7901. }
  7902. }
  7903. }
  7904. else
  7905. {
  7906. itemStr = itemStr.Insert(0, "A段\r\n");
  7907. itemStr += "B段\r\n";
  7908. foreach (var ListItem in List)
  7909. {
  7910. if (ListItem.number > 0)
  7911. {
  7912. if (ListItem.code.Contains("TBR"))
  7913. {
  7914. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7915. }
  7916. else
  7917. {
  7918. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7919. }
  7920. TotalPrice += (ListItem.number * ListItem.price);
  7921. }
  7922. }
  7923. }
  7924. }
  7925. #region 替换Word模板书签内容
  7926. Dictionary<string, string> marks = new Dictionary<string, string>();
  7927. marks.Add("To", di.ClientUnit);//付款方
  7928. marks.Add("ToTel", di.TellPhone);//付款方电话
  7929. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7930. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7931. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7932. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7933. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7934. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7935. marks.Add("PayItemContent", itemStr);//详细信息
  7936. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7937. #endregion
  7938. ////注
  7939. //if (doc.Range.Bookmarks["Attention"] != null)
  7940. //{
  7941. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7942. // mark.Text = frList[0].Attention;
  7943. //}
  7944. foreach (var item in marks.Keys)
  7945. {
  7946. if (doc.Range.Bookmarks[item] != null)
  7947. {
  7948. Bookmark mark = doc.Range.Bookmarks[item];
  7949. mark.Text = marks[item];
  7950. }
  7951. }
  7952. byte[] bytes = null;
  7953. using (MemoryStream stream = new MemoryStream())
  7954. {
  7955. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7956. bytes = stream.ToArray();
  7957. }
  7958. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7959. return Ok(JsonView(true, "", new
  7960. {
  7961. Data = bytes,
  7962. strFileName,
  7963. }));
  7964. }
  7965. else
  7966. {
  7967. return Ok(JsonView(false, "团组信息不存在!"));
  7968. }
  7969. }
  7970. /// <summary>
  7971. /// 导出团组成本
  7972. /// </summary>
  7973. /// <param name="dto"></param>
  7974. /// <returns></returns>
  7975. [HttpPost]
  7976. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7977. {
  7978. var jw = JsonView(false);
  7979. if (dto.Diid == 0)
  7980. {
  7981. return Ok(JsonView(false, "请传递团组id"));
  7982. }
  7983. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7984. if (deleInfo.Code != 0)
  7985. {
  7986. return Ok(JsonView(false, "团组信息查询失败!"));
  7987. }
  7988. var di = deleInfo.Data as DelegationInfoWebView;
  7989. if (di == null)
  7990. {
  7991. return Ok(JsonView(false, "团组信息查询失败!"));
  7992. }
  7993. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7994. WorkbookDesigner designer = new WorkbookDesigner();
  7995. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7996. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7997. for (int i = 0; i < List_GC.Count; i++)
  7998. {
  7999. GroupCost_Excel gc = new GroupCost_Excel();
  8000. gc.Id = List_GC[i].Id;
  8001. gc.Diid = List_GC[i].Diid.ToString();
  8002. gc.DAY = List_GC[i].DAY;
  8003. string week = "";
  8004. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  8005. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  8006. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  8007. gc.ITIN = List_GC[i].ITIN;
  8008. gc.CarType = List_GC[i].CarType;
  8009. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  8010. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  8011. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  8012. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  8013. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  8014. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  8015. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  8016. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  8017. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  8018. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  8019. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  8020. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  8021. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  8022. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  8023. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  8024. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  8025. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  8026. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  8027. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  8028. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  8029. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  8030. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  8031. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  8032. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  8033. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  8034. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  8035. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  8036. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  8037. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  8038. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  8039. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  8040. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  8041. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  8042. List_GC1.Add(gc);
  8043. }
  8044. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  8045. dt.TableName = "TB";
  8046. //报表标题等不用dt的值
  8047. designer.SetDataSource("TeamName", dto.title.TeamName);
  8048. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  8049. designer.SetDataSource("Tax", dto.title.Tax);
  8050. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  8051. designer.SetDataSource("Currency", dto.title.Currency);
  8052. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  8053. designer.SetDataSource("Rate", dto.title.Rate);
  8054. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  8055. var Aparams = hotels.Find(x => x.Type == "Default");
  8056. if (Aparams == null)
  8057. {
  8058. return Ok(jw);
  8059. }
  8060. //酒店数量
  8061. var txtSGRNumber = Aparams.SGR.ToString();
  8062. var txtTBRNumber = Aparams.TBR.ToString();
  8063. var txtJSESNumber = Aparams.JSES.ToString();
  8064. var txtSUITENumbe = Aparams.SUITE.ToString();
  8065. if (dto.costType == "B")
  8066. {
  8067. Aparams = hotels.Find(x => x.Type == "A");
  8068. var Bparams = hotels.Find(x => x.Type == "B");
  8069. if (Aparams == null || Bparams == null)
  8070. {
  8071. return Ok(jw);
  8072. }
  8073. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  8074. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  8075. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  8076. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  8077. }
  8078. designer.SetDataSource("SGRNumber", txtSGRNumber);
  8079. designer.SetDataSource("TBRNumber", txtTBRNumber);
  8080. designer.SetDataSource("JSESNumber", txtJSESNumber);
  8081. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  8082. var ws = designer.Workbook.Worksheets[0];
  8083. int Row = List_GC.Count;
  8084. int startIndex = 11;
  8085. int HideRows = 0;
  8086. List<int> hideRowsList = new List<int>();
  8087. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  8088. #region A段left数据
  8089. var left = dto.leftInfo.Find(x => x.Type == "A");
  8090. if (left == null)
  8091. {
  8092. return Ok(jw);
  8093. }
  8094. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  8095. if (leftBindData != null)
  8096. {
  8097. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  8098. designer.SetDataSource("VisaRS", leftBindData.rs);
  8099. designer.SetDataSource("VisaXS", leftBindData.xs);
  8100. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8101. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8102. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8103. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8104. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8105. }
  8106. else
  8107. {
  8108. hideRowsList.Add(Row + startIndex + HideRows);
  8109. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8110. }
  8111. HideRows += 2;
  8112. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  8113. if (leftBindData != null)
  8114. {
  8115. designer.SetDataSource("BXDRCB", leftBindData.cb);
  8116. designer.SetDataSource("BXRS", leftBindData.rs);
  8117. designer.SetDataSource("BXXS", leftBindData.xs);
  8118. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8119. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8120. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8121. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8122. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8123. }
  8124. else
  8125. {
  8126. hideRowsList.Add(Row + startIndex + HideRows);
  8127. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8128. }
  8129. HideRows += 2;
  8130. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8131. if (leftBindData != null)
  8132. {
  8133. designer.SetDataSource("HSDRCB", leftBindData.cb);
  8134. designer.SetDataSource("HSRS", leftBindData.rs);
  8135. designer.SetDataSource("HSXS", leftBindData.xs);
  8136. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8137. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8138. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8139. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8140. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8141. }
  8142. else
  8143. {
  8144. hideRowsList.Add(Row + startIndex + HideRows);
  8145. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8146. }
  8147. HideRows += 2;
  8148. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8149. if (leftBindData != null)
  8150. {
  8151. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  8152. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  8153. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  8154. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8155. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8156. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8157. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8158. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8159. }
  8160. else
  8161. {
  8162. hideRowsList.Add(Row + startIndex + HideRows);
  8163. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8164. }
  8165. HideRows += 2;
  8166. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8167. if (leftBindData != null)
  8168. {
  8169. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  8170. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  8171. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  8172. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8173. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8174. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8175. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8176. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8177. }
  8178. else
  8179. {
  8180. hideRowsList.Add(Row + startIndex + HideRows);
  8181. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8182. }
  8183. HideRows += 2;
  8184. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8185. if (leftBindData != null)
  8186. {
  8187. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  8188. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  8189. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  8190. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8191. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8192. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8193. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8194. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8195. }
  8196. else
  8197. {
  8198. hideRowsList.Add(Row + startIndex + HideRows);
  8199. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8200. }
  8201. HideRows += 2;
  8202. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8203. if (leftBindData != null)
  8204. {
  8205. ////TBR
  8206. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8207. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8208. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8209. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8210. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8211. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8212. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8213. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8214. }
  8215. else
  8216. {
  8217. hideRowsList.Add(Row + startIndex + HideRows);
  8218. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8219. }
  8220. HideRows += 2;
  8221. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8222. if (leftBindData != null)
  8223. {
  8224. ////SGR
  8225. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8226. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8227. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8228. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8229. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8230. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8231. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8232. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8233. }
  8234. else
  8235. {
  8236. hideRowsList.Add(Row + startIndex + HideRows);
  8237. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8238. }
  8239. HideRows += 2;
  8240. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8241. if (leftBindData != null)
  8242. {
  8243. ////JS/ES
  8244. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8245. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8246. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8247. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8248. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8249. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8250. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8251. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8252. }
  8253. else
  8254. {
  8255. hideRowsList.Add(Row + startIndex + HideRows);
  8256. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8257. }
  8258. HideRows += 2;
  8259. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8260. if (leftBindData != null)
  8261. {
  8262. ////SUITE
  8263. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8264. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8265. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8266. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8267. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8268. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8269. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8270. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8271. }
  8272. else
  8273. {
  8274. hideRowsList.Add(Row + startIndex + HideRows);
  8275. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8276. }
  8277. HideRows += 2;
  8278. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8279. if (leftBindData != null)
  8280. {
  8281. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8282. designer.SetDataSource("DJRS", leftBindData.rs);
  8283. designer.SetDataSource("DJXS", leftBindData.xs);
  8284. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8285. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8286. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8287. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8288. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8289. }
  8290. else
  8291. {
  8292. hideRowsList.Add(Row + startIndex + HideRows);
  8293. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8294. }
  8295. HideRows += 2;
  8296. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8297. if (leftBindData != null)
  8298. {
  8299. designer.SetDataSource("HCPCB", leftBindData.cb);
  8300. designer.SetDataSource("HCPRS", leftBindData.rs);
  8301. designer.SetDataSource("HCPXS", leftBindData.xs);
  8302. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8303. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8304. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8305. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8306. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8307. }
  8308. else
  8309. {
  8310. hideRowsList.Add(Row + startIndex + HideRows);
  8311. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8312. }
  8313. HideRows += 2;
  8314. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8315. if (leftBindData != null)
  8316. {
  8317. designer.SetDataSource("CPCB", leftBindData.cb);
  8318. designer.SetDataSource("CPRS", leftBindData.rs);
  8319. designer.SetDataSource("CPXS", leftBindData.xs);
  8320. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8321. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8322. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8323. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8324. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8325. }
  8326. else
  8327. {
  8328. hideRowsList.Add(Row + startIndex + HideRows);
  8329. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8330. }
  8331. HideRows += 2;
  8332. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8333. if (leftBindData != null)
  8334. {
  8335. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8336. designer.SetDataSource("GWRS", leftBindData.rs);
  8337. designer.SetDataSource("GWXS", leftBindData.xs);
  8338. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8339. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8340. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8341. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8342. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8343. }
  8344. else
  8345. {
  8346. hideRowsList.Add(Row + startIndex + HideRows);
  8347. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8348. }
  8349. HideRows += 2;
  8350. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8351. if (leftBindData != null)
  8352. {
  8353. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8354. designer.SetDataSource("LYJRS", leftBindData.rs);
  8355. designer.SetDataSource("LYJXS", leftBindData.xs);
  8356. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8357. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8358. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8359. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8360. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8361. }
  8362. else
  8363. {
  8364. hideRowsList.Add(Row + startIndex + HideRows);
  8365. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8366. }
  8367. #endregion
  8368. #region A段Right信息
  8369. var right = dto.rightInfo.Find(x => x.Type == "A");
  8370. if (right == null)
  8371. {
  8372. return Ok(jw);
  8373. }
  8374. HideRows += 4;
  8375. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8376. if (rightBindData != null)
  8377. {
  8378. //经济舱 + 双人间 TBR
  8379. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8380. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8381. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8382. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8383. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8384. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8385. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8386. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8387. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8388. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8389. }
  8390. else
  8391. {
  8392. hideRowsList.Add(Row + startIndex + HideRows);
  8393. }
  8394. HideRows += 2;
  8395. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8396. if (rightBindData != null)
  8397. {
  8398. //经济舱 + 单人间 SGR
  8399. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8400. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8401. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8402. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8403. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8404. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8405. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8406. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8407. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8408. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8409. }
  8410. else
  8411. {
  8412. hideRowsList.Add(Row + startIndex + HideRows);
  8413. }
  8414. HideRows += 2;
  8415. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8416. if (rightBindData != null)
  8417. {
  8418. //公务舱 + 单人间 SGR
  8419. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8420. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8421. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8422. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8423. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8424. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8425. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8426. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8427. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8428. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8429. }
  8430. else
  8431. {
  8432. hideRowsList.Add(Row + startIndex + HideRows);
  8433. }
  8434. HideRows += 2;
  8435. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8436. if (rightBindData != null)
  8437. {
  8438. //公务舱 + 小套房 JSES
  8439. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8440. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8441. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8442. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8443. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8444. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8445. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8446. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8447. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8448. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8449. }
  8450. else
  8451. {
  8452. hideRowsList.Add(Row + startIndex + HideRows);
  8453. }
  8454. HideRows += 2;
  8455. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8456. if (rightBindData != null)
  8457. {
  8458. //公务舱 + 小套房 JSES
  8459. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8460. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8461. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8462. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8463. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8464. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8465. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8466. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8467. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8468. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8469. }
  8470. else
  8471. {
  8472. hideRowsList.Add(Row + startIndex + HideRows);
  8473. }
  8474. HideRows += 2;
  8475. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8476. if (rightBindData != null)
  8477. {
  8478. //经济舱 + 大套房
  8479. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8480. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8481. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8482. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8483. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8484. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8485. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8486. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8487. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8488. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8489. }
  8490. else
  8491. {
  8492. hideRowsList.Add(Row + startIndex + HideRows);
  8493. }
  8494. HideRows += 2;
  8495. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8496. if (rightBindData != null)
  8497. {
  8498. //头等舱 + 小套房 JSES
  8499. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8500. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8501. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8502. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8503. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8504. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8505. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8506. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8507. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8508. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8509. }
  8510. else
  8511. {
  8512. hideRowsList.Add(Row + startIndex + HideRows);
  8513. }
  8514. HideRows += 2;
  8515. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8516. if (rightBindData != null)
  8517. {
  8518. //头等舱 + 大套房
  8519. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8520. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8521. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8522. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8523. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8524. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8525. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8526. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8527. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8528. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8529. }
  8530. else
  8531. {
  8532. hideRowsList.Add(Row + startIndex + HideRows);
  8533. }
  8534. #endregion
  8535. #region B段标题清空
  8536. designer.SetDataSource("CostBDRCB", "");
  8537. designer.SetDataSource("CostBRS", "");
  8538. designer.SetDataSource("CostBXS", "");
  8539. designer.SetDataSource("CostBZCB", "");
  8540. designer.SetDataSource("CostBDRBJ", "");
  8541. designer.SetDataSource("CostBZBJ", "");
  8542. designer.SetDataSource("CostBDRLR", "");
  8543. designer.SetDataSource("CostBZLR", "");
  8544. designer.SetDataSource("CostBDRCBOM", "");
  8545. designer.SetDataSource("CostBRSOM", "");
  8546. designer.SetDataSource("CostBZCBOM", "");
  8547. designer.SetDataSource("CostBDRBJOM", "");
  8548. designer.SetDataSource("CostBZBJOM", "");
  8549. designer.SetDataSource("CostBDRLROM", "");
  8550. designer.SetDataSource("CostBZLROM", "");
  8551. #endregion
  8552. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8553. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8554. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8555. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8556. designer.SetDataSource("DJName", "地接(CNY)");
  8557. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8558. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8559. designer.SetDataSource("GWName", "公务(CNY)");
  8560. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8561. designer.SetDataSource("LYJName", "零用金(CNY)");
  8562. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8563. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8564. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8565. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8566. designer.SetDataSource("BXName", "保险(CNY)");
  8567. designer.SetDataSource("VisaName", "签证(CNY)");
  8568. #region B段基本数据
  8569. if (dto.costType == "B")
  8570. {
  8571. left = dto.leftInfo.Find(x => x.Type == "B");
  8572. if (left == null)
  8573. {
  8574. return Ok(jw);
  8575. }
  8576. #region B段left数据
  8577. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8578. if (leftBindData != null)
  8579. {
  8580. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8581. designer.SetDataSource("BHSRS", leftBindData.rs);
  8582. designer.SetDataSource("BHSXS", leftBindData.xs);
  8583. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8584. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8585. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8586. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8587. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8588. }
  8589. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8590. if (leftBindData != null)
  8591. {
  8592. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8593. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8594. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8595. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8596. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8597. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8598. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8599. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8600. }
  8601. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8602. if (leftBindData != null)
  8603. {
  8604. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8605. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8606. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8607. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8608. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8609. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8610. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8611. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8612. }
  8613. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8614. if (leftBindData != null)
  8615. {
  8616. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8617. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8618. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8619. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8620. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8621. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8622. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8623. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8624. }
  8625. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8626. if (leftBindData != null)
  8627. {
  8628. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8629. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8630. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8631. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8632. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8633. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8634. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8635. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8636. }
  8637. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8638. if (leftBindData != null)
  8639. {
  8640. designer.SetDataSource("BCPCB", leftBindData.cb);
  8641. designer.SetDataSource("BCPRS", leftBindData.rs);
  8642. designer.SetDataSource("BCPXS", leftBindData.xs);
  8643. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8644. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8645. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8646. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8647. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8648. }
  8649. //TBR
  8650. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8651. if (leftBindData != null)
  8652. {
  8653. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8654. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8655. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8656. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8657. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8658. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8659. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8660. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8661. }
  8662. //SGR
  8663. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8664. if (leftBindData != null)
  8665. {
  8666. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8667. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8668. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8669. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8670. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8671. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8672. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8673. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8674. }
  8675. //JS/ES
  8676. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8677. if (leftBindData != null)
  8678. {
  8679. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8680. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8681. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8682. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8683. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8684. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8685. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8686. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8687. }
  8688. //SUITE
  8689. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8690. if (leftBindData != null)
  8691. {
  8692. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8693. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8694. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8695. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8696. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8697. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8698. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8699. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8700. }
  8701. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8702. if (leftBindData != null)
  8703. {
  8704. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8705. designer.SetDataSource("BDJRS", leftBindData.rs);
  8706. designer.SetDataSource("BDJXS", leftBindData.xs);
  8707. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8708. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8709. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8710. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8711. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8712. }
  8713. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8714. if (leftBindData != null)
  8715. {
  8716. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8717. designer.SetDataSource("BGWRS", leftBindData.rs);
  8718. designer.SetDataSource("BGWXS", leftBindData.xs);
  8719. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8720. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8721. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8722. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8723. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8724. }
  8725. #region 优化方案
  8726. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8727. //excelBind.Add("零用金", new {
  8728. //cb="",
  8729. //rs="",
  8730. //xs ="",
  8731. //zcb = "",
  8732. //});
  8733. #endregion
  8734. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8735. if (leftBindData != null)
  8736. {
  8737. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8738. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8739. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8740. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8741. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8742. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8743. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8744. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8745. }
  8746. #endregion
  8747. #region B段Right信息
  8748. right = dto.rightInfo.Find(x => x.Type == "B");
  8749. if (right == null)
  8750. {
  8751. return Ok(jw);
  8752. }
  8753. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8754. if (rightBindData != null)
  8755. {
  8756. //经济舱 + 双人间 TBR
  8757. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8758. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8759. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8760. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8761. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8762. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8763. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8764. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8765. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8766. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8767. }
  8768. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8769. if (rightBindData != null)
  8770. {
  8771. //经济舱 + 单人间 SGR
  8772. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8773. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8774. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8775. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8776. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8777. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8778. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8779. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8780. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8781. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8782. }
  8783. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8784. if (rightBindData != null)
  8785. {
  8786. //公务舱 + 单人间 SGR
  8787. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8788. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8789. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8790. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8791. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8792. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8793. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8794. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8795. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8796. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8797. }
  8798. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8799. if (rightBindData != null)
  8800. {
  8801. //公务舱 + 小套房 JSES
  8802. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8803. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8804. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8805. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8806. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8807. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8808. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8809. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8810. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8811. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8812. }
  8813. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8814. if (rightBindData != null)
  8815. {
  8816. //公务舱 + 小套房 JSES
  8817. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8818. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8819. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8820. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8821. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8822. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8823. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8824. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8825. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8826. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8827. }
  8828. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8829. if (rightBindData != null)
  8830. {
  8831. //经济舱 + 大套房
  8832. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8833. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8834. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8835. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8836. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8837. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8838. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8839. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8840. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8841. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8842. }
  8843. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8844. if (rightBindData != null)
  8845. {
  8846. //头等舱 + 小套房 JSES
  8847. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8848. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8849. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8850. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8851. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8852. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8853. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8854. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8855. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8856. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8857. }
  8858. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8859. if (rightBindData != null)
  8860. {
  8861. //头等舱 + 大套房
  8862. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8863. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8864. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8865. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8866. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8867. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8868. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8869. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8870. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8871. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8872. }
  8873. #endregion
  8874. #region 标题
  8875. designer.SetDataSource("CostBDRCB", "单人成本");
  8876. designer.SetDataSource("CostBRS", "人数");
  8877. designer.SetDataSource("CostBXS", "系数");
  8878. designer.SetDataSource("CostBZCB", "总成本");
  8879. designer.SetDataSource("CostBDRBJ", "单人报价");
  8880. designer.SetDataSource("CostBZBJ", "总报价");
  8881. designer.SetDataSource("CostBDRLR", "单人利润");
  8882. designer.SetDataSource("CostBZLR", "总利润");
  8883. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8884. designer.SetDataSource("CostBRSOM", "人数");
  8885. designer.SetDataSource("CostBZCBOM", "总成本");
  8886. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8887. designer.SetDataSource("CostBZBJOM", "总报价");
  8888. designer.SetDataSource("CostBDRLROM", "单人利润");
  8889. designer.SetDataSource("CostBZLROM", "总利润");
  8890. #endregion
  8891. }
  8892. #endregion
  8893. designer.SetDataSource("TzZCB2", TzZCB2);
  8894. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8895. designer.SetDataSource("TzZLR2", TzZLR2);
  8896. string[] dataSourceKeys = new string[]
  8897. {
  8898. "VF",
  8899. "TGS",
  8900. "TGOF",
  8901. "TGM",
  8902. "TGA",
  8903. "TGTF",
  8904. "TGEF",
  8905. "CFM",
  8906. "CFOF",
  8907. "B",
  8908. "L",
  8909. "D",
  8910. "TBR",
  8911. "SGR",
  8912. "JSES",
  8913. "Suite",
  8914. "TV",
  8915. "1L",
  8916. "IF",
  8917. "EF",
  8918. "BRF",
  8919. "TE",
  8920. "TGT",
  8921. "DRVT",
  8922. "PC",
  8923. "TLF",
  8924. "ECT"
  8925. };
  8926. foreach (var item in dataSourceKeys)
  8927. {
  8928. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8929. if (find != null)
  8930. {
  8931. designer.SetDataSource(item, find.text);
  8932. }
  8933. else
  8934. {
  8935. designer.SetDataSource(item, 0);
  8936. }
  8937. }
  8938. designer.SetDataSource(dt);
  8939. //根据数据源处理生成报表内容
  8940. designer.Process();
  8941. designer.Workbook.Worksheets[0].Name = "清单";
  8942. Worksheet sheet = designer.Workbook.Worksheets[0];
  8943. foreach (var Rowindex in hideRowsList)
  8944. {
  8945. ws.Cells.HideRows(Rowindex, 2);
  8946. }
  8947. byte[] bytes = null;
  8948. string strFileName = di.TeamName + "-团组-成本.xls";
  8949. using (MemoryStream stream = new MemoryStream())
  8950. {
  8951. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8952. bytes = stream.ToArray();
  8953. }
  8954. return Ok(JsonView(true, "", new
  8955. {
  8956. Data = bytes,
  8957. strFileName,
  8958. }));
  8959. }
  8960. /// <summary>
  8961. /// 导出客户报表
  8962. /// </summary>
  8963. /// <returns></returns>
  8964. [HttpPost]
  8965. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8966. {
  8967. var jw = JsonView(false);
  8968. if (dto.Diid == 0)
  8969. {
  8970. return Ok(JsonView(false, "请传递团组id"));
  8971. }
  8972. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8973. if (deleInfo.Code != 0)
  8974. {
  8975. return Ok(JsonView(false, "团组信息查询失败!"));
  8976. }
  8977. var di = deleInfo.Data as DelegationInfoWebView;
  8978. if (di == null)
  8979. {
  8980. return Ok(JsonView(false, "团组信息查询失败!"));
  8981. }
  8982. //文件名
  8983. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8984. //获取模板
  8985. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8986. //载入模板
  8987. Document doc = new Document(tmppath);
  8988. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8989. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8990. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8991. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8992. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8993. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8994. if (AParameter == null)
  8995. {
  8996. return Ok(JsonView(false, "系数不存在!"));
  8997. }
  8998. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8999. , TzAirDesc, TzZCost;
  9000. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  9001. = TzAirDesc = TzZCost = string.Empty;
  9002. TzNumber = AParameter.CostTypenumber.ToString();
  9003. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  9004. CarGuides1 = dto.CarGuides1;
  9005. Meal = dto.Meal;
  9006. SubsidizedMeals = dto.SubsidizedMeals;
  9007. NightRepair = dto.NightRepair;
  9008. AttractionsTickets = dto.AttractionsTickets;
  9009. MiscellaneousFees = dto.MiscellaneousFees;
  9010. ATip = dto.ATip;
  9011. TzHotelDesc = "";
  9012. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  9013. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  9014. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  9015. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  9016. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  9017. TzAirDesc = "";
  9018. TzZCost = dto.TzZCost;
  9019. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  9020. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  9021. var index = 1;
  9022. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  9023. foreach (var item in TzHotelDescArr)
  9024. {
  9025. if (AinfoArr != null)
  9026. {
  9027. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9028. if (Ainfo != null)
  9029. {
  9030. if (int.Parse(Ainfo.rs) <= 0)
  9031. {
  9032. continue;
  9033. }
  9034. var hotelText = string.Empty;
  9035. switch (item)
  9036. {
  9037. case "SGR":
  9038. hotelText = "单人间";
  9039. break;
  9040. case "JSES":
  9041. hotelText = "小套房";
  9042. break;
  9043. case "SUITE":
  9044. hotelText = "套房";
  9045. break;
  9046. case "TBR":
  9047. hotelText = "双人间";
  9048. break;
  9049. }
  9050. if (item != "TBR")
  9051. {
  9052. 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";
  9053. }
  9054. else
  9055. {
  9056. 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";
  9057. }
  9058. index++;
  9059. }
  9060. }
  9061. }
  9062. index = 1;
  9063. foreach (var item in TzAirDescArr)
  9064. {
  9065. if (AinfoArr != null)
  9066. {
  9067. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9068. if (Ainfo != null)
  9069. {
  9070. if (int.Parse(Ainfo.rs) <= 0)
  9071. {
  9072. continue;
  9073. }
  9074. 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";
  9075. index++;
  9076. }
  9077. }
  9078. }
  9079. if (dto.costType == "B")
  9080. {
  9081. if (BParameter == null)
  9082. {
  9083. return Ok(JsonView(false, "B段系数不存在!"));
  9084. }
  9085. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  9086. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  9087. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  9088. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  9089. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  9090. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  9091. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  9092. foreach (var item in TzHotelDescArr)
  9093. {
  9094. if (AinfoArr != null)
  9095. {
  9096. TzHotelDesc += "B段信息 \r\n";
  9097. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9098. if (Ainfo != null)
  9099. {
  9100. if (int.Parse(Ainfo.rs) <= 0)
  9101. {
  9102. continue;
  9103. }
  9104. var hotelText = string.Empty;
  9105. switch (item)
  9106. {
  9107. case "SGR":
  9108. hotelText = "单人间";
  9109. break;
  9110. case "JSES":
  9111. hotelText = "小套房";
  9112. break;
  9113. case "SUITE":
  9114. hotelText = "套房";
  9115. break;
  9116. case "TBR":
  9117. hotelText = "双人间";
  9118. break;
  9119. }
  9120. if (item != "TBR")
  9121. {
  9122. 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";
  9123. }
  9124. else
  9125. {
  9126. 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";
  9127. }
  9128. index++;
  9129. }
  9130. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  9131. }
  9132. }
  9133. index = 1;
  9134. foreach (var item in TzAirDescArr)
  9135. {
  9136. if (AinfoArr != null)
  9137. {
  9138. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9139. if (Ainfo != null)
  9140. {
  9141. if (int.Parse(Ainfo.rs) <= 0)
  9142. {
  9143. continue;
  9144. }
  9145. 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";
  9146. index++;
  9147. }
  9148. }
  9149. }
  9150. }
  9151. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  9152. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  9153. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  9154. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  9155. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  9156. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  9157. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  9158. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  9159. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  9160. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  9161. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  9162. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  9163. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  9164. DickeyValue.Add("Visa", Visa); // 签证单人报价
  9165. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  9166. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  9167. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  9168. DickeyValue.Add("TzZCost", TzZCost);
  9169. foreach (var key in DickeyValue.Keys)
  9170. {
  9171. if (doc.Range.Bookmarks[key] != null)
  9172. {
  9173. Bookmark mark = doc.Range.Bookmarks[key];
  9174. mark.Text = DickeyValue[key];
  9175. }
  9176. }
  9177. byte[] bytes = null;
  9178. string strFileName = di.TeamName + "-客户报价.doc";
  9179. using (MemoryStream stream = new MemoryStream())
  9180. {
  9181. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9182. bytes = stream.ToArray();
  9183. }
  9184. return Ok(JsonView(true, "", new
  9185. {
  9186. Data = bytes,
  9187. strFileName,
  9188. }));
  9189. }
  9190. /// <summary>
  9191. /// 团组成本 各模块(酒店,地接,机票)成本提示
  9192. /// </summary>
  9193. /// <param name="dto"></param>
  9194. /// <returns></returns>
  9195. [HttpPost]
  9196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9197. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  9198. {
  9199. try
  9200. {
  9201. #region 参数验证
  9202. if (dto.DiId < 0)
  9203. {
  9204. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9205. }
  9206. List<int> cTableIds = new List<int>() {
  9207. 76 ,//酒店预订
  9208. 77 ,//行程
  9209. 79 ,//车/导游地接
  9210. 80 ,//签证
  9211. 81 ,//邀请/公务活
  9212. 82 ,//团组客户保险
  9213. 85 ,//机票预订
  9214. 98 ,//其他款项
  9215. 285 ,//收款退还
  9216. 751 ,//酒店早餐
  9217. 1015 // 超支费用
  9218. };
  9219. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9220. {
  9221. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9222. }
  9223. #endregion
  9224. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9225. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9226. if (_GroupCostParameters.Count <= 0)
  9227. {
  9228. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9229. }
  9230. if (_GroupCostParameters[0].IsShare == 0)
  9231. {
  9232. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9233. }
  9234. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9235. //处理date为空问题
  9236. if (_GroupCosts.Count > 0)
  9237. {
  9238. for (int i = 0; i < _GroupCosts.Count; i++)
  9239. {
  9240. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9241. {
  9242. if (i > 0)
  9243. {
  9244. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9245. }
  9246. }
  9247. }
  9248. }
  9249. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9250. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9251. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9252. string currCode = "";
  9253. #region currCode 验证
  9254. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9255. if (isInt)
  9256. {
  9257. var currData = currDatas.Find(it => it.Id == intCurrency);
  9258. if (currData != null)
  9259. {
  9260. currCode = currData.Name;
  9261. }
  9262. }
  9263. else
  9264. {
  9265. currCode = _GroupCostParameters[0].Currency.Trim();
  9266. }
  9267. #endregion
  9268. //op,酒店单段模式存储
  9269. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9270. {
  9271. CurrencyCode = currCode,
  9272. Rate = _GroupCostParameters[0].Rate,
  9273. CostType = _GroupCostParameters[0].CostType,
  9274. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9275. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9276. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9277. };
  9278. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9279. if (_GroupCostParameters.Count == 2)
  9280. {
  9281. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9282. }
  9283. foreach (var item in _GroupCostParameters)
  9284. {
  9285. decimal _rate = 1;
  9286. decimal _rate1 = item.Rate;
  9287. decimal _scale = 1;
  9288. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9289. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9290. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9291. //if (userInfo != null)
  9292. //{
  9293. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9294. // {
  9295. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9296. // {
  9297. // _scale = 1.00M;
  9298. // }
  9299. // }
  9300. //}
  9301. #endregion
  9302. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9303. {
  9304. CurrencyCode = currCode,
  9305. Rate = _rate1,
  9306. CostType = item.CostType,
  9307. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9308. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9309. CostTypeNumber = item.CostTypenumber
  9310. };
  9311. if (_GroupCostParameters.Count > 1)
  9312. {
  9313. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9314. }
  9315. else
  9316. {
  9317. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9318. }
  9319. if (dto.CTable == 79)//
  9320. {
  9321. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9322. modulePromptInfo.TotalCost = item.DJCB;
  9323. }
  9324. List<string> costTypes = new List<string>() { "A", "B" };
  9325. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9326. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9327. if (_GroupCostsDuplicates.Count() == 1)
  9328. {
  9329. _GroupCostsTypeData = _GroupCosts;
  9330. }
  9331. else
  9332. {
  9333. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9334. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9335. }
  9336. /*
  9337. * 76 酒店预订
  9338. * 77 行程
  9339. * 79 车/导游地接
  9340. * 80 签证
  9341. * 81 邀请/公务活动
  9342. * 82 团组客户保险
  9343. * 85 机票预订
  9344. * 98 其他款项
  9345. * 285 收款退还
  9346. * 751 酒店早餐
  9347. * 1015 超支费用
  9348. */
  9349. switch (dto.CTable)
  9350. {
  9351. case 76: // 酒店预订
  9352. _ModuleSubPromptInfo.AddRange(
  9353. _GroupCostsTypeData.Select(it => new
  9354. {
  9355. it.DAY,
  9356. it.Date,
  9357. it.ACCON,
  9358. it.ITIN,
  9359. it.SGR,
  9360. it.TBR,
  9361. it.JS_ES,
  9362. it.Suite
  9363. })
  9364. );
  9365. break;
  9366. case 79: // 车/导游地接
  9367. _ModuleSubPromptInfo.AddRange(
  9368. _GroupCostsTypeData.Select(it => new
  9369. {
  9370. Date = it.Date, //日期
  9371. CarFee = it.CarCost * _rate * _scale, //车费用
  9372. CarType = it.CarType, //车型
  9373. DriverFee = it.CFS * _rate * _scale, //司机工资
  9374. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9375. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9376. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9377. GuideFee = it.TGS * _rate * _scale, //导游费用
  9378. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9379. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9380. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9381. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9382. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9383. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9384. Breakfast = it.B * _rate * _scale, //早餐费
  9385. Lunch = it.L * _rate * _scale, //午餐费
  9386. Dinner = it.D * _rate * _scale, //晚餐费
  9387. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9388. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9389. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9390. TicketFee = it.EF * _rate * _scale, //门票费
  9391. TicketRemark = it.EFR, //门票费描述
  9392. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9393. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9394. SpentCash = it.PC * _rate * _scale, //零用金
  9395. LeadersFee = it.TLF * _rate * _scale, //领队费
  9396. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9397. })
  9398. );
  9399. break;
  9400. case 85: // 机票
  9401. List<dynamic> datas = new List<dynamic>();
  9402. datas.Add(
  9403. new
  9404. {
  9405. AirType = "经济舱",
  9406. AirNum = item.JJCRS,
  9407. AirDRCB = item.JJCCB,
  9408. AirZCB = (item.JJCRS * item.JJCCB)
  9409. }
  9410. );
  9411. datas.Add(
  9412. new
  9413. {
  9414. AirType = "公务舱",
  9415. AirNum = item.GWCRS,
  9416. AirDRCB = item.GWCCB,
  9417. AirZCB = (item.GWCRS * item.GWCCB)
  9418. }
  9419. );
  9420. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9421. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9422. modulePromptInfo.Data = new
  9423. {
  9424. airFeeData = datas,
  9425. airInitData = initDatas
  9426. };
  9427. _ModulePromptInfos.Add(modulePromptInfo);
  9428. break;
  9429. default:
  9430. break;
  9431. }
  9432. }
  9433. if (dto.CTable != 85)
  9434. {
  9435. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9436. _ModulePromptInfos.Add(_ModulePromptInfo);
  9437. }
  9438. _view.ModulePromptInfos = _ModulePromptInfos;
  9439. return Ok(JsonView(true, "操作成功!", _view));
  9440. }
  9441. catch (Exception ex)
  9442. {
  9443. return Ok(JsonView(false, ex.Message));
  9444. }
  9445. }
  9446. /// <summary>
  9447. /// 根据黑屏代码重新生成行程
  9448. /// </summary>
  9449. /// <param name="dto"></param>
  9450. /// <returns></returns>
  9451. [HttpPost]
  9452. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9453. {
  9454. var jw = JsonView(false);
  9455. var Create = _GroupCostRepository.
  9456. CreateGroupCostByBlackCode(dto.Diid);
  9457. jw.Msg = Create.Msg;
  9458. if (Create.Code == 0)
  9459. {
  9460. jw.Code = 200;
  9461. jw.Data = new
  9462. {
  9463. groupCost = Create.Data,
  9464. blackCodeIsTrue = true
  9465. };
  9466. }
  9467. else
  9468. {
  9469. jw.Code = 400;
  9470. jw.Data = new
  9471. {
  9472. groupCost = Create.Data,
  9473. blackCodeIsTrue = false,
  9474. };
  9475. }
  9476. return Ok(jw);
  9477. }
  9478. /// <summary>
  9479. /// 成本获取OP历史车费用
  9480. /// </summary>
  9481. /// <param name="dto"></param>
  9482. /// <returns></returns>
  9483. [HttpPost]
  9484. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9485. {
  9486. var jw = JsonView(false);
  9487. try
  9488. {
  9489. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9490. //获取现有所有车的数据
  9491. if (!dto.Param.IsNullOrWhiteSpace())
  9492. {
  9493. string sql = $@"
  9494. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9495. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9496. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9497. 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
  9498. AND gctggr.ServiceEndTime is not NULL
  9499. ORDER by gctggrc.id DESC
  9500. ";
  9501. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9502. var numeberResult = await Task.Run(() =>
  9503. {
  9504. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9505. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9506. return numberArr;
  9507. });
  9508. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9509. foreach (var item in numeberResult)
  9510. {
  9511. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9512. {
  9513. Country = "数据异常!",
  9514. City = string.Empty,
  9515. };
  9516. item.Area = find.Country + " " + find.City;
  9517. }
  9518. dbResult.AddRange(numeberResult);
  9519. if (dto.Param.Contains("、"))
  9520. {
  9521. var sp = dto.Param.Split("、");
  9522. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9523. .Where(x =>
  9524. {
  9525. return System.Array.Exists(sp, e =>
  9526. {
  9527. bool where = false;
  9528. if (x.Area != null)
  9529. {
  9530. where = x.Area.Contains(e);
  9531. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9532. {
  9533. return false;
  9534. }
  9535. }
  9536. if (x.PriceName != null && !where)
  9537. {
  9538. where = x.PriceName.Contains(e);
  9539. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9540. {
  9541. return false;
  9542. }
  9543. }
  9544. return where;
  9545. });
  9546. }).ToList();
  9547. }
  9548. else
  9549. {
  9550. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9551. .Where(x =>
  9552. {
  9553. bool where = false;
  9554. if (x.Area != null)
  9555. {
  9556. where = x.Area.Contains(dto.Param);
  9557. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9558. {
  9559. return false;
  9560. }
  9561. }
  9562. if (x.PriceName != null && !where)
  9563. {
  9564. where = x.PriceName.Contains(dto.Param);
  9565. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9566. {
  9567. return false;
  9568. }
  9569. }
  9570. return where;
  9571. }
  9572. )
  9573. .ToList();
  9574. }
  9575. }
  9576. var view = dbResult.Select(x =>
  9577. {
  9578. decimal dp = 0.00M;
  9579. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9580. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9581. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9582. {
  9583. if (startB && endB)
  9584. {
  9585. var timesp = endD.Subtract(startD);
  9586. if ((timesp.Days + 1) != 0)
  9587. {
  9588. dp = x.Price / (timesp.Days + 1);
  9589. }
  9590. }
  9591. }
  9592. else
  9593. {
  9594. dp = x.Price;
  9595. }
  9596. return new
  9597. {
  9598. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9599. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9600. x.Area,
  9601. x.id,
  9602. price = x.Price.ToString("F2"),
  9603. x.PriceName,
  9604. x.PriceContent,
  9605. x.TeamName,
  9606. x.DatePrice,
  9607. dayPrice = dp.ToString("F2"),
  9608. };
  9609. }).OrderByDescending(x => x.id).ToList();
  9610. jw = JsonView(true, "获取成功!", view);
  9611. }
  9612. catch (Exception e)
  9613. {
  9614. jw = JsonView(false, e.Message);
  9615. }
  9616. return Ok(jw);
  9617. }
  9618. #endregion
  9619. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9620. /// <summary>
  9621. /// 酒店预订
  9622. /// 酒店费用列表 根据团组Id查询
  9623. /// </summary>
  9624. /// <param name="_dto"></param>
  9625. /// <returns></returns>
  9626. [HttpPost]
  9627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9628. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9629. {
  9630. #region 参数验证
  9631. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9632. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9633. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9634. #region 团组操作权限验证 76 酒店预定模块
  9635. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9636. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9637. #endregion
  9638. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9639. #region 页面操作权限验证
  9640. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9641. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9642. #endregion
  9643. #endregion
  9644. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9645. }
  9646. /// <summary>
  9647. /// 酒店预订
  9648. /// 基础数据
  9649. /// </summary>
  9650. /// <param name="_dto"></param>
  9651. /// <returns></returns>
  9652. [HttpPost]
  9653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9654. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9655. {
  9656. #region 参数验证
  9657. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9658. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9659. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9660. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9661. #region 页面操作权限验证
  9662. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9663. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9664. #endregion
  9665. #region 团组操作权限验证 76 酒店预定模块
  9666. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9667. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9668. #endregion
  9669. #endregion
  9670. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9671. }
  9672. /// <summary>
  9673. /// 酒店预订
  9674. /// 创建 入住卷号码
  9675. /// </summary>
  9676. /// <param name="_dto"></param>
  9677. /// <returns></returns>
  9678. [HttpPost]
  9679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9680. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9681. {
  9682. #region 参数验证
  9683. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9684. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9685. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9687. #region 页面操作权限验证
  9688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9689. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9690. #endregion
  9691. #region 团组操作权限验证 76 酒店预定模块
  9692. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9693. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9694. #endregion
  9695. #endregion
  9696. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9697. if (data.Code != 0)
  9698. {
  9699. return Ok(JsonView(false, data.Msg));
  9700. }
  9701. return Ok(JsonView(true, data.Msg, data.Data));
  9702. }
  9703. /// <summary>
  9704. /// 酒店预订
  9705. /// 详情
  9706. /// </summary>
  9707. /// <param name="_dto"></param>
  9708. /// <returns></returns>
  9709. [HttpPost]
  9710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9711. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9712. {
  9713. #region 参数验证
  9714. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9715. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9716. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9717. #region 团组操作权限验证 76 酒店预定模块
  9718. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9719. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9720. #endregion
  9721. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9722. #region 页面操作权限验证
  9723. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9724. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9725. #endregion
  9726. #endregion
  9727. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9728. }
  9729. /// <summary>
  9730. /// 酒店预订
  9731. /// Add Or Edit
  9732. /// </summary>
  9733. /// <param name="_dto"></param>
  9734. /// <returns></returns>
  9735. [HttpPost]
  9736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9737. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9738. {
  9739. #region 参数验证
  9740. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9741. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9742. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9743. #region 团组操作权限验证 76 酒店预定模块
  9744. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9745. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9746. #endregion
  9747. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9748. #region 页面操作权限验证
  9749. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9750. if (_dto.Id == 0) // Add
  9751. {
  9752. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9753. }
  9754. else if (_dto.Id > 1) // Edit
  9755. {
  9756. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9757. }
  9758. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9759. #endregion
  9760. #endregion
  9761. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9762. if (_view.Code != 200)
  9763. {
  9764. return Ok(_view);
  9765. }
  9766. #region 应用推送
  9767. try
  9768. {
  9769. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9770. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9771. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9772. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  9773. //2024-10-21 新增LZ UID
  9774. var userIds = new List<int>() { 21 };
  9775. string title = $"费用审核";
  9776. var diId = _dto.DiId;
  9777. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9778. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9779. string content = "";
  9780. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9781. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9782. try
  9783. {
  9784. var iosRes1 = await APNsTools.iOS_PushNotifications1("051", title, "", content);
  9785. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  9786. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  9787. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  9788. }
  9789. catch (Exception ex )
  9790. {
  9791. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  9792. }
  9793. }
  9794. catch (Exception ex)
  9795. {
  9796. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  9797. }
  9798. try
  9799. {
  9800. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9801. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9802. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9803. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9804. //自动审核
  9805. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9806. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9807. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9808. //2024-10-21 新增LZ UID
  9809. var userIds = new List<int>() { 21 };
  9810. string title = $"系统通知";
  9811. var diId = _dto.DiId;
  9812. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9813. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9814. string content = "";
  9815. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9816. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9817. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9818. }
  9819. catch (Exception ex)
  9820. {
  9821. }
  9822. #endregion
  9823. return Ok(_view);
  9824. }
  9825. /// <summary>
  9826. /// 酒店自动审核测试
  9827. /// Add Or Edit
  9828. /// </summary>
  9829. /// <param name="_dto"></param>
  9830. /// <returns></returns>
  9831. [HttpPost]
  9832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9833. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9834. {
  9835. #region 应用推送
  9836. try
  9837. {
  9838. //自动审核
  9839. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9840. }
  9841. catch (Exception ex)
  9842. {
  9843. return Ok(JsonView(false, "操作失败"));
  9844. }
  9845. #endregion
  9846. return Ok(JsonView(false, "操作成功"));
  9847. }
  9848. /// <summary>
  9849. /// 酒店预订
  9850. /// Del
  9851. /// </summary>
  9852. /// <param name="_dto"></param>
  9853. /// <returns></returns>
  9854. [HttpPost]
  9855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9856. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9857. {
  9858. #region 参数验证
  9859. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9860. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9861. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9862. #region 团组操作权限验证 76 酒店预定模块
  9863. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9864. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9865. #endregion
  9866. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9867. #region 页面操作权限验证
  9868. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9869. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9870. #endregion
  9871. #endregion
  9872. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9873. }
  9874. /// <summary>
  9875. /// 酒店预订
  9876. /// 生成VOUCHER
  9877. /// 2024.05.06 之前版本
  9878. /// </summary>
  9879. /// <param name="_dto"></param>
  9880. /// <returns></returns>
  9881. [HttpPost]
  9882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9883. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9884. {
  9885. try
  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. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9892. #region 团组操作权限验证 76 酒店预定模块
  9893. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9894. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9895. #endregion
  9896. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9897. #region 页面操作权限验证
  9898. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9899. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9900. #endregion
  9901. #endregion
  9902. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9903. //判断数据是否完整
  9904. if (hr != null)
  9905. {
  9906. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9907. {
  9908. string strFileName = "HotelStatement/";
  9909. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9910. if (dele != null)
  9911. strFileName += dele.TourCode;
  9912. //载入模板
  9913. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9914. Document doc = new Document(sss);
  9915. DocumentBuilder builder = new DocumentBuilder(doc);
  9916. #region 替换Word模板书签内容
  9917. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9918. //入住卷预定号码
  9919. if (doc.Range.Bookmarks["VNO"] != null)
  9920. {
  9921. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9922. mark.Text = hr.CheckNumber;
  9923. }
  9924. //酒店时间
  9925. if (doc.Range.Bookmarks["Date"] != null)
  9926. {
  9927. Bookmark mark = doc.Range.Bookmarks["Date"];
  9928. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9929. }
  9930. //团号
  9931. if (doc.Range.Bookmarks["TNo"] != null)
  9932. {
  9933. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9934. mark.Text = dele.TourCode;
  9935. }
  9936. //预定号码
  9937. if (doc.Range.Bookmarks["BookingId"] != null)
  9938. {
  9939. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9940. mark.Text = hr.ReservationsNo;
  9941. }
  9942. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9943. {
  9944. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9945. mark.Text = hr.DetermineNo;
  9946. }
  9947. //酒店城市
  9948. if (doc.Range.Bookmarks["City"] != null)
  9949. {
  9950. Bookmark mark = doc.Range.Bookmarks["City"];
  9951. mark.Text = hr.City;
  9952. }
  9953. //酒店名称
  9954. if (doc.Range.Bookmarks["HName"] != null)
  9955. {
  9956. Bookmark mark = doc.Range.Bookmarks["HName"];
  9957. mark.Text = hr.HotelName;
  9958. }
  9959. //酒店地址
  9960. if (doc.Range.Bookmarks["Address"] != null)
  9961. {
  9962. Bookmark mark = doc.Range.Bookmarks["Address"];
  9963. mark.Text = hr.HotelAddress;
  9964. }
  9965. //酒店电话
  9966. if (doc.Range.Bookmarks["Tel"] != null)
  9967. {
  9968. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9969. mark.Text = hr.HotelTel;
  9970. }
  9971. //酒店传真
  9972. if (doc.Range.Bookmarks["Fax"] != null)
  9973. {
  9974. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9975. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9976. {
  9977. mark.Text = hr.HotelFax;
  9978. }
  9979. }
  9980. //入住时间
  9981. if (doc.Range.Bookmarks["CIn"] != null)
  9982. {
  9983. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9984. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9985. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9986. }
  9987. //退房时间
  9988. if (doc.Range.Bookmarks["COut"] != null)
  9989. {
  9990. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9991. Bookmark mark = doc.Range.Bookmarks["COut"];
  9992. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9993. }
  9994. //客户名称
  9995. if (doc.Range.Bookmarks["GName"] != null)
  9996. {
  9997. string guestName = "";
  9998. string[] clients = new string[] { };
  9999. if (hr.GuestName.Contains(","))
  10000. {
  10001. clients = hr.GuestName.Split(",");
  10002. }
  10003. else
  10004. {
  10005. clients = new string[] { hr.GuestName };
  10006. }
  10007. List<int> clientIds_int = new List<int>();
  10008. if (clients.Length > 0)
  10009. {
  10010. foreach (var item in clients)
  10011. {
  10012. if (item.IsNumeric())
  10013. {
  10014. clientIds_int.Add(int.Parse(item));
  10015. }
  10016. }
  10017. }
  10018. if (clientIds_int.Count > 0)
  10019. {
  10020. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  10021. foreach (var client in _clientDatas)
  10022. {
  10023. //男
  10024. if (client.Sex == 0) guestName += $"Mr.";
  10025. //女
  10026. else if (client.Sex == 1) guestName += $"Ms.";
  10027. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  10028. {
  10029. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  10030. }
  10031. //guestName += $"{client.Pinyin},";
  10032. }
  10033. if (guestName.Length > 0)
  10034. {
  10035. guestName = guestName.Substring(0, guestName.Length - 1);
  10036. }
  10037. }
  10038. else
  10039. {
  10040. guestName = hr.GuestName;
  10041. }
  10042. Bookmark mark = doc.Range.Bookmarks["GName"];
  10043. mark.Text = guestName;
  10044. }
  10045. //房间介绍
  10046. if (doc.Range.Bookmarks["ROOM"] != null)
  10047. {
  10048. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  10049. mark.Text = hr.RoomExplanation;
  10050. }
  10051. //报价描述
  10052. if (doc.Range.Bookmarks["NOTE"] != null)
  10053. {
  10054. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  10055. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  10056. if (ss != null)
  10057. mark.Text = ss.Name;
  10058. }
  10059. //入住时间
  10060. if (doc.Range.Bookmarks["CheckIn"] != null)
  10061. {
  10062. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  10063. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  10064. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10065. }
  10066. //退房时间
  10067. if (doc.Range.Bookmarks["CheckOut"] != null)
  10068. {
  10069. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  10070. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  10071. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  10072. }
  10073. //日期
  10074. if (doc.Range.Bookmarks["DT"] != null)
  10075. {
  10076. Bookmark mark = doc.Range.Bookmarks["DT"];
  10077. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  10078. }
  10079. //名称
  10080. if (doc.Range.Bookmarks["VName"] != null)
  10081. {
  10082. Bookmark mark = doc.Range.Bookmarks["VName"];
  10083. mark.Text = hr.HotelName;
  10084. }
  10085. //号码
  10086. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  10087. {
  10088. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  10089. mark.Text = hr.CheckNumber;
  10090. }
  10091. #endregion
  10092. strFileName += "VOUCHER.doc";
  10093. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10094. doc.Save(fileDir);
  10095. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10096. return Ok(JsonView(true, "操作成功!", Url));
  10097. }
  10098. else
  10099. {
  10100. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  10101. }
  10102. }
  10103. else
  10104. {
  10105. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  10106. }
  10107. }
  10108. catch (Exception ex)
  10109. {
  10110. return Ok(JsonView(false, ex.Message));
  10111. }
  10112. }
  10113. /// <summary>
  10114. /// 酒店预订
  10115. /// 生成VOUCHER
  10116. /// 2024.05.06 之后版本
  10117. /// </summary>
  10118. /// <param name="_dto"></param>
  10119. /// <returns></returns>
  10120. [HttpPost]
  10121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10122. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  10123. {
  10124. #region 参数验证
  10125. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10126. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10127. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10128. #region 团组操作权限验证 76 酒店预定模块
  10129. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10130. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10131. #endregion
  10132. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10133. #region 页面操作权限验证
  10134. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10135. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10136. #endregion
  10137. #endregion
  10138. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10139. //判断数据是否完整
  10140. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10141. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10142. string strFileName = "HotelStatement/";
  10143. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10144. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  10145. #region 数据处理
  10146. List<int> guestIds = new List<int>();
  10147. int index = 0;
  10148. foreach (var item in hrDtas)
  10149. {
  10150. if (item.GuestName.Contains(","))
  10151. {
  10152. string[] guestIdArr = item.GuestName.Split(',');
  10153. foreach (var guestIdStr in guestIdArr)
  10154. {
  10155. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  10156. if (guestBool)
  10157. {
  10158. guestIds.Add(guestId);
  10159. }
  10160. }
  10161. }
  10162. else guestNames += item.GuestName;
  10163. var voucherInfo = new HotelVoucherInfoView()
  10164. {
  10165. HotelName = item.HotelName,
  10166. CheckInDate = item.CheckInDate,
  10167. CheckOutDate = item.CheckOutDate,
  10168. ConfirmationNumber = item.DetermineNo.Trim(),
  10169. RoomType = item.RoomExplanation
  10170. };
  10171. vouchers.Add(voucherInfo);
  10172. }
  10173. if (guestIds.Count > 0)
  10174. {
  10175. guestIds = guestIds.Distinct().ToList();
  10176. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  10177. if (guestDatas.Count > 0)
  10178. {
  10179. guestNames = "";
  10180. foreach (var guest in guestDatas)
  10181. {
  10182. string guestName = "";
  10183. if (guest.Sex == 0) guestName += @"MR.";
  10184. else if (guest.Sex == 1) guestName += @"MS.";
  10185. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10186. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10187. guestNames += @$"{guestName.Trim()}、";
  10188. }
  10189. if (guestNames.Length > 0)
  10190. {
  10191. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10192. }
  10193. }
  10194. }
  10195. #endregion
  10196. //载入模板
  10197. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  10198. Document doc = new Document(sss);
  10199. DocumentBuilder builder = new DocumentBuilder(doc);
  10200. if (doc.Range.Bookmarks["GuestName"] != null)
  10201. {
  10202. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  10203. mark.Text = guestNames;
  10204. }
  10205. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10206. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  10207. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  10208. for (int i = 1; i <= vouchers.Count; i++)
  10209. {
  10210. HotelVoucherInfoView hviv = vouchers[i - 1];
  10211. builder.MoveToCell(0, i, 0, 0);
  10212. builder.Write(hviv.HotelName);
  10213. builder.MoveToCell(0, i, 1, 0);
  10214. builder.Write(hviv.CheckInDate);
  10215. builder.MoveToCell(0, i, 2, 0);
  10216. builder.Write(hviv.CheckOutDate);
  10217. builder.MoveToCell(0, i, 3, 0);
  10218. builder.Write(hviv.RoomType);
  10219. builder.MoveToCell(0, i, 4, 0);
  10220. builder.Write(hviv.ConfirmationNumber);
  10221. }
  10222. //删除多余行
  10223. int currRowIndex = vouchers.Count + 1;
  10224. int delRows = 21 - currRowIndex;
  10225. if (delRows > 0)
  10226. {
  10227. for (int i = 0; i < delRows; i++)
  10228. {
  10229. table.Rows.RemoveAt(currRowIndex);
  10230. //cultivateRowIndex++;
  10231. }
  10232. }
  10233. strFileName += "VOUCHER.docx";
  10234. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10235. doc.Save(fileDir);
  10236. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10237. return Ok(JsonView(true, "操作成功!", Url));
  10238. }
  10239. /// <summary>
  10240. /// 酒店预订
  10241. /// 生成VOUCHER 批量生成
  10242. /// New
  10243. /// </summary>
  10244. /// <param name="_dto"></param>
  10245. /// <returns></returns>
  10246. [HttpPost]
  10247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10248. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10249. {
  10250. #region 参数验证
  10251. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10252. if (_dto.PageId < 1) _dto.PageId = 28;
  10253. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10254. #region 团组操作权限验证 76 酒店预定模块
  10255. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10256. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10257. #endregion
  10258. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10259. #region 页面操作权限验证
  10260. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10261. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10262. #endregion
  10263. #endregion
  10264. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10265. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10266. .OrderBy(x => x.CheckInDate)
  10267. .ToListAsync();
  10268. //判断数据是否完整
  10269. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10270. string strFileName = "HotelStatement/";
  10271. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10272. if (dele != null)
  10273. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10274. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10275. for (int i = 0; i < hrDtas.Count; i++)
  10276. {
  10277. string guestNames = string.Empty;
  10278. List<int> guestIds = new List<int>();
  10279. var item = hrDtas[i];
  10280. //处理客户姓名
  10281. if (item.GuestName.Contains(","))
  10282. {
  10283. string[] guestIdArr = item.GuestName.Split(',');
  10284. foreach (var guestIdStr in guestIdArr)
  10285. if (int.TryParse(guestIdStr, out int guestId))
  10286. guestIds.Add(guestId);
  10287. }
  10288. else
  10289. {
  10290. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10291. if (guestIdBool)
  10292. {
  10293. guestIds.Add(guestId);
  10294. }
  10295. //NaN
  10296. if (item.GuestName.Contains("NaN"))
  10297. {
  10298. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10299. }
  10300. }
  10301. if (guestIds.Count > 0)
  10302. {
  10303. guestIds = guestIds.Distinct().ToList();
  10304. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10305. if (guestDatas1.Count > 0)
  10306. {
  10307. guestNames = "";
  10308. foreach (var guest in guestDatas1)
  10309. {
  10310. string guestName = "";
  10311. if (guest.Sex == 0) guestName += @"MR.";
  10312. else if (guest.Sex == 1) guestName += @"MS.";
  10313. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10314. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10315. guestNames += @$"{guestName.Trim()}、";
  10316. }
  10317. if (guestNames.Length > 0)
  10318. {
  10319. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10320. }
  10321. }
  10322. }
  10323. //if (!string.IsNullOrEmpty(guestNames))
  10324. //{
  10325. hrDtas[i].GuestName = guestNames;
  10326. //}
  10327. }
  10328. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10329. Document doc = new Document();
  10330. DocumentBuilder builder = new DocumentBuilder(doc);
  10331. try
  10332. {
  10333. builder.MoveToDocumentStart();
  10334. foreach (var item in hrDtas)
  10335. {
  10336. //标题
  10337. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10338. builder.ParagraphFormat.LineSpacing = 1;
  10339. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10340. builder.ParagraphFormat.Style.Font.Size = 9;
  10341. builder.ParagraphFormat.Style.Font.Bold = true;
  10342. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10343. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10344. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10345. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10346. builder.ParagraphFormat.LineSpacing = 1;
  10347. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10348. builder.ParagraphFormat.Style.Font.Size = 9;
  10349. builder.ParagraphFormat.Style.Font.Bold = true;
  10350. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10351. builder.StartTable();
  10352. // 设置边框颜色
  10353. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10354. //设置边框样式
  10355. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10356. //表格
  10357. #region 第一行
  10358. builder.InsertCell();
  10359. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10360. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10361. //builder.CellFormat.AllowAutoFit = false;
  10362. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10363. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10364. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10365. builder.CellFormat.WrapText = true; //自动换行
  10366. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10367. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10368. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10369. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10370. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10371. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10372. builder.Write("TOUR NO:");
  10373. builder.InsertCell();
  10374. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10375. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10376. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10377. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10378. builder.ParagraphFormat.Style.Font.Bold = false;
  10379. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10380. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10381. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10382. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10383. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10384. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10385. builder.Write($"{dele?.TourCode ?? "-"}");
  10386. builder.InsertCell();
  10387. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10388. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10389. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10390. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10391. builder.ParagraphFormat.Style.Font.Bold = false;
  10392. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10393. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10394. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10395. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10396. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10397. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10398. builder.Write($"CITY:");
  10399. builder.InsertCell();
  10400. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10401. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10402. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10403. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10404. builder.ParagraphFormat.Style.Font.Bold = false;
  10405. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10406. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10407. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10408. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10409. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10410. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10411. builder.Write($"{item.City}");
  10412. builder.EndRow();
  10413. #endregion
  10414. #region 第二行
  10415. builder.InsertCell();
  10416. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10417. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10418. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10419. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10420. builder.ParagraphFormat.Style.Font.Bold = false;
  10421. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10422. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10423. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10424. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10425. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10426. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10427. builder.Write("CONFIRMATION NO:");
  10428. builder.InsertCell();
  10429. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10430. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10431. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10432. builder.ParagraphFormat.Style.Font.Bold = false;
  10433. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10434. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10435. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10436. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10437. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10438. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10439. builder.CellFormat.VerticalMerge = CellMerge.None;
  10440. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10441. builder.Write($"{item.DetermineNo}");
  10442. builder.InsertCell();
  10443. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10444. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10445. builder.InsertCell();
  10446. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10447. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10448. builder.EndRow();
  10449. #endregion
  10450. #region 第三行
  10451. builder.InsertCell();
  10452. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10453. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10454. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10455. builder.ParagraphFormat.Style.Font.Bold = false;
  10456. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10457. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10458. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10459. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10460. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10461. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10462. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10463. builder.Write($"HOTEL NAME:");
  10464. builder.InsertCell();
  10465. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10466. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10467. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10468. builder.ParagraphFormat.Style.Font.Bold = false;
  10469. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10470. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10471. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10472. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10473. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10474. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10475. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10476. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10477. builder.Write($"{item.HotelName}");
  10478. builder.InsertCell();
  10479. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10480. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10481. builder.InsertCell();
  10482. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10483. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10484. builder.EndRow();
  10485. #endregion
  10486. #region 第四行
  10487. builder.InsertCell();
  10488. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10489. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10490. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10491. builder.ParagraphFormat.Style.Font.Bold = false;
  10492. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10493. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10494. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10495. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10496. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10497. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10498. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10499. builder.Write($"HOTEL ADDRESS:");
  10500. builder.InsertCell();
  10501. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10502. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10503. builder.ParagraphFormat.Style.Font.Size = 8;
  10504. builder.ParagraphFormat.Style.Font.Bold = false;
  10505. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10506. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10507. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10508. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10509. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10510. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10511. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10512. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10513. builder.Write($"{item.HotelAddress}");
  10514. builder.InsertCell();
  10515. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10516. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10517. builder.InsertCell();
  10518. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10519. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10520. builder.EndRow();
  10521. #endregion
  10522. #region 第五行
  10523. builder.InsertCell();
  10524. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10525. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10526. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10527. builder.ParagraphFormat.Style.Font.Bold = false;
  10528. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10529. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10530. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10531. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10532. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10533. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10534. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10535. builder.Write("TEL:");
  10536. builder.InsertCell();
  10537. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10538. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10539. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10540. builder.ParagraphFormat.Style.Font.Bold = false;
  10541. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10542. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10543. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10544. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10545. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10546. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10547. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10548. builder.Write($"{item.HotelTel}");
  10549. builder.InsertCell();
  10550. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10551. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10552. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10553. builder.ParagraphFormat.Style.Font.Bold = false;
  10554. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10555. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10556. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10557. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10558. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10559. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10560. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10561. builder.Write($"FAX:");
  10562. builder.InsertCell();
  10563. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10564. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10565. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10566. builder.ParagraphFormat.Style.Font.Bold = false;
  10567. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10568. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10569. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10570. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10571. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10572. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10573. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10574. builder.Write($"{item.HotelFax}");
  10575. builder.EndRow();
  10576. #endregion
  10577. #region 第六行
  10578. builder.InsertCell();
  10579. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10580. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10581. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10582. builder.ParagraphFormat.Style.Font.Bold = false;
  10583. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10584. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10585. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10586. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10587. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10588. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10589. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10590. builder.Write("CHECK IN:");
  10591. builder.InsertCell();
  10592. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10593. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10594. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10595. builder.ParagraphFormat.Style.Font.Bold = false;
  10596. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10597. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10598. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10599. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10600. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10601. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10602. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10603. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10604. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10605. builder.Write($"{checkInStr}");
  10606. builder.InsertCell();
  10607. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10608. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10609. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10610. builder.ParagraphFormat.Style.Font.Bold = false;
  10611. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10612. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10613. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10614. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10615. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10616. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10617. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10618. builder.Write($"CHECK OUT:");
  10619. builder.InsertCell();
  10620. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10621. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10622. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10623. builder.ParagraphFormat.Style.Font.Bold = false;
  10624. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10625. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10626. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10627. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10628. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10629. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10630. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10631. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10632. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10633. builder.Write($"{checkOutStr}");
  10634. builder.EndRow();
  10635. #endregion
  10636. #region 第七行
  10637. builder.InsertCell();
  10638. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10639. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10640. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10641. builder.ParagraphFormat.Style.Font.Bold = false;
  10642. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10643. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10644. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10645. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10646. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10647. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10648. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10649. builder.Write($"GUEST NAME:");
  10650. builder.InsertCell();
  10651. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10652. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10653. builder.ParagraphFormat.Style.Font.Size = 8;
  10654. builder.ParagraphFormat.Style.Font.Bold = false;
  10655. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10656. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10657. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10658. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10659. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10660. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10661. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10662. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10663. builder.Write($"{item.GuestName}");
  10664. builder.InsertCell();
  10665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10666. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10667. builder.InsertCell();
  10668. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10669. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10670. builder.EndRow();
  10671. #endregion
  10672. #region 第八行
  10673. builder.InsertCell();
  10674. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10675. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10676. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10677. builder.ParagraphFormat.Style.Font.Bold = false;
  10678. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10679. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10680. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10681. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10682. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10683. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10684. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10685. builder.Write($"ROOM TYPE:");
  10686. builder.InsertCell();
  10687. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10688. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10689. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10690. builder.ParagraphFormat.Style.Font.Bold = false;
  10691. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10692. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10693. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10694. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10695. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10696. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10697. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10698. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10699. builder.Write($"{item.RoomExplanation}");
  10700. builder.InsertCell();
  10701. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10702. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10703. builder.InsertCell();
  10704. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10705. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10706. builder.EndRow();
  10707. #endregion
  10708. #region 第九行
  10709. builder.InsertCell();
  10710. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10711. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10712. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10713. builder.ParagraphFormat.Style.Font.Bold = false;
  10714. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10715. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10716. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10717. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10718. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10719. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10720. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10721. builder.Write($"NOTE:");
  10722. builder.InsertCell();
  10723. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10724. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10725. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10726. builder.ParagraphFormat.Style.Font.Bold = false;
  10727. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10728. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10729. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10730. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10731. 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.");
  10732. builder.InsertCell();
  10733. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10734. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10735. builder.InsertCell();
  10736. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10737. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10738. builder.EndRow();
  10739. #endregion
  10740. builder.EndTable();
  10741. //换行
  10742. builder.Writeln("");
  10743. builder.Writeln("");
  10744. }
  10745. #region 获取文档中的所有表格 设置文字自适应
  10746. // 获取文档中的所有表格。
  10747. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10748. {
  10749. // 遍历表格中的所有行。
  10750. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10751. {
  10752. foreach (Cell cell in row.Cells)
  10753. {
  10754. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10755. cellFormat.Width = 0;
  10756. }
  10757. }
  10758. }
  10759. #endregion
  10760. #region 设置页眉
  10761. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10762. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10763. if (System.IO.File.Exists(voucherHeaderPath))
  10764. {
  10765. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10766. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10767. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10768. Shape shape = builder.InsertImage(imageBytes);
  10769. // 调整图片位置
  10770. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10771. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10772. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10773. shape.Left = 0; // 将图片距离页面左边缘的距离
  10774. shape.Width = 81; // 设置图片宽度
  10775. shape.Height = 36; // 设置图片高度
  10776. }
  10777. //靠右
  10778. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10779. //// 设置页脚上下边距
  10780. //builder.PageSetup.HeaderDistance = 42;
  10781. // 添加页眉线
  10782. Aspose.Words.Border borderHeader = null;
  10783. try
  10784. {
  10785. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10786. }
  10787. catch (Exception e)
  10788. {
  10789. // TODO Auto-generated catch block
  10790. //e.printStackTrace();
  10791. }
  10792. borderHeader.Shadow = true;
  10793. borderHeader.DistanceFromText = 2;
  10794. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10795. #endregion
  10796. }
  10797. catch (Exception ex)
  10798. {
  10799. }
  10800. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10801. doc.Save(fileDir);
  10802. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10803. return Ok(JsonView(true, "操作成功!", Url));
  10804. }
  10805. /// <summary>
  10806. /// 酒店预订
  10807. /// 生成 预定成本 Excel
  10808. /// </summary>
  10809. /// <param name="_dto"></param>
  10810. /// <returns></returns>
  10811. [HttpPost]
  10812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10813. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10814. {
  10815. #region 参数验证
  10816. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10817. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10818. if (!vadalitorRes.IsValid)
  10819. {
  10820. var errors = new StringBuilder();
  10821. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10822. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10823. }
  10824. #region 团组操作权限验证 76 酒店预定模块
  10825. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10826. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10827. #endregion
  10828. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10829. #region 页面操作权限验证
  10830. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10831. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10832. #endregion
  10833. #endregion
  10834. decimal _rate = 1.00M;
  10835. string _currency = string.Empty;
  10836. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10837. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10838. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10839. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10840. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10841. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  10842. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10843. if (_GroupCostParameter == null)
  10844. {
  10845. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10846. bool isIntType = int.TryParse(_currency, out int currId);
  10847. if (isIntType)
  10848. {
  10849. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10850. }
  10851. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10852. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10853. if (currInfo == null)
  10854. {
  10855. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10856. }
  10857. else _rate = currInfo.Rate;
  10858. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  10859. {
  10860. _rate = _GroupCostParameter.Rate;
  10861. }
  10862. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10863. string strFileName = "HotelStatement/";
  10864. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10865. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10866. var rateDatas = new List<dynamic>();
  10867. #region 数据处理
  10868. foreach (var item in hrDtas)
  10869. {
  10870. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10871. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10872. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10873. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10874. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10875. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  10876. {
  10877. continue;
  10878. }
  10879. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10880. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  10881. string singleRoomFeeStr = string.Empty,
  10882. doubleRoomFeeStr = string.Empty,
  10883. suiteRoomFeeStr = string.Empty,
  10884. otherRoomFeeStr = string.Empty,
  10885. payMoneyStr = string.Empty,
  10886. cardPriceStr = string.Empty;
  10887. if (roomCurr.Equals("CNY"))
  10888. {
  10889. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  10890. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10891. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10892. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10893. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10894. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  10895. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  10896. }
  10897. else
  10898. {
  10899. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10900. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10901. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10902. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10903. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10904. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10905. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10906. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10907. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10908. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10909. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  10910. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  10911. if (ccpPaymentCurrency.Equals("CNY"))
  10912. {
  10913. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  10914. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10915. }
  10916. else
  10917. {
  10918. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  10919. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  10920. }
  10921. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  10922. if (hotelcardPriceCurrency.Equals("CNY"))
  10923. {
  10924. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10925. }
  10926. else
  10927. {
  10928. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  10929. }
  10930. }
  10931. string breakfastPriceStr = string.Empty,
  10932. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10933. governmentRentStr = string.Empty,
  10934. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10935. cityTaxStr = string.Empty,
  10936. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10937. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  10938. if (!string.IsNullOrEmpty(breakfastCurrency1))
  10939. {
  10940. if (breakfastCurrency1.Equals("CNY"))
  10941. {
  10942. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10943. }
  10944. else
  10945. {
  10946. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  10947. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  10948. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  10949. }
  10950. }
  10951. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10952. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  10953. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  10954. {
  10955. if (governmentRentCurrency.Equals("CNY"))
  10956. {
  10957. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10958. }
  10959. else
  10960. {
  10961. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  10962. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  10963. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  10964. }
  10965. }
  10966. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10967. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  10968. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  10969. {
  10970. if (cityTaxStrCurrency1.Equals("CNY"))
  10971. {
  10972. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10973. }
  10974. else
  10975. {
  10976. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  10977. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  10978. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  10979. }
  10980. }
  10981. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10982. int payDId = roomInfo?.PayDId ?? 0;
  10983. pcfds.Add(new HotelReservations_PCFD_View()
  10984. {
  10985. City = item.City,
  10986. HotelName = item.HotelName,
  10987. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10988. // SingleRoomCount = item.SingleRoomCount,
  10989. SingleRoomPrice = singleRoomFeeStr,
  10990. // DoubleRoomCount = item.DoubleRoomCount,
  10991. DoubleRoomPrice = doubleRoomFeeStr,
  10992. //SuiteRoomCount = item.SuiteRoomCount,
  10993. SuiteRoomPrice = suiteRoomFeeStr,
  10994. OtherRoomPrice = otherRoomFeeStr,
  10995. //OtherRoomCount = item.OtherRoomCount,
  10996. BreakfastPrice = breakfastPriceStr,
  10997. GovernmentRent = governmentRentStr,
  10998. CityTax = cityTaxStr,
  10999. RoomExplanation = item.RoomExplanation,
  11000. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11001. PayTime = roomInfo?.ConsumptionDate,
  11002. BankNo = roomInfo?.BankNo,
  11003. PayMoney = payMoneyStr,
  11004. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11005. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11006. CardPrice = cardPriceStr,
  11007. Remark = ccpInfo.Remark
  11008. });
  11009. }
  11010. #endregion
  11011. //载入模板
  11012. WorkbookDesigner designer = new WorkbookDesigner();
  11013. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11014. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11015. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11016. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11017. var rateDatas1 = rateDatas.Distinct();
  11018. var rateStr = string.Empty;
  11019. foreach (var item in rateDatas1)
  11020. {
  11021. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  11022. }
  11023. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  11024. designer.SetDataSource("Opertor", userInfo.CnName);
  11025. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11026. dt.TableName = "ViewMyHotelReservations";
  11027. designer.SetDataSource(dt);
  11028. designer.Process();
  11029. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11030. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11031. designer.Workbook.Save(serverPath);
  11032. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11033. #region 删除指定行
  11034. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11035. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11036. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11037. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11038. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11039. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11040. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11041. cssIndex = dt.Columns["CityTax"].Ordinal,
  11042. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11043. remarkIndex = dt.Columns["Remark"].Ordinal;
  11044. //删除指定列
  11045. foreach (DataRow item in dt.Rows)
  11046. {
  11047. string singleStr = item["SingleRoomPrice"].ToString();
  11048. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11049. if (containsDigitButNotZero1) singleDel = false;
  11050. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11051. string doubleStr = item["DoubleRoomPrice"].ToString();
  11052. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11053. if (containsDigitButNotZero2) doubleDel = false;
  11054. string suiteStr = item["SuiteRoomPrice"].ToString();
  11055. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11056. if (containsDigitButNotZero3) suiteDel = false;
  11057. string otherStr = item["OtherRoomPrice"].ToString();
  11058. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11059. if (containsDigitButNotZero4) otherDel = false;
  11060. string zcStr = item["BreakfastPrice"].ToString();
  11061. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11062. if (containsDigitButNotZero5) zcDel = false;
  11063. string dsStr = item["GovernmentRent"].ToString();
  11064. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11065. if (containsDigitButNotZero6) dsDel = false;
  11066. string cssStr = item["CityTax"].ToString();
  11067. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11068. if (containsDigitButNotZero7) cssDel = false;
  11069. string cpStr = item["ConsumptionPatterns"].ToString();
  11070. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11071. string remarkStr = item["Remark"].ToString();
  11072. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11073. }
  11074. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11075. DeleteColumn(serverPath, cpIndex, cpDel);
  11076. DeleteColumn(serverPath, dsIndex, dsDel);
  11077. DeleteColumn(serverPath, cssIndex, cssDel);
  11078. DeleteColumn(serverPath, zcIndex, zcDel);
  11079. DeleteColumn(serverPath, otherIndex, otherDel);
  11080. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11081. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11082. DeleteColumn(serverPath, singleIndex, singleDel);
  11083. #endregion
  11084. //只保留第一个表格
  11085. DeleteSheet(serverPath);
  11086. return Ok(JsonView(true, "操作成功", url = rst));
  11087. }
  11088. else
  11089. {
  11090. _currency = _GroupCostParameter.Currency;
  11091. bool isIntType = int.TryParse(_currency, out int currId);
  11092. if (isIntType)
  11093. {
  11094. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  11095. }
  11096. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  11097. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  11098. if (currInfo == null)
  11099. {
  11100. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  11101. }
  11102. if (!_currency.ToUpper().Equals("CNY"))
  11103. {
  11104. _rate = _GroupCostParameter.Rate;
  11105. }
  11106. _rate = currInfo.Rate;
  11107. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11108. string strFileName = "HotelStatement/";
  11109. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11110. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  11111. #region 数据处理
  11112. foreach (var item in hrDtas)
  11113. {
  11114. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  11115. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  11116. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  11117. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  11118. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  11119. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  11120. string singleRoomFeeStr = string.Empty,
  11121. doubleRoomFeeStr = string.Empty,
  11122. suiteRoomFeeStr = string.Empty,
  11123. otherRoomFeeStr = string.Empty,
  11124. payMoneyStr = string.Empty,
  11125. cardPriceStr = string.Empty;
  11126. if (roomCurr.Equals(_currency))
  11127. {
  11128. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  11129. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  11130. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  11131. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  11132. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  11133. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  11134. }
  11135. else
  11136. {
  11137. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11138. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11139. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11140. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11141. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  11142. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  11143. }
  11144. string breakfastPriceStr = string.Empty,
  11145. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  11146. governmentRentStr = string.Empty,
  11147. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  11148. cityTaxStrStr = string.Empty,
  11149. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  11150. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  11151. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  11152. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  11153. int payDId = roomInfo?.PayDId ?? 0;
  11154. pcfds.Add(new HotelReservations_PCFD_View()
  11155. {
  11156. City = item.City,
  11157. HotelName = item.HotelName,
  11158. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  11159. // SingleRoomCount = item.SingleRoomCount,
  11160. SingleRoomPrice = singleRoomFeeStr,
  11161. // DoubleRoomCount = item.DoubleRoomCount,
  11162. DoubleRoomPrice = doubleRoomFeeStr,
  11163. //SuiteRoomCount = item.SuiteRoomCount,
  11164. SuiteRoomPrice = suiteRoomFeeStr,
  11165. OtherRoomPrice = otherRoomFeeStr,
  11166. //OtherRoomCount = item.OtherRoomCount,
  11167. BreakfastPrice = breakfastPriceStr,
  11168. GovernmentRent = governmentRentStr,
  11169. CityTax = cityTaxStrStr,
  11170. RoomExplanation = item.RoomExplanation,
  11171. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11172. PayTime = roomInfo?.ConsumptionDate,
  11173. BankNo = roomInfo?.BankNo,
  11174. PayMoney = payMoneyStr,
  11175. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11176. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11177. CardPrice = cardPriceStr,
  11178. Remark = ccpInfo.Remark
  11179. });
  11180. }
  11181. #endregion
  11182. //载入模板
  11183. WorkbookDesigner designer = new WorkbookDesigner();
  11184. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11185. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11186. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11187. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11188. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  11189. designer.SetDataSource("Opertor", userInfo.CnName);
  11190. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11191. dt.TableName = "ViewMyHotelReservations";
  11192. designer.SetDataSource(dt);
  11193. designer.Process();
  11194. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11195. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11196. designer.Workbook.Save(serverPath);
  11197. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11198. #region 删除指定行
  11199. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11200. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11201. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11202. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11203. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11204. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11205. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11206. cssIndex = dt.Columns["CityTax"].Ordinal,
  11207. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11208. remarkIndex = dt.Columns["Remark"].Ordinal;
  11209. //删除指定列
  11210. foreach (DataRow item in dt.Rows)
  11211. {
  11212. string singleStr = item["SingleRoomPrice"].ToString();
  11213. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11214. if (containsDigitButNotZero1) singleDel = false;
  11215. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11216. string doubleStr = item["DoubleRoomPrice"].ToString();
  11217. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11218. if (containsDigitButNotZero2) doubleDel = false;
  11219. string suiteStr = item["SuiteRoomPrice"].ToString();
  11220. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11221. if (containsDigitButNotZero3) suiteDel = false;
  11222. string otherStr = item["OtherRoomPrice"].ToString();
  11223. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11224. if (containsDigitButNotZero4) otherDel = false;
  11225. string zcStr = item["BreakfastPrice"].ToString();
  11226. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11227. if (containsDigitButNotZero5) zcDel = false;
  11228. string dsStr = item["GovernmentRent"].ToString();
  11229. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11230. if (containsDigitButNotZero6) dsDel = false;
  11231. string cssStr = item["CityTax"].ToString();
  11232. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11233. if (containsDigitButNotZero7) cssDel = false;
  11234. string cpStr = item["ConsumptionPatterns"].ToString();
  11235. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11236. string remarkStr = item["Remark"].ToString();
  11237. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11238. }
  11239. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11240. DeleteColumn(serverPath, cpIndex, cpDel);
  11241. DeleteColumn(serverPath, dsIndex, dsDel);
  11242. DeleteColumn(serverPath, cssIndex, cssDel);
  11243. DeleteColumn(serverPath, zcIndex, zcDel);
  11244. DeleteColumn(serverPath, otherIndex, otherDel);
  11245. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11246. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11247. DeleteColumn(serverPath, singleIndex, singleDel);
  11248. #endregion
  11249. //只保留第一个表格
  11250. DeleteSheet(serverPath);
  11251. return Ok(JsonView(true, "操作成功", url = rst));
  11252. }
  11253. return Ok(JsonView(false));
  11254. }
  11255. /// <summary>
  11256. /// 删除指定列
  11257. /// </summary>
  11258. /// <param name="file"></param>
  11259. /// <param name="columnIndex"></param>
  11260. /// <param name="isDel"></param>
  11261. private void DeleteColumn(string file, int columnIndex, bool isDel)
  11262. {
  11263. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11264. //wb.Save(file);
  11265. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  11266. if (sheet1 != null)
  11267. {
  11268. if (isDel)
  11269. {
  11270. Cells cells = sheet1.Cells;
  11271. cells.DeleteColumn(columnIndex);
  11272. }
  11273. }
  11274. wb.Save(file);
  11275. }
  11276. /// <summary>
  11277. /// 删除sheet
  11278. /// </summary>
  11279. /// <param name="file"></param>
  11280. /// <param name="sheetName"></param>
  11281. private void DeleteSheet(string file, string sheetName = "")
  11282. {
  11283. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11284. //wb.Save(file);
  11285. List<string> sheets = new List<string>();
  11286. foreach (var item in wb.Worksheets)
  11287. {
  11288. sheets.Add(item.Name);
  11289. }
  11290. if (sheets.Count > 0)
  11291. {
  11292. sheets.RemoveAt(0);//不删除第一个sheet
  11293. foreach (var item in sheets)
  11294. {
  11295. wb.Worksheets.RemoveAt(item);
  11296. }
  11297. }
  11298. wb.Save(file);
  11299. }
  11300. /// <summary>
  11301. /// 酒店预订
  11302. /// 确认单
  11303. /// </summary>
  11304. /// <param name="_dto"></param>
  11305. /// <returns></returns>
  11306. [HttpPost]
  11307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11308. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  11309. {
  11310. try
  11311. {
  11312. #region 参数验证
  11313. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11314. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11315. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11316. #region 团组操作权限验证 76 酒店预定模块
  11317. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11318. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11319. #endregion
  11320. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11321. #region 页面操作权限验证
  11322. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11323. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11324. #endregion
  11325. #endregion
  11326. //团组信息
  11327. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  11328. //酒店数据
  11329. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  11330. if (listhoteldata.Count < 0)
  11331. {
  11332. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  11333. }
  11334. //利datatable存储
  11335. DataTable dt = new DataTable();
  11336. dt.Columns.Add("CheckInDate", typeof(string));
  11337. dt.Columns.Add("City", typeof(string));
  11338. dt.Columns.Add("Hotel", typeof(string));
  11339. dt.Columns.Add("Room", typeof(string));
  11340. for (int i = 0; i < listhoteldata.Count; i++)
  11341. {
  11342. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  11343. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  11344. while (dayStart < dayEnd)
  11345. {
  11346. string temp = "";
  11347. DataRow row = dt.NewRow();
  11348. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  11349. row["City"] = listhoteldata[i].City;
  11350. row["Hotel"] = listhoteldata[i].HotelName;
  11351. if (listhoteldata[i].SingleRoomCount > 0)
  11352. {
  11353. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  11354. }
  11355. if (listhoteldata[i].DoubleRoomCount > 0)
  11356. {
  11357. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  11358. }
  11359. if (listhoteldata[i].SuiteRoomCount > 0)
  11360. {
  11361. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  11362. }
  11363. if (listhoteldata[i].OtherRoomCount > 0)
  11364. {
  11365. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  11366. }
  11367. row["Room"] = temp;
  11368. dt.Rows.Add(row);
  11369. dayStart = dayStart.AddDays(1);
  11370. }
  11371. }
  11372. Dictionary<string, string> dic = new Dictionary<string, string>();
  11373. dic.Add("Dele", di.TeamName);
  11374. dic.Add("City", di.VisitCountry);
  11375. //模板路径
  11376. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  11377. //载入模板
  11378. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  11379. DocumentBuilder builder = new DocumentBuilder(doc);
  11380. foreach (var key in dic.Keys)
  11381. {
  11382. builder.MoveToBookmark(key);
  11383. builder.Write(dic[key]);
  11384. }
  11385. //获取word里所有表格
  11386. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11387. //获取所填表格的序数
  11388. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11389. var rowStart = tableOne.Rows[0]; //获取第1行
  11390. //循环赋值
  11391. for (int i = 0; i < dt.Rows.Count; i++)
  11392. {
  11393. builder.MoveToCell(0, i + 1, 0, 0);
  11394. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  11395. builder.MoveToCell(0, i + 1, 1, 0);
  11396. builder.Write(dt.Rows[i]["City"].ToString());
  11397. builder.MoveToCell(0, i + 1, 2, 0);
  11398. builder.Write(dt.Rows[i]["Hotel"].ToString());
  11399. builder.MoveToCell(0, i + 1, 3, 0);
  11400. builder.Write(dt.Rows[i]["Room"].ToString());
  11401. }
  11402. //删除多余行
  11403. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  11404. {
  11405. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  11406. }
  11407. string strFileName = di.TeamName + "酒店确认单.doc";
  11408. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  11409. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  11410. return Ok(JsonView(true, "成功", url));
  11411. }
  11412. catch (Exception ex)
  11413. {
  11414. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  11415. }
  11416. }
  11417. #endregion
  11418. #region 团组状态
  11419. /// <summary>
  11420. /// 团组状态列表 Page
  11421. /// </summary>
  11422. /// <param name="dto">团组列表请求dto</param>
  11423. /// <returns></returns>
  11424. [HttpPost]
  11425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11426. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  11427. {
  11428. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11429. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  11430. {
  11431. string sqlWhere = string.Empty;
  11432. if (dto.IsSure == 0) //未完成
  11433. {
  11434. sqlWhere += string.Format(@" And IsSure = 0");
  11435. }
  11436. else if (dto.IsSure == 1) //已完成
  11437. {
  11438. sqlWhere += string.Format(@" And IsSure = 1");
  11439. }
  11440. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  11441. {
  11442. string tj = dto.SearchCriteria;
  11443. 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}%')",
  11444. tj, tj, tj, tj, tj);
  11445. }
  11446. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  11447. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  11448. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  11449. From (
  11450. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  11451. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  11452. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  11453. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  11454. From Grp_DelegationInfo gdi
  11455. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  11456. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  11457. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  11458. Where gdi.IsDel = 0 {0}
  11459. ) temp ", sqlWhere);
  11460. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  11461. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  11462. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  11463. }
  11464. else
  11465. {
  11466. return Ok(JsonView(false, "查询失败"));
  11467. }
  11468. }
  11469. /// <summary>
  11470. /// 团组状态
  11471. /// 设置操作完成
  11472. /// </summary>
  11473. /// <param name="dto">团组列表请求dto</param>
  11474. /// <returns></returns>
  11475. [HttpPost]
  11476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11477. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  11478. {
  11479. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11480. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  11481. {
  11482. Id = dto.Id,
  11483. IsSure = 1
  11484. };
  11485. var result = await _sqlSugar.Updateable(_DelegationInfo)
  11486. .UpdateColumns(it => new { it.IsSure })
  11487. .WhereColumns(it => new { it.Id })
  11488. .ExecuteCommandAsync();
  11489. if (result > 0)
  11490. {
  11491. return Ok(JsonView(true, "操作完成!"));
  11492. }
  11493. return Ok(JsonView(false, "操作失败!"));
  11494. }
  11495. #endregion
  11496. #region 保险费用录入
  11497. /// <summary>
  11498. /// 根据团组Id查询保险费用列表
  11499. /// </summary>
  11500. /// <param name="dto"></param>
  11501. /// <returns></returns>
  11502. [HttpPost]
  11503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11504. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11505. {
  11506. Result groupData = await _customersRep.CustomersByDiId(dto);
  11507. if (groupData.Code != 0)
  11508. {
  11509. return Ok(JsonView(false, groupData.Msg));
  11510. }
  11511. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11512. }
  11513. /// <summary>
  11514. /// 根据保险费用Id查询保险费用详细
  11515. /// </summary>
  11516. /// <param name="dto"></param>
  11517. /// <returns></returns>
  11518. [HttpPost]
  11519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11520. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11521. {
  11522. try
  11523. {
  11524. Result groupData = await _customersRep.CustomersById(dto);
  11525. if (groupData.Code != 0)
  11526. {
  11527. return Ok(JsonView(false, groupData.Msg));
  11528. }
  11529. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11530. }
  11531. catch (Exception ex)
  11532. {
  11533. return Ok(JsonView(false, ex.Message));
  11534. }
  11535. }
  11536. /// <summary>
  11537. /// 保险费用录入页面初始化绑定
  11538. /// </summary>
  11539. /// <param name="dto"></param>
  11540. /// <returns></returns>
  11541. [HttpPost]
  11542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11543. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11544. {
  11545. try
  11546. {
  11547. Result groupData = await _customersRep.CustomersInitialize(dto);
  11548. if (groupData.Code != 0)
  11549. {
  11550. return Ok(JsonView(false, groupData.Msg));
  11551. }
  11552. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11553. }
  11554. catch (Exception ex)
  11555. {
  11556. return Ok(JsonView(false, ex.Message));
  11557. }
  11558. }
  11559. /// <summary>
  11560. /// 保险费用操作(Status:1.新增,2.修改)
  11561. /// </summary>
  11562. /// <param name="dto"></param>
  11563. /// <returns></returns>
  11564. [HttpPost]
  11565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11566. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11567. {
  11568. Result groupData = await _customersRep.OpCustomers(dto);
  11569. if (groupData.Code != 0)
  11570. {
  11571. return Ok(JsonView(false, groupData.Msg));
  11572. }
  11573. #region 应用推送
  11574. try
  11575. {
  11576. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11577. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11578. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11579. //2024-10-21 新增LZ UID
  11580. var userIds = new List<int>() { 21 };
  11581. string title = $"系统通知";
  11582. var diId = dto.DiId;
  11583. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11584. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11585. string content = "";
  11586. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11587. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11588. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11589. await APNsTools.iOS_PushNotifications1("051", $"保险费用审核", "", content);
  11590. }
  11591. catch (Exception ex)
  11592. {
  11593. }
  11594. #endregion
  11595. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11596. }
  11597. /// <summary>
  11598. /// 保险文件上传
  11599. /// </summary>
  11600. /// <param name="file"></param>
  11601. /// <returns></returns>
  11602. [HttpPost]
  11603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11604. public async Task<IActionResult> UploadCus(IFormFile file)
  11605. {
  11606. try
  11607. {
  11608. if (file != null)
  11609. {
  11610. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11611. //文件名称
  11612. string projectFileName = file.FileName;
  11613. //上传的文件的路径
  11614. string filePath = "";
  11615. if (!Directory.Exists(fileDir))
  11616. {
  11617. Directory.CreateDirectory(fileDir);
  11618. }
  11619. //上传的文件的路径
  11620. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11621. using (FileStream fs = System.IO.File.Create(filePath))
  11622. {
  11623. file.CopyTo(fs);
  11624. fs.Flush();
  11625. }
  11626. return Ok(JsonView(true, "上传成功!", projectFileName));
  11627. }
  11628. else
  11629. {
  11630. return Ok(JsonView(false, "上传失败!"));
  11631. }
  11632. }
  11633. catch (Exception ex)
  11634. {
  11635. return Ok(JsonView(false, "程序错误!"));
  11636. throw;
  11637. }
  11638. }
  11639. /// <summary>
  11640. /// 保险删除指定文件
  11641. /// </summary>
  11642. /// <param name="dto"></param>
  11643. /// <returns></returns>
  11644. [HttpPost]
  11645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11646. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11647. {
  11648. try
  11649. {
  11650. string filePath = "";
  11651. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11652. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11653. //int id = 0;
  11654. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11655. // 删除该文件
  11656. try
  11657. {
  11658. System.IO.File.Delete(filePath);
  11659. 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()
  11660. {
  11661. Attachment = "",
  11662. }).ExecuteCommandAsync();
  11663. if (result != 0)
  11664. {
  11665. return Ok(JsonView(true, "成功!"));
  11666. }
  11667. else
  11668. {
  11669. return Ok(JsonView(false, "失败!"));
  11670. }
  11671. }
  11672. catch (Exception)
  11673. {
  11674. 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()
  11675. {
  11676. Attachment = "",
  11677. }).ExecuteCommandAsync();
  11678. if (result != 0)
  11679. {
  11680. return Ok(JsonView(true, "成功!"));
  11681. }
  11682. else
  11683. {
  11684. return Ok(JsonView(false, "失败!"));
  11685. }
  11686. }
  11687. }
  11688. catch (Exception ex)
  11689. {
  11690. return Ok(JsonView(false, "程序错误!"));
  11691. throw;
  11692. }
  11693. }
  11694. /// <summary>
  11695. /// 保险费用操作(删除)
  11696. /// </summary>
  11697. /// <param name="dto"></param>
  11698. /// <returns></returns>
  11699. [HttpPost]
  11700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11701. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11702. {
  11703. try
  11704. {
  11705. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11706. if (!res)
  11707. {
  11708. return Ok(JsonView(false, "删除失败"));
  11709. }
  11710. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11711. {
  11712. IsDel = 1,
  11713. DeleteUserId = dto.DeleteUserId,
  11714. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11715. }).ExecuteCommandAsync();
  11716. return Ok(JsonView(true, "删除成功!"));
  11717. }
  11718. catch (Exception ex)
  11719. {
  11720. return Ok(JsonView(false, "程序错误!"));
  11721. throw;
  11722. }
  11723. }
  11724. #endregion
  11725. #region 接团客户名单 PageId 104
  11726. /// <summary>
  11727. /// 接团客户名单
  11728. /// 迁移数据(慎用!)
  11729. /// </summary>
  11730. /// <param name="dto"></param>
  11731. /// <returns></returns>
  11732. [HttpPost]
  11733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11734. public async Task<IActionResult> PostTourClientListChange()
  11735. {
  11736. try
  11737. {
  11738. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11739. //var groupClinetData1
  11740. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11741. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11742. int updateCount = 0;
  11743. if (oldOAClientList.Count > 0)
  11744. {
  11745. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11746. _sqlSugar.BeginTran();
  11747. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11748. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11749. foreach (var item in oldOAClientList)
  11750. {
  11751. int comId = 0;
  11752. string format = "yyyy-MM-dd HH:mm:ss";
  11753. string data11 = "1990-01-01 00:00";
  11754. var data1 = IsValidDate(item.OPdate, format);
  11755. if (data1) data11 = item.OPdate;
  11756. //客户公司验证
  11757. if (!string.IsNullOrEmpty(item.Company))
  11758. {
  11759. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11760. if (clientComInfo == null) // add
  11761. {
  11762. var addInfo = new Crm_CustomerCompany()
  11763. {
  11764. CompanyAbbreviation = "",
  11765. CompanyFullName = item.Company,
  11766. Address = "",
  11767. PostCodes = "",
  11768. LastedOpUserId = item.OPer,
  11769. LastedOpDt = Convert.ToDateTime(data11),
  11770. CreateUserId = item.OPer,
  11771. CreateTime = Convert.ToDateTime(data11),
  11772. IsDel = 0
  11773. };
  11774. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11775. if (comId1 > 0) comId = comId1;
  11776. }
  11777. else comId = clientComInfo.Id;
  11778. }
  11779. //客户人员验证
  11780. int clientId = 0;
  11781. string name = item.LastName + item.Name;
  11782. if (!string.IsNullOrEmpty(name))
  11783. {
  11784. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11785. if (clientInfo == null)
  11786. {
  11787. DateTime? dateTime = null;
  11788. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11789. if (isDt) dateTime = birthDayDt;
  11790. var addInfo1 = new Crm_DeleClient()
  11791. {
  11792. CrmCompanyId = comId,
  11793. DiId = -1,
  11794. LastName = item.LastName,
  11795. FirstName = item.Name,
  11796. OldName = "",
  11797. Pinyin = item.Pinyin,
  11798. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11799. Marriage = 0,
  11800. Phone = item.Phone,
  11801. Job = item.Job,
  11802. BirthDay = dateTime
  11803. };
  11804. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11805. if (clientId1 > 0) clientId = clientId1;
  11806. }
  11807. else clientId = clientInfo.Id;
  11808. }
  11809. if (clientId < 1)
  11810. {
  11811. continue;
  11812. }
  11813. int airType = 0;
  11814. if (item.AirType == "超经舱") airType = 459;
  11815. else if (item.AirType == "公务舱") airType = 458;
  11816. else if (item.AirType == "经济舱") airType = 460;
  11817. else if (item.AirType == "其他") airType = 565;
  11818. else if (item.AirType == "头等舱") airType = 457;
  11819. var _TourClientListEntity = new Grp_TourClientList()
  11820. {
  11821. DiId = item.Diid,
  11822. ClientId = clientId,
  11823. CreateUserId = item.OPer,
  11824. CreateTime = Convert.ToDateTime(data11),
  11825. Remark = item.Remark,
  11826. IsDel = item.Isdel,
  11827. ShippingSpaceTypeId = airType,
  11828. ShippingSpaceSpecialNeeds = item.AirRemark,
  11829. HotelSpecialNeeds = item.RoomType
  11830. };
  11831. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11832. if (_TourClientList > 0)
  11833. {
  11834. updateCount++;
  11835. }
  11836. }
  11837. _sqlSugar.CommitTran();
  11838. }
  11839. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11840. }
  11841. catch (Exception ex)
  11842. {
  11843. _sqlSugar.RollbackTran();
  11844. return Ok(JsonView(false, ex.Message));
  11845. }
  11846. return Ok(JsonView(true));
  11847. }
  11848. private bool IsValidDate(string dateString, string format)
  11849. {
  11850. DateTime dateValue;
  11851. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11852. return valid;
  11853. }
  11854. /// <summary>
  11855. /// 接团客户名单
  11856. /// 根据团组Id查询List
  11857. /// </summary>
  11858. /// <param name="dto"></param>
  11859. /// <returns></returns>
  11860. [HttpPost]
  11861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11862. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11863. {
  11864. #region 参数验证
  11865. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11866. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11867. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11868. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11869. #region 页面操作权限验证
  11870. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11871. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11872. #endregion
  11873. #endregion
  11874. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11875. if (viewData.Code != 0)
  11876. {
  11877. return Ok(JsonView(false, viewData.Msg));
  11878. }
  11879. return Ok(JsonView(viewData.Data));
  11880. }
  11881. /// <summary>
  11882. /// 接团客户名单
  11883. /// 基础数据 Init
  11884. /// </summary>
  11885. /// <param name="_dto"></param>
  11886. /// <returns></returns>
  11887. [HttpPost]
  11888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11889. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11890. {
  11891. #region 参数验证
  11892. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11893. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11894. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11895. #region 页面操作权限验证
  11896. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11897. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11898. #endregion
  11899. #endregion
  11900. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11901. }
  11902. /// <summary>
  11903. /// 接团客户名单
  11904. /// 根据 Id查询 Details
  11905. /// </summary>
  11906. /// <param name="_dto"></param>
  11907. /// <returns></returns>
  11908. [HttpPost]
  11909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11910. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11911. {
  11912. #region 参数验证
  11913. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11914. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11915. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11916. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11917. #region 页面操作权限验证
  11918. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11919. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11920. #endregion
  11921. #endregion
  11922. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11923. if (viewData.Code != 0)
  11924. {
  11925. return Ok(JsonView(false, viewData.Msg));
  11926. }
  11927. return Ok(JsonView(viewData.Data));
  11928. }
  11929. /// <summary>
  11930. /// 接团客户名单
  11931. /// Add Or Edit
  11932. /// </summary>
  11933. /// <param name="_dto"></param>
  11934. /// <returns></returns>
  11935. [HttpPost]
  11936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11937. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11938. {
  11939. #region 参数验证
  11940. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11941. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11942. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11943. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11944. #region 页面操作权限验证
  11945. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11946. if (_dto.Id == 0) //添加
  11947. {
  11948. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11949. }
  11950. else if (_dto.Id >= 0) //修改
  11951. {
  11952. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11953. }
  11954. #endregion
  11955. #endregion
  11956. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11957. if (viewData.Code != 0)
  11958. {
  11959. return Ok(JsonView(false, viewData.Msg));
  11960. }
  11961. return Ok(JsonView(true));
  11962. }
  11963. /// <summary>
  11964. /// 接团客户名单
  11965. /// AddMultiple(添加多个)
  11966. /// </summary>
  11967. /// <param name="_dto"></param>
  11968. /// <returns></returns>
  11969. [HttpPost]
  11970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11971. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11972. {
  11973. #region 参数验证
  11974. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11975. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11976. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11977. #region 页面操作权限验证
  11978. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11979. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11980. #endregion
  11981. #endregion
  11982. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11983. if (viewData.Code != 0)
  11984. {
  11985. return Ok(JsonView(false, viewData.Msg));
  11986. }
  11987. return Ok(JsonView(true));
  11988. }
  11989. /// <summary>
  11990. /// 接团客户名单
  11991. /// Del
  11992. /// </summary>
  11993. /// <param name="_dto"></param>
  11994. /// <returns></returns>
  11995. [HttpPost]
  11996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11997. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11998. {
  11999. #region 参数验证
  12000. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12001. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12002. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12003. #region 页面操作权限验证
  12004. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12005. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12006. #endregion
  12007. #endregion
  12008. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  12009. if (viewData.Code != 0)
  12010. {
  12011. return Ok(JsonView(false, viewData.Msg));
  12012. }
  12013. return Ok(JsonView(true));
  12014. }
  12015. /// <summary>
  12016. /// 接团客户名单
  12017. /// 文件下载 客户名单
  12018. /// </summary>
  12019. /// <param name="_dto"></param>
  12020. /// <returns></returns>
  12021. [HttpPost]
  12022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12023. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  12024. {
  12025. #region 参数验证
  12026. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12027. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12028. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  12029. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12030. #region 页面操作权限验证
  12031. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12032. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12033. #endregion
  12034. #endregion
  12035. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  12036. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  12037. From Grp_TourClientList tcl
  12038. Left Join
  12039. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  12040. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  12041. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  12042. From Crm_DeleClient dc
  12043. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  12044. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  12045. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  12046. Where dc.IsDel = 0) temp
  12047. On temp.DcId =tcl.ClientId
  12048. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  12049. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  12050. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  12051. //载入模板
  12052. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  12053. if (_dto.Language == 1)
  12054. {
  12055. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  12056. }
  12057. //载入模板
  12058. var doc = new Document(tempPath);
  12059. DocumentBuilder builder = new DocumentBuilder(doc);
  12060. //获取word里所有表格
  12061. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12062. //获取所填表格的序数
  12063. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12064. var rowStart = tableOne.Rows[0]; //获取第1行
  12065. if (_dto.Language == 0)
  12066. {
  12067. //循环赋值
  12068. for (int i = 0; i < DcList.Count; i++)
  12069. {
  12070. builder.MoveToCell(0, i + 1, 0, 0);
  12071. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  12072. builder.MoveToCell(0, i + 1, 1, 0);
  12073. int sex = DcList[i].Sex;
  12074. string sexStr = string.Empty;
  12075. if (sex == 0) sexStr = "男";
  12076. else if (sex == 1) sexStr = "女";
  12077. else sexStr = "未设置";
  12078. builder.Write(sexStr);
  12079. builder.MoveToCell(0, i + 1, 2, 0);
  12080. string birthDay = DcList[i].BirthDay;
  12081. string birthDayStr = string.Empty;
  12082. if (!string.IsNullOrEmpty(birthDay))
  12083. {
  12084. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  12085. }
  12086. builder.Write(birthDayStr);
  12087. builder.MoveToCell(0, i + 1, 3, 0);
  12088. string company = "";
  12089. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12090. {
  12091. company = DcList[i].CompanyFullName.ToString();
  12092. }
  12093. builder.Write(company);
  12094. builder.MoveToCell(0, i + 1, 4, 0);
  12095. builder.Write(DcList[i].Job);
  12096. }
  12097. }
  12098. else if (_dto.Language == 1)
  12099. {
  12100. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  12101. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  12102. List<string> transArrayStr = new List<string>();
  12103. string transStrRes1 = "";
  12104. for (int i = 0; i < DcList.Count; i++)
  12105. {
  12106. var dc = DcList[i];
  12107. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  12108. if (dc.Job.Equals("暂无")) dc.Job = "-";
  12109. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  12110. if (DcList.Count - 1 == i) transStrRes1 += str1;
  12111. else transStrRes1 += $"{str1}|";
  12112. }
  12113. //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";
  12114. string transStrRes = "";
  12115. if (transStrRes1.Length > 0)
  12116. {
  12117. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  12118. }
  12119. //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
  12120. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  12121. //List<string> transArray = new List<string> { };
  12122. List<TranslateInfo> transArray = new List<TranslateInfo>();
  12123. if (transStrRes.Contains("|"))
  12124. {
  12125. string[] transArray1 = transStrRes.Split('|');
  12126. if (transArray1.Length > 0)
  12127. {
  12128. foreach (var item in transArray1)
  12129. {
  12130. if (item.Contains("&"))
  12131. {
  12132. string[] transArray2 = item.Split('&');
  12133. int index = 0;
  12134. string companyName = "", job = "";
  12135. if (transArray2.Length > 0)
  12136. {
  12137. bool success = int.TryParse(transArray2[0].Trim(), out index);
  12138. if (1 < transArray2.Length) companyName = transArray2[1];
  12139. if (2 < transArray2.Length) job = transArray2[2];
  12140. }
  12141. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  12142. }
  12143. }
  12144. }
  12145. }
  12146. //循环赋值
  12147. for (int i = 0; i < DcList.Count; i++)
  12148. {
  12149. string PYName = "";
  12150. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  12151. {
  12152. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  12153. string PY_First = DcList[i].Pinyin.Split('/')[1];
  12154. PYName = PY_First + " " + PY_Last;
  12155. }
  12156. else
  12157. {
  12158. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  12159. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  12160. PYName = PY_First + " " + PY_Last;
  12161. }
  12162. builder.MoveToCell(0, i + 1, 0, 0);
  12163. builder.Write(PYName);
  12164. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  12165. builder.MoveToCell(0, i + 1, 1, 0);
  12166. builder.Write(sex);
  12167. DateTime birthDt;
  12168. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  12169. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  12170. builder.MoveToCell(0, i + 1, 2, 0);
  12171. builder.Write(birthday);
  12172. string company = string.Empty, job = string.Empty;
  12173. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  12174. if (dcTransInfo != null)
  12175. {
  12176. company = dcTransInfo.CompanyName;
  12177. job = dcTransInfo.Job;
  12178. }
  12179. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12180. {
  12181. //查询对照表
  12182. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  12183. if (tempCec != null)
  12184. {
  12185. company = tempCec.enName;
  12186. }
  12187. //翻译
  12188. else
  12189. {
  12190. }
  12191. }
  12192. builder.MoveToCell(0, i + 1, 3, 0);
  12193. builder.Write(company);
  12194. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  12195. {
  12196. //查询对照表
  12197. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  12198. if (tempPec != null)
  12199. {
  12200. job = tempPec.enName;
  12201. }
  12202. //翻译
  12203. else
  12204. {
  12205. }
  12206. }
  12207. builder.MoveToCell(0, i + 1, 4, 0);
  12208. builder.Write(job);
  12209. }
  12210. }
  12211. //删除多余行
  12212. while (tableOne.Rows.Count > DcList.Count + 1)
  12213. {
  12214. tableOne.Rows.RemoveAt(DcList.Count + 1);
  12215. }
  12216. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  12217. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  12218. doc.Save(fileDir);
  12219. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  12220. return Ok(JsonView(true, "操作成功!", Url));
  12221. }
  12222. private class TranslateInfo
  12223. {
  12224. public int Index { get; set; }
  12225. public string CompanyName { get; set; }
  12226. public string Job { get; set; }
  12227. }
  12228. #endregion
  12229. #region 团组倒推表
  12230. /// <summary>
  12231. /// 倒推表基础数据
  12232. /// Init
  12233. /// </summary>
  12234. /// <param name="dto"></param>
  12235. /// <returns></returns>
  12236. [HttpPost]
  12237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12238. public async Task<IActionResult> PostInvertedListInit()
  12239. {
  12240. var viewData = await _invertedListRep._Init();
  12241. if (viewData.Code != 0)
  12242. {
  12243. return Ok(JsonView(false, viewData.Msg));
  12244. }
  12245. return Ok(JsonView(viewData.Data));
  12246. }
  12247. /// <summary>
  12248. /// 倒推表
  12249. /// Info
  12250. /// </summary>
  12251. /// <param name="dto"></param>
  12252. /// <returns></returns>
  12253. [HttpPost]
  12254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12255. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  12256. {
  12257. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  12258. if (viewData.Code != 0)
  12259. {
  12260. return Ok(JsonView(false, viewData.Msg));
  12261. }
  12262. return Ok(JsonView(viewData.Data));
  12263. }
  12264. /// <summary>
  12265. /// 倒推表
  12266. /// Create
  12267. /// </summary>
  12268. /// <param name="dto"></param>
  12269. /// <returns></returns>
  12270. [HttpPost]
  12271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12272. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  12273. {
  12274. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  12275. if (viewData.Code != 0)
  12276. {
  12277. return Ok(JsonView(false, viewData.Msg));
  12278. }
  12279. return Ok(JsonView(viewData.Data));
  12280. }
  12281. /// <summary>
  12282. /// 倒推表
  12283. /// Update
  12284. /// </summary>
  12285. /// <param name="dto"></param>
  12286. /// <returns></returns>
  12287. [HttpPost]
  12288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12289. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  12290. {
  12291. var viewData = await _invertedListRep._Update(dto);
  12292. if (viewData.Code != 0)
  12293. {
  12294. return Ok(JsonView(false, viewData.Msg));
  12295. }
  12296. return Ok(JsonView(viewData.Data));
  12297. }
  12298. /// <summary>
  12299. /// 倒推表
  12300. /// File Download
  12301. /// </summary>
  12302. /// <param name="dto"></param>
  12303. /// <returns></returns>
  12304. [HttpPost]
  12305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12306. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  12307. {
  12308. var info2 = await _invertedListRep._Info(1, dto.DiId);
  12309. if (info2.Code != 0)
  12310. {
  12311. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  12312. }
  12313. var info1 = info2.Data as InvertedListInfoView;
  12314. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  12315. string teamName = "";
  12316. if (info != null) teamName = info.TeamName;
  12317. //载入模板
  12318. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  12319. DocumentBuilder builder = new DocumentBuilder(doc);
  12320. //利用键值对存放数据
  12321. Dictionary<string, string> dic = new Dictionary<string, string>();
  12322. dic.Add("TeamName", teamName);
  12323. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  12324. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  12325. dic.Add("BPRemark", info1.ApprovalDataRemark);
  12326. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  12327. dic.Add("SQRemark", info1.ApprovalRemark);
  12328. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  12329. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  12330. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  12331. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  12332. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  12333. dic.Add("QZRemark", info1.VisaInformationRemark);
  12334. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  12335. dic.Add("SQQZRemark", info1.SendVisaRemark);
  12336. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  12337. dic.Add("CQRemark", info1.IssueVisaRemark);
  12338. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  12339. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  12340. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  12341. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  12342. #region 填充word模板书签内容
  12343. foreach (var key in dic.Keys)
  12344. {
  12345. builder.MoveToBookmark(key);
  12346. builder.Write(dic[key]);
  12347. }
  12348. #endregion
  12349. var fileDir = AppSettingsHelper.Get("WordBasePath");
  12350. string fileName = $"{teamName}团出行准备流程表.doc";
  12351. string filePath = fileDir + $@"InvertedList/{fileName}";
  12352. doc.Save(filePath);
  12353. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  12354. return Ok(JsonView(true, "操作成功!", Url));
  12355. }
  12356. #endregion
  12357. #region 三公签证费用(签证费、代办费)
  12358. /// <summary>
  12359. /// 三公签证费用(签证费、代办费)
  12360. /// List
  12361. /// </summary>
  12362. /// <returns></returns>
  12363. [HttpPost]
  12364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12365. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  12366. {
  12367. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  12368. if (_view.Code != 0)
  12369. {
  12370. return Ok(JsonView(false, _view.Msg));
  12371. }
  12372. return Ok(JsonView(true, "操作成功!", _view.Data));
  12373. }
  12374. /// <summary>
  12375. /// 三公签证费用(签证费、代办费)
  12376. /// Add Or Update
  12377. /// </summary>
  12378. /// <returns></returns>
  12379. [HttpPost]
  12380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12381. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  12382. {
  12383. var _view = await _visaFeeInfoRep._Update(_dto);
  12384. if (_view.Code != 0)
  12385. {
  12386. return Ok(JsonView(false, _view.Msg));
  12387. }
  12388. return Ok(JsonView(true, _view.Msg));
  12389. }
  12390. #endregion
  12391. #region 酒店询价
  12392. /// <summary>
  12393. /// 酒店询价
  12394. /// Init
  12395. /// </summary>
  12396. /// <param name="dto"></param>
  12397. /// <returns></returns>
  12398. [HttpPost]
  12399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12400. public async Task<IActionResult> PostHotelInquiryInit()
  12401. {
  12402. var res = await _hotelInquiryRep._Init();
  12403. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12404. return Ok(JsonView(true, res.Msg, res.Data));
  12405. }
  12406. /// <summary>
  12407. /// 酒店询价
  12408. /// page Item
  12409. /// </summary>
  12410. /// <param name="_dto"></param>
  12411. /// <returns></returns>
  12412. [HttpPost]
  12413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12414. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  12415. {
  12416. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  12417. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12418. var view = res.Data as PageDataViewBase;
  12419. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  12420. }
  12421. /// <summary>
  12422. /// 酒店询价
  12423. /// info
  12424. /// </summary>
  12425. /// <param name="_dto"></param>
  12426. /// <returns></returns>
  12427. [HttpPost]
  12428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12429. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  12430. {
  12431. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  12432. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12433. return Ok(JsonView(true, res.Msg, res.Data));
  12434. }
  12435. /// <summary>
  12436. /// 酒店询价
  12437. /// Add Or Edit
  12438. /// </summary>
  12439. /// <param name="_dto"></param>
  12440. /// <returns></returns>
  12441. [HttpPost]
  12442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12443. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  12444. {
  12445. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  12446. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12447. return Ok(JsonView(true, res.Msg, res.Data));
  12448. }
  12449. /// <summary>
  12450. /// 酒店询价
  12451. /// Del
  12452. /// </summary>
  12453. /// <param name="_dto"></param>
  12454. /// <returns></returns>
  12455. [HttpPost]
  12456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12457. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  12458. {
  12459. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  12460. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12461. return Ok(JsonView(true, res.Msg, res.Data));
  12462. }
  12463. #endregion
  12464. #region 下载匹配op行程单
  12465. /// <summary>
  12466. /// 匹配op行程单
  12467. /// Init
  12468. /// </summary>
  12469. /// <param name="dto">团组列表请求dto</param>
  12470. /// <returns></returns>
  12471. [HttpPost]
  12472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12473. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  12474. {
  12475. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12476. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12477. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  12478. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  12479. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  12480. .Where(it => it.IsDel == 0)
  12481. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  12482. .OrderByDescending(it => it.CreateUserId)
  12483. .ToList();
  12484. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  12485. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12486. var diids = groupInfos.Select(it => it.Id).ToList();
  12487. List<string> countrys = new List<string>();
  12488. foreach (var item in country)
  12489. {
  12490. var data = _groupRepository.FormartTeamName(item);
  12491. var dataArray = _groupRepository.GroupSplitCountry(data);
  12492. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12493. }
  12494. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12495. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12496. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12497. foreach (var item in areaItem)
  12498. {
  12499. string areaStr = item.Value;
  12500. if (!string.IsNullOrEmpty(areaStr))
  12501. {
  12502. string[] str1 = areaStr.Split("-");
  12503. if (str1.Length > 0)
  12504. {
  12505. areaArray.AddRange(str1);
  12506. }
  12507. }
  12508. }
  12509. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12510. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12511. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12512. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12513. .ToList();
  12514. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12515. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12516. .Where(it => countriesIds.Contains(it.Id))
  12517. .Select(it => new { it.Id, Name = it.Name_CN })
  12518. .ToList();
  12519. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12520. .Select(it => it.TeamName).ToList();
  12521. stopwatch.Stop();
  12522. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12523. }
  12524. ///// <summary>
  12525. ///// 匹配op行程单
  12526. ///// Init 查询区域数据
  12527. ///// </summary>
  12528. ///// <param name="dto">团组列表请求dto</param>
  12529. ///// <returns></returns>
  12530. //[HttpPost]
  12531. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12532. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12533. //{
  12534. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12535. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12536. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12537. // if (string.IsNullOrEmpty(countriesDataStr))
  12538. // {
  12539. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12540. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12541. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12542. // }
  12543. // else
  12544. // {
  12545. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12546. // }
  12547. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12548. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12549. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12550. // List<dynamic> childList = new List<dynamic>();
  12551. // int parentId = dto.CountriesId;
  12552. // if (provinceData.Count > 1)
  12553. // {
  12554. // foreach (var item1 in provinceData)
  12555. // {
  12556. // List<dynamic> childList1 = new List<dynamic>();
  12557. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12558. // foreach (var item2 in citiesData1)
  12559. // {
  12560. // List<dynamic> childList2 = new List<dynamic>();
  12561. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12562. // foreach (var item3 in countiesData1)
  12563. // {
  12564. // childList2.Add(new
  12565. // {
  12566. // id = item3.Id,
  12567. // parentId = item2.Id,
  12568. // level = "district",
  12569. // name = item3.Name_CN,
  12570. // });
  12571. // }
  12572. // childList1.Add(new
  12573. // {
  12574. // id = item2.Id,
  12575. // parentId = item1.Id,
  12576. // level = "city",
  12577. // name = item2.Name_CN,
  12578. // childList = childList2
  12579. // });
  12580. // }
  12581. // childList.Add(new
  12582. // {
  12583. // id = item1.Id,
  12584. // parentId = parentId,
  12585. // level = "province",
  12586. // name = item1.Name_CN,
  12587. // childList = childList1
  12588. // });
  12589. // }
  12590. // //城市
  12591. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12592. // foreach (var item2 in citiesData2)
  12593. // {
  12594. // List<dynamic> childList22 = new List<dynamic>();
  12595. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12596. // foreach (var item3 in countiesData1)
  12597. // {
  12598. // childList22.Add(new
  12599. // {
  12600. // id = item3.Id,
  12601. // parentId = item2.Id,
  12602. // level = "district",
  12603. // name = item3.Name_CN,
  12604. // });
  12605. // }
  12606. // childList.Add(new
  12607. // {
  12608. // id = item2.Id,
  12609. // parentId = parentId,
  12610. // level = "city",
  12611. // name = item2.Name_CN,
  12612. // childList = childList22
  12613. // });
  12614. // }
  12615. // }
  12616. // else
  12617. // {
  12618. // foreach (var item2 in citiesData)
  12619. // {
  12620. // string cname = item2.Name_CN;
  12621. // List<dynamic> childList1 = new List<dynamic>();
  12622. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12623. // foreach (var item3 in countiesData1)
  12624. // {
  12625. // childList1.Add(new
  12626. // {
  12627. // Id = item3.Id,
  12628. // parentId = item2.Id,
  12629. // level = "district",
  12630. // name = item3.Name_CN
  12631. // });
  12632. // }
  12633. // childList.Add(new
  12634. // {
  12635. // id = item2.Id,
  12636. // parentId = parentId,
  12637. // level = "city",
  12638. // name = item2.Name_CN,
  12639. // childList = childList1
  12640. // });
  12641. // }
  12642. // }
  12643. // stopwatch.Stop();
  12644. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12645. //}
  12646. /// <summary>
  12647. /// 匹配op行程单
  12648. /// 接团信息列表 Page
  12649. /// </summary>
  12650. /// <param name="dto">团组列表请求dto</param>
  12651. /// <returns></returns>
  12652. [HttpPost]
  12653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12654. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12655. {
  12656. var swatch = new Stopwatch();
  12657. swatch.Start();
  12658. #region 参数验证
  12659. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12660. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12661. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12662. #region 页面操作权限验证
  12663. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12664. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12665. #endregion
  12666. #endregion
  12667. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12668. {
  12669. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12670. string sqlWhere = "";
  12671. if (!string.IsNullOrEmpty(dto.Country))
  12672. {
  12673. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12674. }
  12675. if (!string.IsNullOrEmpty(dto.Area))
  12676. {
  12677. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12678. }
  12679. if (!string.IsNullOrEmpty(dto.TeamName))
  12680. {
  12681. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12682. }
  12683. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12684. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12685. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12686. swatch.Stop();
  12687. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12688. }
  12689. else
  12690. {
  12691. return Ok(JsonView(false, "查询失败"));
  12692. }
  12693. }
  12694. /// <summary>
  12695. /// 匹配op行程单
  12696. /// 行程单下载
  12697. /// </summary>
  12698. /// <param name="dto">团组列表请求dto</param>
  12699. /// <returns></returns>
  12700. [HttpPost]
  12701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12702. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12703. {
  12704. #region 参数验证
  12705. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12706. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12707. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12708. #region 页面操作权限验证
  12709. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12710. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12711. #endregion
  12712. #endregion
  12713. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12714. {
  12715. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12716. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12717. }
  12718. else
  12719. {
  12720. return Ok(JsonView(false, "下载失败!"));
  12721. }
  12722. }
  12723. #endregion
  12724. #region 国家信息 数据 注释
  12725. //[HttpPost]
  12726. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12727. //{
  12728. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12729. // foreach (var item in dto)
  12730. // {
  12731. // infos.Add(new Grp_GroupsTaskAssignment()
  12732. // {
  12733. // DIId = item,
  12734. // CTId = 82,
  12735. // UId = 248,
  12736. // IsEnable = 1,
  12737. // CreateUserId = 233,
  12738. // CreateTime = DateTime.Now,
  12739. // IsDel = 0
  12740. // });
  12741. // infos.Add(new Grp_GroupsTaskAssignment()
  12742. // {
  12743. // DIId = item,
  12744. // CTId = 82,
  12745. // UId = 286,
  12746. // IsEnable = 1,
  12747. // CreateUserId = 233,
  12748. // CreateTime = DateTime.Now,
  12749. // IsDel = 0
  12750. // });
  12751. // }
  12752. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12753. // return Ok("操作成功");
  12754. //}
  12755. //public class paramJsonDto
  12756. //{
  12757. // public List<CountriesInfo> str { get; set; }
  12758. //}
  12759. //[HttpPost]
  12760. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12761. //{
  12762. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12763. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12764. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12765. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12766. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12767. // _sqlSugar.BeginTran();
  12768. // int countitiesIndex = 0;
  12769. // foreach (var item in dto.str)
  12770. // {
  12771. // dynamic data = item.c;
  12772. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12773. // if (data != null)
  12774. // {
  12775. // countitiesIndex++;
  12776. // foreach (var item1 in data)
  12777. // {
  12778. // string cnname = item1.cn;
  12779. // string enname = item1.en;
  12780. // Sys_Cities provinceInfo = new Sys_Cities()
  12781. // {
  12782. // CountriesId = countriesId,
  12783. // Name_CN = cnname,
  12784. // Name_EN = enname,
  12785. // ParentId = 0,
  12786. // IsCapital = 1,
  12787. // CreateUserId = 208,
  12788. // CreateTime = DateTime.Now,
  12789. // IsDel = 0
  12790. // };
  12791. // if (item1.lv == "province") //省份
  12792. // {
  12793. // provinceInfo.Level = 1;
  12794. // int provinceId = 0;
  12795. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12796. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12797. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12798. // var data1 = item1.c;
  12799. // foreach (var item2 in data1)
  12800. // {
  12801. // if (item2.lv == "city")
  12802. // {
  12803. // string citycnname = item2.cn;
  12804. // string cityenname = item2.en;
  12805. // Sys_Cities cityInfo = new Sys_Cities()
  12806. // {
  12807. // CountriesId = countriesId,
  12808. // ParentId = provinceId,
  12809. // Level = 2,
  12810. // Name_CN = citycnname,
  12811. // Name_EN = cityenname,
  12812. // IsCapital = 1,
  12813. // CreateUserId = 208,
  12814. // CreateTime = DateTime.Now,
  12815. // IsDel = 0
  12816. // };
  12817. // if (item2.c != null)
  12818. // {
  12819. // int cityId = 0;
  12820. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12821. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12822. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12823. // foreach (var item3 in item2.c)
  12824. // {
  12825. // if (item3.lv == "district")
  12826. // {
  12827. // var districtInfo = new Sys_Cities()
  12828. // {
  12829. // CountriesId = countriesId,
  12830. // Name_CN = item3.cn,
  12831. // Name_EN = item3.en,
  12832. // Level = 3,
  12833. // ParentId = cityId,
  12834. // IsCapital = 1,
  12835. // CreateUserId = 208,
  12836. // CreateTime = DateTime.Now,
  12837. // IsDel = 0
  12838. // };
  12839. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12840. // //{
  12841. // districts.Add(districtInfo);
  12842. // //}
  12843. // }
  12844. // }
  12845. // }
  12846. // else
  12847. // {
  12848. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12849. // //{
  12850. // cities.Add(cityInfo);
  12851. // //}
  12852. // }
  12853. // }
  12854. // }
  12855. // }
  12856. // else if (item1.lv == "city")//城市
  12857. // {
  12858. // provinceInfo.Level = 2;
  12859. // if (item1.c != null)
  12860. // {
  12861. // int cityId = 0;
  12862. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12863. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12864. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12865. // foreach (var item3 in item1.c)
  12866. // {
  12867. // if (item3.lv == "district")
  12868. // {
  12869. // var districtInfo = new Sys_Cities()
  12870. // {
  12871. // CountriesId = countriesId,
  12872. // Name_CN = item3.cn,
  12873. // Name_EN = item3.en,
  12874. // Level = 3,
  12875. // ParentId = cityId,
  12876. // IsCapital = 1,
  12877. // CreateUserId = 208,
  12878. // CreateTime = DateTime.Now,
  12879. // IsDel = 0
  12880. // };
  12881. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12882. // //{
  12883. // districts.Add(districtInfo);
  12884. // //}
  12885. // }
  12886. // }
  12887. // }
  12888. // else
  12889. // {
  12890. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12891. // //{
  12892. // cities.Add(provinceInfo);
  12893. // //}
  12894. // }
  12895. // }
  12896. // }
  12897. // }
  12898. // }
  12899. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12900. // cities = cities.Distinct().ToList();
  12901. // districts = districts.Distinct().ToList();
  12902. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12903. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12904. // cities.AddRange(districts);
  12905. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12906. // //_sqlSugar.RollbackTran();
  12907. // _sqlSugar.CommitTran();
  12908. // return Ok(JsonView(false, "操作成功!"));
  12909. //}
  12910. //[HttpPost]
  12911. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12912. //{
  12913. // List<CountitiesInfo> infos = dto.MyProperty;
  12914. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12915. // _sqlSugar.BeginTran();
  12916. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12917. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12918. // foreach (var item in infos)
  12919. // {
  12920. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12921. // if (countryInfo != null)
  12922. // {
  12923. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12924. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12925. // if (cityInfo1 != null)
  12926. // {
  12927. // cityInfo1.IsCapital = 0;
  12928. // cityInfos.Add(cityInfo1);
  12929. // }
  12930. // }
  12931. // }
  12932. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12933. // .UpdateColumns(it => it.IsCapital)
  12934. // .WhereColumns(it => it.Id)
  12935. // .ExecuteCommand();
  12936. // //_sqlSugar.RollbackTran();
  12937. // _sqlSugar.CommitTran();
  12938. // return Ok(JsonView(false, "操作成功!"));
  12939. //}
  12940. //public class CounrtiesDto
  12941. //{
  12942. // public List<CountitiesInfo> MyProperty { get; set; }
  12943. //}
  12944. //public class CountitiesInfo
  12945. //{
  12946. // /// <summary>
  12947. // /// 圣约翰
  12948. // /// </summary>
  12949. // public string capital_name_chinese { get; set; }
  12950. // /// <summary>
  12951. // ///
  12952. // /// </summary>
  12953. // public string capital_name { get; set; }
  12954. // /// <summary>
  12955. // ///
  12956. // /// </summary>
  12957. // public string country_type { get; set; }
  12958. // /// <summary>
  12959. // /// 安提瓜和巴布达
  12960. // /// </summary>
  12961. // public string country_name_chinese { get; set; }
  12962. // /// <summary>
  12963. // /// 安提瓜和巴布达
  12964. // /// </summary>
  12965. // public string country_name_chinese_short { get; set; }
  12966. // /// <summary>
  12967. // /// 安提瓜和巴布达
  12968. // /// </summary>
  12969. // public string country_name_chinese_UN { get; set; }
  12970. // /// <summary>
  12971. // ///
  12972. // /// </summary>
  12973. // public string country_name_english_abbreviation { get; set; }
  12974. // /// <summary>
  12975. // ///
  12976. // /// </summary>
  12977. // public string country_name_english_formal { get; set; }
  12978. // /// <summary>
  12979. // ///
  12980. // /// </summary>
  12981. // public string country_name_english_UN { get; set; }
  12982. // /// <summary>
  12983. // ///
  12984. // /// </summary>
  12985. // public string continent_name { get; set; }
  12986. // /// <summary>
  12987. // ///
  12988. // /// </summary>
  12989. // public string subregion_name { get; set; }
  12990. // /// <summary>
  12991. // ///
  12992. // /// </summary>
  12993. // public string country_code2 { get; set; }
  12994. // /// <summary>
  12995. // ///
  12996. // /// </summary>
  12997. // public string country_code3 { get; set; }
  12998. // /// <summary>
  12999. // ///
  13000. // /// </summary>
  13001. // public string phone_code { get; set; }
  13002. //}
  13003. //public class CountriesInfo : BasicInfo
  13004. //{
  13005. // public List<CitiesInfo> c { get; set; }
  13006. //}
  13007. //public class CitiesInfo : BasicInfo
  13008. //{
  13009. // public List<AreaInfo> c { get; set; }
  13010. //}
  13011. //public class AreaInfo : BasicInfo
  13012. //{
  13013. // public List<AreaInfo> c { get; set; }
  13014. //}
  13015. //public class BasicInfo
  13016. //{
  13017. // public string code { get; set; }
  13018. // public string cn { get; set; }
  13019. // public string lv { get; set; }
  13020. // public string en { get; set; }
  13021. //}
  13022. #endregion
  13023. #region 查看邀请方
  13024. /// <summary>
  13025. /// 查看邀请方
  13026. /// 邀请方信息 Init
  13027. /// </summary>
  13028. /// <param name="dto"></param>
  13029. /// <returns></returns>
  13030. [HttpPost]
  13031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13032. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  13033. {
  13034. string sqlWhere = string.Empty;
  13035. if (!string.IsNullOrEmpty(dto.Search))
  13036. {
  13037. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  13038. }
  13039. string sql = string.Format($@"Select
  13040. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  13041. Id,
  13042. UnitName
  13043. From Res_InvitationOfficialActivityData
  13044. Where IsDel = 0
  13045. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  13046. RefAsync<int> total = 0;
  13047. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13048. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  13049. }
  13050. /// <summary>
  13051. /// 查看邀请方
  13052. /// 国家信息 Init
  13053. /// </summary>
  13054. /// <param name="dto"></param>
  13055. /// <returns></returns>
  13056. [HttpPost]
  13057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13058. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  13059. {
  13060. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  13061. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13062. var diids = groupInfos.Select(it => it.Id).ToList();
  13063. List<string> countrys = new List<string>();
  13064. foreach (var item in country)
  13065. {
  13066. var data = _groupRepository.FormartTeamName(item);
  13067. var dataArray = _groupRepository.GroupSplitCountry(data);
  13068. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13069. }
  13070. countrys = countrys.Distinct().ToList();
  13071. for (int i = 0; i < countrys.Count; i++)
  13072. {
  13073. string item = countrys[i];
  13074. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  13075. {
  13076. countrys.Remove(item);
  13077. i--;
  13078. }
  13079. }
  13080. RefAsync<int> total = 0;
  13081. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  13082. .Where(it => countrys.Contains(it.Name_CN))
  13083. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  13084. .Select(it => new { id = it.Id, name = it.Name_CN })
  13085. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13086. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  13087. }
  13088. /// <summary>
  13089. /// 查看邀请方
  13090. /// 城市信息 Init
  13091. /// </summary>
  13092. /// <param name="dto"></param>
  13093. /// <returns></returns>
  13094. [HttpPost]
  13095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13096. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  13097. {
  13098. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  13099. RefAsync<int> total = 0;
  13100. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  13101. .Where(it => it.CountriesId == dto.CountiesId)
  13102. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  13103. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  13104. .Select(it => new { id = it.Id, name = it.Name_CN })
  13105. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13106. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  13107. }
  13108. /// <summary>
  13109. /// 查看邀请方
  13110. /// 团组名称 Init
  13111. /// </summary>
  13112. /// <param name="dto"></param>
  13113. /// <returns></returns>
  13114. [HttpPost]
  13115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13116. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  13117. {
  13118. var watch = new Stopwatch();
  13119. watch.Start();
  13120. RefAsync<int> total = 0;
  13121. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  13122. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  13123. .Where((oa, di) => oa.IsDel == 0)
  13124. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  13125. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  13126. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  13127. .Distinct()
  13128. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13129. watch.Stop();
  13130. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  13131. }
  13132. /// <summary>
  13133. /// 查看邀请方
  13134. /// 团组 & 邀请方信息
  13135. /// </summary>
  13136. /// <param name="dto"></param>
  13137. /// <returns></returns>
  13138. [HttpPost]
  13139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13140. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  13141. {
  13142. var watch = new Stopwatch();
  13143. watch.Start();
  13144. RefAsync<int> total = 0;
  13145. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  13146. .AS("Grp_DelegationInfo")
  13147. .Includes(x => x.InvitingInfos)
  13148. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  13149. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  13150. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  13151. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  13152. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  13153. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  13154. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13155. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  13156. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  13157. infos.ForEach(x =>
  13158. {
  13159. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  13160. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  13161. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  13162. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  13163. });
  13164. watch.Stop();
  13165. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  13166. }
  13167. #endregion
  13168. #region 报批行程
  13169. /// <summary>
  13170. /// 报批行程初始化
  13171. /// </summary>
  13172. /// <param name="dto"></param>
  13173. /// <returns></returns>
  13174. [HttpPost]
  13175. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  13176. {
  13177. const int chiNumber = 5;
  13178. var jw = JsonView(false);
  13179. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  13180. var group = groupList.First();
  13181. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13182. group = groupList.First(x => x.Id == diid);
  13183. if (group == null)
  13184. {
  13185. jw.Msg = "暂无团组!";
  13186. return Ok(jw);
  13187. }
  13188. var data = new
  13189. {
  13190. groupList = groupList.Select(x => new
  13191. {
  13192. x.TeamName,
  13193. x.Id
  13194. }),
  13195. content = new ArrayList(),
  13196. groupInfo = new
  13197. {
  13198. group.VisitDays,
  13199. group.TourCode,
  13200. group.VisitPNumber,
  13201. group.TeamName,
  13202. group.Id,
  13203. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  13204. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  13205. },
  13206. };
  13207. var resultArr = new ArrayList();
  13208. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  13209. if (content.Count == 0)
  13210. {
  13211. var stay = "-";
  13212. var cityPath = "-";
  13213. //添加城市路径以及住宿地
  13214. //黑屏代码数据
  13215. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13216. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13217. {
  13218. jw = JsonView(true, "黑屏代码有误!", data);
  13219. return Ok(jw);
  13220. }
  13221. foreach (DataRow row in dtBlack.Rows)
  13222. {
  13223. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13224. {
  13225. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  13226. return Ok(jw);
  13227. }
  13228. }
  13229. //黑屏代码获取时间区间
  13230. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13231. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13232. _sqlSugar.BeginTran();
  13233. for (int i = 0; i < timeArr.Count; i++)
  13234. {
  13235. stay = "-";
  13236. cityPath = "-";
  13237. DateTime NewData = DateTime.Parse(timeArr[i]);
  13238. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13239. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13240. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13241. if (tbSelect.Length > 0)
  13242. {
  13243. List<string> threeCodeStr = new List<string>();
  13244. foreach (var item in tbSelect)
  13245. {
  13246. var threeCode = item["Three"].ToString() ?? "";
  13247. if (threeCode.Length == 6)
  13248. {
  13249. var start = threeCode.Substring(0, 3);
  13250. var end = threeCode.Substring(3, 3);
  13251. if (threeCodeStr.Count == 0)
  13252. {
  13253. threeCodeStr.Add(start);
  13254. threeCodeStr.Add(end);
  13255. }
  13256. else
  13257. {
  13258. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13259. {
  13260. threeCodeStr.Add(end);
  13261. }
  13262. else
  13263. {
  13264. threeCodeStr.Add(start);
  13265. threeCodeStr.Add(end);
  13266. }
  13267. }
  13268. }
  13269. }
  13270. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13271. var last = threeCodeStr.Last();
  13272. foreach (var item in threeCodeStr)
  13273. {
  13274. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13275. if (item.Equals(last))
  13276. {
  13277. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13278. }
  13279. }
  13280. cityPath = cityPath.Trim('-');
  13281. }
  13282. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13283. appro.Diid = diid ?? -1;
  13284. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13285. appro.Id = thisId;
  13286. appro.CreateUserId = dto.UserId;
  13287. appro.CreateTime = DateTime.Now;
  13288. content.Add(appro);
  13289. }
  13290. _sqlSugar.CommitTran();
  13291. }
  13292. foreach (var x in content)
  13293. {
  13294. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  13295. if (chiList.Count < chiNumber)
  13296. {
  13297. for (int i = chiList.Count; i < chiNumber; i++)
  13298. {
  13299. chiList.Add(new Grp_ApprovalTravelDetails());
  13300. }
  13301. }
  13302. resultArr.Add(new
  13303. {
  13304. x.Id,
  13305. x.Date,
  13306. x.Diid,
  13307. chiList = chiList.Select(x1 => new
  13308. {
  13309. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13310. x1.Details,
  13311. x1.ParentId,
  13312. x1.Id
  13313. })
  13314. });
  13315. }
  13316. data = data with
  13317. {
  13318. content = resultArr,
  13319. };
  13320. jw = JsonView(true, "获取成功!", data);
  13321. return Ok(jw);
  13322. }
  13323. /// <summary>
  13324. /// 报批行程删除
  13325. /// </summary>
  13326. /// <param name="dto"></param>
  13327. /// <returns></returns>
  13328. [HttpPost]
  13329. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  13330. {
  13331. var jw = JsonView(false);
  13332. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13333. if (group == null)
  13334. {
  13335. jw.Msg = "团组参数有误!";
  13336. return Ok(jw);
  13337. }
  13338. try
  13339. {
  13340. _sqlSugar.BeginTran();
  13341. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  13342. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  13343. {
  13344. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13345. DeleteUserId = dto.uesrId,
  13346. IsDel = 1
  13347. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  13348. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  13349. {
  13350. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13351. DeleteUserId = dto.uesrId,
  13352. IsDel = 1
  13353. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  13354. _sqlSugar.CommitTran();
  13355. jw = JsonView(true, "删除成功");
  13356. }
  13357. catch (Exception ex)
  13358. {
  13359. jw = JsonView(false, ex.Message);
  13360. }
  13361. return Ok(jw);
  13362. }
  13363. /// <summary>
  13364. /// 报批行程保存
  13365. /// </summary>
  13366. /// <param name="dto"></param>
  13367. /// <returns></returns>
  13368. [HttpPost]
  13369. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  13370. {
  13371. var jw = JsonView(false);
  13372. var Find = dto.Arr.Find(x => x.id == 0);
  13373. if (Find != null)
  13374. {
  13375. jw.Msg = "生成的ID为0!";
  13376. return Ok(jw);
  13377. }
  13378. foreach (var item in dto.Arr)
  13379. {
  13380. foreach (var chi in item.chiList)
  13381. {
  13382. if (chi.parentId == 0)
  13383. {
  13384. chi.parentId = item.id;
  13385. }
  13386. }
  13387. }
  13388. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  13389. _sqlSugar.BeginTran();
  13390. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  13391. {
  13392. var parentIds = dto.Arr.Select(x => x.id).ToList();
  13393. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  13394. {
  13395. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13396. DeleteUserId = dto.UserId,
  13397. IsDel = 1
  13398. }).ExecuteCommand();
  13399. }
  13400. try
  13401. {
  13402. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  13403. {
  13404. CreateTime = DateTime.Now,
  13405. CreateUserId = dto.UserId,
  13406. Details = x.details,
  13407. ParentId = x.parentId,
  13408. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13409. Remark = "",
  13410. IsDel = 0
  13411. }).ToList()).ExecuteCommand();
  13412. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  13413. {
  13414. Id = x.id,
  13415. Details = x.details,
  13416. ParentId = x.parentId,
  13417. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13418. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  13419. {
  13420. Details = x.Details,
  13421. ParentId = x.ParentId,
  13422. Time = x.Time
  13423. }).ExecuteCommand();
  13424. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  13425. {
  13426. Id = x.id,
  13427. Date = x.date,
  13428. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  13429. {
  13430. Date = x.Date
  13431. }).ExecuteCommand();
  13432. _sqlSugar.CommitTran();
  13433. jw = JsonView(true, "保存成功!");
  13434. }
  13435. catch (Exception ex)
  13436. {
  13437. _sqlSugar.RollbackTran();
  13438. jw = JsonView(false, "保存失败!" + ex.Message);
  13439. }
  13440. return Ok(jw);
  13441. }
  13442. /// <summary>
  13443. /// 报批行程生成
  13444. /// </summary>
  13445. /// <param name="dto"></param>
  13446. /// <returns></returns>
  13447. [HttpPost]
  13448. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  13449. {
  13450. var jw = JsonView(false);
  13451. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13452. if (group == null)
  13453. {
  13454. jw.Msg = "暂无该团组!";
  13455. return Ok(jw);
  13456. }
  13457. //黑屏代码数据
  13458. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13459. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13460. {
  13461. jw.Msg = "黑屏代码有误!";
  13462. return Ok(jw);
  13463. }
  13464. foreach (DataRow row in dtBlack.Rows)
  13465. {
  13466. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13467. {
  13468. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  13469. return Ok(jw);
  13470. }
  13471. }
  13472. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13473. var resultArr = new ArrayList();
  13474. if (officialActivitiesArr.Count == 0)
  13475. {
  13476. jw.Msg = "暂无公务出访信息!";
  13477. return Ok(jw);
  13478. }
  13479. try
  13480. {
  13481. _sqlSugar.BeginTran();
  13482. DeleteApprovalJourney(new
  13483. Domain.Dtos.Groups.DeleteApprovalJourney
  13484. {
  13485. Diid = dto.Diid,
  13486. uesrId = dto.Userid
  13487. });
  13488. var stay = "-";
  13489. var cityPath = "-";
  13490. //添加城市路径以及住宿地
  13491. //黑屏代码获取时间区间
  13492. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13493. var empty = "【未收入该三字码!请机票同事录入】";
  13494. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13495. for (int i = 0; i < timeArr.Count; i++)
  13496. {
  13497. stay = "-";
  13498. cityPath = "-";
  13499. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13500. DateTime NewData = DateTime.Parse(timeArr[i]);
  13501. 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();
  13502. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13503. if (tbSelect.Length > 0)
  13504. {
  13505. List<string> threeCodeStr = new List<string>();
  13506. bool isTrade = false;
  13507. string trip = string.Empty;
  13508. var rowLast = tbSelect.Last();
  13509. var rowFirst = tbSelect.First();
  13510. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13511. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13512. var takeOffTime = DateTime.Parse(timeArr[i]);
  13513. var fallToTime = DateTime.Parse(timeArr[i]);
  13514. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13515. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13516. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13517. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13518. foreach (var item in tbSelect)
  13519. {
  13520. var start = string.Empty;
  13521. var end = string.Empty;
  13522. var threeCode = item["Three"].ToString() ?? "";
  13523. if (threeCode.Length == 6)
  13524. {
  13525. start = threeCode.Substring(0, 3);
  13526. end = threeCode.Substring(3, 3);
  13527. if (threeCodeStr.Count == 0)
  13528. {
  13529. threeCodeStr.Add(start);
  13530. threeCodeStr.Add(end);
  13531. }
  13532. else
  13533. {
  13534. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13535. {
  13536. threeCodeStr.Add(end);
  13537. }
  13538. else
  13539. {
  13540. threeCodeStr.Add(start);
  13541. threeCodeStr.Add(end);
  13542. }
  13543. }
  13544. }
  13545. //处理机票信息
  13546. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13547. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13548. if (start_Object == null)
  13549. {
  13550. start_Object = new Res_ThreeCode()
  13551. {
  13552. AirPort = empty,
  13553. AirPort_En = empty,
  13554. City = empty,
  13555. Country = empty,
  13556. Four = empty,
  13557. Three = empty,
  13558. };
  13559. }
  13560. if (end_Object == null)
  13561. {
  13562. end_Object = new Res_ThreeCode()
  13563. {
  13564. AirPort = empty,
  13565. AirPort_En = empty,
  13566. City = empty,
  13567. Country = empty,
  13568. Four = empty,
  13569. Three = empty,
  13570. };
  13571. }
  13572. //机型判断
  13573. string airModel = item["AirModel"].ToString();
  13574. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13575. string flightTime = item["FlightTime"].ToString();
  13576. if (flightTime!.Contains(":"))
  13577. {
  13578. flightTime = flightTime.Replace(":", "小时");
  13579. flightTime += "分钟";
  13580. }
  13581. if (flightTime.Contains("H"))
  13582. {
  13583. flightTime = flightTime.Replace("H", "小时");
  13584. }
  13585. if (flightTime.Contains("M"))
  13586. {
  13587. flightTime = flightTime.Replace("M", "分钟");
  13588. }
  13589. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13590. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13591. {
  13592. flightTime = flightDataTime.Hour > 0
  13593. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13594. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13595. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13596. }
  13597. //航班号
  13598. string flightcode = item["Fliagtcode"].ToString();
  13599. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13600. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13601. if (aircompany == null)
  13602. {
  13603. aircompany = new Res_AirCompany
  13604. {
  13605. CnName = hsEmpty,
  13606. EnName = hsEmpty,
  13607. ShortCode = hsEmpty,
  13608. };
  13609. }
  13610. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13611. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13612. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13613. if (isTrade)
  13614. {
  13615. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13616. }
  13617. else
  13618. {
  13619. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13620. }
  13621. }
  13622. chiarr.Add(new Grp_ApprovalTravelDetails
  13623. {
  13624. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13625. CreateTime = DateTime.Now,
  13626. CreateUserId = dto.Userid,
  13627. ParentId = 0,
  13628. Details = trip
  13629. });
  13630. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13631. var last = threeCodeStr.Last();
  13632. foreach (var item in threeCodeStr)
  13633. {
  13634. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13635. if (item.Equals(last))
  13636. {
  13637. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13638. }
  13639. }
  13640. cityPath = cityPath.Trim('-');
  13641. }
  13642. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13643. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13644. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13645. appro.Diid = dto.Diid;
  13646. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13647. appro.Id = thisId;
  13648. appro.CreateUserId = dto.Userid;
  13649. appro.CreateTime = DateTime.Now;
  13650. foreach (var item in gwinfo)
  13651. {
  13652. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13653. chi.Details = "拜访" + item.Client;
  13654. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13655. {
  13656. chi.Details += "," + item.ReqSample;
  13657. }
  13658. chi.ParentId = thisId;
  13659. chi.Time = item.Time;
  13660. chiarr.Add(chi);
  13661. }
  13662. if (chiarr.Count < 5)
  13663. {
  13664. for (int j = chiarr.Count; j < 5; j++)
  13665. {
  13666. chiarr.Add(new
  13667. Grp_ApprovalTravelDetails());
  13668. }
  13669. }
  13670. resultArr.Add(new
  13671. {
  13672. appro.Id,
  13673. appro.Date,
  13674. appro.Diid,
  13675. chiList = chiarr.Select(x1 => new
  13676. {
  13677. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13678. x1.Details,
  13679. x1.ParentId,
  13680. x1.Id
  13681. })
  13682. });
  13683. }
  13684. _sqlSugar.CommitTran();
  13685. jw = JsonView(true, "生成成功!", resultArr);
  13686. }
  13687. catch (Exception ex)
  13688. {
  13689. jw.Code = 400;
  13690. jw.Msg = "生成失败!" + ex.Message;
  13691. }
  13692. return Ok(jw);
  13693. }
  13694. /// <summary>
  13695. /// 报批行程word导出
  13696. /// </summary>
  13697. /// <param name="dto"></param>
  13698. /// <returns></returns>
  13699. [HttpPost]
  13700. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13701. {
  13702. var jw = JsonView(false);
  13703. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13704. if (group == null)
  13705. {
  13706. jw.Msg = "暂无该团组!";
  13707. return Ok(jw);
  13708. }
  13709. //模板路径
  13710. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13711. //载入模板
  13712. Document doc = new Document(tempPath);
  13713. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13714. //获取所填表格的序数
  13715. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13716. Aspose.Words.Tables.Row titleRowClone = null;
  13717. Aspose.Words.Tables.Row CenterRowClone = null;
  13718. int index = 0;
  13719. int indexChi = 0;
  13720. int SetIndex = 0;
  13721. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13722. //获取数据,放到datatable
  13723. foreach (var item in ApprovalTravelArr)
  13724. {
  13725. if (index > 0)
  13726. {
  13727. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13728. tableOne.AppendChild(titleRowClone);
  13729. }
  13730. var textTime = item.Date;
  13731. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13732. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13733. SetIndex++;
  13734. if (ChiRep.Count > 0)
  13735. {
  13736. foreach (var itemChi in ChiRep)
  13737. {
  13738. var txtTime = itemChi.Time;
  13739. var txtDetail = itemChi.Details;
  13740. if (indexChi > 0)
  13741. {
  13742. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13743. tableOne.AppendChild(CenterRowClone);
  13744. }
  13745. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13746. {
  13747. SetCells(tableOne, doc, SetIndex, 0, "");
  13748. SetCells(tableOne, doc, SetIndex, 1, "");
  13749. indexChi++;
  13750. SetIndex++;
  13751. break;
  13752. }
  13753. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13754. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13755. indexChi++;
  13756. SetIndex++;
  13757. }
  13758. }
  13759. else
  13760. {
  13761. if (indexChi > 0)
  13762. {
  13763. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13764. tableOne.AppendChild(CenterRowClone);
  13765. }
  13766. SetCells(tableOne, doc, SetIndex, 0, "");
  13767. SetCells(tableOne, doc, SetIndex, 1, "");
  13768. indexChi++;
  13769. SetIndex++;
  13770. }
  13771. index++;
  13772. }
  13773. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13774. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13775. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13776. jw.Code = 200;
  13777. jw.Msg = "";
  13778. return Ok(jw);
  13779. }
  13780. private string intToString(int numberVal)
  13781. {
  13782. string numberval = numberVal.ToString();
  13783. Dictionary<char, string> Number = new Dictionary<char, string>();
  13784. Number.Add('1', "一");
  13785. Number.Add('2', "二");
  13786. Number.Add('3', "三");
  13787. Number.Add('4', "四");
  13788. Number.Add('5', "五");
  13789. Number.Add('6', "六");
  13790. Number.Add('7', "七");
  13791. Number.Add('8', "八");
  13792. Number.Add('9', "九");
  13793. string stringNumberVal = string.Empty;
  13794. for (int i = 0; i < numberval.Length; i++)
  13795. {
  13796. if (i == 0)
  13797. {
  13798. stringNumberVal += Number[numberval[i]];
  13799. }
  13800. else if (i >= 1)
  13801. {
  13802. if (numberval[i] == '0')
  13803. {
  13804. stringNumberVal = "十";
  13805. }
  13806. else
  13807. {
  13808. stringNumberVal += "十" + Number[numberval[i]];
  13809. }
  13810. }
  13811. }
  13812. return stringNumberVal;
  13813. }
  13814. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13815. {
  13816. //获取table中的某个单元格,从0开始
  13817. Cell lshCell = table.Rows[rows].Cells[cells];
  13818. //将单元格中段落移除
  13819. foreach (Node item in lshCell.Paragraphs)
  13820. {
  13821. lshCell.Paragraphs.Remove(item);
  13822. }
  13823. if (val.Contains("\r\n"))
  13824. {
  13825. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13826. foreach (var item in spArr)
  13827. {
  13828. //新建一个段落
  13829. Paragraph p = new Paragraph(doc);
  13830. var r = new Run(doc, item);
  13831. //把设置的值赋给之前新建的段落
  13832. p.AppendChild(r);
  13833. //将此段落加到单元格内
  13834. lshCell.AppendChild(p);
  13835. }
  13836. }
  13837. else
  13838. {
  13839. //新建一个段落
  13840. Paragraph p = new Paragraph(doc);
  13841. var r = new Run(doc, val);
  13842. //把设置的值赋给之前新建的段落
  13843. p.AppendChild(r);
  13844. //将此段落加到单元格内
  13845. lshCell.AppendChild(p);
  13846. }
  13847. }
  13848. [HttpPost]
  13849. public async Task<IActionResult> ServerHttp(string paramStr)
  13850. {
  13851. paramStr = paramStr.TrimEnd('\'');
  13852. paramStr = paramStr.TrimStart('\'');
  13853. JsonView jw = JsonView(false);
  13854. JObject param = JObject.Parse(paramStr);
  13855. if (!param.ContainsKey("url"))
  13856. {
  13857. jw.Msg = "url null";
  13858. return Ok(jw);
  13859. }
  13860. string url = param["url"]!.ToString();
  13861. var methon = "get";
  13862. Dictionary<string, string> headValues = null;
  13863. string bodyStr = string.Empty;
  13864. if (param.ContainsKey("methon"))
  13865. {
  13866. methon = param["methon"]!.ToString().ToLower();
  13867. }
  13868. if (param.ContainsKey("header"))
  13869. {
  13870. var header = param["header"]!.ToString();
  13871. JObject headerJobject = JObject.Parse(header);
  13872. headValues = new Dictionary<string, string>();
  13873. foreach (JProperty item in headerJobject.Properties())
  13874. {
  13875. var value = item.Value.ToString();
  13876. var head = item.Path;
  13877. headValues.Add(head, value);
  13878. }
  13879. }
  13880. HttpClient client = new HttpClient();
  13881. string responseString = string.Empty;
  13882. StringContent content = null;
  13883. if (headValues != null)
  13884. {
  13885. foreach (var item in headValues.Keys)
  13886. {
  13887. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13888. {
  13889. if (param.ContainsKey("body"))
  13890. {
  13891. bodyStr = param["body"]!.ToString();
  13892. }
  13893. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13894. }
  13895. else
  13896. {
  13897. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13898. }
  13899. }
  13900. }
  13901. try
  13902. {
  13903. if (methon == "get")
  13904. {
  13905. responseString = await client.GetStringAsync(url);
  13906. }
  13907. else if (methon == "post")
  13908. {
  13909. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13910. {
  13911. Content = content
  13912. };
  13913. var response = await client.SendAsync(request);
  13914. try
  13915. {
  13916. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13917. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13918. {
  13919. using (StreamReader reader = new StreamReader(gzipStream))
  13920. {
  13921. responseString = await reader.ReadToEndAsync();
  13922. }
  13923. }
  13924. }
  13925. catch (Exception)
  13926. {
  13927. responseString = await response.Content.ReadAsStringAsync();
  13928. }
  13929. }
  13930. else
  13931. {
  13932. responseString = "methon error";
  13933. }
  13934. jw = JsonView(true, "success", responseString);
  13935. }
  13936. catch (Exception ex)
  13937. {
  13938. jw.Msg = "error " + ex.Message;
  13939. jw.Data = ex.StackTrace;
  13940. }
  13941. finally
  13942. {
  13943. client.Dispose();
  13944. }
  13945. return Ok(jw);
  13946. }
  13947. #endregion
  13948. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13949. /// <summary>
  13950. /// 团组接待意见调查 - 信息管理
  13951. /// 基础数据(团组)
  13952. /// </summary>
  13953. /// <param name="dto"></param>
  13954. /// <returns></returns>
  13955. [HttpGet]
  13956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13957. public async Task<IActionResult> OpinionaireInit()
  13958. {
  13959. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13960. .Select(x => new
  13961. {
  13962. x.Id,
  13963. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13964. })
  13965. .OrderByDescending(x => x.Id)
  13966. .ToListAsync();
  13967. return Ok(JsonView(groupData, groupData.Count));
  13968. }
  13969. /// <summary>
  13970. /// 团组接待意见调查 - 信息管理
  13971. /// 列表
  13972. /// </summary>
  13973. /// <param name="groupId"></param>
  13974. /// <returns></returns>
  13975. [HttpGet("{groupId}")]
  13976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13977. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13978. {
  13979. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13980. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  13981. .Select(x => new
  13982. {
  13983. x.Id,
  13984. x.TourGuideName,
  13985. x.CityName,
  13986. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  13987. x.CreateTime
  13988. })
  13989. .OrderBy(x => x.Id)
  13990. .ToListAsync();
  13991. return Ok(JsonView(data));
  13992. }
  13993. /// <summary>
  13994. /// 团组接待意见调查 - 信息管理
  13995. /// 保存
  13996. /// </summary>
  13997. /// <param name="dto"></param>
  13998. /// <returns></returns>
  13999. [HttpPost]
  14000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14001. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  14002. {
  14003. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  14004. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  14005. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14006. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  14007. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  14008. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  14009. _opinionaireRep.BeginTran();
  14010. if (addData != null && addData.Count > 0)
  14011. {
  14012. foreach (var item in addData)
  14013. {
  14014. item.CreateUserId = currUserInfo.UserId;
  14015. item.DiId = dto.DiId;
  14016. }
  14017. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  14018. }
  14019. if (updData != null && updData.Count > 0)
  14020. {
  14021. var upd = await _opinionaireRep._sqlSugar
  14022. .Updateable(updData)
  14023. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  14024. .WhereColumns(x => new { x.Id })
  14025. .ExecuteCommandAsync();
  14026. }
  14027. _opinionaireRep.CommitTran();
  14028. return Ok(JsonView("操作成功!"));
  14029. }
  14030. /// <summary>
  14031. /// 团组接待意见调查 - 信息管理
  14032. /// 删除
  14033. /// </summary>
  14034. /// <param name="id"></param>
  14035. /// <returns></returns>
  14036. [HttpDelete("{id}")]
  14037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14038. public async Task<IActionResult> OpinionaireManageDel(int id)
  14039. {
  14040. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  14041. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  14042. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  14043. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  14044. if (!del) return Ok(JsonView("操作失败!"));
  14045. return Ok(JsonView("操作成功!"));
  14046. }
  14047. /// <summary>
  14048. /// 团组接待意见调查 - 用户
  14049. /// 列表
  14050. /// </summary>
  14051. /// <param name="id"></param>
  14052. /// <returns></returns>
  14053. [HttpGet("{diId}")]
  14054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14055. public async Task<IActionResult> OpinionaireUserList(int diId)
  14056. {
  14057. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14058. var sql = string.Format(@"
  14059. SELECT
  14060. o.Id,
  14061. o.DiId,
  14062. di.TeamName AS 'GroupName',
  14063. di.VisitPNumber AS 'PeopleNumber',
  14064. di.ClientName AS 'LeadGroup',
  14065. di.VisitCountry AS 'Travel',
  14066. di.VisitDays AS 'Days',
  14067. o.CityName,
  14068. o.TourGuideName,
  14069. o.Catering,
  14070. o.CateringReason,
  14071. o.Stay,
  14072. o.StayReason,
  14073. o.[Route],
  14074. o.RouteReason,
  14075. o.OfficialActivity,
  14076. o.OfficialActivityReason,
  14077. o.TourGuide,
  14078. o.TourGuideReason,
  14079. o.[Translate],
  14080. o.TranslateReason,
  14081. o.Trip,
  14082. o.TripReason,
  14083. o.ESFileName,
  14084. o.SignatureDate,
  14085. o.Remark
  14086. FROM
  14087. Grp_Opinionaire o
  14088. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  14089. WHERE
  14090. o.IsDel = 0
  14091. AND o.DiId = {0}
  14092. ORDER BY
  14093. o.Id ASC", diId);
  14094. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  14095. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  14096. return Ok(JsonView(data));
  14097. }
  14098. /// <summary>
  14099. /// 团组接待意见调查 - 用户
  14100. /// 保存
  14101. /// </summary>
  14102. /// <param name="id"></param>
  14103. /// <returns></returns>
  14104. [HttpPost]
  14105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14106. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  14107. {
  14108. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  14109. foreach (var item in dto)
  14110. {
  14111. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  14112. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  14113. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  14114. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  14115. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  14116. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  14117. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  14118. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  14119. }
  14120. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  14121. if (!Directory.Exists(filePathBase))
  14122. {
  14123. Directory.CreateDirectory(filePathBase);
  14124. }
  14125. #region 上传文件
  14126. var filePaths = new List<string>();
  14127. foreach (var item in dto)
  14128. {
  14129. var file = item.File;
  14130. // 将文件保存到指定位置
  14131. var filePath = Path.Combine(filePathBase, file.FileName);
  14132. using (var stream = new FileStream(filePath, FileMode.Create))
  14133. {
  14134. await file.CopyToAsync(stream);
  14135. }
  14136. //验证文件是否上传成功
  14137. if (!System.IO.File.Exists(filePath))
  14138. {
  14139. foreach (var filePathStr in filePaths)
  14140. {
  14141. System.IO.File.Delete(filePathStr);
  14142. }
  14143. return Ok(JsonView(false, "文件上传失败!"));
  14144. }
  14145. item.ESFileName = file.FileName;
  14146. }
  14147. #endregion
  14148. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  14149. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  14150. .UpdateColumns(x => new
  14151. {
  14152. x.Catering,
  14153. x.CateringReason,
  14154. x.Stay,
  14155. x.StayReason,
  14156. x.Route,
  14157. x.RouteReason,
  14158. x.OfficialActivity,
  14159. x.OfficialActivityReason,
  14160. x.TourGuide,
  14161. x.TourGuideReason,
  14162. x.Translate,
  14163. x.TranslateReason,
  14164. x.Trip,
  14165. x.TripReason,
  14166. x.ESFileName,
  14167. x.SignatureDate,
  14168. x.Remark
  14169. })
  14170. .WhereColumns(x => new { x.Id })
  14171. .ExecuteCommandAsync();
  14172. if (upd < 1)
  14173. {
  14174. foreach (var filePathStr in filePaths)
  14175. {
  14176. System.IO.File.Delete(filePathStr);
  14177. }
  14178. return Ok(JsonView(false));
  14179. }
  14180. return Ok(JsonView(true));
  14181. }
  14182. #endregion
  14183. // /// <summary>
  14184. // ///
  14185. // /// </summary>
  14186. // /// <param name="_dto"></param>
  14187. // /// <returns></returns>
  14188. // [HttpPost]
  14189. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14190. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14191. // {
  14192. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14193. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  14194. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  14195. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14196. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  14197. // dic_psg.Add("客人", 974);
  14198. // dic_psg.Add("司机", 975);
  14199. // dic_psg.Add("导游", 976);
  14200. // dic_psg.Add("公司内部人员", 977);
  14201. // dic_psg.Add("司机/导游/公司内部人员", 978);
  14202. // foreach (var item in list_visa)
  14203. // {
  14204. // Grp_VisaInfo temp = new Grp_VisaInfo();
  14205. // temp.Id = item.Id;
  14206. // temp.DIId = item.DIId;
  14207. // temp.VisaClient = item.VisaClient;
  14208. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  14209. // temp.VisaCurrency = item.VisaCurrency;
  14210. // temp.IsThird = item.IsThird;
  14211. // if (dic_psg.ContainsKey(item.PassengerType))
  14212. // {
  14213. // temp.PassengerType = dic_psg[item.PassengerType];
  14214. // }
  14215. // else {
  14216. // temp.PassengerType = -1;
  14217. // }
  14218. // temp.VisaNumber = item.VisaNumber;
  14219. // temp.VisaFreeNumber = item.VisaFreeNumber;
  14220. // temp.CreateUserId = item.Operators;
  14221. // DateTime dt_ct;
  14222. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  14223. // if (b_ct)
  14224. // {
  14225. // temp.CreateTime = dt_ct;
  14226. // }
  14227. // else
  14228. // {
  14229. // temp.CreateTime = DateTime.Now;
  14230. // }
  14231. // temp.DeleteTime = "";
  14232. // temp.DeleteUserId = 0;
  14233. // temp.Remark = item.Remark;
  14234. // if (string.IsNullOrEmpty(temp.Remark)) {
  14235. // temp.Remark = "";
  14236. // }
  14237. // temp.IsDel = item.IsDel;
  14238. // temp.VisaDescription = item.VisaAttachment;
  14239. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  14240. //([Id]
  14241. // ,[DIId]
  14242. // ,[VisaClient]
  14243. // ,[VisaPrice]
  14244. // ,[VisaCurrency]
  14245. // ,[IsThird]
  14246. // ,[PassengerType]
  14247. // ,[VisaNumber]
  14248. // ,[VisaFreeNumber]
  14249. // ,[CreateUserId]
  14250. // ,[CreateTime]
  14251. // ,[DeleteTime]
  14252. // ,[DeleteUserId]
  14253. // ,[Remark]
  14254. // ,[IsDel]
  14255. // ,[visaDescription])
  14256. // VALUES
  14257. // ({0},{1},'{2}',{3},{4}
  14258. //,{5},{6},{7},{8},{9}
  14259. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  14260. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  14261. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  14262. //);
  14263. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  14264. // }
  14265. // return Ok(JsonView(true, "操作成功!"));
  14266. // }
  14267. /// <summary>
  14268. /// 123132123
  14269. /// </summary>
  14270. /// <param name="_dto"></param>
  14271. /// <returns></returns>
  14272. [HttpPost]
  14273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14274. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14275. {
  14276. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14277. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  14278. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  14279. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14280. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  14281. dicDetail.Add(789, 1034);
  14282. dicDetail.Add(790, 1035);
  14283. dicDetail.Add(791, 1036);
  14284. dicDetail.Add(792, 1037);
  14285. dicDetail.Add(793, 1038);
  14286. dicDetail.Add(794, 1039);
  14287. dicDetail.Add(795, 1040);
  14288. dicDetail.Add(796, 1041);
  14289. dicDetail.Add(797, 1042);
  14290. dicDetail.Add(798, 1043);
  14291. dicDetail.Add(801, 1044);
  14292. dicDetail.Add(802, 1045);
  14293. dicDetail.Add(803, 1046);
  14294. Dictionary<int, int> dic = new Dictionary<int, int>();
  14295. dic.Add(806, 1027);
  14296. dic.Add(807, 1028);
  14297. dic.Add(808, 1029);
  14298. dic.Add(809, 1030);
  14299. dic.Add(810, 1031);
  14300. dic.Add(811, 1032);
  14301. dic.Add(812, 1033);
  14302. foreach (var item in list_visa)
  14303. {
  14304. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  14305. temp.Coefficient = item.coefficient;
  14306. DateTime dtCrt;
  14307. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  14308. if (b1)
  14309. {
  14310. temp.CreateTime = dtCrt;
  14311. }
  14312. else
  14313. {
  14314. temp.CreateTime = DateTime.Now;
  14315. }
  14316. temp.CreateUserId = item.Operators;
  14317. temp.DeleteTime = "";
  14318. temp.DeleteUserId = 0;
  14319. temp.DiId = int.Parse(item.DIID);
  14320. temp.FilePath = item.FilePath;
  14321. temp.IsDel = item.IsDel;
  14322. temp.Price = item.Price;
  14323. temp.PriceCount = 1;
  14324. temp.PriceCurrency = item.Currency;
  14325. int detailId = 0;
  14326. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  14327. {
  14328. detailId = dicDetail[item.PriceTypeDetail];
  14329. }
  14330. temp.PriceDetailType = detailId;
  14331. temp.PriceDt = DateTime.Now;
  14332. temp.PriceName = item.PriceName;
  14333. temp.PriceSum = item.Price;
  14334. int tid = 0;
  14335. if (dic.ContainsKey(item.PriceType))
  14336. {
  14337. tid = dic[item.PriceType];
  14338. }
  14339. temp.PriceType = tid;
  14340. temp.Remark = item.Remark;
  14341. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  14342. }
  14343. return Ok(JsonView(true, "操作成功!"));
  14344. }
  14345. }
  14346. }