GroupsController.cs 833 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using EyeSoft.Collections.Generic;
  7. using EyeSoft.IO;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.SignalR;
  10. using MySqlX.XDevAPI.Relational;
  11. using NetUV.Core.Handles;
  12. using NPOI.HSSF.UserModel;
  13. using NPOI.POIFS.Crypt.Dsig;
  14. using NPOI.SS.Format;
  15. using NPOI.SS.Formula.Functions;
  16. using NPOI.SS.UserModel;
  17. using NPOI.SS.Util;
  18. using NPOI.XSSF.UserModel;
  19. using OASystem.API.OAMethodLib;
  20. using OASystem.API.OAMethodLib.APNs;
  21. using OASystem.API.OAMethodLib.File;
  22. using OASystem.API.OAMethodLib.Hub.HubClients;
  23. using OASystem.API.OAMethodLib.Hub.Hubs;
  24. using OASystem.API.OAMethodLib.JuHeAPI;
  25. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  26. using OASystem.Domain.AesEncryption;
  27. using OASystem.Domain.Dtos.CRM;
  28. using OASystem.Domain.Dtos.FileDto;
  29. using OASystem.Domain.Dtos.Financial;
  30. using OASystem.Domain.Dtos.Groups;
  31. using OASystem.Domain.Entities.Customer;
  32. using OASystem.Domain.Entities.Financial;
  33. using OASystem.Domain.Entities.Groups;
  34. using OASystem.Domain.ViewModels;
  35. using OASystem.Domain.ViewModels.Financial;
  36. using OASystem.Domain.ViewModels.Groups;
  37. using OASystem.Domain.ViewModels.Statistics;
  38. using OASystem.Infrastructure.Repositories.CRM;
  39. using OASystem.Infrastructure.Repositories.Financial;
  40. using OASystem.Infrastructure.Repositories.Groups;
  41. using OfficeOpenXml;
  42. using Org.BouncyCastle.Asn1.Ocsp;
  43. using Quartz.Util;
  44. using SqlSugar;
  45. using SqlSugar.Extensions;
  46. using System.Collections;
  47. using System.Data;
  48. using System.Data.OleDb;
  49. using System.Diagnostics;
  50. using System.Globalization;
  51. using System.IO;
  52. using System.IO.Compression;
  53. using System.Net.Http;
  54. using System.Reflection.PortableExecutable;
  55. using System.Security.Cryptography;
  56. using Ubiety.Dns.Core;
  57. using static NPOI.POIFS.Crypt.CryptoFunctions;
  58. using static OASystem.API.OAMethodLib.JWTHelper;
  59. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  60. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  61. using Bookmark = Aspose.Words.Bookmark;
  62. using Cell = Aspose.Words.Tables.Cell;
  63. using Table = Aspose.Words.Tables.Table;
  64. namespace OASystem.API.Controllers
  65. {
  66. /// <summary>
  67. /// 团组相关
  68. /// </summary>
  69. //[Authorize]
  70. [Route("api/[controller]/[action]")]
  71. public class GroupsController : ControllerBase
  72. {
  73. private readonly ILogger<GroupsController> _logger;
  74. private readonly GrpScheduleRepository _grpScheduleRep;
  75. private readonly IMapper _mapper;
  76. private readonly DelegationInfoRepository _groupRepository;
  77. private readonly TaskAssignmentRepository _taskAssignmentRep;
  78. private readonly AirTicketResRepository _airTicketResRep;
  79. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  80. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  81. private readonly DelegationEnDataRepository _delegationEnDataRep;
  82. private readonly DelegationVisaRepository _delegationVisaRep;
  83. private readonly VisaPriceRepository _visaPriceRep;
  84. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  85. private readonly HotelPriceRepository _hotelPriceRep;
  86. private readonly CustomersRepository _customersRep;
  87. private readonly MessageRepository _message;
  88. private readonly SqlSugarClient _sqlSugar;
  89. private readonly TourClientListRepository _tourClientListRep;
  90. private readonly TeamRateRepository _teamRateRep;
  91. #region 成本相关
  92. private readonly CheckBoxsRepository _checkBoxs;
  93. private readonly GroupCostRepository _GroupCostRepository;
  94. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  95. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  96. #endregion
  97. private readonly SetDataRepository _setDataRep;
  98. private string url;
  99. private string path;
  100. private readonly EnterExitCostRepository _enterExitCostRep;
  101. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  102. private readonly UsersRepository _usersRep;
  103. private readonly IJuHeApiService _juHeApi;
  104. private readonly InvertedListRepository _invertedListRep;
  105. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  106. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  107. private readonly ThreeCodeRepository _threeCodeRepository;
  108. private readonly HotelInquiryRepository _hotelInquiryRep;
  109. private readonly FeeAuditRepository _feeAuditRep;
  110. private readonly VisaCommissionRepository _visaCommissionRep;
  111. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  112. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  113. private readonly List<CurrencyInfo> _currencyInit;
  114. private readonly List<int> _portTypeData;
  115. private readonly TableOperationRecordRepository _tableorRep;
  116. public GroupsController(
  117. ILogger<GroupsController> logger,
  118. IMapper mapper,
  119. IHubContext<ChatHub, IChatClient> hubContext,
  120. SqlSugarClient sqlSugar,
  121. GrpScheduleRepository grpScheduleRep,
  122. DelegationInfoRepository groupRepository,
  123. TaskAssignmentRepository taskAssignmentRep,
  124. AirTicketResRepository airTicketResRep,
  125. DecreasePaymentsRepository decreasePaymentsRep,
  126. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  127. DelegationEnDataRepository delegationEnDataRep,
  128. EnterExitCostRepository enterExitCostRep,
  129. DelegationVisaRepository delegationVisaRep,
  130. MessageRepository message,
  131. VisaPriceRepository visaPriceRep,
  132. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  133. CheckBoxsRepository checkBoxs,
  134. GroupCostRepository GroupCostRepository,
  135. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  136. GroupCostParameterRepository GroupCostParameterRepository,
  137. HotelPriceRepository hotelPriceRep,
  138. CustomersRepository customersRep,
  139. SetDataRepository setDataRep,
  140. TourClientListRepository tourClientListRep,
  141. TeamRateRepository teamRateRep,
  142. UsersRepository usersRep, IJuHeApiService juHeApi,
  143. InvertedListRepository invertedListRep,
  144. VisaFeeInfoRepository visaFeeInfoRep,
  145. TicketBlackCodeRepository ticketBlackCodeRep,
  146. HotelInquiryRepository hotelInquiryRep,
  147. ThreeCodeRepository threeCodeRepository,
  148. FeeAuditRepository feeAuditRep,
  149. VisaCommissionRepository visaCommissionRep,
  150. ForeignReceivablesRepository ffrRep,
  151. OpinionaireRepository opinionaireRep,
  152. TableOperationRecordRepository tableorRep
  153. )
  154. {
  155. _logger = logger;
  156. _mapper = mapper;
  157. _grpScheduleRep = grpScheduleRep;
  158. _groupRepository = groupRepository;
  159. _taskAssignmentRep = taskAssignmentRep;
  160. _airTicketResRep = airTicketResRep;
  161. _sqlSugar = sqlSugar;
  162. url = AppSettingsHelper.Get("ExcelBaseUrl");
  163. path = AppSettingsHelper.Get("ExcelBasePath");
  164. if (!System.IO.Directory.Exists(path))
  165. {
  166. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  167. }
  168. _decreasePaymentsRep = decreasePaymentsRep;
  169. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  170. _delegationEnDataRep = delegationEnDataRep;
  171. _enterExitCostRep = enterExitCostRep;
  172. _delegationVisaRep = delegationVisaRep;
  173. _message = message;
  174. _visaPriceRep = visaPriceRep;
  175. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  176. _checkBoxs = checkBoxs;
  177. _GroupCostRepository = GroupCostRepository;
  178. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  179. _GroupCostParameterRepository = GroupCostParameterRepository;
  180. _hotelPriceRep = hotelPriceRep;
  181. _customersRep = customersRep;
  182. _setDataRep = setDataRep;
  183. _tourClientListRep = tourClientListRep;
  184. _teamRateRep = teamRateRep;
  185. _hubContext = hubContext;
  186. _usersRep = usersRep;
  187. _juHeApi = juHeApi;
  188. _invertedListRep = invertedListRep;
  189. _visaFeeInfoRep = visaFeeInfoRep;
  190. _ticketBlackCodeRep = ticketBlackCodeRep;
  191. _hotelInquiryRep = hotelInquiryRep;
  192. _threeCodeRepository = threeCodeRepository;
  193. _feeAuditRep = feeAuditRep;
  194. _visaCommissionRep = visaCommissionRep;
  195. _ffrRep = ffrRep;
  196. _opinionaireRep = opinionaireRep;
  197. _currencyInit = new List<CurrencyInfo>()
  198. {
  199. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  200. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  201. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  202. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  203. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  204. };
  205. _portTypeData = new List<int>() { 2, 3 };
  206. _tableorRep = tableorRep;
  207. }
  208. #region 流程管控
  209. /// <summary>
  210. /// 获取团组流程管控信息
  211. /// </summary>
  212. /// <param name="paras">参数Json字符串</param>
  213. /// <returns></returns>
  214. [HttpPost]
  215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  216. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  217. {
  218. if (string.IsNullOrEmpty(_jsonDto.Paras))
  219. {
  220. return Ok(JsonView(false, "参数为空"));
  221. }
  222. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  223. if (_ScheduleDto != null)
  224. {
  225. if (_ScheduleDto.SearchType == 2)//获取列表
  226. {
  227. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  228. return Ok(JsonView(_grpScheduleViewList));
  229. }
  230. else//获取对象
  231. {
  232. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  233. if (_grpScheduleView != null)
  234. {
  235. return Ok(JsonView(_grpScheduleView));
  236. }
  237. }
  238. }
  239. else
  240. {
  241. return Ok(JsonView(false, "参数反序列化失败"));
  242. }
  243. return Ok(JsonView(false, "暂无数据!"));
  244. }
  245. /// <summary>
  246. /// 修改团组流程管控详细表数据
  247. /// </summary>
  248. /// <param name="paras"></param>
  249. /// <returns></returns>
  250. [HttpPost]
  251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  252. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  253. {
  254. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  255. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  256. .SetColumns(it => it.Duty == _detail.Duty)
  257. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  258. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  259. .SetColumns(it => it.JobContent == _detail.JobContent)
  260. .SetColumns(it => it.Remark == _detail.Remark)
  261. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  262. .Where(s => s.Id == dto.Id)
  263. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  264. .ExecuteCommandAsync();
  265. if (result > 0)
  266. {
  267. return Ok(JsonView(true, "保存成功!"));
  268. }
  269. return Ok(JsonView(false, "保存失败!"));
  270. }
  271. /// <summary>
  272. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  273. /// </summary>
  274. /// <param name="dto"></param>
  275. /// <returns></returns>
  276. [HttpPost]
  277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  278. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  279. {
  280. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  281. _detail.IsDel = 1;
  282. _detail.DeleteUserId = dto.Duty;
  283. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  284. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  285. .SetColumns(it => it.IsDel == _detail.IsDel)
  286. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  287. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  288. .Where(it => it.Id == dto.Id)
  289. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  290. //.WhereColumns(s => s.Id == dto.Id)
  291. .ExecuteCommandAsync();
  292. if (result > 0)
  293. {
  294. return Ok(JsonView(true, "删除成功!"));
  295. }
  296. return Ok(JsonView(false, "删除失败!"));
  297. }
  298. /// <summary>
  299. /// 增加团组流程管控详细表数据
  300. /// </summary>
  301. /// <param name="dto"></param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  305. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  306. {
  307. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  308. if (DateTime.Now < _detail.ExpectBeginDt)
  309. {
  310. _detail.StepStatus = 0;
  311. }
  312. else
  313. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  314. _detail.StepStatus = 1;
  315. }
  316. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  317. if (result > 0)
  318. {
  319. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  320. return Ok(JsonView(true, "添加成功!", _result));
  321. }
  322. return Ok(JsonView(false, "添加失败!"));
  323. }
  324. #endregion
  325. #region 团组基本信息
  326. /// <summary>
  327. /// 接团信息列表
  328. /// </summary>
  329. /// <param name="dto">团组列表请求dto</param>
  330. /// <returns></returns>
  331. [HttpPost]
  332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  333. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  334. {
  335. var groupData = await _groupRepository.GetGroupList(dto);
  336. if (groupData.Code != 0)
  337. {
  338. return Ok(JsonView(false, groupData.Msg));
  339. }
  340. return Ok(JsonView(groupData.Data));
  341. }
  342. /// <summary>
  343. /// 分页查询团组列表
  344. /// </summary>
  345. /// <param name="dto"></param>
  346. /// <returns></returns>
  347. [HttpPost]
  348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  349. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  350. {
  351. var watch = new Stopwatch();
  352. watch.Start();
  353. RefAsync<int> total = 0;
  354. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  355. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  356. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  357. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  358. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  359. .Distinct()
  360. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  361. watch.Stop();
  362. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  363. }
  364. /// <summary>
  365. /// 接团信息列表 Page
  366. /// </summary>
  367. /// <param name="dto">团组列表请求dto</param>
  368. /// <returns></returns>
  369. [HttpPost]
  370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  371. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  372. {
  373. #region 参数验证
  374. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  375. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  376. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  377. #region 页面操作权限验证
  378. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  379. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  380. #endregion
  381. #endregion
  382. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  383. {
  384. string sqlWhere = string.Empty;
  385. if (dto.IsSure == 0) //未完成
  386. {
  387. sqlWhere += string.Format(@" And IsSure = 0");
  388. }
  389. else if (dto.IsSure == 1) //已完成
  390. {
  391. sqlWhere += string.Format(@" And IsSure = 1");
  392. }
  393. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  394. {
  395. string tj = dto.SearchCriteria;
  396. 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}%')",
  397. tj, tj, tj, tj, tj);
  398. }
  399. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  400. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  401. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  402. JietuanOperator,IsSure,CreateTime,IsBid
  403. From (
  404. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  405. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  406. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  407. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  408. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  409. From Grp_DelegationInfo gdi
  410. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  411. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  412. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  413. Where gdi.IsDel = 0 {0}
  414. ) temp", sqlWhere);
  415. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  416. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  417. #region 处理所属部门
  418. /*
  419. * 1.sq 和 gyy 等显示 市场部
  420. * 2.王鸽和主管及张总还有管理员号统一国交部
  421. * 2-1. 4 管理员 ,21 张海麟
  422. */
  423. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  424. List<int> userIds1 = new List<int>() { 4, 21 };
  425. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  426. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  427. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  428. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  429. .ToList();
  430. foreach (var item in _DelegationList)
  431. {
  432. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  433. }
  434. #endregion
  435. var _view = new
  436. {
  437. PageFuncAuth = pageFunAuthView,
  438. Data = _DelegationList
  439. };
  440. return Ok(JsonView(true, "查询成功!", _view, total));
  441. }
  442. else
  443. {
  444. return Ok(JsonView(false, "查询失败"));
  445. }
  446. }
  447. /// <summary>
  448. /// 团组列表
  449. /// </summary>
  450. /// <returns></returns>
  451. [HttpPost]
  452. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  453. {
  454. #region 参数验证
  455. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  456. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  457. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  458. #region 页面操作权限验证
  459. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  460. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  461. #endregion
  462. #endregion
  463. if (dto.PortType != 1 && dto.PortType != 2)
  464. {
  465. return Ok(JsonView(false, "查询失败!"));
  466. }
  467. string orderbyStr = "order by gdi.CreateTime Desc";
  468. string sqlWhere = string.Empty;
  469. if (dto.IsSure == 0) //未完成
  470. {
  471. sqlWhere += string.Format(@" And IsSure = 0");
  472. }
  473. else if (dto.IsSure == 1) //已完成
  474. {
  475. sqlWhere += string.Format(@" And IsSure = 1");
  476. }
  477. //团组类型
  478. if (dto.TeamDid > 0)
  479. {
  480. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  481. }
  482. //团组名称
  483. if (!string.IsNullOrEmpty(dto.TeamName))
  484. {
  485. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  486. }
  487. //客户名称
  488. if (!string.IsNullOrEmpty(dto.ClientName))
  489. {
  490. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  491. }
  492. //客户单位
  493. if (!string.IsNullOrEmpty(dto.ClientUnit))
  494. {
  495. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  496. }
  497. //出访时间
  498. if (!string.IsNullOrEmpty(dto.visitDataTime))
  499. {
  500. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  501. orderbyStr = "order by gdi.VisitDate";
  502. }
  503. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  504. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  505. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  506. JietuanOperator,IsSure,CreateTime
  507. From (
  508. Select row_number() over({0}) as Row_Number,
  509. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  510. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  511. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  512. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  513. From Grp_DelegationInfo gdi
  514. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  515. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  516. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  517. Where gdi.IsDel = 0 {1}
  518. ) temp ", orderbyStr, sqlWhere);
  519. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  520. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  521. #region 处理所属部门
  522. /*
  523. * 1.sq 和 gyy 等显示 市场部
  524. * 2.王鸽和主管及张总还有管理员号统一国交部
  525. * 2-1. 4 管理员 ,21 张海麟
  526. */
  527. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  528. List<int> userIds1 = new List<int>() { 4, 21 };
  529. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  530. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  531. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  532. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  533. .ToList();
  534. foreach (var item in _DelegationList)
  535. {
  536. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  537. }
  538. #endregion
  539. var _view = new
  540. {
  541. PageFuncAuth = pageFunAuthView,
  542. Data = _DelegationList
  543. };
  544. return Ok(JsonView(true, "查询成功!", _view, total));
  545. }
  546. /// <summary>
  547. /// 接团信息详情
  548. /// </summary>
  549. /// <param name="dto">团组info请求dto</param>
  550. /// <returns></returns>
  551. [HttpPost]
  552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  553. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  554. {
  555. var groupData = await _groupRepository.GetGroupInfo(dto);
  556. if (groupData.Code != 0)
  557. {
  558. return Ok(JsonView(false, groupData.Msg));
  559. }
  560. return Ok(JsonView(groupData.Data));
  561. }
  562. /// <summary>
  563. /// 接团信息 编辑添加
  564. /// 基础信息数据源
  565. /// </summary>
  566. /// <param name="dto"></param>
  567. /// <returns></returns>
  568. [HttpPost]
  569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  570. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  571. {
  572. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  573. if (groupData.Code != 0)
  574. {
  575. return Ok(JsonView(false, groupData.Msg));
  576. }
  577. return Ok(JsonView(groupData.Data));
  578. }
  579. /// <summary>
  580. /// 接团信息 操作(增改)
  581. /// </summary>
  582. /// <param name="dto"></param>
  583. /// <returns></returns>
  584. [HttpPost]
  585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  586. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  587. {
  588. try
  589. {
  590. decimal ffrPrice = 0.00M;
  591. DateTime? visitDt = null;
  592. if (dto.Status == 2)
  593. {
  594. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  595. if (groupInfo != null)
  596. {
  597. ffrPrice = groupInfo.PaymentMoney;
  598. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  599. }
  600. }
  601. var groupData = await _groupRepository.GroupOperation(dto);
  602. if (groupData.Code != 0)
  603. {
  604. return Ok(JsonView(false, groupData.Msg));
  605. }
  606. int diId = 0;
  607. //添加时 默认加入团组汇率
  608. if (dto.Status == 1) //添加
  609. {
  610. diId = groupData.Data;
  611. //添加默认币种
  612. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  613. //默认分配权限
  614. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  615. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  616. var _managerIds = new List<int>() { 22, 32, 21 };
  617. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  618. if (userIds.Count > 0)
  619. {
  620. userIds.Add(208);
  621. //创建团组管控
  622. GroupStepForDelegation.CreateWorkStep(diId);
  623. //发送消息
  624. string groupName = dto.TeamName;
  625. string createGroupUser = string.Empty;
  626. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  627. if (userInfo != null) createGroupUser = userInfo.CnName;
  628. string title = $"系统通知";
  629. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  630. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  631. }
  632. //默认创建倒推表
  633. await _invertedListRep._Create(dto.UserId, diId);
  634. }
  635. else if (dto.Status == 2)
  636. {
  637. diId = dto.Id;
  638. }
  639. #region 签证人员团组时间通知
  640. #region 计算出访起止时间
  641. var startTime = new DateTime();
  642. var endTime = new DateTime();
  643. if (DateTime.TryParse(dto.VisitDate, out startTime))
  644. {
  645. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  646. }
  647. #endregion
  648. if (diId > 0)
  649. {
  650. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  651. }
  652. #endregion
  653. #region 团组操作默认添加/修改收款账单
  654. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  655. {
  656. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  657. .Where(x => x.IsDel == 0 &&
  658. x.Diid == diId &&
  659. x.Remark.Equals("预付款")
  660. )
  661. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  662. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  663. .FirstAsync();
  664. ffrInfo = new Fin_ForeignReceivables()
  665. {
  666. Diid = diId,
  667. PriceName = dto.ClientUnit,
  668. Price = dto.PaymentMoney,
  669. Count = 1,
  670. Unit = $"元",
  671. ItemSumPrice = dto.PaymentMoney,
  672. Rate = 1.0000M,
  673. Currency = 836,
  674. AddingWay = 0,
  675. CreateUserId = dto.UserId,
  676. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  677. Remark = $"预付款"
  678. };
  679. if (ffrInfo == null) //Add
  680. {
  681. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  682. }
  683. else //修改
  684. {
  685. await _sqlSugar.Updateable(ffrInfo)
  686. .UpdateColumns(x => new
  687. {
  688. x.PriceName,
  689. x.Price,
  690. x.ItemSumPrice,
  691. x.CreateTime,
  692. x.CreateUserId
  693. })
  694. .WhereColumns(x => x.Id)
  695. .ExecuteCommandAsync();
  696. }
  697. }
  698. #endregion
  699. return Ok(JsonView(true, "操作成功!", diId));
  700. }
  701. catch (Exception ex)
  702. {
  703. Logs("[response]" + JsonConvert.SerializeObject(dto));
  704. Logs(ex.Message);
  705. return Ok(JsonView(false, ex.Message));
  706. }
  707. }
  708. /// <summary>
  709. /// 接团流程操作(增改)
  710. /// 安卓端使用 建团时添加客户名单
  711. /// </summary>
  712. /// <param name="dto"></param>
  713. /// <returns></returns>
  714. [HttpPost]
  715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  716. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  717. {
  718. try
  719. {
  720. #region 参数验证
  721. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  722. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  723. #region 页面操作权限验证
  724. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  725. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  726. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  727. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  728. #endregion
  729. #endregion
  730. _sqlSugar.BeginTran();
  731. decimal ffrPrice = 0.00M;
  732. DateTime? visitDt = null;
  733. if (dto.Status == 2)
  734. {
  735. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  736. if (groupInfo != null)
  737. {
  738. ffrPrice = groupInfo.PaymentMoney;
  739. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  740. }
  741. }
  742. var _dto = new GroupOperationDto();
  743. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  744. var groupData = await _groupRepository.GroupOperation(_dto);
  745. if (groupData.Code != 0)
  746. {
  747. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  748. }
  749. int diId = 0;
  750. //添加时 默认加入团组汇率
  751. if (dto.Status == 1) //添加
  752. {
  753. diId = groupData.Data;
  754. //添加默认币种
  755. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  756. //默认分配权限
  757. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  758. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  759. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  760. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  761. if (userIds.Count > 0)
  762. {
  763. userIds.Add(208);
  764. //创建团组管控
  765. GroupStepForDelegation.CreateWorkStep(diId);
  766. //发送消息
  767. string groupName = dto.TeamName;
  768. string createGroupUser = string.Empty;
  769. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  770. if (userInfo != null) createGroupUser = userInfo.CnName;
  771. string title = $"系统通知";
  772. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  773. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  774. }
  775. #region 应用推送
  776. try
  777. {
  778. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  779. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  780. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  781. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  782. {
  783. List<string> userList = new List<string>() { users.QiyeChatUserId };
  784. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  785. }
  786. }
  787. catch (Exception ex)
  788. {
  789. }
  790. #endregion
  791. //默认创建倒推表
  792. await _invertedListRep._Create(dto.UserId, diId);
  793. }
  794. if (dto.Status == 2)
  795. {
  796. diId = dto.Id;
  797. if (diId == 0)
  798. {
  799. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  800. }
  801. }
  802. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  803. if (viewData.Code != 0)
  804. {
  805. _sqlSugar.RollbackTran();
  806. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  807. }
  808. #region 团组操作默认添加/修改收款账单
  809. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  810. {
  811. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  812. .Where(x => x.IsDel == 0 &&
  813. x.Diid == diId &&
  814. x.Remark.Equals("预付款")
  815. )
  816. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  817. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  818. .FirstAsync();
  819. ffrInfo = new Fin_ForeignReceivables()
  820. {
  821. Diid = diId,
  822. PriceName = dto.ClientUnit,
  823. Price = dto.PaymentMoney,
  824. Count = 1,
  825. Unit = $"元",
  826. ItemSumPrice = dto.PaymentMoney,
  827. Rate = 1.0000M,
  828. Currency = 836,
  829. AddingWay = 0,
  830. CreateUserId = dto.UserId,
  831. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  832. Remark = $"预付款"
  833. };
  834. if (ffrInfo == null) //Add
  835. {
  836. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  837. }
  838. else //修改
  839. {
  840. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  841. .UpdateColumns(x => new
  842. {
  843. x.PriceName,
  844. x.Price,
  845. x.ItemSumPrice,
  846. x.CreateTime,
  847. x.CreateUserId
  848. })
  849. .WhereColumns(x => x.Id)
  850. .ExecuteCommandAsync();
  851. }
  852. }
  853. #endregion
  854. #region 签证人员团组时间通知
  855. #region 计算出访起止时间
  856. var startTime = new DateTime();
  857. var endTime = new DateTime();
  858. if (DateTime.TryParse(dto.VisitDate, out startTime))
  859. {
  860. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  861. }
  862. #endregion
  863. if (diId > 0)
  864. {
  865. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  866. }
  867. #endregion
  868. _sqlSugar.CommitTran();
  869. return Ok(JsonView(true, "添加成功"));
  870. }
  871. catch (Exception ex)
  872. {
  873. _sqlSugar.RollbackTran();
  874. return Ok(JsonView(false, ex.Message));
  875. }
  876. }
  877. /// <summary>
  878. /// 接团信息 操作(删除)
  879. /// </summary>
  880. /// <param name="dto"></param>
  881. /// <returns></returns>
  882. [HttpPost]
  883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  884. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  885. {
  886. var diId = dto.Id;
  887. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  888. #region 删除 验证 (费用录入、出入境费用、收款账单)
  889. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  890. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  891. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  892. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  893. #endregion
  894. var groupData = await _groupRepository.GroupDel(dto);
  895. if (groupData.Code != 0)
  896. {
  897. return Ok(JsonView(false, groupData.Msg));
  898. }
  899. return Ok(JsonView(true));
  900. }
  901. /// <summary>
  902. /// 获取团组销售报价号
  903. /// 团组添加时 使用
  904. /// </summary>
  905. /// <returns></returns>
  906. [HttpPost]
  907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  908. public async Task<IActionResult> GetGroupSalesQuoteNo()
  909. {
  910. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  911. if (groupData.Code != 0)
  912. {
  913. return Ok(JsonView(false, groupData.Msg));
  914. }
  915. object salesQuoteNo = new
  916. {
  917. SalesQuoteNo = groupData.Data
  918. };
  919. return Ok(JsonView(salesQuoteNo));
  920. }
  921. /// <summary>
  922. /// 设置确认出团
  923. /// </summary>
  924. /// <param name="dto"></param>
  925. /// <returns></returns>
  926. [HttpPost]
  927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  928. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  929. {
  930. var groupData = await _groupRepository.ConfirmationGroup(dto);
  931. if (groupData.Code != 0)
  932. {
  933. return Ok(JsonView(false, groupData.Msg));
  934. }
  935. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  936. #region OA消息推送
  937. try
  938. {
  939. string groupName = groupInfo.TeamName;
  940. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  941. List<int> userIds = new List<int>();
  942. listUser.ForEach(s => userIds.Add(s.Id));
  943. string title = $"系统通知";
  944. string content = $"团组[{groupName}]已确认出团!";
  945. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  946. }
  947. catch (Exception ex)
  948. {
  949. }
  950. #endregion
  951. #region 应用推送
  952. try
  953. {
  954. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  955. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  956. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  957. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  958. {
  959. List<string> userList = new List<string>() { users.QiyeChatUserId };
  960. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  961. }
  962. }
  963. catch (Exception ex)
  964. {
  965. }
  966. #endregion
  967. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  968. return Ok(JsonView(true, "操作成功!", groupData.Data));
  969. }
  970. /// <summary>
  971. /// 获取团组名称data And 签证国别Data
  972. /// </summary>
  973. /// <param name="dto"></param>
  974. /// <returns></returns>
  975. [HttpPost]
  976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  977. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  978. {
  979. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  980. if (groupData.Code != 0)
  981. {
  982. return Ok(JsonView(false, groupData.Msg));
  983. }
  984. return Ok(JsonView(groupData.Data));
  985. }
  986. /// <summary>
  987. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  988. /// </summary>
  989. /// <returns></returns>
  990. [HttpPost]
  991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  992. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  993. {
  994. try
  995. {
  996. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  997. if (groupData.Code != 0)
  998. {
  999. return Ok(JsonView(false, groupData.Msg));
  1000. }
  1001. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1002. }
  1003. catch (Exception ex)
  1004. {
  1005. return Ok(JsonView(false, "程序错误!"));
  1006. throw;
  1007. }
  1008. }
  1009. /// <summary>
  1010. /// 团组清单 Excel
  1011. /// </summary>
  1012. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1013. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1014. /// <returns></returns>
  1015. [HttpGet]
  1016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1017. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1018. {
  1019. DateTime _beginDt, _endDt;
  1020. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1021. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1022. if (!beginBool && !endBool)
  1023. {
  1024. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1025. }
  1026. string sql = string.Format(@"
  1027. SELECT
  1028. ROW_NUMBER,
  1029. Id,
  1030. SalesQuoteNo,
  1031. TourCode,
  1032. TeamTypeId,
  1033. TeamType,
  1034. TeamLevId,
  1035. TeamLev,
  1036. TeamName,
  1037. ClientName,
  1038. ClientUnit,
  1039. VisitDate,
  1040. VisitDays,
  1041. VisitPNumber,
  1042. JietuanOperatorId,
  1043. JietuanOperator,
  1044. IsSure,
  1045. CreateTime,
  1046. IsBid
  1047. FROM
  1048. (
  1049. SELECT
  1050. ROW_NUMBER() OVER(
  1051. ORDER BY
  1052. gdi.CreateTime Desc
  1053. ) AS ROW_NUMBER,
  1054. gdi.Id,
  1055. SalesQuoteNo,
  1056. TourCode,
  1057. ssd.Id TeamTypeId,
  1058. ssd.Name TeamType,
  1059. ssd1.Id TeamLevId,
  1060. ssd1.Name TeamLev,
  1061. TeamName,
  1062. ClientName,
  1063. ClientUnit,
  1064. VisitDate,
  1065. VisitDays,
  1066. VisitPNumber,
  1067. JietuanOperator JietuanOperatorId,
  1068. su.CnName JietuanOperator,
  1069. IsSure,
  1070. gdi.CreateTime,
  1071. gdi.IsBid
  1072. FROM
  1073. Grp_DelegationInfo gdi
  1074. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1075. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1076. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1077. WHERE
  1078. gdi.IsDel = 0
  1079. AND gdi.IsBid = 0
  1080. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1081. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1082. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1083. #region 处理所属部门
  1084. /*
  1085. * 1.sq 和 gyy 等显示 市场部
  1086. * 2.王鸽和主管及张总还有管理员号统一国交部
  1087. * 2-1. 4 管理员 ,21 张海麟
  1088. */
  1089. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1090. List<int> userIds1 = new List<int>() { 4, 21 };
  1091. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1092. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1093. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1094. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1095. .ToListAsync();
  1096. foreach (var item in groupList)
  1097. {
  1098. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1099. }
  1100. #endregion
  1101. #region Excel
  1102. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1103. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1104. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1105. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1106. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1107. //载入模板
  1108. WorkbookDesigner designer = new WorkbookDesigner();
  1109. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1110. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1111. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1112. dt.TableName = "GroupList";
  1113. designer.SetDataSource(dt);
  1114. designer.Process();
  1115. if (!Directory.Exists(savePath))
  1116. {
  1117. Directory.CreateDirectory(savePath);
  1118. }
  1119. string serverPath = $"{savePath}{fileName}";
  1120. designer.Workbook.Save(serverPath);
  1121. string rst = $"{servicePath}{ftpPath}{fileName}";
  1122. #endregion
  1123. return Ok(JsonView(true, "操作成功!", rst));
  1124. }
  1125. #endregion
  1126. #region 团组&签证
  1127. /// <summary>
  1128. /// 根据团组Id获取签证客户信息List
  1129. /// </summary>
  1130. /// <param name="dto">请求dto</param>
  1131. /// <returns></returns>
  1132. [HttpPost]
  1133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1134. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1135. {
  1136. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1137. if (groupData.Code != 0)
  1138. {
  1139. return Ok(JsonView(false, groupData.Msg));
  1140. }
  1141. return Ok(JsonView(groupData.Data));
  1142. }
  1143. /// <summary>
  1144. /// IOS获取团组签证拍照上传进度01(团组列表)
  1145. /// </summary>
  1146. /// <param name="dto">请求dto</param>
  1147. /// <returns></returns>
  1148. [HttpPost]
  1149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1150. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1151. {
  1152. if (dto == null)
  1153. {
  1154. return Ok(JsonView(false, "参数为空"));
  1155. }
  1156. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1157. return Ok(JsonView(visaList));
  1158. }
  1159. /// <summary>
  1160. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1161. /// </summary>
  1162. /// <returns></returns>
  1163. [HttpPost]
  1164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1165. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1166. {
  1167. if (dto == null)
  1168. {
  1169. return Ok(JsonView(false, "请求错误:"));
  1170. }
  1171. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1172. return Ok(JsonView(list));
  1173. }
  1174. /// <summary>
  1175. /// IOS获取团组签证拍照上传进度03(相册)
  1176. /// </summary>
  1177. /// <returns></returns>
  1178. [HttpPost]
  1179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1180. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1181. {
  1182. if (dto == null)
  1183. {
  1184. return Ok(JsonView(false, "请求错误:"));
  1185. }
  1186. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1187. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1188. list.ForEach(s => s.url = url);
  1189. return Ok(JsonView(list));
  1190. }
  1191. /// <summary>
  1192. /// IOS获取团组签证拍照上传进度04(图片上传)
  1193. /// </summary>
  1194. /// <param name="dto"></param>
  1195. /// <returns></returns>
  1196. [HttpPost]
  1197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1198. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1199. {
  1200. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1201. //if (!string.IsNullOrEmpty(result))
  1202. //{
  1203. //}
  1204. //else {
  1205. // return Ok(JsonView(false, "上传失败"));
  1206. //}
  1207. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1208. int sucNum = 0;
  1209. try
  1210. {
  1211. foreach (var item in dto.base64DataList)
  1212. {
  1213. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1214. string result = decodeBase64ToImage(item, imageName);
  1215. if (!string.IsNullOrEmpty(result))
  1216. {
  1217. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1218. pic.CreateUserId = dto.CreateUserId;
  1219. pic.PicName = imageName;
  1220. pic.PicPath = result;
  1221. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1222. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1223. if (insertResult > 0)
  1224. {
  1225. sucNum++;
  1226. }
  1227. }
  1228. }
  1229. }
  1230. catch (Exception ex)
  1231. {
  1232. return Ok(JsonView(false, ex.Message));
  1233. }
  1234. string msg = string.Format(@"成功上传{0}张", sucNum);
  1235. return Ok(JsonView(true, msg));
  1236. }
  1237. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1238. {
  1239. string filename = "";//声明一个string类型的相对路径
  1240. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1241. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1242. try//会有异常抛出,try,catch一下
  1243. {
  1244. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1245. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1246. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1247. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1248. //文件名称
  1249. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1250. //上传的文件的路径
  1251. string filePath = "";
  1252. if (!Directory.Exists(fileDir))
  1253. {
  1254. Directory.CreateDirectory(fileDir);
  1255. }
  1256. //上传的文件的路径
  1257. filePath = fileDir + filename;
  1258. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1259. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1260. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1261. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1262. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1263. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1264. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1265. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1266. bitmap.Dispose();
  1267. }
  1268. catch (Exception e)
  1269. {
  1270. string massage = e.Message;
  1271. Logs("IOS图片上传Error:" + massage);
  1272. //filename = e.Message;
  1273. }
  1274. return filename;//返回相对路径
  1275. }
  1276. /// <summary>
  1277. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1278. /// </summary>
  1279. /// <param name="dto"></param>
  1280. /// <returns></returns>
  1281. [HttpPost]
  1282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1283. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1284. {
  1285. if (dto == null)
  1286. {
  1287. return Ok(JsonView(false, "请求错误:"));
  1288. }
  1289. string msg = "参数错误";
  1290. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1291. {
  1292. try
  1293. {
  1294. //_delegationVisaRep.BeginTran();
  1295. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1296. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1297. .Where(s => s.Id == dto.visaProgressCustomerId)
  1298. .ExecuteCommandAsync();
  1299. if (updCount > 0 && dto.publishCode == 1)
  1300. {
  1301. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1302. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1303. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1304. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1305. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1306. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1307. if (groupData == null)
  1308. {
  1309. _delegationVisaRep.RollbackTran();
  1310. }
  1311. string title = string.Format(@"[签证进度更新]");
  1312. string content = string.Format(@"测试文本");
  1313. bool rst = await _message.AddMsg(new MessageDto()
  1314. {
  1315. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1316. IssuerId = dto.publisher,
  1317. Title = title,
  1318. Content = content,
  1319. ReleaseTime = DateTime.Now,
  1320. UIdList = new List<int> {
  1321. 234
  1322. }
  1323. });
  1324. if (rst)
  1325. {
  1326. return Ok(JsonView(true, "发送通知成功"));
  1327. }
  1328. }
  1329. //_delegationVisaRep.CommitTran();
  1330. }
  1331. catch (Exception)
  1332. {
  1333. //_delegationVisaRep.RollbackTran();
  1334. }
  1335. }
  1336. return Ok(JsonView(true, msg));
  1337. }
  1338. #endregion
  1339. #region 团组任务分配
  1340. /// <summary>
  1341. /// 团组任务分配初始化
  1342. /// </summary>
  1343. /// <param name="dto"></param>
  1344. /// <returns></returns>
  1345. [HttpPost]
  1346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1347. public async Task<IActionResult> GetTaskAssignmen()
  1348. {
  1349. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1350. if (groupData.Code != 0)
  1351. {
  1352. return Ok(JsonView(false, groupData.Msg));
  1353. }
  1354. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1355. }
  1356. /// <summary>
  1357. /// 团组任务分配查询
  1358. /// </summary>
  1359. /// <param name="dto"></param>
  1360. /// <returns></returns>
  1361. [HttpPost]
  1362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1363. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1364. {
  1365. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1366. if (groupData.Code != 0)
  1367. {
  1368. return Ok(JsonView(false, groupData.Msg));
  1369. }
  1370. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1371. }
  1372. /// <summary>
  1373. /// 团组任务分配操作
  1374. /// </summary>
  1375. /// <param name="dto"></param>
  1376. /// <returns></returns>
  1377. [HttpPost]
  1378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1379. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1380. {
  1381. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1382. if (groupData.Code != 0)
  1383. {
  1384. return Ok(JsonView(false, groupData.Msg));
  1385. }
  1386. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1387. }
  1388. /// <summary>
  1389. /// 团组任务分配
  1390. /// 批量分配
  1391. /// 查询团组
  1392. /// </summary>
  1393. /// <param name="dto"></param>
  1394. /// <returns></returns>
  1395. [HttpPost]
  1396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1397. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1398. {
  1399. //参数验证
  1400. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1401. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1402. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1403. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1404. }
  1405. /// <summary>
  1406. /// 团组任务分配
  1407. /// 批量分配
  1408. /// </summary>
  1409. /// <param name="dto"></param>
  1410. /// <returns></returns>
  1411. [HttpPost]
  1412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1413. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1414. {
  1415. //参数验证
  1416. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1417. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1418. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1419. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1420. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1421. }
  1422. #endregion
  1423. #region 团组费用审核
  1424. /// <summary>
  1425. /// 费用审核
  1426. /// 团组列表 Page
  1427. /// </summary>
  1428. /// <param name="_dto">团组列表请求dto</param>
  1429. /// <returns></returns>
  1430. [HttpPost]
  1431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1432. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1433. {
  1434. #region 参数验证
  1435. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1436. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1437. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1438. #region 页面操作权限验证
  1439. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1440. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1441. #endregion
  1442. #endregion
  1443. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1444. {
  1445. string sqlWhere = string.Empty;
  1446. if (_dto.IsSure == 0) //未完成
  1447. {
  1448. sqlWhere += string.Format(@" And IsSure = 0");
  1449. }
  1450. else if (_dto.IsSure == 1) //已完成
  1451. {
  1452. sqlWhere += string.Format(@" And IsSure = 1");
  1453. }
  1454. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1455. {
  1456. string tj = _dto.SearchCriteria;
  1457. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  1458. tj, tj, tj, tj, tj);
  1459. }
  1460. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1461. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1462. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1463. From (
  1464. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1465. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1466. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1467. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1468. From Grp_DelegationInfo gdi
  1469. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1470. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1471. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1472. Where gdi.IsDel = 0 {0}
  1473. ) temp ", sqlWhere);
  1474. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1475. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1476. var _view = new
  1477. {
  1478. PageFuncAuth = pageFunAuthView,
  1479. Data = _DelegationList
  1480. };
  1481. return Ok(JsonView(true, "查询成功!", _view, total));
  1482. }
  1483. else
  1484. {
  1485. return Ok(JsonView(false, "查询失败"));
  1486. }
  1487. }
  1488. /// <summary>
  1489. /// 获取团组费用审核
  1490. /// </summary>
  1491. /// <param name="paras">参数Json字符串</param>
  1492. /// <returns></returns>
  1493. [HttpPost]
  1494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1495. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1496. {
  1497. try
  1498. {
  1499. #region 参数验证
  1500. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1501. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1502. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1503. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1504. #region 页面操作权限验证
  1505. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1506. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1507. #endregion
  1508. #endregion
  1509. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1510. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1511. #region 费用清单
  1512. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1513. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1514. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1515. List<Grp_CreditCardPayment> entityList = _groupRepository
  1516. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1517. .Where(exp.ToExpression())
  1518. .ToList();
  1519. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1520. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1521. /*
  1522. * 76://酒店预订
  1523. */
  1524. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1525. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1526. .ToListAsync();
  1527. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1528. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1529. .ToListAsync();
  1530. /*
  1531. * 79://车/导游地接
  1532. */
  1533. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1534. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1535. .ToListAsync();
  1536. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1537. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1538. .ToListAsync();
  1539. /*
  1540. * 80: //签证
  1541. */
  1542. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1543. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1544. .ToListAsync();
  1545. /*
  1546. *81: //邀请/公务活动
  1547. */
  1548. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1549. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1550. .ToListAsync();
  1551. /*
  1552. * 82: //团组客户保险
  1553. */
  1554. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1555. /*
  1556. * Lable = 85 机票预订
  1557. */
  1558. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1559. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1560. .ToListAsync();
  1561. /*
  1562. * 85 机票预定
  1563. */
  1564. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1565. /*
  1566. * 98 其他款项
  1567. */
  1568. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1569. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1570. .ToListAsync();
  1571. /*
  1572. * 285:收款退还
  1573. */
  1574. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1575. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1576. .ToListAsync();
  1577. /*
  1578. * 1015: //超支费用
  1579. */
  1580. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1581. /*
  1582. * 币种信息
  1583. */
  1584. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1585. /*
  1586. * 车/导游地接 费用类型
  1587. */
  1588. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1589. /*
  1590. * 车/导游地接 费用类型
  1591. */
  1592. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1593. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1594. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1595. /*
  1596. * 用户信息
  1597. */
  1598. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1599. /*
  1600. * 费用模块
  1601. */
  1602. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1603. string priceModule = string.Empty;
  1604. if (sdPriceName != null)
  1605. {
  1606. priceModule = sdPriceName.Name;
  1607. }
  1608. /*
  1609. * 成本信息
  1610. */
  1611. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1612. decimal _groupRate = 0.0000M;
  1613. string _groupCurrencyCode = "-";
  1614. if (groupCost != null)
  1615. {
  1616. _groupRate = groupCost.Rate;
  1617. if (int.TryParse(groupCost.Currency, out int _currency))
  1618. {
  1619. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1620. }
  1621. else _groupCurrencyCode = groupCost.Currency;
  1622. }
  1623. string costContentSql = $"Select * From Grp_GroupCost";
  1624. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1625. //处理日期为空的天数
  1626. for (int i = 0; i < groupCostDetails.Count; i++)
  1627. if (i != 0)
  1628. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1629. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1630. /*
  1631. * 处理详情数据
  1632. */
  1633. foreach (var entity in entityList)
  1634. {
  1635. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1636. _detail.Id = entity.Id;
  1637. _detail.PriceName = priceModule;
  1638. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1639. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1640. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1641. //处理金额
  1642. if (entity.CTable == 1015)
  1643. {
  1644. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1645. if (czInfo != null)
  1646. {
  1647. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1648. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1649. }
  1650. }
  1651. /*
  1652. * 应付款金额
  1653. */
  1654. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1655. string PaymentCurrency_WaitPay = "Unknown";
  1656. string hotelCurrncyCode = "Unknown";
  1657. string hotelCurrncyName = "Unknown";
  1658. if (sdPaymentCurrency_WaitPay != null)
  1659. {
  1660. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1661. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1662. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1663. if (hotelCurrncyCode.Equals("CNY"))
  1664. {
  1665. entity.DayRate = 1.0000M;
  1666. }
  1667. }
  1668. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1669. /*
  1670. * 此次付款金额
  1671. */
  1672. decimal CurrPayStr = 0.00M,
  1673. OriginalCurrPay = 0.00M;
  1674. if (entity.PayPercentage == 0)
  1675. {
  1676. if (entity.PayThenMoney != 0)
  1677. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1678. }
  1679. else
  1680. {
  1681. if (entity.PayMoney != 0)
  1682. {
  1683. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1684. }
  1685. }
  1686. if (_dto.Label == 79)
  1687. {
  1688. string original = string.Empty;
  1689. if (hotelCurrncyCode.Equals("CNY"))
  1690. {
  1691. OriginalCurrPay = CurrPayStr;
  1692. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1693. }
  1694. else
  1695. {
  1696. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1697. //760 EUR(7600.00 CNY)
  1698. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1699. }
  1700. }
  1701. else
  1702. {
  1703. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1704. }
  1705. /*
  1706. * 剩余尾款
  1707. */
  1708. decimal BalanceStr = 0;
  1709. if (CurrPayStr != 0)
  1710. {
  1711. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1712. BalanceStr = 0;
  1713. else
  1714. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1715. }
  1716. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1717. /*
  1718. * Bus名称
  1719. */
  1720. _detail.BusName = "待增加";
  1721. /*
  1722. *费用所属
  1723. */
  1724. switch (entity.CTable)
  1725. {
  1726. case 76://酒店预订
  1727. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1728. if (hotelReservations != null)
  1729. {
  1730. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1731. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1732. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1733. string roomFeeStr = "", roomFeestr1 = "";
  1734. //是否比较房型价格
  1735. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1736. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1737. roomFeeStr += $"<br/>";
  1738. if (hotelReservations.SingleRoomPrice > 0)
  1739. {
  1740. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1741. __isSingle = true;
  1742. }
  1743. if (hotelReservations.DoubleRoomPrice > 0)
  1744. {
  1745. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1746. __isDouble = true;
  1747. }
  1748. if (hotelReservations.SuiteRoomPrice > 0)
  1749. {
  1750. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1751. __isSuite = true;
  1752. }
  1753. if (hotelReservations.OtherRoomPrice > 0)
  1754. {
  1755. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1756. __isOther = true;
  1757. }
  1758. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1759. else roomFeeStr += " 0.00 * 0";
  1760. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1761. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1762. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1763. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1764. /*
  1765. * 费用类型
  1766. * 1:房费
  1767. * 2:早餐
  1768. * 3:地税
  1769. * 4:城市税
  1770. * </summary>
  1771. */
  1772. //地税
  1773. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1774. if (governmentRentData != null)
  1775. {
  1776. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1777. governmentRentFee = governmentRentData.Price;
  1778. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1779. if (governmentRentCurrData != null)
  1780. {
  1781. governmentRentCode = governmentRentCurrData.Name;
  1782. governmentRentName = $"({governmentRentCurrData.Remark})";
  1783. }
  1784. }
  1785. //城市税
  1786. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1787. if (cityTaxData != null)
  1788. {
  1789. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1790. cityTaxFee = cityTaxData.Price;
  1791. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1792. if (cityTaxCurrData != null)
  1793. {
  1794. cityTaxCode = cityTaxCurrData.Name;
  1795. cityTaxName = $"({cityTaxCurrData.Remark})";
  1796. }
  1797. }
  1798. //酒店早餐
  1799. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1800. if (breakfastData != null)
  1801. {
  1802. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1803. breakfastFee = breakfastData.Price;
  1804. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1805. if (breakfastCurrData != null)
  1806. {
  1807. breakfastCode = breakfastCurrData.Name;
  1808. breakfastName = $"({breakfastCurrData.Remark})";
  1809. }
  1810. }
  1811. //房间费用
  1812. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1813. if (roomData != null)
  1814. {
  1815. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1816. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1817. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1818. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1819. roomFee = roomData.Price;
  1820. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1821. if (roomCurrData != null)
  1822. {
  1823. roomCode = roomCurrData.Name;
  1824. roomName = $"({roomCurrData.Remark})";
  1825. }
  1826. }
  1827. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1828. string hotelCostStr = "";
  1829. decimal hotelCsotTotal = 0.00M;
  1830. if (groupCost != null)
  1831. {
  1832. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1833. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1834. }
  1835. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1836. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1837. string hotelCost_day = "";
  1838. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1839. foreach (var item in hotelCostDetails1)
  1840. {
  1841. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1842. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1843. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1844. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1845. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1846. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1847. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1848. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1849. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1850. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1851. hotelCost_day += @$"<br/>";
  1852. }
  1853. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1854. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1855. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1856. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1857. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1858. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1859. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1860. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1861. $"房间说明: {hotelReservations.Remark} <br/>" +
  1862. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1863. $"{hotelBreakfastStr}" +
  1864. $"{hotelGovernmentRentStr}" +
  1865. $"{hotelCityTaxStr}";
  1866. _detail.PriceNameContent = hotelReservations.HotelName;
  1867. }
  1868. break;
  1869. case 79://车/导游地接
  1870. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1871. if (touristGuideGroundReservations != null)
  1872. {
  1873. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1874. {
  1875. _detail.BusName = touristGuideGroundReservations.BusName;
  1876. }
  1877. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1878. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1879. //if (isInt)
  1880. //{
  1881. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1882. // if (cityInfo != null)
  1883. // {
  1884. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1885. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1886. // if (carFeeItem != null)
  1887. // {
  1888. // nameContent += $@"({carFeeItem.Name})";
  1889. // }
  1890. // _detail.PriceNameContent = nameContent;
  1891. // }
  1892. //}
  1893. //else
  1894. //{
  1895. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1896. //}
  1897. var touristGuideGroundReservationsContents =
  1898. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1899. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1900. foreach (var item in touristGuideGroundReservationsContents)
  1901. {
  1902. string typeName = "Unknown";
  1903. string carCurrencyCode = "Unknown";
  1904. string carCurrencyName = "Unknown";
  1905. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1906. if (carTypeData != null) typeName = carTypeData.Name;
  1907. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1908. if (currencyData != null)
  1909. {
  1910. carCurrencyCode = currencyData.Name;
  1911. carCurrencyName = currencyData.Remark;
  1912. }
  1913. //op、成本 币种是否一致
  1914. bool IsCurrencyAgreement = false;
  1915. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1916. string opCostStr = string.Empty;
  1917. decimal opCostTypePrice = 0.00M;
  1918. #region 处理成本各项费用
  1919. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1920. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1921. if (opCost.Count > 0)
  1922. {
  1923. switch (item.SId)
  1924. {
  1925. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1926. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1927. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1928. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1929. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1930. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1931. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1932. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1933. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1934. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1935. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1936. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1937. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1938. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1939. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1940. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1941. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1942. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1943. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1944. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1945. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1946. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1947. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1948. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1949. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1950. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1951. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1952. }
  1953. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1954. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1955. }
  1956. #endregion
  1957. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1958. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1959. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1960. $"{opTypeStr} {opCostStr}<br/>" +
  1961. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1962. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1963. }
  1964. _detail.PriceMsgContent = priceMsg;
  1965. }
  1966. break;
  1967. case 80: //签证
  1968. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1969. if (visaInfo != null)
  1970. {
  1971. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1972. _detail.PriceNameContent = visaInfo.VisaDescription;
  1973. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1974. }
  1975. break;
  1976. case 81: //邀请/公务活动
  1977. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1978. if (_ioa != null)
  1979. {
  1980. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1981. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1982. sendCurrName = "Unknown", //快递费用币种 Name
  1983. sendCurrCode = "Unknown", //快递费用币种 Code
  1984. eventsCurrName = "Unknown", //公务活动费币种 Name
  1985. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1986. translateCurrName = "Unknown", //公务翻译费 Name
  1987. translateCurrCode = "Unknown"; //公务翻译费 Code
  1988. #region 处理费用币种
  1989. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1990. if (inviteCurrData != null)
  1991. {
  1992. inviteCurrName = inviteCurrData.Remark;
  1993. inviteCurrCode = inviteCurrData.Name;
  1994. }
  1995. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1996. if (sendCurrData != null)
  1997. {
  1998. sendCurrName = sendCurrData.Remark;
  1999. sendCurrCode = sendCurrData.Name;
  2000. }
  2001. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2002. if (eventsCurrData != null)
  2003. {
  2004. eventsCurrName = eventsCurrData.Remark;
  2005. eventsCurrCode = eventsCurrData.Name;
  2006. }
  2007. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2008. if (translateCurrData != null)
  2009. {
  2010. translateCurrName = translateCurrData.Remark;
  2011. translateCurrCode = translateCurrData.Name;
  2012. }
  2013. #endregion
  2014. _detail.PriceNameContent = _ioa.InviterArea;
  2015. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2016. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2017. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2018. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2019. $@"备注:" + _ioa.Remark + "<br/>";
  2020. }
  2021. break;
  2022. case 82: //团组客户保险
  2023. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2024. if (customers != null)
  2025. {
  2026. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2027. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2028. }
  2029. break;
  2030. case 85: //机票预订
  2031. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2032. if (jpRes != null)
  2033. {
  2034. string FlightsDescription = jpRes.FlightsDescription;
  2035. string PriceDescription = jpRes.PriceDescription;
  2036. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2037. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2038. }
  2039. break;
  2040. case 98://其他款项
  2041. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2042. if (gdpRes != null)
  2043. {
  2044. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2045. _detail.PriceNameContent = gdpRes.PriceName;
  2046. }
  2047. break;
  2048. case 285://收款退还
  2049. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2050. if (refundAndOtherMoney != null)
  2051. {
  2052. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2053. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2054. }
  2055. break;
  2056. case 751://酒店早餐
  2057. break;
  2058. case 1015://超支费用
  2059. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2060. if (groupExtraCost != null)
  2061. {
  2062. _detail.PriceNameContent = groupExtraCost.PriceName;
  2063. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2064. }
  2065. break;
  2066. default:
  2067. break;
  2068. }
  2069. /*
  2070. * 申请人
  2071. */
  2072. string operatorName = " - ";
  2073. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2074. if (_opUser != null)
  2075. {
  2076. operatorName = _opUser.CnName;
  2077. }
  2078. _detail.OperatorName = operatorName;
  2079. /*
  2080. * 审核人
  2081. */
  2082. string auditOperatorName = "Unknown";
  2083. if (entity.AuditGMOperate == 0)
  2084. auditOperatorName = " - ";
  2085. else if (entity.AuditGMOperate == 4)
  2086. auditOperatorName = "自动审核";
  2087. else
  2088. {
  2089. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2090. if (_adUser != null)
  2091. {
  2092. auditOperatorName = _adUser.CnName;
  2093. }
  2094. }
  2095. _detail.AuditOperatorName = auditOperatorName;
  2096. /*
  2097. * 超预算比例
  2098. */
  2099. string overBudgetStr = "";
  2100. if (entity.ExceedBudget == -1)
  2101. overBudgetStr = sdPriceName.Name + "尚无预算";
  2102. else if (entity.ExceedBudget == 0)
  2103. {
  2104. if (entity.CTable == 76 || entity.CTable == 79)
  2105. {
  2106. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2107. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2108. }
  2109. else
  2110. {
  2111. overBudgetStr = "未超预算";
  2112. }
  2113. }
  2114. else
  2115. overBudgetStr = entity.ExceedBudget.ToString("P");
  2116. _detail.OverBudget = overBudgetStr;
  2117. /*
  2118. * 已审核金额
  2119. */
  2120. decimal auditFee = 0.00M;
  2121. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2122. /*
  2123. * 费用总计
  2124. */
  2125. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2126. {
  2127. CurrencyId = entity.PaymentCurrency,
  2128. CurrencyName = PaymentCurrency_WaitPay,
  2129. AmountPayable = entity.PayMoney,
  2130. ThisPayment = OriginalCurrPay,
  2131. BalancePayment = BalanceStr,
  2132. AuditedFunds = auditFee
  2133. });
  2134. _detail.IsAuditGM = entity.IsAuditGM;
  2135. detailList.Add(_detail);
  2136. }
  2137. #endregion
  2138. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2139. /*
  2140. * 下方描述处理
  2141. */
  2142. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2143. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2144. if (ccpCurrencyPrice != null)
  2145. {
  2146. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2147. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2148. }
  2149. else
  2150. {
  2151. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2152. }
  2153. string amountPayableStr = string.Format(@"应付款总金额: ");
  2154. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2155. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2156. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2157. foreach (var item in nonDuplicat)
  2158. {
  2159. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2160. if (strs.Count > 0)
  2161. {
  2162. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2163. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2164. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2165. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2166. //单独处理此次付款金额
  2167. if (item.CurrencyId == 836) //人民币
  2168. {
  2169. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2170. }
  2171. else
  2172. {
  2173. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2174. }
  2175. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2176. //单独处理已审核费用
  2177. if (item.CurrencyId == 836) //人民币
  2178. {
  2179. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2180. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2181. }
  2182. else
  2183. {
  2184. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2185. }
  2186. }
  2187. }
  2188. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2189. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2190. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2191. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2192. var _view1 = new
  2193. {
  2194. PageFuncAuth = pageFunAuthView,
  2195. Data = _view
  2196. };
  2197. return Ok(JsonView(_view1));
  2198. }
  2199. catch (Exception ex)
  2200. {
  2201. return Ok(JsonView(false, ex.Message));
  2202. }
  2203. }
  2204. /// <summary>
  2205. /// 费用审核
  2206. /// 修改团组费用审核状态
  2207. /// </summary>
  2208. /// <param name="_dto">参数Json字符串</param>
  2209. /// <returns></returns>
  2210. [HttpPost]
  2211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2212. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2213. {
  2214. #region 参数验证
  2215. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2216. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2217. #endregion
  2218. #region 页面操作权限验证
  2219. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2220. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2221. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2222. #endregion
  2223. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2224. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2225. DateTime dtNow = DateTime.Now;
  2226. _groupRepository.BeginTran();
  2227. int rst = 0;
  2228. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2229. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2230. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2231. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2232. List<dynamic> msgDatas = new List<dynamic>();
  2233. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2234. foreach (var item in idList)
  2235. {
  2236. int CreditId = int.Parse(item);
  2237. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2238. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2239. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2240. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2241. .Where(s => s.Id == CreditId)
  2242. .ExecuteCommandAsync();
  2243. if (result < 1)
  2244. {
  2245. rst = -1;
  2246. _groupRepository.RollbackTran();
  2247. return Ok(JsonView(false, "操作失败并回滚!"));
  2248. }
  2249. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2250. if (creditData != null)
  2251. {
  2252. #region 应用通知配置
  2253. try
  2254. {
  2255. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2256. }
  2257. catch (Exception ex)
  2258. {
  2259. }
  2260. #endregion
  2261. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2262. string groupNameStr = string.Empty;
  2263. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2264. if (groupData != null) groupNameStr = groupData.TeamName;
  2265. string creditTypeStr = string.Empty;
  2266. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2267. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2268. string creditCurrency = string.Empty;
  2269. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2270. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2271. if (creditCurrency.Equals("CNY"))
  2272. {
  2273. creditData.DayRate = 1.0000M;
  2274. }
  2275. if (creditData.PayPercentage == 0.00M)
  2276. {
  2277. creditData.PayPercentage = 100M;
  2278. }
  2279. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2280. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2281. string msgContent = "";
  2282. if (creditCurrency.Equals("CNY"))
  2283. {
  2284. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2285. }
  2286. else
  2287. {
  2288. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2289. }
  2290. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2291. }
  2292. }
  2293. if (rst == 0)
  2294. {
  2295. _groupRepository.CommitTran();
  2296. foreach (var item in msgDatas)
  2297. {
  2298. //发送消息
  2299. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2300. }
  2301. #region 应用推送
  2302. try
  2303. {
  2304. foreach (var ccpId in dic_ccp_user.Keys)
  2305. {
  2306. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2307. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2308. }
  2309. }
  2310. catch (Exception)
  2311. {
  2312. }
  2313. #endregion
  2314. return Ok(JsonView(true, "操作成功!"));
  2315. }
  2316. return Ok(JsonView(false, "操作失败!"));
  2317. }
  2318. #endregion
  2319. #region 机票费用录入
  2320. /// <summary>
  2321. /// 机票录入当前登录人可操作团组
  2322. /// </summary>
  2323. /// <param name="dto"></param>
  2324. /// <returns></returns>
  2325. [HttpPost]
  2326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2327. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2328. {
  2329. try
  2330. {
  2331. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2332. if (groupData.Code != 0)
  2333. {
  2334. return Ok(JsonView(false, groupData.Msg));
  2335. }
  2336. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2337. }
  2338. catch (Exception ex)
  2339. {
  2340. return Ok(JsonView(false, "程序错误!"));
  2341. throw;
  2342. }
  2343. }
  2344. /// <summary>
  2345. /// 机票费用录入列表
  2346. /// </summary>
  2347. /// <param name="dto"></param>
  2348. /// <returns></returns>
  2349. [HttpPost]
  2350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2351. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2352. {
  2353. try
  2354. {
  2355. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2356. if (groupData.Code != 0)
  2357. {
  2358. return Ok(JsonView(false, groupData.Msg));
  2359. }
  2360. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2361. }
  2362. catch (Exception ex)
  2363. {
  2364. return Ok(JsonView(false, ex.Message));
  2365. throw;
  2366. }
  2367. }
  2368. /// <summary>
  2369. /// 根据id查询费用录入信息
  2370. /// </summary>
  2371. /// <param name="dto"></param>
  2372. /// <returns></returns>
  2373. [HttpPost]
  2374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2375. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2376. {
  2377. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2378. if (groupData.Code != 0)
  2379. {
  2380. return Ok(JsonView(false, groupData.Msg));
  2381. }
  2382. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2383. }
  2384. /// <summary>
  2385. /// 机票费用录入操作(Status:1.新增,2.修改)
  2386. /// </summary>
  2387. /// <param name="dto"></param>
  2388. /// <returns></returns>
  2389. [HttpPost]
  2390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2391. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2392. {
  2393. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2394. if (groupData.Code != 0)
  2395. {
  2396. return Ok(JsonView(false, groupData.Msg));
  2397. }
  2398. #region 应用推送
  2399. try
  2400. {
  2401. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2402. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2403. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2404. //2024-10-21 新增LZ UID
  2405. var userIds = new List<int>() { 21 };
  2406. string title = $"系统通知";
  2407. string content = "";
  2408. var diId = dto.AirTicketResOpData.DiId;
  2409. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2410. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2411. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2412. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2413. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2414. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2415. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2416. }
  2417. catch (Exception ex)
  2418. {
  2419. }
  2420. #endregion
  2421. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2422. }
  2423. /// <summary>
  2424. /// 根据舱位类型查询接团客户名单信息
  2425. /// </summary>
  2426. /// <param name="dto"></param>
  2427. /// <returns></returns>
  2428. [HttpPost]
  2429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2430. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2431. {
  2432. try
  2433. {
  2434. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2435. if (crm_Groups.Count != 0)
  2436. {
  2437. List<dynamic> Customer = new List<dynamic>();
  2438. foreach (var item in crm_Groups)
  2439. {
  2440. var data = new
  2441. {
  2442. Id = item.Id,
  2443. Pinyin = item.Pinyin,
  2444. Name = item.LastName + item.FirstName
  2445. };
  2446. Customer.Add(data);
  2447. }
  2448. return Ok(JsonView(true, "查询成功!", Customer));
  2449. }
  2450. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2451. }
  2452. catch (Exception ex)
  2453. {
  2454. return Ok(JsonView(false, "程序错误!"));
  2455. throw;
  2456. }
  2457. }
  2458. /// <summary>
  2459. /// 根据团号获取客户信息
  2460. /// </summary>
  2461. /// <param name="dto"></param>
  2462. /// <returns></returns>
  2463. [HttpPost]
  2464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2465. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2466. {
  2467. var jw = JsonView(false);
  2468. if (dto.DIID < 1)
  2469. {
  2470. jw.Msg += "请输入正确的diid";
  2471. return Ok(jw);
  2472. }
  2473. var arr = getSimplClientList(dto.DIID);
  2474. jw = JsonView(true, "获取成功!", arr);
  2475. return Ok(jw);
  2476. }
  2477. private List<SimplClientInfo> getSimplClientList(int diId)
  2478. {
  2479. 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);
  2480. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2481. foreach (var item in arr)
  2482. {
  2483. EncryptionProcessor.DecryptProperties(item);
  2484. }
  2485. return arr;
  2486. }
  2487. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2488. {
  2489. string result = origin;
  2490. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2491. {
  2492. string[] temparr = origin.Split(',');
  2493. string fistrStr = temparr[0];
  2494. int count = temparr.Count();
  2495. int tempId;
  2496. bool success = int.TryParse(fistrStr, out tempId);
  2497. if (success)
  2498. {
  2499. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2500. if (tempInfo != null)
  2501. {
  2502. if (count > 1)
  2503. {
  2504. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2505. }
  2506. else
  2507. {
  2508. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2509. }
  2510. }
  2511. }
  2512. }
  2513. return result;
  2514. }
  2515. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2516. {
  2517. string result = origin;
  2518. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2519. {
  2520. string[] temparr = origin.Split(',');
  2521. result = "";
  2522. foreach (var item in temparr)
  2523. {
  2524. int tempId;
  2525. bool success = int.TryParse(item, out tempId);
  2526. if (success)
  2527. {
  2528. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2529. if (tempInfo != null)
  2530. {
  2531. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2532. }
  2533. }
  2534. }
  2535. }
  2536. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2537. return result;
  2538. }
  2539. /// <summary>
  2540. /// 机票费用录入,删除
  2541. /// </summary>
  2542. /// <param name="dto"></param>
  2543. /// <returns></returns>
  2544. [HttpPost]
  2545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2546. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2547. {
  2548. try
  2549. {
  2550. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2551. if (res)
  2552. {
  2553. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2554. {
  2555. IsDel = 1,
  2556. DeleteUserId = dto.DeleteUserId,
  2557. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2558. }).ExecuteCommandAsync();
  2559. return Ok(JsonView(true, "删除成功!"));
  2560. }
  2561. return Ok(JsonView(false, "删除失败!"));
  2562. }
  2563. catch (Exception ex)
  2564. {
  2565. return Ok(JsonView(false, "程序错误!"));
  2566. throw;
  2567. }
  2568. }
  2569. /// <summary>
  2570. /// 导出机票录入报表
  2571. /// </summary>
  2572. /// <param name="dto"></param>
  2573. /// <returns></returns>
  2574. [HttpPost]
  2575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2576. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2577. {
  2578. try
  2579. {
  2580. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2581. if (groupData.Code != 0)
  2582. {
  2583. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2584. }
  2585. else
  2586. {
  2587. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2588. if (AirTicketReservations.Count != 0)
  2589. {
  2590. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2591. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2592. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2593. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2594. WorkbookDesigner designer = new WorkbookDesigner();
  2595. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2596. decimal countCost = 0;
  2597. foreach (var item in AirTicketReservations)
  2598. {
  2599. #region 处理客人姓名
  2600. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2601. item.ClientName = clientNames;
  2602. #endregion
  2603. if (item.BankType == "其他")
  2604. {
  2605. item.BankNo = "--";
  2606. }
  2607. else
  2608. {
  2609. if (!string.IsNullOrEmpty(item.BankType))
  2610. {
  2611. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2612. }
  2613. }
  2614. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2615. item.Price = System.Decimal.Round(item.Price, 2);
  2616. countCost += Convert.ToDecimal(item.Price);
  2617. }
  2618. designer.SetDataSource("Export", AirTicketReservations);
  2619. designer.SetDataSource("ExportDiCode", diCode);
  2620. designer.SetDataSource("ExportDiName", diName);
  2621. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2622. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2623. designer.Process();
  2624. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2625. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2626. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2627. return Ok(JsonView(true, "成功", url = rst));
  2628. }
  2629. else
  2630. {
  2631. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2632. }
  2633. }
  2634. }
  2635. catch (Exception ex)
  2636. {
  2637. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2638. throw;
  2639. }
  2640. }
  2641. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2642. /// <summary>
  2643. /// 行程单导出
  2644. /// </summary>
  2645. /// <param name="dto"></param>
  2646. /// <returns></returns>
  2647. [HttpPost]
  2648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2649. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2650. {
  2651. try
  2652. {
  2653. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2654. if (groupData.Code != 0)
  2655. {
  2656. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2657. }
  2658. else
  2659. {
  2660. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2661. if (dto.Language == "CN")
  2662. {
  2663. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2664. DocumentBuilder builder = new DocumentBuilder(doc);
  2665. int tableIndex = 0;//表格索引
  2666. //得到文档中的第一个表格
  2667. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2668. foreach (var item in _AirTicketReservations)
  2669. {
  2670. #region 处理固定数据
  2671. string[] FlightsCode = item.FlightsCode.Split('/');
  2672. if (FlightsCode.Length != 0)
  2673. {
  2674. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2675. if (_AirCompany != null)
  2676. {
  2677. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2678. }
  2679. else
  2680. {
  2681. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2682. }
  2683. }
  2684. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2685. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2686. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2687. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2688. string name = "";
  2689. foreach (string clientName in nameArray)
  2690. {
  2691. if (!name.Contains(clientName))
  2692. {
  2693. name += clientName + ",";
  2694. }
  2695. }
  2696. if (!string.IsNullOrWhiteSpace(name))
  2697. {
  2698. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2699. }
  2700. else
  2701. {
  2702. table.Range.Bookmarks["ClientName"].Text = "--";
  2703. }
  2704. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2705. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2706. table.Range.Bookmarks["JointTicket"].Text = "--";
  2707. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2708. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2709. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2710. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2711. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2712. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2713. #endregion
  2714. #region 循环数据处理
  2715. List<AirInfo> airs = new List<AirInfo>();
  2716. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2717. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2718. for (int i = 0; i < FlightsCode.Length; i++)
  2719. {
  2720. AirInfo air = new AirInfo();
  2721. string[] tempstr = DayArray[i]
  2722. .Replace("\r\n", string.Empty)
  2723. .Replace("\\r\\n", string.Empty)
  2724. .TrimStart().TrimEnd()
  2725. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2726. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2727. string starCity = "";
  2728. if (star_Three != null)
  2729. {
  2730. starCity = star_Three.AirPort;
  2731. }
  2732. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2733. string EndCity = "";
  2734. if (End_Three != null)
  2735. {
  2736. EndCity = End_Three.AirPort;
  2737. }
  2738. air.Destination = starCity + "/" + EndCity;
  2739. air.Flight = FlightsCode[i];
  2740. air.SeatingClass = item.CTypeName;
  2741. string dateTime = tempstr[2];
  2742. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2743. air.FlightDate = DateTemp;
  2744. air.DepartureTime = tempstr[5];
  2745. air.LandingTime = tempstr[6];
  2746. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2747. air.TicketStatus = "--";
  2748. air.Luggage = "--";
  2749. air.DepartureTerminal = "--";
  2750. air.LandingTerminal = "--";
  2751. airs.Add(air);
  2752. }
  2753. int row = 13;
  2754. for (int i = 0; i < airs.Count; i++)
  2755. {
  2756. if (airs.Count > 2)
  2757. {
  2758. for (int j = 0; j < airs.Count - 2; j++)
  2759. {
  2760. var CopyRow = table.Rows[12].Clone(true);
  2761. table.Rows.Add(CopyRow);
  2762. }
  2763. }
  2764. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2765. int index = 0;
  2766. foreach (PropertyInfo property in properties)
  2767. {
  2768. string value = property.GetValue(airs[i]).ToString();
  2769. Cell ishcel0 = table.Rows[row].Cells[index];
  2770. Paragraph p = new Paragraph(doc);
  2771. string s = value;
  2772. p.AppendChild(new Run(doc, s));
  2773. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2774. ishcel0.AppendChild(p);
  2775. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2776. index++;
  2777. }
  2778. row++;
  2779. }
  2780. #endregion
  2781. Paragraph lastParagraph = new Paragraph(doc);
  2782. //第一个表格末尾加段落
  2783. table.ParentNode.InsertAfter(lastParagraph, table);
  2784. //复制第一个表格
  2785. Table cloneTable = (Table)table.Clone(true);
  2786. //在文档末尾段落后面加入复制的表格
  2787. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2788. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2789. {
  2790. int rownewsIndex = 13;
  2791. for (int i = 0; i < 2; i++)
  2792. {
  2793. var CopyRow = table.Rows[12].Clone(true);
  2794. table.Rows.RemoveAt(13);
  2795. table.Rows.Add(CopyRow);
  2796. rownewsIndex++;
  2797. }
  2798. }
  2799. else
  2800. {
  2801. table.Rows.RemoveAt(12);
  2802. }
  2803. cloneTable.Rows.RemoveAt(12);
  2804. }
  2805. if (_AirTicketReservations.Count != 0)
  2806. {
  2807. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2808. if (FlightsCode.Length != 0)
  2809. {
  2810. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2811. if (_AirCompany != null)
  2812. {
  2813. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2814. }
  2815. else
  2816. {
  2817. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2818. }
  2819. }
  2820. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2821. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2822. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2823. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2824. string name = "";
  2825. foreach (string clientName in nameArray)
  2826. {
  2827. if (!name.Contains(clientName))
  2828. {
  2829. name += clientName + ",";
  2830. }
  2831. }
  2832. if (!string.IsNullOrWhiteSpace(name))
  2833. {
  2834. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2835. }
  2836. else
  2837. {
  2838. table.Range.Bookmarks["ClientName"].Text = "--";
  2839. }
  2840. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2841. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2842. table.Range.Bookmarks["JointTicket"].Text = "--";
  2843. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2844. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2845. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2846. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2847. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2848. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2849. }
  2850. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2851. //保存合并后的文档
  2852. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2853. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2854. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2855. return Ok(JsonView(true, "成功!", rst));
  2856. }
  2857. else
  2858. {
  2859. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2860. DocumentBuilder builder = new DocumentBuilder(doc);
  2861. int tableIndex = 0;//表格索引
  2862. //得到文档中的第一个表格
  2863. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2864. List<string> texts = new List<string>();
  2865. foreach (var item in _AirTicketReservations)
  2866. {
  2867. string[] FlightsCode = item.FlightsCode.Split('/');
  2868. if (FlightsCode.Length != 0)
  2869. {
  2870. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2871. if (_AirCompany != null)
  2872. {
  2873. if (!transDic.ContainsKey(_AirCompany.CnName))
  2874. {
  2875. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2876. }
  2877. }
  2878. else
  2879. {
  2880. if (!transDic.ContainsKey("--"))
  2881. {
  2882. transDic.Add("--", "--");
  2883. }
  2884. }
  2885. }
  2886. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2887. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2888. string name = "";
  2889. foreach (string clientName in nameArray)
  2890. {
  2891. name += clientName + ",";
  2892. }
  2893. if (!texts.Contains(name))
  2894. {
  2895. texts.Add(name);
  2896. }
  2897. List<AirInfo> airs = new List<AirInfo>();
  2898. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2899. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2900. for (int i = 0; i < FlightsCode.Length; i++)
  2901. {
  2902. AirInfo air = new AirInfo();
  2903. string[] tempstr = DayArray[i]
  2904. .Replace("\r\n", string.Empty)
  2905. .Replace("\\r\\n", string.Empty)
  2906. .TrimStart().TrimEnd()
  2907. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2908. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2909. if (star_Three != null)
  2910. {
  2911. if (!transDic.ContainsKey(star_Three.AirPort))
  2912. {
  2913. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2914. }
  2915. }
  2916. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2917. if (End_Three != null)
  2918. {
  2919. if (!transDic.ContainsKey(End_Three.AirPort))
  2920. {
  2921. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2922. }
  2923. }
  2924. if (!texts.Contains(item.CTypeName))
  2925. {
  2926. texts.Add(item.CTypeName);
  2927. }
  2928. }
  2929. }
  2930. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2931. if (transData.Count > 0)
  2932. {
  2933. foreach (TranslateResult item in transData)
  2934. {
  2935. if (!transDic.ContainsKey(item.Query))
  2936. {
  2937. transDic.Add(item.Query, item.Translation);
  2938. }
  2939. }
  2940. }
  2941. foreach (var item in _AirTicketReservations)
  2942. {
  2943. #region 处理固定数据
  2944. string[] FlightsCode = item.FlightsCode.Split('/');
  2945. if (FlightsCode.Length != 0)
  2946. {
  2947. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2948. if (_AirCompany != null)
  2949. {
  2950. string str = "--";
  2951. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2952. if (!string.IsNullOrEmpty(translateResult))
  2953. {
  2954. str = translateResult;
  2955. str = _airTicketResRep.Processing(str);
  2956. }
  2957. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2958. }
  2959. else
  2960. {
  2961. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2962. }
  2963. }
  2964. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2965. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2966. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2967. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2968. string names = "";
  2969. foreach (string clientName in nameArray)
  2970. {
  2971. names += clientName + ",";
  2972. }
  2973. if (!string.IsNullOrWhiteSpace(names))
  2974. {
  2975. string str = "--";
  2976. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2977. if (!string.IsNullOrEmpty(translateResult))
  2978. {
  2979. str = translateResult;
  2980. str = _airTicketResRep.Processing(str);
  2981. }
  2982. table.Range.Bookmarks["ClientName"].Text = str;
  2983. }
  2984. else
  2985. {
  2986. table.Range.Bookmarks["ClientName"].Text = "--";
  2987. }
  2988. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2989. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2990. table.Range.Bookmarks["JointTicket"].Text = "--";
  2991. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2992. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2993. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2994. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2995. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2996. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2997. #endregion
  2998. #region 循环数据处理
  2999. List<AirInfo> airs = new List<AirInfo>();
  3000. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3001. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3002. for (int i = 0; i < FlightsCode.Length; i++)
  3003. {
  3004. AirInfo air = new AirInfo();
  3005. string[] tempstr = DayArray[i]
  3006. .Replace("\r\n", string.Empty)
  3007. .Replace("\\r\\n", string.Empty)
  3008. .TrimStart().TrimEnd()
  3009. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3010. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3011. string starCity = "";
  3012. if (star_Three != null)
  3013. {
  3014. string str2 = "--";
  3015. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3016. if (!string.IsNullOrEmpty(translateResult2))
  3017. {
  3018. str2 = translateResult2;
  3019. str2 = _airTicketResRep.Processing(str2);
  3020. }
  3021. starCity = str2;
  3022. }
  3023. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3024. string EndCity = "";
  3025. if (End_Three != null)
  3026. {
  3027. string str1 = "--";
  3028. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3029. if (!string.IsNullOrEmpty(translateResult1))
  3030. {
  3031. str1 = translateResult1;
  3032. str1 = _airTicketResRep.Processing(str1);
  3033. }
  3034. EndCity = str1;
  3035. }
  3036. air.Destination = starCity + "/" + EndCity;
  3037. air.Flight = FlightsCode[i];
  3038. string str = "--";
  3039. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3040. if (!string.IsNullOrEmpty(translateResult))
  3041. {
  3042. str = translateResult;
  3043. str = _airTicketResRep.Processing(str);
  3044. }
  3045. air.SeatingClass = str;
  3046. string dateTime = tempstr[2];
  3047. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3048. air.FlightDate = DateTemp;
  3049. air.DepartureTime = tempstr[5];
  3050. air.LandingTime = tempstr[6];
  3051. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3052. air.TicketStatus = "--";
  3053. air.Luggage = "--";
  3054. air.DepartureTerminal = "--";
  3055. air.LandingTerminal = "--";
  3056. airs.Add(air);
  3057. }
  3058. int row = 13;
  3059. for (int i = 0; i < airs.Count; i++)
  3060. {
  3061. if (airs.Count > 2)
  3062. {
  3063. for (int j = 0; j < airs.Count - 2; j++)
  3064. {
  3065. var CopyRow = table.Rows[12].Clone(true);
  3066. table.Rows.Add(CopyRow);
  3067. }
  3068. }
  3069. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3070. int index = 0;
  3071. foreach (PropertyInfo property in properties)
  3072. {
  3073. string value = property.GetValue(airs[i]).ToString();
  3074. Cell ishcel0 = table.Rows[row].Cells[index];
  3075. Paragraph p = new Paragraph(doc);
  3076. string s = value;
  3077. p.AppendChild(new Run(doc, s));
  3078. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3079. ishcel0.AppendChild(p);
  3080. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3081. //ishcel0.CellFormat.VerticalAlignment=
  3082. index++;
  3083. }
  3084. row++;
  3085. }
  3086. #endregion
  3087. Paragraph lastParagraph = new Paragraph(doc);
  3088. //第一个表格末尾加段落
  3089. table.ParentNode.InsertAfter(lastParagraph, table);
  3090. //复制第一个表格
  3091. Table cloneTable = (Table)table.Clone(true);
  3092. //在文档末尾段落后面加入复制的表格
  3093. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3094. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3095. {
  3096. int rownewsIndex = 13;
  3097. for (int i = 0; i < 2; i++)
  3098. {
  3099. var CopyRow = table.Rows[12].Clone(true);
  3100. table.Rows.RemoveAt(13);
  3101. table.Rows.Add(CopyRow);
  3102. rownewsIndex++;
  3103. }
  3104. }
  3105. else
  3106. {
  3107. table.Rows.RemoveAt(12);
  3108. }
  3109. cloneTable.Rows.RemoveAt(12);
  3110. }
  3111. if (_AirTicketReservations.Count != 0)
  3112. {
  3113. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3114. if (FlightsCode.Length != 0)
  3115. {
  3116. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3117. if (_AirCompany != null)
  3118. {
  3119. string str = "--";
  3120. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3121. if (!string.IsNullOrEmpty(translateResult))
  3122. {
  3123. str = translateResult;
  3124. str = _airTicketResRep.Processing(str);
  3125. }
  3126. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3127. }
  3128. else
  3129. {
  3130. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3131. }
  3132. }
  3133. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3134. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3135. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3136. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3137. string names = "";
  3138. foreach (string clientName in nameArray)
  3139. {
  3140. names += clientName + ",";
  3141. }
  3142. if (!string.IsNullOrWhiteSpace(names))
  3143. {
  3144. string str = "--";
  3145. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3146. if (!string.IsNullOrEmpty(translateResult))
  3147. {
  3148. str = translateResult;
  3149. str = _airTicketResRep.Processing(str);
  3150. }
  3151. table.Range.Bookmarks["ClientName"].Text = str;
  3152. }
  3153. else
  3154. {
  3155. table.Range.Bookmarks["ClientName"].Text = "--";
  3156. }
  3157. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3158. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3159. table.Range.Bookmarks["JointTicket"].Text = "--";
  3160. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3161. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3162. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3163. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3164. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3165. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3166. }
  3167. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3168. //保存合并后的文档
  3169. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3170. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3171. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3172. return Ok(JsonView(true, "成功!", rst));
  3173. }
  3174. }
  3175. }
  3176. catch (Exception ex)
  3177. {
  3178. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3179. throw;
  3180. }
  3181. }
  3182. #endregion
  3183. #region 团组增减款项 --> 其他款项
  3184. /// <summary>
  3185. /// 团组增减款项下拉框绑定
  3186. /// </summary>
  3187. /// <param name="dto"></param>
  3188. /// <returns></returns>
  3189. [HttpPost]
  3190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3191. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3192. {
  3193. #region 参数验证
  3194. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3195. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3196. #endregion
  3197. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3198. }
  3199. /// <summary>
  3200. /// 根据团组Id查询团组增减款项
  3201. /// </summary>
  3202. /// <param name="dto"></param>
  3203. /// <returns></returns>
  3204. [HttpPost]
  3205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3206. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3207. {
  3208. #region 参数验证
  3209. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3210. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3211. #endregion
  3212. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3213. }
  3214. /// <summary>
  3215. /// 团组增减款项操作(Status:1.新增,2.修改)
  3216. /// </summary>
  3217. /// <param name="dto"></param>
  3218. /// <returns></returns>
  3219. [HttpPost]
  3220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3221. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3222. {
  3223. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3224. if (groupData.Code != 200)
  3225. {
  3226. return Ok(JsonView(false, groupData.Msg));
  3227. }
  3228. #region 应用推送
  3229. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3230. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3231. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3232. //自动审核
  3233. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3234. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3235. //2024-10-21 新增LZ UID
  3236. var userIds = new List<int>() { 21 };
  3237. string title = $"系统通知";
  3238. string content = "";
  3239. var diId = dto.DiId;
  3240. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3241. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3242. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3243. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3244. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3245. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3246. #endregion
  3247. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3248. }
  3249. /// <summary>
  3250. /// 团组增减款项操作 删除
  3251. /// </summary>
  3252. /// <param name="dto"></param>
  3253. /// <returns></returns>
  3254. [HttpPost]
  3255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3256. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3257. {
  3258. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3259. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3260. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3261. if (res.Code == 0)
  3262. {
  3263. return Ok(JsonView(true, "删除成功!"));
  3264. }
  3265. return Ok(JsonView(false, "删除失败!"));
  3266. }
  3267. /// <summary>
  3268. /// 根据团组增减款项Id查询
  3269. /// </summary>
  3270. /// <param name="dto"></param>
  3271. /// <returns></returns>
  3272. [HttpPost]
  3273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3274. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3275. {
  3276. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3277. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3278. }
  3279. /// <summary>
  3280. /// 查询供应商名称
  3281. /// </summary>
  3282. /// <param name="dto"></param>
  3283. /// <returns></returns>
  3284. [HttpPost]
  3285. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3286. {
  3287. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3288. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3289. ?? new List<Grp_DecreasePayments>();
  3290. dbResult = dbResult.Distinct(new
  3291. ProductComparer()).ToList();
  3292. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3293. {
  3294. x.Id,
  3295. x.SupplierAddress,
  3296. x.SupplierArea,
  3297. x.SupplierContact,
  3298. x.SupplierContactNumber,
  3299. x.SupplierEmail,
  3300. x.SupplierName,
  3301. x.SupplierSocialAccount,
  3302. x.SupplierTypeId,
  3303. }).ToList());
  3304. return Ok(jw);
  3305. }
  3306. /// <summary>
  3307. /// 团组增减款项 OTA匹配
  3308. /// </summary>
  3309. /// <param name="file"></param>
  3310. /// <returns></returns>
  3311. [HttpPost]
  3312. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3313. {
  3314. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3315. string fileName = file.FileName;
  3316. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3317. {
  3318. return Ok(JsonView(false, "请上传Excel文件!"));
  3319. }
  3320. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3321. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3322. if (!Directory.Exists(path))
  3323. {
  3324. Directory.CreateDirectory(path);
  3325. }
  3326. var filePath = @$"{path}/{fileName}";
  3327. //保存文件
  3328. using (FileStream fs = System.IO.File.Create(filePath))
  3329. {
  3330. file.CopyTo(fs);
  3331. fs.Flush();
  3332. }
  3333. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3334. //读取ExcelFile
  3335. DataTable dt = ConvertExcelToDataTable(filePath);
  3336. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3337. dt.TableName = "TB";
  3338. //修改table列名
  3339. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3340. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3341. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3342. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3343. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3344. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3345. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3346. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3347. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3348. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3349. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3350. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3351. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3352. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3353. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3354. var otaOrderNos = new List<string>();
  3355. foreach (DataRow item in dt.Rows)
  3356. {
  3357. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3358. }
  3359. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3360. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3361. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3362. .Select((dp, di) => new
  3363. {
  3364. dp.PriceName,
  3365. dp.OTAOrderNo,
  3366. dp.FeeTotal,
  3367. di.TeamName,
  3368. })
  3369. .ToListAsync();
  3370. foreach (DataRow item in dt.Rows)
  3371. {
  3372. var otaOrderNo = item["OTAOrderNo"].ToString();
  3373. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3374. if (oaData == null) continue;
  3375. item["GroupName"] = oaData.TeamName;
  3376. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3377. }
  3378. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3379. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3380. List<DataTable> datas = new List<DataTable>();
  3381. datas.Add(dt);
  3382. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3383. return Ok(JsonView(true, "操作成功", new { url = url }));
  3384. }
  3385. #region
  3386. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3387. {
  3388. // 创建Workbook对象
  3389. Workbook workbook = new Workbook(excelFilePath);
  3390. // 获取第一个工作表
  3391. Worksheet worksheet = workbook.Worksheets[0];
  3392. // 将工作表转换为DataTable
  3393. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3394. return dataTable;
  3395. }
  3396. #endregion
  3397. #endregion
  3398. #region 文件上传、删除
  3399. /// <summary>
  3400. /// region 文件上传 可以带参数
  3401. /// </summary>
  3402. /// <param name="file"></param>
  3403. /// <returns></returns>
  3404. [HttpPost]
  3405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3406. public async Task<IActionResult> UploadProject(IFormFile file)
  3407. {
  3408. //var TypeName = Request.Headers["TypeName"].ToString();
  3409. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3410. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3411. ////文件名称
  3412. //string projectFileName = file.FileName;
  3413. ////上传的文件的路径
  3414. //string filePath = $"{fileDir}/{projectFileName}";
  3415. //if (TypeName == "A")//A代表团组增减款项
  3416. //{
  3417. // filePath = fileDir + $@"\团组增减款项相关文件";
  3418. // if (!Directory.Exists(filePath))
  3419. // {
  3420. // Directory.CreateDirectory(filePath);
  3421. // }
  3422. // //上传的文件的路径
  3423. // filePath += $@"\{projectFileName}";
  3424. //}
  3425. //else if (TypeName == "B")//B代表商邀相关文件
  3426. //{
  3427. // //上传的文件的路径
  3428. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3429. // if (!Directory.Exists(filePath))
  3430. // {
  3431. // Directory.CreateDirectory(filePath);
  3432. // }
  3433. // //上传的文件的路径
  3434. // filePath = $@"\{projectFileName}";
  3435. //}
  3436. //try
  3437. //{
  3438. // using (FileStream fs = System.IO.File.Create(filePath))
  3439. // {
  3440. // file.CopyTo(fs);
  3441. // fs.Flush();
  3442. // }
  3443. //}
  3444. //catch (Exception ex)
  3445. //{
  3446. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3447. //}
  3448. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3449. try
  3450. {
  3451. var TypeName = Request.Headers["TypeName"].ToString();
  3452. if (file != null)
  3453. {
  3454. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3455. //文件名称
  3456. string projectFileName = file.FileName;
  3457. //上传的文件的路径
  3458. string filePath = $"{fileDir}/{projectFileName}";
  3459. if (TypeName == "A")//A代表团组增减款项
  3460. {
  3461. if (!Directory.Exists(fileDir))
  3462. {
  3463. Directory.CreateDirectory(fileDir);
  3464. }
  3465. //上传的文件的路径
  3466. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3467. }
  3468. else if (TypeName == "B")//B代表商邀相关文件
  3469. {
  3470. if (!Directory.Exists(fileDir))
  3471. {
  3472. Directory.CreateDirectory(fileDir);
  3473. }
  3474. //上传的文件的路径
  3475. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3476. }
  3477. using (FileStream fs = System.IO.File.Create(filePath))
  3478. {
  3479. file.CopyTo(fs);
  3480. fs.Flush();
  3481. }
  3482. return Ok(JsonView(true, "上传成功!", projectFileName));
  3483. }
  3484. else
  3485. {
  3486. return Ok(JsonView(false, "上传失败!"));
  3487. }
  3488. }
  3489. catch (Exception ex)
  3490. {
  3491. return Ok(JsonView(false, "程序错误!"));
  3492. }
  3493. }
  3494. /// <summary>
  3495. /// 删除指定文件
  3496. /// </summary>
  3497. /// <param name="dto"></param>
  3498. /// <returns></returns>
  3499. [HttpPost]
  3500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3501. public async Task<IActionResult> DelFile(DelFileDto dto)
  3502. {
  3503. try
  3504. {
  3505. var TypeName = Request.Headers["TypeName"].ToString();
  3506. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3507. string filePath = "";
  3508. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3509. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3510. int id = 0;
  3511. if (TypeName == "A")
  3512. {
  3513. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3514. // 删除该文件
  3515. System.IO.File.Delete(filePath);
  3516. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3517. .Where(a => a.Id == dto.Id)
  3518. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3519. .ExecuteCommandAsync();
  3520. }
  3521. else if (TypeName == "B")
  3522. {
  3523. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3524. // 删除该文件
  3525. System.IO.File.Delete(filePath);
  3526. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3527. if (info != null)
  3528. {
  3529. string[] files = new string[] { };
  3530. if (!string.IsNullOrEmpty(info.Attachment))
  3531. {
  3532. try
  3533. {
  3534. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3535. }
  3536. catch (Exception)
  3537. {
  3538. files = new List<string>() { info.Attachment }.ToArray();
  3539. }
  3540. }
  3541. if (files.Length > 0)
  3542. {
  3543. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3544. string filePath2 = string.Empty;
  3545. if (files1.Length > 0)
  3546. {
  3547. filePath2 = JsonConvert.SerializeObject(files1);
  3548. }
  3549. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3550. .Where(a => a.Id == dto.Id)
  3551. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3552. .ExecuteCommandAsync();
  3553. }
  3554. }
  3555. }
  3556. if (id != 0)
  3557. {
  3558. return Ok(JsonView(true, "成功!"));
  3559. }
  3560. else
  3561. {
  3562. return Ok(JsonView(false, "失败!"));
  3563. }
  3564. }
  3565. catch (Exception ex)
  3566. {
  3567. return Ok(JsonView(false, "程序错误!"));
  3568. throw;
  3569. }
  3570. }
  3571. /// <summary>
  3572. /// 文件上传多个文件 可以带参数
  3573. /// </summary>
  3574. /// <param name="file"></param>
  3575. /// <returns></returns>
  3576. [HttpPost]
  3577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3578. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3579. {
  3580. try
  3581. {
  3582. var TypeName = Request.Headers["TypeName"].ToString();
  3583. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3584. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3585. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3586. var filePahts = new List<string>();
  3587. foreach (var file in files)
  3588. {
  3589. //文件名称
  3590. string projectFileName = file.FileName;
  3591. //上传的文件的路径
  3592. string filePath = $"{fileDir}/{projectFileName}";
  3593. if (TypeName == "A")//A代表团组增减款项
  3594. {
  3595. if (!Directory.Exists(fileDir))
  3596. {
  3597. Directory.CreateDirectory(fileDir);
  3598. }
  3599. //上传的文件的路径
  3600. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3601. }
  3602. else if (TypeName == "B")//B代表商邀相关文件
  3603. {
  3604. if (!Directory.Exists(fileDir))
  3605. {
  3606. Directory.CreateDirectory(fileDir);
  3607. }
  3608. //上传的文件的路径
  3609. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3610. }
  3611. using (FileStream fs = System.IO.File.Create(filePath))
  3612. {
  3613. file.CopyTo(fs);
  3614. fs.Flush();
  3615. }
  3616. filePahts.Add(projectFileName);
  3617. }
  3618. return Ok(JsonView(true, "上传成功!", filePahts));
  3619. }
  3620. catch (Exception ex)
  3621. {
  3622. return Ok(JsonView(false, "程序错误!"));
  3623. }
  3624. }
  3625. #endregion
  3626. #region 商邀费用录入
  3627. /// <summary>
  3628. /// 根据团组Id查询商邀费用列表
  3629. /// </summary>
  3630. /// <param name="dto"></param>
  3631. /// <returns></returns>
  3632. [HttpPost]
  3633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3634. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3635. {
  3636. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3637. if (groupData.Code != 0)
  3638. {
  3639. return Ok(JsonView(false, groupData.Msg));
  3640. }
  3641. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3642. }
  3643. /// <summary>
  3644. /// 商邀费用列表
  3645. /// 下载文件
  3646. /// </summary>
  3647. /// <param name="dto"></param>
  3648. /// <returns></returns>
  3649. [HttpGet("{id}")]
  3650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3651. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3652. {
  3653. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3654. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3655. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3656. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3657. var filePaths = new List<string>();
  3658. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3659. try
  3660. {
  3661. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3662. }
  3663. catch (Exception ex)
  3664. {
  3665. filePaths.Add(info.Attachment);
  3666. }
  3667. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3668. for (int i = 0; i < filePaths.Count; i++)
  3669. {
  3670. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3671. }
  3672. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3673. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3674. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3675. {
  3676. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3677. {
  3678. foreach (string filePath in filePaths)
  3679. {
  3680. if (System.IO.File.Exists(filePath))
  3681. {
  3682. // 获取文件名
  3683. string fileName = Path.GetFileName(filePath);
  3684. // 将文件添加到ZIP归档中
  3685. zipArchive.CreateEntryFromFile(filePath, fileName);
  3686. }
  3687. }
  3688. }
  3689. }
  3690. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3691. }
  3692. /// <summary>
  3693. /// 商邀费用 Info Page 基础数据源
  3694. /// </summary>
  3695. /// <param name="dto"></param>
  3696. /// <returns></returns>
  3697. [HttpPost]
  3698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3699. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3700. {
  3701. try
  3702. {
  3703. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3704. if (groupData.Code != 0)
  3705. {
  3706. return Ok(JsonView(false, groupData.Msg));
  3707. }
  3708. return Ok(JsonView(true, "操作成功", groupData.Data));
  3709. }
  3710. catch (Exception ex)
  3711. {
  3712. return Ok(JsonView(false, ex.Message));
  3713. throw;
  3714. }
  3715. }
  3716. /// <summary>
  3717. /// 根据商邀费用ID查询C表和商邀费用数据
  3718. /// </summary>
  3719. /// <param name="dto"></param>
  3720. /// <returns></returns>
  3721. [HttpPost]
  3722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3723. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3724. {
  3725. try
  3726. {
  3727. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3728. if (groupData.Code != 0)
  3729. {
  3730. return Ok(JsonView(false, groupData.Msg));
  3731. }
  3732. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3733. }
  3734. catch (Exception ex)
  3735. {
  3736. return Ok(JsonView(false, ex.Message));
  3737. throw;
  3738. }
  3739. }
  3740. /// <summary>
  3741. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3742. /// </summary>
  3743. /// <param name="dto"></param>
  3744. /// <returns></returns>
  3745. [HttpPost]
  3746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3747. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3748. {
  3749. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3750. if (groupData.Code != 0)
  3751. {
  3752. return Ok(JsonView(false, groupData.Msg));
  3753. }
  3754. #region 应用推送
  3755. try
  3756. {
  3757. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3758. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3759. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3760. //2024-10-21 新增LZ UID
  3761. var userIds = new List<int>() { 21 };
  3762. string title = $"系统通知";
  3763. string content = "";
  3764. var diId = dto.DiId;
  3765. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3766. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3767. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3768. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3769. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3770. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3771. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3772. }
  3773. catch (Exception ex)
  3774. {
  3775. }
  3776. #endregion
  3777. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3778. }
  3779. /// <summary>
  3780. /// 商邀删除
  3781. /// </summary>
  3782. /// <param name="dto"></param>
  3783. /// <returns></returns>
  3784. [HttpPost]
  3785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3786. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3787. {
  3788. try
  3789. {
  3790. _sqlSugar.BeginTran();
  3791. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3792. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3793. {
  3794. IsDel = 1,
  3795. DeleteUserId = dto.DeleteUserId,
  3796. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3797. })
  3798. .Where(it => it.Id == dto.Id)
  3799. .ExecuteCommand();
  3800. if (res1 > 0)
  3801. {
  3802. int _diId = 0;
  3803. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3804. if (_ioaInfo != null)
  3805. {
  3806. _diId = _ioaInfo.DiId;
  3807. }
  3808. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3809. .SetColumns(a => new Grp_CreditCardPayment()
  3810. {
  3811. IsDel = 1,
  3812. DeleteUserId = dto.DeleteUserId,
  3813. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3814. })
  3815. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3816. .ExecuteCommand();
  3817. if (res2 > 0)
  3818. {
  3819. _sqlSugar.CommitTran();
  3820. return Ok(JsonView(true, "删除成功!"));
  3821. }
  3822. }
  3823. _sqlSugar.RollbackTran();
  3824. return Ok(JsonView(false, "删除失败"));
  3825. }
  3826. catch (Exception ex)
  3827. {
  3828. _sqlSugar.RollbackTran();
  3829. return Ok(JsonView(false, ex.Message));
  3830. }
  3831. }
  3832. /// <summary>
  3833. /// 团组模块文件上传
  3834. /// </summary>
  3835. /// <param name="dto"></param>
  3836. /// <returns></returns>
  3837. [HttpPost]
  3838. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3839. {
  3840. var jw = JsonView(false);
  3841. long M = 1024 * 1024;
  3842. if (dto.Files == null || dto.Files.Count == 0)
  3843. {
  3844. jw.Msg = "无文件信息!";
  3845. return Ok(jw);
  3846. }
  3847. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3848. {
  3849. jw.Msg = "文件大小超过20M!";
  3850. return Ok(jw);
  3851. }
  3852. //var nameSp = dto.File.FileName.Split(".");
  3853. //if (nameSp.Length < 2)
  3854. //{
  3855. // jw.Msg = "拓展名称有误!";
  3856. // return Ok(jw);
  3857. //}
  3858. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3859. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3860. //{
  3861. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3862. // return Ok(jw);
  3863. //}
  3864. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3865. if (Ctable == null)
  3866. {
  3867. jw.Msg = "Ctable指向有误!";
  3868. return Ok(jw);
  3869. }
  3870. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3871. if (groupInfo == null)
  3872. {
  3873. jw.Msg = "团组信息不存在!";
  3874. return Ok(jw);
  3875. }
  3876. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3877. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3878. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3879. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3880. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3881. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3882. try
  3883. {
  3884. if (!Directory.Exists(fileBase))
  3885. {
  3886. Directory.CreateDirectory(fileBase);
  3887. }
  3888. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3889. foreach (var fileStream in dto.Files)
  3890. {
  3891. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3892. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3893. {
  3894. Cid = dto.Cid,
  3895. CreateTime = DateTime.Now,
  3896. CreateUserId = dto.Userid,
  3897. Ctable = dto.Ctable,
  3898. Diid = dto.Diid,
  3899. IsDel = 0,
  3900. FilePath = saveFilePath,
  3901. FileName = fileStream.FileName
  3902. };
  3903. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3904. {
  3905. fileStream.CopyTo(fs);
  3906. fs.Flush();
  3907. }
  3908. saveArr.Add(file);
  3909. }
  3910. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3911. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3912. jw = JsonView(true, "保存成功!", new
  3913. {
  3914. count = addResult,
  3915. filesName = saveArr.Select(x => x.FileName)
  3916. });
  3917. }
  3918. catch (Exception ex)
  3919. {
  3920. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3921. {
  3922. count = 0,
  3923. filesName = new string[0],
  3924. });
  3925. }
  3926. return Ok(jw);
  3927. }
  3928. /// <summary>
  3929. /// 查询各模块已保存文件
  3930. /// </summary>
  3931. /// <param name="dto"></param>
  3932. /// <returns></returns>
  3933. [HttpPost]
  3934. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3935. {
  3936. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3937. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3938. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3939. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3940. {
  3941. expression = Expressionable.Create<Grp_GroupModelFile>()
  3942. .And(x => visaIds.Contains(x.CreateUserId));
  3943. }
  3944. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3945. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3946. .Where(expression.ToExpression())
  3947. .ToList();
  3948. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3949. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3950. {
  3951. x.FileName,
  3952. x.Id,
  3953. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3954. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3955. })));
  3956. }
  3957. /// <summary>
  3958. /// 下载该团组下的所有文件
  3959. /// </summary>
  3960. /// <param name="dto"></param>
  3961. /// <returns></returns>
  3962. [HttpPost]
  3963. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3964. {
  3965. var jw = JsonView(false);
  3966. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3967. if (groupInfo == null)
  3968. {
  3969. jw.Msg = "团组信息不存在!";
  3970. return Ok(jw);
  3971. }
  3972. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3973. var isModule = Convert.ToBoolean(dto.isModule);
  3974. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3975. IOOperatorHelper io = new IOOperatorHelper();
  3976. if (isModule)
  3977. {
  3978. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3979. foreach (var moduleArr in moduleGroup)
  3980. {
  3981. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3982. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3983. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3984. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3985. foreach (var item in moduleArr)
  3986. {
  3987. if (System.IO.File.Exists(item.FilePath))
  3988. {
  3989. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3990. {
  3991. byte[] bytes = new byte[fileStream.Length];
  3992. fileStream.Read(bytes, 0, bytes.Length);
  3993. fileStream.Close();
  3994. Stream stream = new MemoryStream(bytes);
  3995. chiZips.Add(item.FileName, stream);
  3996. }
  3997. }
  3998. }
  3999. if (chiZips.Count > 0)
  4000. {
  4001. var byts = io.ConvertZipStream(chiZips);
  4002. Stream stream = new MemoryStream(byts);
  4003. Zips.Add(key.Name + "_.zip", stream);
  4004. }
  4005. }
  4006. }
  4007. else
  4008. {
  4009. foreach (var item in dbQuery)
  4010. {
  4011. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4012. {
  4013. byte[] bytes = new byte[fileStream.Length];
  4014. fileStream.Read(bytes, 0, bytes.Length);
  4015. fileStream.Close();
  4016. Stream stream = new MemoryStream(bytes);
  4017. while (Zips.Keys.Contains(item.FileName))
  4018. {
  4019. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4020. }
  4021. Zips.Add(item.FileName, stream);
  4022. }
  4023. }
  4024. }
  4025. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4026. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4027. if (Zips.Count > 0)
  4028. {
  4029. var byts = io.ConvertZipStream(Zips);
  4030. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4031. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4032. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4033. }
  4034. else
  4035. {
  4036. jw.Msg = "暂无生成文件!";
  4037. }
  4038. return Ok(jw);
  4039. }
  4040. /// <summary>
  4041. /// 下载该团组下此模块的所有文件
  4042. /// </summary>
  4043. /// <param name="dto"></param>
  4044. /// <returns></returns>
  4045. [HttpPost]
  4046. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4047. {
  4048. var jw = JsonView(false);
  4049. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4050. if (groupInfo == null)
  4051. {
  4052. jw.Msg = "团组信息不存在!";
  4053. return Ok(jw);
  4054. }
  4055. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4056. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4057. && x.IsDel == 0);
  4058. if (key == null)
  4059. {
  4060. jw.Msg = "Ctable指向错误!";
  4061. return Ok(jw);
  4062. }
  4063. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4064. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4065. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4066. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4067. IOOperatorHelper io = new IOOperatorHelper();
  4068. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4069. foreach (var item in dbQuery)
  4070. {
  4071. if (System.IO.File.Exists(item.FilePath))
  4072. {
  4073. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4074. {
  4075. byte[] bytes = new byte[fileStream.Length];
  4076. fileStream.Read(bytes, 0, bytes.Length);
  4077. fileStream.Close();
  4078. Stream stream = new MemoryStream(bytes);
  4079. while (Zips.Keys.Contains(item.FileName))
  4080. {
  4081. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4082. }
  4083. Zips.Add(item.FileName, stream);
  4084. }
  4085. }
  4086. }
  4087. if (Zips.Count > 0)
  4088. {
  4089. var byts = io.ConvertZipStream(Zips);
  4090. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4091. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4092. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4093. }
  4094. else
  4095. {
  4096. jw.Msg = "暂无生成文件!";
  4097. }
  4098. return Ok(jw);
  4099. }
  4100. /// <summary>
  4101. /// 删除该团组下的指定文件
  4102. /// </summary>
  4103. /// <param name="dto"></param>
  4104. /// <returns></returns>
  4105. [HttpPost]
  4106. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4107. {
  4108. var jw = JsonView(false);
  4109. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4110. if (sing == null)
  4111. {
  4112. jw.Msg = "暂无";
  4113. return Ok(jw);
  4114. }
  4115. if (System.IO.File.Exists(sing.FilePath))
  4116. {
  4117. try
  4118. {
  4119. System.IO.File.Delete(sing.FilePath);
  4120. }
  4121. catch (Exception ex)
  4122. {
  4123. jw.Msg = "删除失败!" + ex.Message;
  4124. return Ok(jw);
  4125. }
  4126. }
  4127. sing.IsDel = 1;
  4128. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4129. sing.DeleteUserId = dto.UserId;
  4130. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4131. jw = JsonView(true, "删除成功!");
  4132. return Ok(jw);
  4133. }
  4134. #endregion
  4135. #region 团组英文资料
  4136. /// <summary>
  4137. /// 查询团组英文所有资料
  4138. /// </summary>
  4139. /// <param name="dto"></param>
  4140. /// <returns></returns>
  4141. [HttpPost]
  4142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4143. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4144. {
  4145. try
  4146. {
  4147. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4148. if (groupData.Code != 0)
  4149. {
  4150. return Ok(JsonView(false, groupData.Msg));
  4151. }
  4152. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4153. }
  4154. catch (Exception ex)
  4155. {
  4156. return Ok(JsonView(false, "程序错误!"));
  4157. throw;
  4158. }
  4159. }
  4160. /// <summary>
  4161. /// 团组英文资料操作(Status:1.新增,2.修改)
  4162. /// </summary>
  4163. /// <param name="dto"></param>
  4164. /// <returns></returns>
  4165. [HttpPost]
  4166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4167. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4168. {
  4169. try
  4170. {
  4171. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4172. if (groupData.Code != 0)
  4173. {
  4174. return Ok(JsonView(false, groupData.Msg));
  4175. }
  4176. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4177. }
  4178. catch (Exception ex)
  4179. {
  4180. return Ok(JsonView(false, "程序错误!"));
  4181. throw;
  4182. }
  4183. }
  4184. /// <summary>
  4185. /// 团组英文资料Id查询数据
  4186. /// </summary>
  4187. /// <param name="dto"></param>
  4188. /// <returns></returns>
  4189. [HttpPost]
  4190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4191. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4192. {
  4193. try
  4194. {
  4195. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4196. if (_DelegationEnData != null)
  4197. {
  4198. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4199. }
  4200. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4201. }
  4202. catch (Exception ex)
  4203. {
  4204. return Ok(JsonView(false, "程序错误!"));
  4205. throw;
  4206. }
  4207. }
  4208. /// <summary>
  4209. /// 团组英文资料删除
  4210. /// </summary>
  4211. /// <param name="dto"></param>
  4212. /// <returns></returns>
  4213. [HttpPost]
  4214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4215. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4216. {
  4217. try
  4218. {
  4219. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4220. if (!res)
  4221. {
  4222. return Ok(JsonView(false, "删除失败"));
  4223. }
  4224. return Ok(JsonView(true, "删除成功!"));
  4225. }
  4226. catch (Exception ex)
  4227. {
  4228. return Ok(JsonView(false, "程序错误!"));
  4229. throw;
  4230. }
  4231. }
  4232. #endregion
  4233. #region 导出邀请函
  4234. /// <summary>
  4235. /// 导出邀请函页面初始化
  4236. /// </summary>
  4237. /// <param name="dto"></param>
  4238. /// <returns></returns>
  4239. [HttpPost]
  4240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4241. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4242. {
  4243. try
  4244. {
  4245. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4246. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4247. if (dto.DiId == 0)
  4248. {
  4249. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4250. }
  4251. else
  4252. {
  4253. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4254. }
  4255. return Ok(JsonView(true, "查询成功!", new
  4256. {
  4257. deleClient = crm_Deles,
  4258. delegations = grp_Delegations
  4259. }));
  4260. }
  4261. catch (Exception ex)
  4262. {
  4263. return Ok(JsonView(false, "程序错误!"));
  4264. throw;
  4265. }
  4266. }
  4267. /// <summary>
  4268. /// 导出邀请函
  4269. /// </summary>
  4270. /// <param name="dto"></param>
  4271. /// <returns></returns>
  4272. [HttpPost]
  4273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4274. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4275. {
  4276. #region 参数验证
  4277. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4278. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4279. #endregion
  4280. try
  4281. {
  4282. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4283. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4284. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4285. From Grp_TourClientList tcl
  4286. Left Join
  4287. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4288. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4289. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4290. From Crm_DeleClient dc
  4291. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4292. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4293. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4294. Where dc.IsDel = 0) temp
  4295. On temp.DcId =tcl.ClientId
  4296. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4297. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4298. List<string> texts = new List<string>();
  4299. if (datas.Count != 0)
  4300. {
  4301. foreach (TourClientListDetailsView item in datas)
  4302. {
  4303. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4304. {
  4305. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4306. }
  4307. else
  4308. {
  4309. string name = item.LastName + item.FirstName;
  4310. texts.Add(name);
  4311. }
  4312. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4313. {
  4314. if (!transDic.ContainsKey(item.Job))
  4315. {
  4316. texts.Add(item.Job);
  4317. }
  4318. }
  4319. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4320. {
  4321. texts.Add(item.CompanyFullName);
  4322. }
  4323. }
  4324. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4325. if (transData.Count > 0)
  4326. {
  4327. foreach (TranslateResult item in transData)
  4328. {
  4329. if (!transDic.ContainsKey(item.Query))
  4330. {
  4331. transDic.Add(item.Query, item.Translation);
  4332. }
  4333. }
  4334. }
  4335. List<GuestList> list = new List<GuestList>();
  4336. foreach (TourClientListDetailsView dele in datas)
  4337. {
  4338. GuestList guestList = new GuestList();
  4339. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4340. {
  4341. guestList.Name = dele.Pinyin;
  4342. }
  4343. else
  4344. {
  4345. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4346. guestList.Name = Name;
  4347. }
  4348. if (dele.Sex == 0)
  4349. {
  4350. guestList.Sex = "Male";
  4351. }
  4352. else if (dele.Sex == 1)
  4353. {
  4354. guestList.Sex = "Female";
  4355. }
  4356. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4357. if (!string.IsNullOrEmpty(dele.Job))
  4358. {
  4359. guestList.Job = dele.Job;
  4360. }
  4361. list.Add(guestList);
  4362. }
  4363. //载入模板
  4364. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4365. DocumentBuilder builder = new DocumentBuilder(doc);
  4366. //获取word里所有表格
  4367. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4368. //获取所填表格的序数
  4369. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4370. var rowStart = tableOne.Rows[0]; //获取第1行
  4371. //循环赋值
  4372. for (int i = 0; i < list.Count; i++)
  4373. {
  4374. builder.MoveToCell(0, i + 1, 0, 0);
  4375. builder.Write(list[i].Name.ToString());
  4376. builder.MoveToCell(0, i + 1, 1, 0);
  4377. builder.Write(list[i].Sex.ToString());
  4378. builder.MoveToCell(0, i + 1, 2, 0);
  4379. builder.Write(list[i].DOB.ToString());
  4380. builder.MoveToCell(0, i + 1, 3, 0);
  4381. builder.Write(list[i].Job.ToString());
  4382. }
  4383. //删除多余行
  4384. while (tableOne.Rows.Count > list.Count + 1)
  4385. {
  4386. tableOne.Rows.RemoveAt(list.Count + 1);
  4387. }
  4388. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4389. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4390. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4391. doc.Save(filePath);
  4392. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4393. return Ok(JsonView(true, "操作成功!", Url));
  4394. }
  4395. else
  4396. {
  4397. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4398. }
  4399. }
  4400. catch (Exception ex)
  4401. {
  4402. return Ok(JsonView(false, ex.Message));
  4403. throw;
  4404. }
  4405. }
  4406. #endregion
  4407. #region 团组经理模块 出入境费用
  4408. ///// <summary>
  4409. ///// 团组模块 - 出入境费用
  4410. ///// </summary>
  4411. ///// <returns></returns>
  4412. //[HttpPost]
  4413. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4414. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4415. //{
  4416. // try
  4417. // {
  4418. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4419. // if (data.Code != 0)
  4420. // {
  4421. // return Ok(JsonView(false, data.Msg));
  4422. // }
  4423. // return Ok(JsonView(true, "查询成功!"));
  4424. // }
  4425. // catch (Exception ex)
  4426. // {
  4427. // return Ok(JsonView(false, ex.Message));
  4428. // throw;
  4429. // }
  4430. //}
  4431. /// <summary>
  4432. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4433. /// </summary>
  4434. /// <returns></returns>
  4435. [HttpPost]
  4436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4437. public async Task<IActionResult> SetDayAndCostAreaChange()
  4438. {
  4439. try
  4440. {
  4441. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4442. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4443. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4444. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4445. foreach (var item in unite) //处理交集数据
  4446. {
  4447. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4448. }
  4449. foreach (var item in merge) //处理差集数据
  4450. {
  4451. int nationalTravelFeeId = 0;
  4452. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4453. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4454. else
  4455. {
  4456. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4457. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4458. }
  4459. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4460. }
  4461. //只更新dayAndCost 的 nationalTravelFeeId;
  4462. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4463. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4464. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4465. }
  4466. catch (Exception ex)
  4467. {
  4468. return Ok(JsonView(false, ex.Message));
  4469. throw;
  4470. }
  4471. }
  4472. /// <summary>
  4473. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4474. /// </summary>
  4475. /// <returns></returns>
  4476. [HttpPost]
  4477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4478. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4479. {
  4480. try
  4481. {
  4482. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4483. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4484. //SetDataInfoView
  4485. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4486. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4487. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4488. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4489. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4490. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4491. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4492. //默认币种显示
  4493. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4494. {
  4495. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4496. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4497. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4498. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4499. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4500. };
  4501. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4502. if (_currencyRate.Count > 0)
  4503. {
  4504. foreach (var item in _currencyInfos)
  4505. {
  4506. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4507. if (rateInfo != null)
  4508. {
  4509. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4510. rate1 *= 1.035M;
  4511. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4512. }
  4513. }
  4514. }
  4515. return Ok(JsonView(true, "查询成功!", new
  4516. {
  4517. GroupNameData = groupNameData.Data,
  4518. CurrencyData = _CurrencyData,
  4519. WordTypeData = _WordTypeData,
  4520. ExcelTypeData = _ExcelTypeData,
  4521. CurrencyInit = _currencyInfos
  4522. }));
  4523. }
  4524. catch (Exception ex)
  4525. {
  4526. return Ok(JsonView(false, ex.Message));
  4527. throw;
  4528. }
  4529. }
  4530. /// <summary>
  4531. /// 团组模块 - 出入境费用
  4532. /// 实时汇率 tips
  4533. /// 签证费用 tips
  4534. /// 机票费用 tips
  4535. /// </summary>
  4536. /// <returns></returns>
  4537. [HttpPost]
  4538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4539. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4540. {
  4541. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4542. //默认币种显示
  4543. var _currencyInfos = _currencyInit;
  4544. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4545. List<dynamic> reteInfos = new List<dynamic>();
  4546. if (_currencyRate.Count > 0)
  4547. {
  4548. foreach (var item in _currencyInfos)
  4549. {
  4550. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4551. if (rateInfo != null)
  4552. {
  4553. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4554. decimal rate1 = item.Rate;
  4555. rate1 *= 1.03M;
  4556. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4557. reteInfos.Add(new
  4558. {
  4559. currCode = item.CurrencyCode,
  4560. currName = item.CurrencyName,
  4561. rate = rate2,
  4562. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4563. });
  4564. }
  4565. }
  4566. }
  4567. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4568. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4569. return Ok(JsonView(true, "查询成功!", new
  4570. {
  4571. //GroupNameData = groupNameData.Data,
  4572. visaData = visaData.Data,
  4573. airData = airData.Data,
  4574. reteInfos = reteInfos
  4575. }));
  4576. }
  4577. /// <summary>
  4578. /// 团组模块 - 出入境费用 - Info
  4579. /// </summary>
  4580. /// <returns></returns>
  4581. [HttpPost]
  4582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4583. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4584. {
  4585. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4586. }
  4587. /// <summary>
  4588. /// 团组模块 - 出入境费用 - Add And Update
  4589. /// </summary>
  4590. /// <returns></returns>
  4591. [HttpPost]
  4592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4593. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4594. {
  4595. try
  4596. {
  4597. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4598. if (dto.DayOtherPriceData.Any())
  4599. {
  4600. var inserList = dto.DayOtherPriceData
  4601. .Where(x => x.Id == 0)
  4602. .Select(x => new Grp_DayOtherPrice
  4603. {
  4604. Cost = x.Cost,
  4605. Id = x.Id,
  4606. CreateTime = DateTime.Now,
  4607. CreateUserId = dto.UserId,
  4608. Currency = x.Currency,
  4609. Diid = x.DiId,
  4610. Index = x.Index,
  4611. IsDel = 0,
  4612. SetDataId = x.SetDataId,
  4613. SubTotal = x.SubTotal,
  4614. Remark = x.Remark
  4615. })
  4616. .ToList();
  4617. var updateList = dto.DayOtherPriceData
  4618. .Where(x => x.Id != 0)
  4619. .Select(x => new Grp_DayOtherPrice
  4620. {
  4621. Cost = x.Cost,
  4622. Id = x.Id,
  4623. CreateTime = DateTime.Now,
  4624. CreateUserId = dto.UserId,
  4625. Currency = x.Currency,
  4626. Diid = x.DiId,
  4627. Index = x.Index,
  4628. IsDel = 0,
  4629. SetDataId = x.SetDataId,
  4630. SubTotal = x.SubTotal,
  4631. Remark = x.Remark
  4632. })
  4633. .ToList();
  4634. //添加
  4635. _sqlSugar.BeginTran();
  4636. if (inserList.Any())
  4637. {
  4638. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4639. }
  4640. if (updateList.Any())
  4641. {
  4642. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4643. }
  4644. _sqlSugar.CommitTran();
  4645. }
  4646. if (data.Code != 0)
  4647. {
  4648. return Ok(JsonView(false, data.Msg));
  4649. }
  4650. //生成默认文件pdf并且通知人员
  4651. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4652. {
  4653. DiId = dto.DiId,
  4654. ExportType = 1,
  4655. SubTypeId = 1005
  4656. }, "pdf");
  4657. //发送通知
  4658. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4659. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4660. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4661. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4662. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4663. //汇率信息记录
  4664. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4665. return Ok(JsonView(true, data.Msg, data.Data));
  4666. }
  4667. catch (Exception ex)
  4668. {
  4669. return Ok(JsonView(false, ex.Message));
  4670. }
  4671. }
  4672. /// <summary>
  4673. /// 团组模块 - 出入境费用 - Confirm 费用
  4674. /// </summary>
  4675. /// <returns></returns>
  4676. [HttpPost]
  4677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4678. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4679. {
  4680. //TODO:测试完毕需把对应的用户ID更改
  4681. //1、数据表添加字段
  4682. //2、更改字段接口()
  4683. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4684. //3、确认成功 给财务发送消息
  4685. if (_view.Code == 200)
  4686. {
  4687. if (dto.Type == 1)
  4688. {
  4689. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4690. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4691. }
  4692. }
  4693. return Ok(_view);
  4694. }
  4695. /// <summary>
  4696. /// 团组模块 - 出入境费用 - File downlaod
  4697. /// </summary>
  4698. /// <param name="dto"></param>
  4699. /// <returns></returns>
  4700. [HttpPost]
  4701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4702. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4703. {
  4704. try
  4705. {
  4706. if (dto.DiId < 1)
  4707. {
  4708. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4709. }
  4710. if (dto.ExportType < 1)
  4711. {
  4712. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4713. }
  4714. if (dto.SubTypeId < 1)
  4715. {
  4716. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4717. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4718. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4719. 3 团组成员名单 1 团组成员名单", ""));
  4720. }
  4721. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4722. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4723. if (_EnterExitCosts == null)
  4724. {
  4725. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4726. }
  4727. //数据源
  4728. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4729. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4730. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4731. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4732. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4733. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4734. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4735. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4736. .Select((x, a, b) => new
  4737. {
  4738. x.Index,
  4739. itemName = a.Name,
  4740. CurrencyStr = b.Name,
  4741. x.Cost,
  4742. x.SubTotal,
  4743. x.Remark
  4744. })
  4745. .OrderBy((x) => x.Index)
  4746. .ToList(); //其他款项费用
  4747. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4748. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4749. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4750. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4751. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4752. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4753. .Select((tcl, dc, cc) => new ClientInfo
  4754. {
  4755. LastName = dc.LastName,
  4756. FirstName = dc.FirstName,
  4757. Sex = dc.Sex,
  4758. Birthday = dc.BirthDay,
  4759. Company = cc.CompanyFullName,
  4760. Job = dc.Job
  4761. })
  4762. .ToList();
  4763. foreach (var item in DeleClientList)
  4764. {
  4765. EncryptionProcessor.DecryptProperties(item);
  4766. }
  4767. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4768. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4769. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4770. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4771. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4772. if (dto.ExportType == 1) //明细表
  4773. {
  4774. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4775. {
  4776. //获取模板
  4777. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4778. //载入模板
  4779. Document doc = new Document(tempPath);
  4780. DocumentBuilder builder = new DocumentBuilder(doc);
  4781. //利用键值对存放数据
  4782. Dictionary<string, string> dic = new Dictionary<string, string>();
  4783. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4784. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4785. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4786. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4787. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4788. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4789. //境内费用(其他费用)
  4790. if (_EnterExitCosts.ChoiceOne == 1)
  4791. {
  4792. string row1_1 = "";
  4793. if (_EnterExitCosts.Visa > 0)
  4794. {
  4795. //insidePayTotal += _EnterExitCosts.Visa;
  4796. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4797. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4798. {
  4799. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4800. }
  4801. }
  4802. string row1_2 = "";
  4803. if (_EnterExitCosts.YiMiao > 0)
  4804. {
  4805. //insidePayTotal += _EnterExitCosts.YiMiao;
  4806. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4807. }
  4808. if (_EnterExitCosts.HeSuan > 0)
  4809. {
  4810. //insidePayTotal += _EnterExitCosts.HeSuan;
  4811. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4812. }
  4813. if (_EnterExitCosts.Service > 0)
  4814. {
  4815. //insidePayTotal += _EnterExitCosts.Service;
  4816. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4817. }
  4818. string row1_3 = "";
  4819. if (_EnterExitCosts.Safe > 0)
  4820. {
  4821. //insidePayTotal += _EnterExitCosts.Safe;
  4822. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4823. }
  4824. if (_EnterExitCosts.Ticket > 0)
  4825. {
  4826. //insidePayTotal += _EnterExitCosts.Ticket;
  4827. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4828. }
  4829. string row1 = "";
  4830. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4831. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4832. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4833. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4834. dic.Add("Row1Str", row1);
  4835. }
  4836. string airTotalStr = string.Empty,
  4837. airPriceStr = string.Empty;
  4838. //经济舱
  4839. if (_EnterExitCosts.SumJJC == 1)
  4840. {
  4841. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4842. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4843. }
  4844. //公务舱
  4845. if (_EnterExitCosts.SumGWC == 1)
  4846. {
  4847. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4848. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4849. }
  4850. //头等舱
  4851. if (_EnterExitCosts.SumTDC == 1)
  4852. {
  4853. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4854. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4855. }
  4856. dic.Add("AirTotalStr", airTotalStr);
  4857. dic.Add("AirPriceStr", airPriceStr);
  4858. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4859. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4860. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4861. int table1Row = 0,
  4862. table2Row = 0,
  4863. table3Row = 0,
  4864. table4Row = 0,
  4865. table5Row = 0;
  4866. //住宿费
  4867. if (_EnterExitCosts.ChoiceThree == 1)
  4868. {
  4869. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4870. table1Row = dac1.Count;
  4871. #region 填充word表格内容
  4872. for (int i = 0; i < dac1.Count; i++)
  4873. {
  4874. Grp_DayAndCost dac = dac1[i];
  4875. if (dac == null) continue;
  4876. builder.MoveToCell(0, i, 0, 0);
  4877. builder.Write("第" + dac.Days.ToString() + "晚:");
  4878. builder.MoveToCell(0, i, 1, 0);
  4879. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4880. //builder.Write(dac.Place == null ? "" : dac.Place);
  4881. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4882. builder.MoveToCell(0, i, 2, 0);
  4883. builder.Write("费用标准:");
  4884. string curr = "";
  4885. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4886. if (currData != null)
  4887. {
  4888. curr = currData.Name;
  4889. }
  4890. builder.MoveToCell(0, i, 3, 0);
  4891. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4892. builder.MoveToCell(0, i, 4, 0);
  4893. builder.Write("费用小计:");
  4894. builder.MoveToCell(0, i, 5, 0);
  4895. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4896. }
  4897. #endregion
  4898. }
  4899. else dic.Add("SubZS", "0.00");
  4900. //删除多余行
  4901. while (table1.Rows.Count > table1Row)
  4902. {
  4903. table1.Rows.RemoveAt(table1Row);
  4904. }
  4905. //伙食费
  4906. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4907. if (_EnterExitCosts.ChoiceFour == 1)
  4908. {
  4909. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4910. table2Row = dac2.Count;
  4911. #region 填充word表格内容
  4912. for (int i = 0; i < dac2.Count; i++)
  4913. {
  4914. Grp_DayAndCost dac = dac2[i];
  4915. if (dac == null) continue;
  4916. builder.MoveToCell(1, i, 0, 0);
  4917. builder.Write("第" + dac.Days.ToString() + "天:");
  4918. builder.MoveToCell(1, i, 1, 0);
  4919. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4920. builder.MoveToCell(1, i, 2, 0);
  4921. builder.Write("费用标准:");
  4922. string curr = "";
  4923. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4924. if (currData != null)
  4925. {
  4926. curr = currData.Name;
  4927. }
  4928. builder.MoveToCell(1, i, 3, 0);
  4929. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4930. builder.MoveToCell(1, i, 4, 0);
  4931. builder.Write("费用小计:");
  4932. builder.MoveToCell(1, i, 5, 0);
  4933. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4934. }
  4935. #endregion
  4936. }
  4937. else dic.Add("SubHS", "0.00");
  4938. //删除多余行
  4939. while (table2.Rows.Count > table2Row)
  4940. {
  4941. table2.Rows.RemoveAt(table2Row);
  4942. }
  4943. //公杂费
  4944. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4945. if (_EnterExitCosts.ChoiceFive == 1)
  4946. {
  4947. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4948. table3Row = dac3.Count;
  4949. #region 填充word表格内容
  4950. for (int i = 0; i < dac3.Count; i++)
  4951. {
  4952. Grp_DayAndCost dac = dac3[i];
  4953. if (dac == null) continue;
  4954. builder.MoveToCell(2, i, 0, 0);
  4955. builder.Write("第" + dac.Days.ToString() + "天:");
  4956. builder.MoveToCell(2, i, 1, 0);
  4957. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4958. builder.MoveToCell(2, i, 2, 0);
  4959. builder.Write("费用标准:");
  4960. string curr = "";
  4961. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4962. if (currData != null)
  4963. {
  4964. curr = currData.Name;
  4965. }
  4966. builder.MoveToCell(2, i, 3, 0);
  4967. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4968. builder.MoveToCell(2, i, 4, 0);
  4969. builder.Write("费用小计:");
  4970. builder.MoveToCell(2, i, 5, 0);
  4971. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4972. }
  4973. //删除多余行
  4974. while (table3.Rows.Count > table3Row)
  4975. {
  4976. table3.Rows.RemoveAt(table3Row);
  4977. }
  4978. #endregion
  4979. }
  4980. else dic.Add("SubGZF", "0.00");
  4981. //删除多余行
  4982. while (table3.Rows.Count > table3Row)
  4983. {
  4984. table3.Rows.RemoveAt(table3Row);
  4985. }
  4986. //培训费
  4987. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4988. if (_EnterExitCosts.ChoiceSix == 1)
  4989. {
  4990. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4991. dic.Add("SubPX", pxStr);
  4992. table4Row = dac4.Count;
  4993. #region 填充word表格内容
  4994. for (int i = 0; i < dac4.Count; i++)
  4995. {
  4996. Grp_DayAndCost dac = dac4[i];
  4997. if (dac == null) continue;
  4998. builder.MoveToCell(3, i, 0, 0);
  4999. builder.Write("第" + dac.Days.ToString() + "天:");
  5000. builder.MoveToCell(3, i, 1, 0);
  5001. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5002. builder.MoveToCell(3, i, 2, 0);
  5003. builder.Write("费用标准:");
  5004. string curr = "";
  5005. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5006. if (currData != null)
  5007. {
  5008. curr = currData.Name;
  5009. }
  5010. builder.MoveToCell(3, i, 3, 0);
  5011. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5012. builder.MoveToCell(3, i, 4, 0);
  5013. builder.Write("费用小计:");
  5014. builder.MoveToCell(3, i, 5, 0);
  5015. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5016. }
  5017. #endregion
  5018. }
  5019. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5020. //删除多余行
  5021. while (table4.Rows.Count > table4Row)
  5022. {
  5023. table4.Rows.RemoveAt(table4Row);
  5024. }
  5025. //其他费用
  5026. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5027. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5028. {
  5029. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5030. dic.Add("titleQi", qtStr);
  5031. table5Row = dac5.Count;
  5032. #region 填充word表格内容
  5033. for (int i = 0; i < dac5.Count; i++)
  5034. {
  5035. var dac = dac5[i];
  5036. if (dac == null) continue;
  5037. builder.MoveToCell(4, i, 0, 0);
  5038. builder.Write("第" + dac.Index.ToString() + "项:");
  5039. builder.MoveToCell(4, i, 1, 0);
  5040. builder.Write(dac.itemName);
  5041. builder.MoveToCell(4, i, 2, 0);
  5042. builder.Write("费用标准:");
  5043. builder.MoveToCell(4, i, 3, 0);
  5044. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5045. builder.MoveToCell(4, i, 4, 0);
  5046. builder.Write("费用小计:");
  5047. builder.MoveToCell(4, i, 5, 0);
  5048. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5049. builder.MoveToCell(4, i, 6, 0);
  5050. builder.Write("备注:");
  5051. builder.MoveToCell(4, i, 7, 0);
  5052. builder.Write(dac.Remark);
  5053. }
  5054. #endregion
  5055. }
  5056. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5057. //删除多余行
  5058. while (table5.Rows.Count > table5Row)
  5059. {
  5060. table5.Rows.RemoveAt(table5Row);
  5061. }
  5062. //加上其他费用
  5063. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5064. decimal subJJC = 0.00M,
  5065. subGWC = 0.00M,
  5066. subTDC = 0.00M;
  5067. //经济舱
  5068. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5069. //公务舱
  5070. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5071. //头等舱
  5072. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5073. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5074. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5075. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5076. #region 填充word模板书签内容
  5077. foreach (var key in dic.Keys)
  5078. {
  5079. Bookmark bookmark = doc.Range.Bookmarks[key];
  5080. if (bookmark != null)
  5081. {
  5082. builder.MoveToBookmark(key);
  5083. builder.Write(dic[key]);
  5084. }
  5085. }
  5086. #endregion
  5087. //文件名
  5088. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5089. AsposeHelper.removewatermark_v2180();
  5090. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5091. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5092. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5093. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5094. }
  5095. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5096. {
  5097. //获取模板
  5098. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5099. //载入模板
  5100. Document doc = new Document(tempPath);
  5101. DocumentBuilder builder = new DocumentBuilder(doc);
  5102. Dictionary<string, string> dic = new Dictionary<string, string>();
  5103. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5104. {
  5105. List<string> list = new List<string>();
  5106. try
  5107. {
  5108. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5109. foreach (var item in spilitArr)
  5110. {
  5111. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5112. var depCode = spDotandEmpty[2].Substring(0, 3);
  5113. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5114. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5115. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5116. list.Add(depName);
  5117. list.Add(arrName);
  5118. }
  5119. list = list.Distinct().ToList();
  5120. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5121. }
  5122. catch (Exception)
  5123. {
  5124. dic.Add("ReturnCode", "行程录入不正确!");
  5125. }
  5126. }
  5127. else
  5128. {
  5129. dic.Add("ReturnCode", "未录入行程!");
  5130. }
  5131. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5132. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5133. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5134. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5135. {
  5136. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5137. dic.Add("Day", sp.Days.ToString());
  5138. }
  5139. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5140. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5141. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5142. //dic.Add("Names", Names);
  5143. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5144. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5145. decimal dac1totalPrice = 0.00M;
  5146. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5147. foreach (var dac in dac1)
  5148. {
  5149. if (dac.SubTotal == 0.00M)
  5150. {
  5151. continue;
  5152. }
  5153. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5154. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5155. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5156. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5157. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5158. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5159. builder.Write(currency);//币种
  5160. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5161. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5162. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5163. builder.Write("");//人数
  5164. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5165. builder.Write("");//天数
  5166. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5167. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5168. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5169. decimal rate = 0.00M;
  5170. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5171. builder.Write(rate.ToString("#0.0000"));//汇率
  5172. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5173. decimal rbmPrice = dac.SubTotal;
  5174. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5175. accommodationStartIndex++;
  5176. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5177. }
  5178. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5179. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5180. {
  5181. table1.Rows.RemoveAt(i - 1);
  5182. foodandotherStartIndex--;
  5183. }
  5184. if (dac2.Count == dac3.Count)//国家 币种 金额
  5185. {
  5186. for (int i = 0; i < dac2.Count; i++)
  5187. {
  5188. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5189. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5190. }
  5191. }
  5192. decimal dac2totalPrice = 0.00M;
  5193. foreach (var dac in dac2)
  5194. {
  5195. if (dac.SubTotal == 0)
  5196. {
  5197. continue;
  5198. }
  5199. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5200. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5201. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5202. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5203. builder.Write(currency);//币种
  5204. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5205. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5206. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5207. builder.Write("");//人数
  5208. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5209. builder.Write("");//天数
  5210. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5211. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5212. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5213. decimal rate = 0.00M;
  5214. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5215. builder.Write(rate.ToString("#0.0000"));//汇率
  5216. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5217. decimal rbmPrice = dac.SubTotal;
  5218. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5219. foodandotherStartIndex++;
  5220. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5221. }
  5222. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5223. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5224. {
  5225. table1.Rows.RemoveAt(i - 1);
  5226. }
  5227. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5228. string otherFeeStr = "";
  5229. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5230. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5231. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5232. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5233. foreach (var otherInfo in dac5)
  5234. {
  5235. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5236. }
  5237. #endregion
  5238. if (otherFeeStr.Length > 0)
  5239. {
  5240. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5241. otherFeeStr = $"({otherFeeStr})";
  5242. dic.Add("OtherFeeStr", otherFeeStr);
  5243. }
  5244. //总计
  5245. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5246. //国际旅费
  5247. string outsideAir = string.Empty;
  5248. string allPriceAir = string.Empty;
  5249. if (_EnterExitCosts.SumJJC == 1)
  5250. {
  5251. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5252. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5253. }
  5254. if (_EnterExitCosts.SumGWC == 1)
  5255. {
  5256. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5257. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5258. }
  5259. if (_EnterExitCosts.SumTDC == 1)
  5260. {
  5261. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5262. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5263. }
  5264. dic.Add("InTravelPrice", $"({outsideAir})");
  5265. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5266. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5267. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5268. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5269. foreach (var key in dic.Keys)
  5270. {
  5271. builder.MoveToBookmark(key);
  5272. builder.Write(dic[key]);
  5273. }
  5274. //模板文件名
  5275. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5276. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5277. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5278. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5279. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5280. }
  5281. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5282. {
  5283. //获取模板
  5284. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5285. //载入模板
  5286. WorkbookDesigner designer = new WorkbookDesigner();
  5287. designer.Workbook = new Workbook(tempPath);
  5288. Dictionary<string, string> dic = new Dictionary<string, string>();
  5289. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5290. {
  5291. List<string> list = new List<string>();
  5292. try
  5293. {
  5294. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5295. foreach (var item in spilitArr)
  5296. {
  5297. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5298. var depCode = spDotandEmpty[2].Substring(0, 3);
  5299. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5300. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5301. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5302. list.Add(depName);
  5303. list.Add(arrName);
  5304. }
  5305. list = list.Distinct().ToList();
  5306. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5307. }
  5308. catch (Exception)
  5309. {
  5310. dic.Add("ReturnCode", "行程录入不正确!");
  5311. }
  5312. }
  5313. else
  5314. {
  5315. dic.Add("ReturnCode", "未录入行程!");
  5316. }
  5317. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5318. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5319. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5320. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5321. {
  5322. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5323. dic.Add("Day", sp.Days.ToString());
  5324. }
  5325. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5326. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5327. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5328. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5329. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5330. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5331. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5332. designer.SetDataSource("Name", Names);
  5333. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5334. designer.SetDataSource("Day", dic["Day"] + "天");
  5335. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5336. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5337. int startIndex = 10;
  5338. const int startIndexcopy = 10;
  5339. if (dac2.Count == dac3.Count)//国家 币种 金额
  5340. {
  5341. for (int i = 0; i < dac2.Count; i++)
  5342. {
  5343. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5344. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5345. }
  5346. }
  5347. DataTable dtdac1 = new DataTable();
  5348. List<string> place = new List<string>();
  5349. dtdac1.Columns.AddRange(new DataColumn[] {
  5350. new DataColumn(){ ColumnName = "city"},
  5351. new DataColumn(){ ColumnName = "curr"},
  5352. new DataColumn(){ ColumnName = "criterion"},
  5353. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5354. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5355. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5356. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5357. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5358. });
  5359. DataTable dtdac2 = new DataTable();
  5360. dtdac2.Columns.AddRange(new DataColumn[] {
  5361. new DataColumn(){ ColumnName = "city"},
  5362. new DataColumn(){ ColumnName = "curr"},
  5363. new DataColumn(){ ColumnName = "criterion"},
  5364. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5365. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5366. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5367. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5368. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5369. });
  5370. dtdac1.TableName = "tb1";
  5371. dtdac2.TableName = "tb2";
  5372. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5373. foreach (var item in dac1)
  5374. {
  5375. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5376. if (place.Contains(item.Place))
  5377. {
  5378. continue;
  5379. }
  5380. DataRow row = dtdac1.NewRow();
  5381. row["city"] = item.Place;
  5382. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5383. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5384. row["curr"] = currency;
  5385. row["rate"] = rate.ToString("#0.0000");
  5386. row["criterion"] = item.Cost.ToString("#0.00");
  5387. row["number"] = 1;
  5388. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5389. //row["costRMB"] = rbmPrice;
  5390. dtdac1.Rows.Add(row);
  5391. place.Add(item.Place);
  5392. }
  5393. place = new List<string>();
  5394. foreach (var item in dac2)
  5395. {
  5396. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5397. if (place.Contains(item.Place))
  5398. {
  5399. continue;
  5400. }
  5401. DataRow row = dtdac2.NewRow();
  5402. row["city"] = item.Place;
  5403. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5404. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5405. row["curr"] = currency;
  5406. row["rate"] = rate.ToString("#0.0000");
  5407. row["criterion"] = item.Cost.ToString("#0.00");
  5408. row["number"] = 1;
  5409. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5410. //row["cost"] = item.SubTotal;
  5411. //row["costRMB"] = rbmPrice;
  5412. dtdac2.Rows.Add(row);
  5413. place.Add(item.Place);
  5414. //dac2totalPrice += rbmPrice;
  5415. }
  5416. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5417. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5418. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5419. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5420. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5421. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5422. string cell4Str1 = string.Empty;
  5423. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5424. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5425. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5426. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5427. string cellStr = $" 5.其他费用(";
  5428. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5429. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5430. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5431. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5432. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5433. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5434. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5435. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5436. foreach (var otherInfo in dac5)
  5437. {
  5438. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5439. }
  5440. #endregion
  5441. if (cellStr.Length > 8)
  5442. {
  5443. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5444. }
  5445. cellStr += ")";
  5446. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5447. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5448. decimal pxFee = dac4.Sum(it => it.Cost);
  5449. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5450. string celllastStr1 = "";
  5451. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5452. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5453. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5454. celllastStr1 += $",国际旅费 元";
  5455. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5456. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5457. designer.SetDataSource("cell4Str", cell4Str);
  5458. designer.SetDataSource("cellStr", cellStr);
  5459. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5460. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5461. designer.SetDataSource("celllastStr", celllastStr);
  5462. Workbook wb = designer.Workbook;
  5463. var sheet = wb.Worksheets[0];
  5464. //绑定datatable数据集
  5465. designer.SetDataSource(dtdac1);
  5466. designer.SetDataSource(dtdac2);
  5467. designer.Process();
  5468. var rowStart = dtdac1.Rows.Count;
  5469. while (rowStart > 0)
  5470. {
  5471. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5472. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5473. startIndex++;
  5474. rowStart--;
  5475. }
  5476. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5477. startIndex += 1; //总计行
  5478. rowStart = dtdac2.Rows.Count;
  5479. while (rowStart > 0)
  5480. {
  5481. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5482. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5483. startIndex++;
  5484. rowStart--;
  5485. }
  5486. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5487. wb.CalculateFormula(true);
  5488. //模板文件名
  5489. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5490. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5491. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5492. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5493. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5494. }
  5495. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5496. {
  5497. //获取模板
  5498. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5499. //载入模板
  5500. Document doc = new Document(tempPath);
  5501. DocumentBuilder builder = new DocumentBuilder(doc);
  5502. Dictionary<string, string> dic = new Dictionary<string, string>();
  5503. dic.Add("GroupName", _DelegationInfo.TeamName);
  5504. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5505. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5506. string missionLeaderJob = "";//负责人job
  5507. int groupNumber = 0; //团人数
  5508. if (DeleClientList.Count > 0)
  5509. {
  5510. missionLeader = DeleClientList[0]?.Name ?? "";
  5511. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5512. }
  5513. dic.Add("MissionLeader", missionLeader); //团负责人
  5514. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5515. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5516. #region MyRegion
  5517. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5518. //{
  5519. // List<string> list = new List<string>();
  5520. // try
  5521. // {
  5522. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5523. // foreach (var item in spilitArr)
  5524. // {
  5525. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5526. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5527. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5528. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5529. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5530. // list.Add(depName);
  5531. // list.Add(arrName);
  5532. // }
  5533. // list = list.Distinct().ToList();
  5534. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5535. // }
  5536. // catch (Exception)
  5537. // {
  5538. // dic.Add("ReturnCode", "行程录入不正确!");
  5539. // }
  5540. //}
  5541. //else
  5542. //{
  5543. // dic.Add("ReturnCode", "未录入行程!");
  5544. //}
  5545. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5546. dic.Add("ReturnCode", string.Join("、", countrys));
  5547. #endregion
  5548. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5549. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5550. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5551. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5552. //{
  5553. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5554. // dic.Add("Day", sp.Days.ToString());
  5555. //}
  5556. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5557. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5558. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5559. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5560. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5561. //培训人员名单
  5562. int cultivateRowIndex = 7;
  5563. foreach (var item in DeleClientList)
  5564. {
  5565. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5566. builder.Write(item.Name);
  5567. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5568. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5569. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5570. string birthDay = "";
  5571. if (item.Birthday != null)
  5572. {
  5573. DateTime dt = Convert.ToDateTime(item.Birthday);
  5574. birthDay = $"{dt.Year}.{dt.Month}";
  5575. }
  5576. builder.Write(birthDay);
  5577. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5578. builder.Write(item.Company);
  5579. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5580. builder.Write(item.Job);
  5581. cultivateRowIndex++;
  5582. }
  5583. //删除多余行
  5584. //cultivateRowIndex -= 2;
  5585. int delRows = 10 + 7 - cultivateRowIndex;
  5586. if (delRows > 0)
  5587. {
  5588. for (int i = 0; i < delRows; i++)
  5589. {
  5590. table1.Rows.RemoveAt(cultivateRowIndex);
  5591. //cultivateRowIndex++;
  5592. }
  5593. }
  5594. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5595. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5596. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5597. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5598. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5599. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5600. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5601. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5602. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5603. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5604. //其他费用
  5605. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5606. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5607. //其他费用合计
  5608. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5609. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5610. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5611. //公务舱合计
  5612. //国际旅费
  5613. string outsideJJ = "";
  5614. string allPriceJJ = "";
  5615. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5616. {
  5617. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5618. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5619. }
  5620. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5621. {
  5622. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5623. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5624. }
  5625. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5626. {
  5627. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5628. dic.Add("AirFeeTotal", airFeeTotalStr);
  5629. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5630. dic.Add("FeeTotal", feeTotalStr);
  5631. }
  5632. foreach (var key in dic.Keys)
  5633. {
  5634. builder.MoveToBookmark(key);
  5635. builder.Write(dic[key]);
  5636. }
  5637. //模板文件名
  5638. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5639. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5640. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5641. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5642. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5643. }
  5644. }
  5645. else if (dto.ExportType == 2) //表格
  5646. {
  5647. //利用键值对存放数据
  5648. Dictionary<string, string> dic = new Dictionary<string, string>();
  5649. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5650. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5651. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5652. dic.Add("Day", sp.Days.ToString());
  5653. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5654. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5655. {
  5656. //获取模板
  5657. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5658. //载入模板
  5659. Document doc = new Document(tempPath);
  5660. DocumentBuilder builder = new DocumentBuilder(doc);
  5661. dic.Add("TeamName", _DelegationInfo.TeamName);
  5662. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5663. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5664. string missionLeaderName = "",
  5665. missionLeaderJob = "";
  5666. if (DeleClientList.Count > 0)
  5667. {
  5668. missionLeaderName = DeleClientList[0].Name;
  5669. missionLeaderJob = DeleClientList[0].Job;
  5670. }
  5671. dic.Add("MissionLeaderName", missionLeaderName);
  5672. dic.Add("MissionLeaderJob", missionLeaderJob);
  5673. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5674. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5675. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5676. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5677. int rowCount = 10;//总人数行
  5678. int startRowIndex = 7; //起始行
  5679. for (int i = 0; i < DeleClientList.Count; i++)
  5680. {
  5681. builder.MoveToCell(0, startRowIndex, 0, 0);
  5682. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5683. builder.MoveToCell(0, startRowIndex, 1, 0);
  5684. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5685. builder.Write(sex);//性别
  5686. builder.MoveToCell(0, startRowIndex, 2, 0);
  5687. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5688. builder.MoveToCell(0, startRowIndex, 3, 0);
  5689. builder.Write(DeleClientList[i].Company);//工作单位
  5690. builder.MoveToCell(0, startRowIndex, 4, 0);
  5691. builder.Write(DeleClientList[i].Job);//职务及级别
  5692. builder.MoveToCell(0, startRowIndex, 5, 0);
  5693. builder.Write("");//人员属性
  5694. builder.MoveToCell(0, startRowIndex, 6, 0);
  5695. builder.Write("");//上次出国时间
  5696. startRowIndex++;
  5697. }
  5698. int nullRow = rowCount - DeleClientList.Count;//空行
  5699. for (int i = 0; i < nullRow; i++)
  5700. {
  5701. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5702. }
  5703. foreach (var key in dic.Keys)
  5704. {
  5705. builder.MoveToBookmark(key);
  5706. builder.Write(dic[key]);
  5707. }
  5708. //模板文件名
  5709. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5710. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5711. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5712. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5713. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5714. }
  5715. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5716. {
  5717. //获取模板
  5718. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5719. //载入模板
  5720. Document doc = new Document(tempPath);
  5721. DocumentBuilder builder = new DocumentBuilder(doc);
  5722. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5723. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5724. dic.Add("Names", Names);
  5725. int accommodationRows = 12, foodandotherRows = 12;
  5726. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5727. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5728. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5729. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5730. int accommodationStartIndex = 6;
  5731. decimal dac1totalPrice = 0.00M;
  5732. foreach (var dac in dac1)
  5733. {
  5734. if (dac.SubTotal == 0)
  5735. {
  5736. continue;
  5737. }
  5738. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5739. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5740. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5741. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5742. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5743. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5744. builder.Write(currency);//币种
  5745. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5746. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5747. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5748. builder.Write("");//人数
  5749. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5750. builder.Write("");//天数
  5751. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5752. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5753. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5754. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5755. builder.Write(rate.ToString("#0.0000"));//汇率
  5756. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5757. decimal rbmPrice = rate * dac.SubTotal;
  5758. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5759. accommodationStartIndex++;
  5760. dac1totalPrice += rbmPrice;
  5761. }
  5762. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5763. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5764. builder.Write("小计");
  5765. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5766. builder.Write(dac1totalPrice.ToString("#0.00"));
  5767. accommodationStartIndex++;
  5768. int nullRow = accommodationRows - dac1.Count;
  5769. //删除空行
  5770. //if (nullRow > 0)
  5771. //{
  5772. // int rowIndex = accommodationStartIndex;
  5773. // for (int i = 0; i < nullRow; i++)
  5774. // {
  5775. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5776. // row.Remove();
  5777. // rowIndex++;
  5778. // }
  5779. //}
  5780. if (dac2.Count == dac3.Count)//国家 币种 金额
  5781. {
  5782. for (int i = 0; i < dac2.Count; i++)
  5783. {
  5784. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5785. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5786. }
  5787. }
  5788. int foodandotherStartIndex = 19;//
  5789. decimal dac2totalPrice = 0.00M;
  5790. foreach (var dac in dac2)
  5791. {
  5792. if (dac.SubTotal == 0)
  5793. {
  5794. continue;
  5795. }
  5796. //foodandotherStartIndex = 12;
  5797. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5798. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5799. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5800. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5801. builder.Write(currency);//币种
  5802. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5803. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5804. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5805. builder.Write("");//人数
  5806. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5807. builder.Write("");//天数
  5808. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5809. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5810. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5811. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5812. builder.Write(rate.ToString("#0.0000"));//汇率
  5813. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5814. decimal rbmPrice = rate * dac.SubTotal;
  5815. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5816. foodandotherStartIndex++;
  5817. dac2totalPrice += rbmPrice;
  5818. }
  5819. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5820. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5821. //删除空行
  5822. //if (dac2.Count < foodandotherRows)
  5823. //{
  5824. // while (table2.Rows.Count > dac2.Count)
  5825. // {
  5826. // table2.Rows.RemoveAt(dac2.Count);
  5827. // }
  5828. //}
  5829. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5830. string otherFeeStr = "";
  5831. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5832. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5833. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5834. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5835. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5836. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5837. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5838. foreach (var otherInfo in dac5)
  5839. {
  5840. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5841. }
  5842. #endregion
  5843. if (otherFeeStr.Length > 0)
  5844. {
  5845. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5846. otherFeeStr = $"({otherFeeStr})";
  5847. dic.Add("OtherFeeStr", otherFeeStr);
  5848. }
  5849. foreach (var key in dic.Keys)
  5850. {
  5851. builder.MoveToBookmark(key);
  5852. builder.Write(dic[key]);
  5853. }
  5854. //模板文件名
  5855. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5856. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5857. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5858. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5859. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5860. }
  5861. }
  5862. else if (dto.ExportType == 3)
  5863. {
  5864. if (dto.SubTypeId == 1) //团组成员名单
  5865. {
  5866. if (DeleClientList.Count < 1)
  5867. {
  5868. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5869. }
  5870. //获取模板
  5871. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5872. //载入模板
  5873. Document doc = new Document(tempPath);
  5874. DocumentBuilder builder = new DocumentBuilder(doc);
  5875. //获取word里所有表格
  5876. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5877. //获取所填表格的序数
  5878. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5879. var rowStart = tableOne.Rows[0]; //获取第1行
  5880. //循环赋值
  5881. for (int i = 0; i < DeleClientList.Count; i++)
  5882. {
  5883. builder.MoveToCell(0, i + 1, 0, 0);
  5884. builder.Write(DeleClientList[i].Name);
  5885. builder.MoveToCell(0, i + 1, 1, 0);
  5886. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5887. builder.Write(sex);
  5888. builder.MoveToCell(0, i + 1, 2, 0);
  5889. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5890. builder.MoveToCell(0, i + 1, 3, 0);
  5891. builder.Write(DeleClientList[i].Company);
  5892. builder.MoveToCell(0, i + 1, 4, 0);
  5893. builder.Write(DeleClientList[i].Job);
  5894. }
  5895. //删除多余行
  5896. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5897. {
  5898. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5899. }
  5900. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5901. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5902. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5903. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5904. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5905. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5906. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5907. }
  5908. }
  5909. return Ok(JsonView(400, "操作失败!", ""));
  5910. }
  5911. catch (Exception ex)
  5912. {
  5913. return Ok(JsonView(400, ex.Message, ""));
  5914. }
  5915. }
  5916. /// <summary>
  5917. /// 获取三公费用标准city
  5918. /// </summary>
  5919. /// <param name="placeData"></param>
  5920. /// <param name="nationalTravelFeeId"></param>
  5921. /// <returns></returns>
  5922. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5923. {
  5924. string _city = string.Empty;
  5925. if (placeData.Count < 1) return _city;
  5926. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5927. if (data == null) return _city;
  5928. string country = data.Country;
  5929. string city = data.City;
  5930. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5931. else _city = city;
  5932. return _city;
  5933. }
  5934. /// <summary>
  5935. /// 团组模块 - 出入境费用 - 明细表导出
  5936. /// </summary>
  5937. /// <returns></returns>
  5938. [HttpPost]
  5939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5940. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5941. {
  5942. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5943. if (data.Code != 0)
  5944. {
  5945. return Ok(JsonView(false, data.Msg));
  5946. }
  5947. return Ok(JsonView(true, data.Msg, data.Data));
  5948. }
  5949. /// <summary>
  5950. /// 团组模块 - 出入境费用 - 一键清空
  5951. /// </summary>
  5952. /// <returns></returns>
  5953. [HttpPost]
  5954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5955. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5956. {
  5957. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5958. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5959. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5960. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5961. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5962. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5963. .SetColumns(x => new Grp_DayOtherPrice
  5964. {
  5965. IsDel = 1,
  5966. DeleteUserId = dto.UserId,
  5967. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5968. })
  5969. .ExecuteCommandAsync();
  5970. if (_view.Code == 0)
  5971. {
  5972. return Ok(JsonView(true, "操作成功"));
  5973. }
  5974. return Ok(JsonView(false, "操作失败"));
  5975. }
  5976. /// <summary>
  5977. /// 团组模块 - 出入境费用 - 子项删除
  5978. /// </summary>
  5979. /// <returns></returns>
  5980. [HttpPost]
  5981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5982. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5983. {
  5984. try
  5985. {
  5986. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5987. if (data.Code != 0)
  5988. {
  5989. return Ok(JsonView(false, data.Msg));
  5990. }
  5991. return Ok(JsonView(true, "操作成功!", data.Data));
  5992. }
  5993. catch (Exception ex)
  5994. {
  5995. return Ok(JsonView(false, ex.Message));
  5996. }
  5997. }
  5998. /// <summary>
  5999. /// 删除三公其他费用
  6000. /// </summary>
  6001. /// <param name="dto"></param>
  6002. /// <returns></returns>
  6003. [HttpPost]
  6004. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6005. {
  6006. var jw = JsonView(false,"删除失败!");
  6007. var data = new Grp_DayOtherPrice()
  6008. {
  6009. Id = dto.Id,
  6010. IsDel = 1,
  6011. DeleteUserId = dto.DeleteUserId,
  6012. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6013. };
  6014. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6015. if (del > 0)
  6016. {
  6017. jw.Code = 200;
  6018. jw.Msg = "删除成功!";
  6019. }
  6020. return Ok(jw);
  6021. }
  6022. /// <summary>
  6023. /// 团组模块 - 出入境国家费用标准 List
  6024. /// </summary>
  6025. /// <returns></returns>
  6026. [HttpPost]
  6027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6028. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6029. {
  6030. try
  6031. {
  6032. Stopwatch sw = new Stopwatch();
  6033. sw.Start();
  6034. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6035. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6036. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6037. Where gntf.Isdel = 0");
  6038. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6039. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6040. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6041. //foreach (var item in nationalTravel)
  6042. //{
  6043. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6044. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6045. // if (otherData != null)
  6046. // {
  6047. // cityData.Remove(otherData);
  6048. // cityData.Add(otherData);
  6049. // }
  6050. // nationalTravelFeeData1.Add(new
  6051. // {
  6052. // Country = item.Country,
  6053. // CityData = cityData
  6054. // });
  6055. //}
  6056. sw.Stop();
  6057. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6058. }
  6059. catch (Exception ex)
  6060. {
  6061. return Ok(JsonView(false, ex.Message));
  6062. throw;
  6063. }
  6064. }
  6065. /// <summary>
  6066. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6067. /// </summary>
  6068. /// <returns></returns>
  6069. [HttpPost]
  6070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6071. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6072. {
  6073. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6074. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6075. List<string> countryData = new List<string>();
  6076. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6077. countryData = countryData.Distinct().ToList();
  6078. List<dynamic> dataSource = new List<dynamic>();
  6079. foreach (var item in countryData)
  6080. {
  6081. List<string> cityData1 = new List<string>();
  6082. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6083. var countryData2 = new
  6084. {
  6085. CountryName = item,
  6086. CityData = cityData1
  6087. };
  6088. dataSource.Add(countryData2);
  6089. }
  6090. return Ok(JsonView(true, "查询成功!", dataSource));
  6091. }
  6092. /// <summary>
  6093. /// 团组模块 - 出入境国家费用标准 Page List
  6094. /// </summary>
  6095. /// <returns></returns>
  6096. [HttpPost]
  6097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6098. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6099. {
  6100. int portId = dto.PortType;
  6101. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6102. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6103. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6104. string whereSql = string.Empty;
  6105. if (!string.IsNullOrEmpty(dto.Country))
  6106. {
  6107. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6108. }
  6109. if (!string.IsNullOrEmpty(dto.City))
  6110. {
  6111. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6112. }
  6113. string pageSql = string.Format(@"Select * From (
  6114. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6115. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6116. From Grp_NationalTravelFee gntf
  6117. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6118. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6119. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6120. RefAsync<int> total = 0;
  6121. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6122. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6123. }
  6124. /// <summary>
  6125. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6126. /// </summary>
  6127. /// <returns></returns>
  6128. [HttpPost]
  6129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6130. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6131. {
  6132. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6133. int portId = dto.PortType;
  6134. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6135. string whereSql = string.Empty;
  6136. if (!string.IsNullOrEmpty(dto.Country))
  6137. {
  6138. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6139. }
  6140. if (!string.IsNullOrEmpty(dto.City))
  6141. {
  6142. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6143. }
  6144. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6145. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6146. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6147. From Grp_NationalTravelFee gntf
  6148. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6149. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6150. Where gntf.Isdel = 0 {0} ", whereSql);
  6151. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6152. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6153. }
  6154. /// <summary>
  6155. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6156. /// </summary>
  6157. /// <returns></returns>
  6158. [HttpPost]
  6159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6160. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6161. {
  6162. try
  6163. {
  6164. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6165. if (data.Code != 0)
  6166. {
  6167. return Ok(JsonView(false, data.Msg));
  6168. }
  6169. return Ok(JsonView(true, "操作成功!", data.Data));
  6170. }
  6171. catch (Exception ex)
  6172. {
  6173. return Ok(JsonView(false, ex.Message));
  6174. }
  6175. }
  6176. /// <summary>
  6177. /// 团组模块 - 出入境国家费用标准 - Del
  6178. /// </summary>
  6179. /// <returns></returns>
  6180. [HttpPost]
  6181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6182. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6183. {
  6184. try
  6185. {
  6186. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6187. {
  6188. Id = dto.Id,
  6189. DeleteUserId = dto.DeleteUserId,
  6190. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6191. IsDel = 1
  6192. };
  6193. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6194. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6195. .WhereColumns(it => new { it.Id })
  6196. .ExecuteCommandAsync();
  6197. if (delStatus <= 0)
  6198. {
  6199. return Ok(JsonView(false, "删除失败!"));
  6200. }
  6201. return Ok(JsonView(true, "操作成功!"));
  6202. }
  6203. catch (Exception ex)
  6204. {
  6205. return Ok(JsonView(false, ex.Message));
  6206. }
  6207. }
  6208. /// <summary>
  6209. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6210. /// 注:Get 请求Headers 加 Token
  6211. /// </summary>
  6212. /// <param name="groupId"></param>
  6213. /// <returns></returns>
  6214. [HttpGet("{groupId}")]
  6215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6216. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6217. {
  6218. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6219. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6220. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6221. data.ForEach(x =>
  6222. {
  6223. x.CreateUserId = _currUserInfo.UserId;
  6224. });
  6225. if (data.Count > 0)
  6226. {
  6227. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6228. if (add > 0)
  6229. {
  6230. return Ok(JsonView(true, "操作成功!"));
  6231. }
  6232. }
  6233. return Ok(JsonView(false, "未操作!"));
  6234. }
  6235. #endregion
  6236. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6237. /// <summary>
  6238. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6239. /// </summary>
  6240. /// <returns></returns>
  6241. [HttpPost]
  6242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6243. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  6244. {
  6245. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6246. //SetDataInfoView
  6247. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6248. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6249. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6250. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6251. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6252. //默认币种显示
  6253. var _currencyInfos = _currencyInit;
  6254. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6255. if (_currencyRate.Count > 0)
  6256. {
  6257. foreach (var item in _currencyInfos)
  6258. {
  6259. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6260. if (rateInfo != null)
  6261. {
  6262. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6263. rate1 *= 1.035M;
  6264. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6265. }
  6266. }
  6267. }
  6268. return Ok(JsonView(true, "查询成功!", new
  6269. {
  6270. WordTypeData = _WordTypeData,
  6271. ExcelTypeData = _ExcelTypeData,
  6272. CurrencyInit = _currencyInfos
  6273. }));
  6274. }
  6275. /// <summary>
  6276. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6277. /// </summary>
  6278. /// <returns></returns>
  6279. [HttpPost]
  6280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6281. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6282. {
  6283. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6284. RefAsync<int> total = 0;
  6285. int diId = 0;
  6286. var status = int.TryParse(dto.GroupName, out diId);
  6287. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6288. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6289. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  6290. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  6291. .Select(x => new
  6292. {
  6293. Id = x.Id,
  6294. GroupName = x.TeamName
  6295. })
  6296. .OrderByDescending(x => x.Id)
  6297. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6298. return Ok(JsonView(true, "查询成功!", data, total));
  6299. }
  6300. /// <summary>
  6301. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6302. /// </summary>
  6303. /// <returns></returns>
  6304. [HttpPost]
  6305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6306. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6307. {
  6308. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6309. RefAsync<int> total = 0;
  6310. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6311. .Where(x => x.IsDel == 0 && x.STid == 66)
  6312. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6313. .Select(x => new
  6314. {
  6315. id = x.Id,
  6316. name = x.Name,
  6317. remark = x.Remark,
  6318. })
  6319. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6320. return Ok(JsonView(true, "查询成功!", data, total));
  6321. }
  6322. /// <summary>
  6323. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种基础数据Data
  6324. /// </summary>
  6325. /// <returns></returns>
  6326. [HttpPost]
  6327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6328. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  6329. {
  6330. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6331. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6332. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  6333. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  6334. var groupOtherRateData = groupRateData.TeamRates;
  6335. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6336. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  6337. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  6338. groupOtherRateData = groupOtherRateData
  6339. .Select(x => new TeamRateDescAddCurrencyIdView {
  6340. CurrencyId = x.CurrencyId,
  6341. CurrencyName = x.CurrencyName,
  6342. CurrencyCode = x.CurrencyCode,
  6343. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  6344. }).ToList();
  6345. return Ok(JsonView(true, "查询成功!", groupOtherRateData));
  6346. }
  6347. /// <summary>
  6348. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6349. /// </summary>
  6350. /// <returns></returns>
  6351. [HttpPost]
  6352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6353. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6354. {
  6355. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6356. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6357. var tipsData = new List<int>() {1,2,3 };
  6358. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6359. if (dto.TipsType == 1)
  6360. {
  6361. //默认币种显示
  6362. var _currencyInfos = _currencyInit;
  6363. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6364. List<dynamic> reteInfos = new List<dynamic>();
  6365. if (_currencyRate.Count > 0)
  6366. {
  6367. foreach (var item in _currencyInfos)
  6368. {
  6369. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6370. if (rateInfo != null)
  6371. {
  6372. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6373. decimal rate1 = item.Rate;
  6374. rate1 *= 1.03M;
  6375. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6376. reteInfos.Add(new
  6377. {
  6378. currCode = item.CurrencyCode,
  6379. currName = item.CurrencyName,
  6380. rate = rate2,
  6381. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6382. });
  6383. }
  6384. }
  6385. }
  6386. return Ok(JsonView(true, "查询成功!", reteInfos));
  6387. }
  6388. else if (dto.TipsType == 2)
  6389. {
  6390. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6391. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6392. }
  6393. else if (dto.TipsType == 3)
  6394. {
  6395. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6396. return Ok(JsonView(true, "查询成功!", airData.Data));
  6397. }
  6398. return Ok(JsonView(false));
  6399. }
  6400. /// <summary>
  6401. /// 团组模块 - 出入境国家费用标准-移动端 List
  6402. /// </summary>
  6403. /// <returns></returns>
  6404. [HttpPost]
  6405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6406. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6407. {
  6408. Stopwatch sw = new Stopwatch();
  6409. sw.Start();
  6410. RefAsync<int> total = 0;
  6411. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6412. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6413. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6414. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6415. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6416. .Select((ntf, sd, u) => new
  6417. {
  6418. Id = ntf.Id,
  6419. Area = $"{ntf.Country}-{ntf.City}",
  6420. Currency = ntf.Currency,
  6421. CurrencyCode = sd.Name,
  6422. CurrencyName = sd.Remark,
  6423. RoomCost = ntf.RoomCost,
  6424. FoodCost = ntf.FoodCost,
  6425. PublicCost = ntf.PublicCost,
  6426. LastUpdateUserId = ntf.LastUpdateUserId,
  6427. LastUpdateUserName = u.CnName,
  6428. LastUpdateTime = ntf.LastUpdateTime,
  6429. })
  6430. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6431. sw.Stop();
  6432. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6433. }
  6434. /// <summary>
  6435. /// 团组模块 - 出入境费用-移动端 - Info
  6436. /// </summary>
  6437. /// <returns></returns>
  6438. [HttpPost]
  6439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6440. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  6441. {
  6442. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6443. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6444. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  6445. return Ok(data);
  6446. }
  6447. /// <summary>
  6448. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  6449. /// </summary>
  6450. /// <returns></returns>
  6451. [HttpPost]
  6452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6453. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  6454. {
  6455. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6456. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6457. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6458. var mobileInfo = new EnterExitCostMobileParentInfoView();
  6459. if (eecInfo == null) return Ok(mobileInfo);
  6460. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  6461. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  6462. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6463. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6464. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6465. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6466. {
  6467. SubId = dac.Id,
  6468. DiId = dac.DiId,
  6469. Type = dac.Type,
  6470. Days = dac.Days,
  6471. NationalTravelFeeId = dac.NationalTravelFeeId,
  6472. Arae = $"{ntf.Country}-{ntf.City}",
  6473. Cost = dac.Cost,
  6474. Currency = dac.Currency,
  6475. CurrencyName = sd.Name,
  6476. SubTotal = dac.SubTotal,
  6477. })
  6478. .ToList();
  6479. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  6480. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  6481. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  6482. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  6483. mobileInfo.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
  6484. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  6485. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  6486. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  6487. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  6488. //其他款项
  6489. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6490. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6491. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6492. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6493. .OrderBy((dop, sd1, sd2) => dop.Index)
  6494. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6495. {
  6496. SubId = dop.Id,
  6497. DiId = dop.Diid,
  6498. Index = dop.Index,
  6499. SetDataId = dop.SetDataId,
  6500. SetDataName = sd1.Name,
  6501. Cost = dop.Cost,
  6502. Currency = dop.Currency,
  6503. CurrencyName = sd2.Remark,
  6504. SubTotal = dop.SubTotal,
  6505. Remark = dop.Remark,
  6506. })
  6507. .ToArray();
  6508. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  6509. return Ok(mobileInfo);
  6510. }
  6511. /// <summary>
  6512. /// 团组模块 - 出入境费用-移动端 - SubInfo
  6513. /// </summary>
  6514. /// <returns></returns>
  6515. [HttpPost]
  6516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6517. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  6518. {
  6519. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6520. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6521. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  6522. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  6523. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6524. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  6525. var subType = dto.SubType;
  6526. if (subType == 1) //1:境内费用
  6527. {
  6528. var oneData = new ChoiceOneMobileSubInfoView()
  6529. {
  6530. Id = eecInfo.Id,
  6531. ChoiceOne = eecInfo.ChoiceOne,
  6532. ChoiceOneTotalCost = eecInfo.InsidePay,
  6533. Visa = eecInfo.Visa,
  6534. VisaRemark = eecInfo.VisaRemark,
  6535. YiMiao = eecInfo.YiMiao,
  6536. HeSuan = eecInfo.HeSuan,
  6537. Service = eecInfo.Service,
  6538. Ticket = eecInfo.Ticket,
  6539. Safe = eecInfo.Safe,
  6540. };
  6541. return Ok(JsonView(oneData));
  6542. }
  6543. else if (subType == 2) //2:国际旅费
  6544. {
  6545. var twoData = new ChoiceTwoMobileSubInfoView() {
  6546. Id = eecInfo.Id,
  6547. ChoiceTwoJJ = eecInfo.SumJJC,
  6548. OutsideJJPay = eecInfo.OutsideJJPay,
  6549. ChoiceTwoGW = eecInfo.SumGWC,
  6550. OutsideGWPay = eecInfo.OutsideGWPay,
  6551. ChoiceTwoTD = eecInfo.SumTDC,
  6552. OutsideTDPay = eecInfo.OutsideTDPay,
  6553. AirJJ = eecInfo.AirJJ,
  6554. AirGW = eecInfo.AirGW,
  6555. AirTD = eecInfo.AirTD,
  6556. CityTranffic = eecInfo.CityTranffic
  6557. };
  6558. return Ok(JsonView(twoData));
  6559. }
  6560. else if (subType == 3) //3:住宿费
  6561. {
  6562. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6563. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6564. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6565. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  6566. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6567. {
  6568. SubId = dac.Id,
  6569. DiId = dac.DiId,
  6570. Type = dac.Type,
  6571. Days = dac.Days,
  6572. NationalTravelFeeId = dac.NationalTravelFeeId,
  6573. Arae = $"{ntf.Country}-{ntf.City}",
  6574. Cost = dac.Cost,
  6575. Currency = dac.Currency,
  6576. CurrencyName = sd.Name,
  6577. SubTotal = dac.SubTotal,
  6578. })
  6579. .ToArray();
  6580. var data = new ChoiceThreeMobileSubInfoView() {
  6581. ParentId = eecInfo.Id,
  6582. ChoiceThree = eecInfo.ChoiceThree,
  6583. ChoiceThreeTotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6584. Details = dayAndCostDatas
  6585. };
  6586. return Ok(JsonView(data));
  6587. }
  6588. else if (subType == 4) //4:伙食费
  6589. {
  6590. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6591. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6592. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6593. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  6594. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6595. {
  6596. SubId = dac.Id,
  6597. DiId = dac.DiId,
  6598. Type = dac.Type,
  6599. Days = dac.Days,
  6600. NationalTravelFeeId = dac.NationalTravelFeeId,
  6601. Arae = $"{ntf.Country}-{ntf.City}",
  6602. Cost = dac.Cost,
  6603. Currency = dac.Currency,
  6604. CurrencyName = sd.Name,
  6605. SubTotal = dac.SubTotal,
  6606. })
  6607. .ToArray();
  6608. var data = new ChoiceFourMobileSubInfoView()
  6609. {
  6610. ParentId = eecInfo.Id,
  6611. ChoiceFour = eecInfo.ChoiceFour,
  6612. ChoiceFourTotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6613. Details = dayAndCostDatas
  6614. };
  6615. return Ok(JsonView(data));
  6616. }
  6617. else if (subType == 5) //5:公杂费
  6618. {
  6619. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6620. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6621. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6622. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  6623. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6624. {
  6625. SubId = dac.Id,
  6626. DiId = dac.DiId,
  6627. Type = dac.Type,
  6628. Days = dac.Days,
  6629. NationalTravelFeeId = dac.NationalTravelFeeId,
  6630. Arae = $"{ntf.Country}-{ntf.City}",
  6631. Cost = dac.Cost,
  6632. Currency = dac.Currency,
  6633. CurrencyName = sd.Name,
  6634. SubTotal = dac.SubTotal,
  6635. })
  6636. .ToArray();
  6637. var data = new ChoiceFiveMobileSubInfoView()
  6638. {
  6639. ParentId = eecInfo.Id,
  6640. ChoiceFive = eecInfo.ChoiceFive,
  6641. ChoiceFiveTotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6642. Details = dayAndCostDatas
  6643. };
  6644. return Ok(JsonView(data));
  6645. }
  6646. else if (subType == 6) //6:培训费
  6647. {
  6648. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6649. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6650. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6651. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  6652. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6653. {
  6654. SubId = dac.Id,
  6655. DiId = dac.DiId,
  6656. Type = dac.Type,
  6657. Days = dac.Days,
  6658. NationalTravelFeeId = dac.NationalTravelFeeId,
  6659. Arae = $"{ntf.Country}-{ntf.City}",
  6660. Cost = dac.Cost,
  6661. Currency = dac.Currency,
  6662. CurrencyName = sd.Name,
  6663. SubTotal = dac.SubTotal,
  6664. })
  6665. .ToArray();
  6666. var data = new ChoiceSixMobileSubInfoView()
  6667. {
  6668. ParentId = eecInfo.Id,
  6669. ChoiceSix = eecInfo.ChoiceSix,
  6670. ChoiceSixTotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6671. Details = dayAndCostDatas
  6672. };
  6673. return Ok(JsonView(data));
  6674. }
  6675. else if (subType == 7) //7:其他
  6676. {
  6677. //其他款项
  6678. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6679. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6680. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6681. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6682. .OrderBy((dop, sd1, sd2) => dop.Index)
  6683. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6684. {
  6685. SubId = dop.Id,
  6686. DiId = dop.Diid,
  6687. Index = dop.Index,
  6688. SetDataId = dop.SetDataId,
  6689. SetDataName = sd1.Name,
  6690. Cost = dop.Cost,
  6691. Currency = dop.Currency,
  6692. CurrencyName = sd2.Remark,
  6693. SubTotal = dop.SubTotal,
  6694. Remark = dop.Remark,
  6695. })
  6696. .ToArray();
  6697. var data = new ChoiceSevenMobileSubInfoView()
  6698. {
  6699. ParentId = eecInfo.Id,
  6700. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  6701. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  6702. Details = otherData
  6703. };
  6704. return Ok(JsonView(data));
  6705. }
  6706. return Ok(JsonView(false));
  6707. }
  6708. #region op
  6709. /// <summary>
  6710. /// 移动端更新费用消息通知
  6711. /// </summary>
  6712. /// <param name="diid"></param>
  6713. /// <param name="id"></param>
  6714. /// <param name="currUserId"></param>
  6715. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  6716. {
  6717. try
  6718. {
  6719. ////生成默认文件pdf并且通知人员
  6720. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6721. //{
  6722. // DiId = diid,
  6723. // ExportType = 1,
  6724. // SubTypeId = 1005
  6725. //}, "pdf");
  6726. ////发送通知
  6727. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6728. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  6729. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  6730. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  6731. ////汇率信息记录
  6732. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  6733. }
  6734. catch (Exception ex)
  6735. {
  6736. //记录日志
  6737. throw;
  6738. }
  6739. }
  6740. /// <summary>
  6741. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  6742. /// </summary>
  6743. /// <returns></returns>
  6744. [HttpPost]
  6745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6746. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  6747. {
  6748. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6749. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6750. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6751. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  6752. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  6753. int id = dto.Id;
  6754. if (id <= 0) //add
  6755. {
  6756. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  6757. if (add < 1) return Ok(JsonView(false));
  6758. id = add;
  6759. }
  6760. else //update
  6761. {
  6762. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  6763. if (upd < 1) return Ok(JsonView(false));
  6764. }
  6765. #region 汇率变更时更改币种相关费用
  6766. var opDayCosts = new List<Grp_DayAndCost>();
  6767. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  6768. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  6769. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  6770. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  6771. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6772. .Select((dac, sd) => new {
  6773. dac.Id,
  6774. dac.DiId,
  6775. CurrencyCode = sd.Name,
  6776. dac.Cost
  6777. })
  6778. .ToList();
  6779. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6780. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  6781. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6782. .Select((dop, sd) => new {
  6783. dop.Id,
  6784. dop.Diid,
  6785. CurrencyCode = sd.Name,
  6786. dop.Cost
  6787. })
  6788. .ToList();
  6789. if (dayCosts.Count > 0)
  6790. {
  6791. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6792. foreach (var dc in new_dayCosts)
  6793. {
  6794. var thisCurrency = dc.Key.ToUpper();
  6795. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6796. if (thisRate == 0.00M) continue;
  6797. foreach (var dcSub in dc)
  6798. {
  6799. opDayCosts.Add(new Grp_DayAndCost() {
  6800. Id = dcSub.Id,
  6801. DiId = dcSub.DiId,
  6802. Cost = dcSub.Cost,
  6803. SubTotal = dcSub.Cost * thisRate,
  6804. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6805. });
  6806. }
  6807. }
  6808. if (opDayCosts.Count > 0)
  6809. {
  6810. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6811. }
  6812. }
  6813. if (dayOtherCosts.Count > 0)
  6814. {
  6815. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6816. foreach (var dc in new_dayOtherCosts)
  6817. {
  6818. var thisCurrency = dc.Key.ToUpper();
  6819. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6820. if (thisRate == 0.00M) continue;
  6821. foreach (var dcSub in dc)
  6822. {
  6823. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  6824. {
  6825. Id = dcSub.Id,
  6826. Diid = dcSub.Diid,
  6827. Cost = dcSub.Cost,
  6828. SubTotal = dcSub.Cost * thisRate,
  6829. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6830. });
  6831. }
  6832. }
  6833. if (opDayOtherCosts.Count > 0)
  6834. {
  6835. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6836. }
  6837. }
  6838. #endregion
  6839. //消息通知
  6840. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  6841. return Ok(JsonView(true));
  6842. }
  6843. /// <summary>
  6844. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  6845. /// </summary>
  6846. /// <returns></returns>
  6847. [HttpPost]
  6848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6849. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  6850. {
  6851. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6852. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6853. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6854. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  6855. int id = dto.Id;
  6856. if (id <= 0) //add
  6857. {
  6858. checkboxInfo.CreateUserId = dto.CurrUserId;
  6859. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6860. if (add < 1) return Ok(JsonView(false));
  6861. }
  6862. else //update
  6863. {
  6864. var upd = await _sqlSugar.Updateable(checkboxInfo)
  6865. .UpdateColumns(x => new {
  6866. x.ChoiceOne,
  6867. x.ChoiceTwo,
  6868. x.SumJJC,
  6869. x.SumGWC,
  6870. x.SumTDC,
  6871. x.ChoiceThree,
  6872. x.ChoiceFour,
  6873. x.ChoiceFive,
  6874. x.ChoiceSix,
  6875. x.OtherExpenses_Checked
  6876. })
  6877. .Where(x => x.Id == id)
  6878. .ExecuteCommandAsync();
  6879. if (upd < 1) return Ok(JsonView(false));
  6880. }
  6881. return Ok(JsonView(true));
  6882. }
  6883. /// <summary>
  6884. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  6885. /// </summary>
  6886. /// <returns></returns>
  6887. [HttpPost]
  6888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6889. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  6890. {
  6891. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6892. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6893. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6894. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6895. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  6896. int id = dto.Id;
  6897. if (id <= 0) //add
  6898. {
  6899. info.CreateUserId = dto.CurrUserId;
  6900. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  6901. if (add < 1) return Ok(JsonView(false));
  6902. id = add;
  6903. }
  6904. else //update
  6905. {
  6906. var upd = await _sqlSugar.Updateable(info)
  6907. .UpdateColumns(x => new {
  6908. x.ChoiceOne,
  6909. x.InsidePay,
  6910. x.VisaRemark,
  6911. x.Visa,
  6912. x.Service,
  6913. x.Safe,
  6914. x.Ticket,
  6915. x.HeSuan,
  6916. x.YiMiao,
  6917. })
  6918. .Where(x => x.Id == id)
  6919. .ExecuteCommandAsync();
  6920. if (upd < 1) return Ok(JsonView(false));
  6921. }
  6922. //消息通知
  6923. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6924. return Ok(JsonView(new { itemTotal = info.InsidePay }));
  6925. }
  6926. /// <summary>
  6927. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  6928. /// </summary>
  6929. /// <returns></returns>
  6930. [HttpPost]
  6931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6932. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  6933. {
  6934. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6935. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6936. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6937. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6938. info.AirJJC_Checked = dto.ChoiceTwoJJ;
  6939. info.AirGWC_Checked = dto.ChoiceTwoGW;
  6940. info.AirTDC_Checked = dto.ChoiceTwoTD;
  6941. int id = dto.Id;
  6942. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  6943. if (id <= 0) //add
  6944. {
  6945. info.CreateUserId = dto.CurrUserId;
  6946. var addInfo = await _sqlSugar.Insertable(info).ExecuteReturnEntityAsync();
  6947. if (addInfo == null) return Ok(JsonView(false));
  6948. id = addInfo.Id;
  6949. }
  6950. else //update
  6951. {
  6952. var upd = await _sqlSugar.Updateable(info)
  6953. .UpdateColumns(x => new {
  6954. x.AirJJC_Checked,
  6955. x.OutsideJJPay,
  6956. x.AirGWC_Checked,
  6957. x.OutsideGWPay,
  6958. x.AirTDC_Checked,
  6959. x.OutsideTDPay,
  6960. x.AirJJ,
  6961. x.AirGW,
  6962. x.AirTD,
  6963. x.CityTranffic
  6964. })
  6965. .Where(x => x.Id == id)
  6966. .ExecuteCommandAsync();
  6967. if (upd > 0) return Ok(JsonView(false));
  6968. }
  6969. jjcItemTotal = info.AirJJ + info.CityTranffic;
  6970. gwcItemTotal = info.AirGW + info.CityTranffic;
  6971. tdcItemTotal = info.AirTD + info.CityTranffic;
  6972. //消息通知
  6973. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6974. return Ok(JsonView(new
  6975. {
  6976. choiceTwoJJ = dto.ChoiceTwoJJ,
  6977. jjcItemTotal = jjcItemTotal,
  6978. choiceTwoGW = dto.ChoiceTwoGW,
  6979. gwcItemTotal = gwcItemTotal,
  6980. choiceTwoTD = dto.ChoiceTwoTD,
  6981. tdcItemTotal = tdcItemTotal
  6982. }));
  6983. }
  6984. /// <summary>
  6985. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  6986. /// </summary>
  6987. /// <returns></returns>
  6988. [HttpPost]
  6989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6990. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  6991. {
  6992. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6993. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6994. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6995. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  6996. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  6997. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  6998. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  6999. var infos = infos1.Select(x => new Grp_DayAndCost
  7000. {
  7001. Id = x.Id,
  7002. DiId = dto.DiId,
  7003. Type = dto.FeeType,
  7004. Days = x.Days,
  7005. NationalTravelFeeId = x.NationalTravelFeeId,
  7006. Cost = x.Cost,
  7007. Currency = x.Currency,
  7008. SubTotal = x.SubTotal,
  7009. CreateUserId = dto.CurrUserId
  7010. })
  7011. .ToList();
  7012. var adds = infos.Where(x => x.Id <= 0).ToList();
  7013. var upds = infos.Where(x => x.Id > 0).ToList();
  7014. if (adds.Count > 0)
  7015. {
  7016. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7017. if (add < 1) return Ok(JsonView(false));
  7018. }
  7019. if (upds.Count > 0)
  7020. {
  7021. var upd = await _sqlSugar.Updateable(adds)
  7022. .UpdateColumns(x => new
  7023. {
  7024. x.Days,
  7025. x.NationalTravelFeeId,
  7026. x.Cost,
  7027. x.Currency,
  7028. x.SubTotal
  7029. })
  7030. .WhereColumns(x => new { x.Id })
  7031. .ExecuteCommandAsync();
  7032. if (upd < 1) return Ok(JsonView(false));
  7033. }
  7034. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7035. //消息通知
  7036. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7037. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7038. return Ok(JsonView(new { itemTotal = itemTotal }));
  7039. }
  7040. /// <summary>
  7041. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  7042. /// </summary>
  7043. /// <returns></returns>
  7044. [HttpPost]
  7045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7046. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  7047. {
  7048. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  7049. int parentId = dto.ParentId, subId = dto.SubId, feeType = dto.FeeType;
  7050. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7051. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7052. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7053. if (!feeTypeIds.Contains(feeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7054. var parentInfo = new Grp_EnterExitCost();
  7055. parentInfo.Id = dto.ParentId;
  7056. parentInfo.CreateUserId = dto.CurrUserId;
  7057. if (feeType == 1) parentInfo.ChoiceThree = dto.IsSelect;
  7058. else if (feeType == 2) parentInfo.ChoiceFour = dto.IsSelect;
  7059. else if (feeType == 3) parentInfo.ChoiceFive = dto.IsSelect;
  7060. else if (feeType == 4) parentInfo.ChoiceSix = dto.IsSelect;
  7061. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  7062. subInfo.Id = subId;
  7063. subInfo.CreateUserId = dto.CurrUserId;
  7064. _sqlSugar.BeginTran();
  7065. //主表op
  7066. if (parentId < 1) //添加
  7067. {
  7068. var parentAdd = await _sqlSugar.Insertable(parentInfo).ExecuteCommandAsync();
  7069. if (parentAdd < 1)
  7070. {
  7071. _sqlSugar.RollbackTran();
  7072. return Ok(JsonView(false));
  7073. }
  7074. //子表op
  7075. if (subId < 1)
  7076. {
  7077. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7078. if (subAdd < 1)
  7079. {
  7080. _sqlSugar.RollbackTran();
  7081. return Ok(JsonView(false));
  7082. }
  7083. }
  7084. else
  7085. {
  7086. var subUpd = await _sqlSugar.Updateable(subInfo)
  7087. .UpdateColumns(x => new
  7088. {
  7089. x.Days,
  7090. x.NationalTravelFeeId,
  7091. x.Cost,
  7092. x.Currency,
  7093. x.SubTotal
  7094. })
  7095. .WhereColumns(x => new { x.Id })
  7096. .ExecuteCommandAsync();
  7097. if (subUpd < 1)
  7098. {
  7099. _sqlSugar.RollbackTran();
  7100. return Ok(JsonView(false));
  7101. }
  7102. }
  7103. }
  7104. else
  7105. {
  7106. var parentUpd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  7107. .SetColumnsIF(feeType == 1, it => it.ChoiceThree == dto.IsSelect)
  7108. .SetColumnsIF(feeType == 2, it => it.ChoiceFour == dto.IsSelect)
  7109. .SetColumnsIF(feeType == 3, it => it.ChoiceFive == dto.IsSelect)
  7110. .SetColumnsIF(feeType == 4, it => it.ChoiceSix == dto.IsSelect)
  7111. .Where(it => it.Id == parentId)
  7112. .ExecuteCommandAsync();
  7113. if (parentUpd < 1)
  7114. {
  7115. _sqlSugar.RollbackTran();
  7116. return Ok(JsonView(false));
  7117. }
  7118. //子表op
  7119. if (subId < 1)
  7120. {
  7121. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7122. if (subAdd < 1)
  7123. {
  7124. _sqlSugar.RollbackTran();
  7125. return Ok(JsonView(false));
  7126. }
  7127. }
  7128. else
  7129. {
  7130. var subUpd = await _sqlSugar.Updateable(subInfo)
  7131. .UpdateColumns(x => new
  7132. {
  7133. x.Days,
  7134. x.NationalTravelFeeId,
  7135. x.Cost,
  7136. x.Currency,
  7137. x.SubTotal
  7138. })
  7139. .WhereColumns(x => new { x.Id })
  7140. .ExecuteCommandAsync();
  7141. if (subUpd < 1)
  7142. {
  7143. _sqlSugar.RollbackTran();
  7144. return Ok(JsonView(false));
  7145. }
  7146. }
  7147. }
  7148. _sqlSugar.CommitTran();
  7149. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7150. //消息通知
  7151. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7152. return Ok(JsonView(new { isSelect = dto.IsSelect, itemTotal = itemTotal }));
  7153. }
  7154. /// <summary>
  7155. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7156. /// </summary>
  7157. /// <returns></returns>
  7158. [HttpPost]
  7159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7160. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  7161. {
  7162. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7163. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7164. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7165. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  7166. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  7167. {
  7168. Id = x.Id,
  7169. Diid = dto.DiId,
  7170. SetDataId = x.SetDataId,
  7171. Index = x.Index,
  7172. Cost = x.Cost,
  7173. Currency = x.Currency,
  7174. SubTotal = x.SubTotal,
  7175. CreateUserId = dto.CurrUserId,
  7176. Remark = x.Remark
  7177. }).ToList();
  7178. var adds = infos.Where(x => x.Id <= 0).ToList();
  7179. var upds = infos.Where(x => x.Id > 0).ToList();
  7180. if (adds.Count > 0)
  7181. {
  7182. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7183. if (add < 1) return Ok(JsonView(false));
  7184. }
  7185. if (upds.Count > 0)
  7186. {
  7187. var upd = await _sqlSugar.Updateable(adds)
  7188. .UpdateColumns(x => new
  7189. {
  7190. x.Index,
  7191. x.SetDataId,
  7192. x.Cost,
  7193. x.Currency,
  7194. x.SubTotal,
  7195. x.Remark
  7196. })
  7197. .WhereColumns(x => new { x.Id })
  7198. .ExecuteCommandAsync();
  7199. if (upd < 1) return Ok(JsonView(false));
  7200. }
  7201. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7202. //消息通知
  7203. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7204. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7205. return Ok(JsonView(new { itemTotal = itemTotal }));
  7206. }
  7207. /// <summary>
  7208. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7209. /// </summary>
  7210. /// <returns></returns>
  7211. [HttpPost]
  7212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7213. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  7214. {
  7215. int parentId = dto.ParentId, subId = dto.SubId;
  7216. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7217. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7218. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7219. var parentInfo = new Grp_EnterExitCost();
  7220. parentInfo.Id = parentId;
  7221. parentInfo.OtherExpenses_Checked = dto.IsSelect;
  7222. parentInfo.CreateUserId = dto.CurrUserId;
  7223. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  7224. subInfo.Id = subId;
  7225. subInfo.CreateUserId = dto.CurrUserId;
  7226. #region 主表op
  7227. _sqlSugar.BeginTran();
  7228. //主表op
  7229. if (parentId < 1)
  7230. {
  7231. var parentAdd = await _sqlSugar.Insertable(parentInfo).ExecuteCommandAsync();
  7232. if (parentAdd < 1)
  7233. {
  7234. _sqlSugar.RollbackTran();
  7235. return Ok(JsonView(false));
  7236. }
  7237. #region 子表op
  7238. if (subId < 1)//add
  7239. {
  7240. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7241. if (subAdd < 1)
  7242. {
  7243. _sqlSugar.RollbackTran();
  7244. return Ok(JsonView(false));
  7245. }
  7246. }
  7247. else //upd
  7248. {
  7249. var subUpd = await _sqlSugar.Updateable(subInfo)
  7250. .UpdateColumns(x => new
  7251. {
  7252. x.Index,
  7253. x.SetDataId,
  7254. x.Cost,
  7255. x.Currency,
  7256. x.SubTotal,
  7257. x.Remark
  7258. })
  7259. .WhereColumns(x => new { x.Id })
  7260. .ExecuteCommandAsync();
  7261. if (subUpd < 1)
  7262. {
  7263. _sqlSugar.RollbackTran();
  7264. return Ok(JsonView(false));
  7265. }
  7266. }
  7267. #endregion
  7268. }
  7269. else
  7270. {
  7271. var parentUpd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  7272. .SetColumns(it => it.OtherExpenses_Checked == dto.IsSelect)
  7273. .Where(it => it.Id == parentId)
  7274. .ExecuteCommandAsync();
  7275. if (parentUpd < 1)
  7276. {
  7277. _sqlSugar.RollbackTran();
  7278. return Ok(JsonView(false));
  7279. }
  7280. #region 子表op
  7281. if (subId < 1)//add
  7282. {
  7283. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7284. if (subAdd < 1)
  7285. {
  7286. _sqlSugar.RollbackTran();
  7287. return Ok(JsonView(false));
  7288. }
  7289. }
  7290. else //upd
  7291. {
  7292. var subUpd = await _sqlSugar.Updateable(subInfo)
  7293. .UpdateColumns(x => new
  7294. {
  7295. x.Index,
  7296. x.SetDataId,
  7297. x.Cost,
  7298. x.Currency,
  7299. x.SubTotal,
  7300. x.Remark
  7301. })
  7302. .WhereColumns(x => new { x.Id })
  7303. .ExecuteCommandAsync();
  7304. if (subUpd < 1)
  7305. {
  7306. _sqlSugar.RollbackTran();
  7307. return Ok(JsonView(false));
  7308. }
  7309. }
  7310. #endregion
  7311. }
  7312. _sqlSugar.CommitTran();
  7313. #endregion
  7314. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7315. //消息通知
  7316. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7317. return Ok(JsonView(new { isSelect = dto.IsSelect, itemTotal = itemTotal }));
  7318. }
  7319. #endregion
  7320. #endregion
  7321. #region 签证费用录入
  7322. /// <summary>
  7323. /// 根据diid查询签证费用列表
  7324. /// </summary>
  7325. /// <param name="dto"></param>
  7326. /// <returns></returns>
  7327. [HttpPost]
  7328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7329. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  7330. {
  7331. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  7332. if (groupData.Code != 0)
  7333. {
  7334. return Ok(JsonView(false, groupData.Msg));
  7335. }
  7336. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7337. }
  7338. /// <summary>
  7339. /// 根据签证费用Id查询单条数据及c表数据
  7340. /// </summary>
  7341. /// <param name="dto"></param>
  7342. /// <returns></returns>
  7343. [HttpPost]
  7344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7345. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  7346. {
  7347. Result groupData = await _visaPriceRep.PostVisaById(dto);
  7348. if (groupData.Code != 0)
  7349. {
  7350. return Ok(JsonView(false, groupData.Msg));
  7351. }
  7352. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7353. }
  7354. /// <summary>
  7355. /// 签证费用删除
  7356. /// </summary>
  7357. /// <param name="dto"></param>
  7358. /// <returns></returns>
  7359. [HttpPost]
  7360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7361. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  7362. {
  7363. _sqlSugar.BeginTran();
  7364. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  7365. if (!res)
  7366. {
  7367. _sqlSugar.RollbackTran();
  7368. return Ok(JsonView(false, "删除失败"));
  7369. }
  7370. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  7371. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  7372. .SetColumns(a => new Grp_CreditCardPayment()
  7373. {
  7374. IsDel = 1,
  7375. DeleteUserId = dto.DeleteUserId,
  7376. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7377. })
  7378. .ExecuteCommand();
  7379. if (resSub < 1)
  7380. {
  7381. _sqlSugar.RollbackTran();
  7382. return Ok(JsonView(false, "删除失败"));
  7383. }
  7384. _sqlSugar.CommitTran();
  7385. return Ok(JsonView(true, "删除成功!"));
  7386. }
  7387. /// <summary>
  7388. /// 签证费用录入下拉框初始化
  7389. /// </summary>
  7390. /// <returns></returns>
  7391. [HttpPost]
  7392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7393. public async Task<IActionResult> VisaPriceAddSelect()
  7394. {
  7395. //支付方式
  7396. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  7397. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  7398. //币种
  7399. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  7400. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  7401. //乘客类型
  7402. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  7403. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  7404. //卡类型
  7405. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  7406. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  7407. //代办费类型
  7408. var agencyFeeTypeData = new List<dynamic>() {
  7409. new { id = 0 , Text = "未选择" },
  7410. new { id = 1 , Text = "小公务" },
  7411. new { id = 2 , Text = "大公务" },
  7412. };
  7413. //签证费用标准国家Data
  7414. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  7415. var data = new
  7416. {
  7417. Payment = _Payment,
  7418. CurrencyList = _CurrencyList,
  7419. PassengerType = _PassengerType,
  7420. BankCard = _BankCard,
  7421. AgencyFeeType = agencyFeeTypeData,
  7422. CountryFeeData = visaCountryFeeData
  7423. };
  7424. return Ok(JsonView(true, "查询成功!", data));
  7425. }
  7426. /// <summary>
  7427. /// 签证费用录入操作(Status:1.新增,2.修改)
  7428. /// </summary>
  7429. /// <param name="dto"></param>
  7430. /// <returns></returns>
  7431. [HttpPost]
  7432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7433. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  7434. {
  7435. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  7436. if (groupData.Code != 0)
  7437. {
  7438. return Ok(JsonView(false, groupData.Msg));
  7439. }
  7440. #region 应用推送
  7441. try
  7442. {
  7443. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7444. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7445. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7446. //2024-10-21 新增LZ UID
  7447. var userIds = new List<int>() { 21 };
  7448. string title = $"系统通知";
  7449. string content = "";
  7450. var diId = dto.DiId;
  7451. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7452. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7453. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7454. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7455. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7456. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7457. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7458. }
  7459. catch (Exception ex)
  7460. {
  7461. }
  7462. #endregion
  7463. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7464. }
  7465. #endregion
  7466. #region 签证提成录入
  7467. /// <summary>
  7468. /// 签证提成录入
  7469. /// 基础数据
  7470. /// </summary>
  7471. /// <param name="_dto"></param>
  7472. /// <returns></returns>
  7473. [HttpGet]
  7474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7475. public async Task<IActionResult> VisaCommissionInit()
  7476. {
  7477. return Ok(await _visaCommissionRep.Init());
  7478. }
  7479. /// <summary>
  7480. /// 签证提成录入
  7481. /// Item
  7482. /// </summary>
  7483. /// <param name="_dto"></param>
  7484. /// <returns></returns>
  7485. [HttpPost]
  7486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7487. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  7488. {
  7489. var validator = new VisaCommissionItemDtoValidator();
  7490. var validatorRes = await validator.ValidateAsync(_dto);
  7491. if (!validatorRes.IsValid)
  7492. {
  7493. StringBuilder sb = new StringBuilder();
  7494. foreach (var item in validatorRes.Errors)
  7495. {
  7496. sb.AppendLine(item.ErrorMessage);
  7497. }
  7498. return Ok(JsonView(false, sb.ToString()));
  7499. }
  7500. return Ok(await _visaCommissionRep.Item(_dto));
  7501. }
  7502. /// <summary>
  7503. /// 签证提成录入
  7504. /// Save
  7505. /// </summary>
  7506. /// <param name="_dto"></param>
  7507. /// <returns></returns>
  7508. [HttpPost]
  7509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7510. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  7511. {
  7512. //参数验证
  7513. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  7514. foreach (var item in _dto.Items)
  7515. {
  7516. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  7517. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  7518. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  7519. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  7520. }
  7521. return Ok(await _visaCommissionRep.Save(_dto));
  7522. }
  7523. /// <summary>
  7524. /// 签证提成录入
  7525. /// Create
  7526. /// </summary>
  7527. /// <param name="_dto"></param>
  7528. /// <returns></returns>
  7529. [HttpPost]
  7530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7531. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  7532. {
  7533. var validator = new VisaCommissionCreateDtoValidator();
  7534. var validatorRes = await validator.ValidateAsync(_dto);
  7535. if (!validatorRes.IsValid)
  7536. {
  7537. StringBuilder sb = new StringBuilder();
  7538. foreach (var item in validatorRes.Errors)
  7539. {
  7540. sb.AppendLine(item.ErrorMessage);
  7541. }
  7542. return Ok(JsonView(false, sb.ToString()));
  7543. }
  7544. return Ok(await _visaCommissionRep.Create(_dto));
  7545. }
  7546. /// <summary>
  7547. /// 签证提成录入
  7548. /// Put(编辑)
  7549. /// </summary>
  7550. /// <param name="id"></param>
  7551. /// <param name="_dto"></param>
  7552. /// <returns></returns>
  7553. [HttpPut]
  7554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7555. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  7556. {
  7557. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7558. var validator = new VisaCommissionCreateDtoValidator();
  7559. var validatorRes = await validator.ValidateAsync(_dto);
  7560. if (!validatorRes.IsValid)
  7561. {
  7562. StringBuilder sb = new StringBuilder();
  7563. foreach (var item in validatorRes.Errors)
  7564. {
  7565. sb.AppendLine(item.ErrorMessage);
  7566. }
  7567. return Ok(JsonView(false, sb.ToString()));
  7568. }
  7569. return Ok(await _visaCommissionRep.Edit(id, _dto));
  7570. }
  7571. /// <summary>
  7572. /// 签证提成录入
  7573. /// Del
  7574. /// </summary>
  7575. /// <param name="id"></param>
  7576. /// <param name="currUserId"></param>
  7577. /// <returns></returns>
  7578. [HttpPost]
  7579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7580. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  7581. {
  7582. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7583. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  7584. return Ok(await _visaCommissionRep.Del(id, currUserId));
  7585. }
  7586. #endregion
  7587. #region op费用录入
  7588. /// <summary>
  7589. /// 根据diid查询op费用列表
  7590. /// </summary>
  7591. /// <param name="dto"></param>
  7592. /// <returns></returns>
  7593. [HttpPost]
  7594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7595. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  7596. {
  7597. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  7598. if (groupData.Code != 0)
  7599. {
  7600. return Ok(JsonView(false, groupData.Msg));
  7601. }
  7602. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7603. }
  7604. /// <summary>
  7605. /// 根据op费用Id查询单条数据及c表数据
  7606. /// </summary>
  7607. /// <param name="dto"></param>
  7608. /// <returns></returns>
  7609. [HttpPost]
  7610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7611. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  7612. {
  7613. try
  7614. {
  7615. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  7616. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  7617. var data = new
  7618. {
  7619. CarTouristGuideGround = _groupData,
  7620. CreditCardPayment = _creditCardPayment
  7621. };
  7622. return Ok(JsonView(true, "查询成功!", data));
  7623. }
  7624. catch (Exception ex)
  7625. {
  7626. return Ok(JsonView(false, "程序错误!"));
  7627. }
  7628. }
  7629. /// <summary>
  7630. /// op费用删除
  7631. /// </summary>
  7632. /// <param name="dto"></param>
  7633. /// <returns></returns>
  7634. [HttpPost]
  7635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7636. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  7637. {
  7638. try
  7639. {
  7640. _sqlSugar.BeginTran();
  7641. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7642. if (!res)
  7643. {
  7644. return Ok(JsonView(false, "删除失败"));
  7645. }
  7646. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  7647. {
  7648. IsDel = 1,
  7649. DeleteUserId = dto.DeleteUserId,
  7650. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7651. }).ExecuteCommandAsync();
  7652. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  7653. {
  7654. IsDel = 1,
  7655. DeleteUserId = dto.DeleteUserId,
  7656. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7657. }).ExecuteCommandAsync();
  7658. #region 删除超支相关数据
  7659. //删除导入的超支数据
  7660. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  7661. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  7662. {
  7663. IsDel = 1,
  7664. DeleteUserId = dto.DeleteUserId,
  7665. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7666. }).ExecuteCommand();
  7667. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  7668. {
  7669. IsDel = 1,
  7670. DeleteUserId = dto.DeleteUserId,
  7671. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7672. }).ExecuteCommand();
  7673. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  7674. {
  7675. IsDel = 1,
  7676. DeleteUserId = dto.DeleteUserId,
  7677. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7678. }).ExecuteCommand();
  7679. #endregion
  7680. _sqlSugar.CommitTran();
  7681. return Ok(JsonView(true, "删除成功!"));
  7682. }
  7683. catch (Exception ex)
  7684. {
  7685. _sqlSugar.RollbackTran();
  7686. return Ok(JsonView(false, "程序错误!" + ex.Message));
  7687. }
  7688. }
  7689. /// <summary>
  7690. /// op费用录入操作(Status:1.新增,2.修改)
  7691. /// </summary>
  7692. /// <param name="dto"></param>
  7693. /// <returns></returns>
  7694. [HttpPost]
  7695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7696. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  7697. {
  7698. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  7699. if (groupData.Code != 0)
  7700. {
  7701. return Ok(JsonView(false, groupData.Msg));
  7702. }
  7703. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7704. }
  7705. /// <summary>
  7706. /// 填写费用详细页面初始化绑定
  7707. /// </summary>
  7708. /// <param name="dto"></param>
  7709. /// <returns></returns>
  7710. [HttpPost]
  7711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7712. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  7713. {
  7714. try
  7715. {
  7716. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  7717. if (groupData.Code != 0)
  7718. {
  7719. return Ok(JsonView(false, groupData.Msg));
  7720. }
  7721. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7722. }
  7723. catch (Exception ex)
  7724. {
  7725. return Ok(JsonView(false, ex.Message));
  7726. }
  7727. }
  7728. /// <summary>
  7729. /// 根据op费用Id查询详细数据
  7730. /// </summary>
  7731. /// <param name="dto"></param>
  7732. /// <returns></returns>
  7733. [HttpPost]
  7734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7735. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  7736. {
  7737. try
  7738. {
  7739. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  7740. if (groupData.Code != 0)
  7741. {
  7742. return Ok(JsonView(false, groupData.Msg));
  7743. }
  7744. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7745. }
  7746. catch (Exception ex)
  7747. {
  7748. return Ok(JsonView(false, ex.Message));
  7749. }
  7750. }
  7751. /// <summary>
  7752. /// OP费用录入填写详情
  7753. /// </summary>
  7754. /// <param name="dto"></param>
  7755. /// <returns></returns>
  7756. [HttpPost]
  7757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7758. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  7759. {
  7760. try
  7761. {
  7762. #region 参数校验
  7763. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  7764. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  7765. if (di == null) return Ok(JsonView(false, "团组错误!"));
  7766. #endregion
  7767. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  7768. if (groupData.Code != 0)
  7769. {
  7770. return Ok(JsonView(false, groupData.Msg));
  7771. }
  7772. //自动审核
  7773. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  7774. #region 应用推送
  7775. try
  7776. {
  7777. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7778. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7779. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7780. //2024-10-21 新增LZ UID
  7781. var userIds = new List<int>() { 21 };
  7782. string title = $"系统通知";
  7783. var diId = dto.DiId;
  7784. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7785. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7786. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  7787. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7788. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7789. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7790. }
  7791. catch (Exception ex)
  7792. {
  7793. }
  7794. #endregion
  7795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7796. }
  7797. catch (Exception ex)
  7798. {
  7799. return Ok(JsonView(false, ex.Message));
  7800. }
  7801. }
  7802. /// <summary>
  7803. /// 获取三公详细所有城市
  7804. /// </summary>
  7805. /// <returns></returns>
  7806. [HttpGet]
  7807. public IActionResult OpCarCityResult()
  7808. {
  7809. var jw = JsonView(false);
  7810. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  7811. {
  7812. x.Id,
  7813. x.Country,
  7814. x.City,
  7815. }).ToList();
  7816. if (data.Count > 0)
  7817. {
  7818. jw = JsonView(true, "获取成功!", data);
  7819. }
  7820. else
  7821. {
  7822. jw.Msg = "城市数据为空!";
  7823. jw.Data = new string[0];
  7824. }
  7825. return Ok(jw);
  7826. }
  7827. /// <summary>
  7828. /// 导出地接费用明细
  7829. /// </summary>
  7830. /// <param name="dto"></param>
  7831. /// <returns></returns>
  7832. [HttpPost]
  7833. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  7834. {
  7835. var jw = JsonView(false);
  7836. if (dto.Diid < 1)
  7837. {
  7838. jw.Msg = "请输入正确的diid!";
  7839. return Ok(jw);
  7840. }
  7841. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  7842. if (group == null)
  7843. {
  7844. jw.Msg = "未找到团组信息!";
  7845. return Ok(jw);
  7846. }
  7847. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  7848. if (localGuideArr.Count == 0)
  7849. {
  7850. jw.Msg = "该团组暂无地接信息!";
  7851. return Ok(jw);
  7852. }
  7853. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  7854. var overspendSoure = new Dictionary<int, int>
  7855. {
  7856. { 91, 982 }, //车
  7857. { 92 , 1059} ,//导游
  7858. { 994 , 1073}, //翻译
  7859. { 988 , 1074 }, //早餐
  7860. { 93 , 1075 }, //午餐
  7861. { 989 , 1076 }, //晚餐
  7862. };
  7863. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  7864. foreach (var groupArr in localGroup)
  7865. {
  7866. var keyValue = groupArr.Key;
  7867. if (int.TryParse(keyValue, out int cityid))
  7868. {
  7869. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  7870. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  7871. }
  7872. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  7873. foreach (var item in groupArr)
  7874. {
  7875. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  7876. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  7877. new Grp_CarTouristGuideGroundReservationsContentExtend
  7878. {
  7879. Count = a.Count,
  7880. CreateTime = a.CreateTime,
  7881. CreateUserId = a.CreateUserId,
  7882. CTGGRId = a.CTGGRId,
  7883. Currency = a.Currency,
  7884. DatePrice = a.DatePrice,
  7885. DeleteTime = a.DeleteTime,
  7886. DeleteUserId = a.DeleteUserId,
  7887. DiId = a.DiId,
  7888. Id = a.Id,
  7889. IsDel = a.IsDel,
  7890. Price = a.Price,
  7891. PriceContent = a.PriceContent,
  7892. Remark = a.Remark,
  7893. SId = a.SId,
  7894. SidName = b.Name,
  7895. Units = a.Units,
  7896. }
  7897. ).ToList();
  7898. if (content.Count > 0)
  7899. {
  7900. contentArr.Add(content);
  7901. }
  7902. }
  7903. //open excel
  7904. //set excel
  7905. //save excel
  7906. try
  7907. {
  7908. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  7909. IWorkbook workbook;
  7910. if (Path.GetExtension(filePath).ToLower() == ".xls")
  7911. {
  7912. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7913. }
  7914. else
  7915. {
  7916. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7917. }
  7918. ISheet sheet = workbook.GetSheetAt(0);
  7919. var rowStartIndex = 2;
  7920. var clounmCount = 10;
  7921. var initStyleRow = sheet.GetRow(2);
  7922. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7923. //var overspendArrDetail =
  7924. var existsId = new List<CarCompare>();
  7925. var lastElem = arr.Last();
  7926. var thisSid = -1;
  7927. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7928. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7929. {
  7930. Name = "未知币种!",
  7931. Remark = "未知币种!",
  7932. };
  7933. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7934. Action cloneRowFn = () =>
  7935. {
  7936. rowStartIndex++;
  7937. var cloneRow = sheet.CreateRow(rowStartIndex);
  7938. // 复制样式
  7939. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7940. {
  7941. ICell sourceCell = initStyleRow.GetCell(i);
  7942. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7943. // 确保单元格存在样式
  7944. if (sourceCell.CellStyle != null)
  7945. {
  7946. targetCell.CellStyle = sourceCell.CellStyle;
  7947. }
  7948. }
  7949. };
  7950. var mergeRow = () =>
  7951. {
  7952. for (int i = 2; i < sheet.LastRowNum; i++)
  7953. {
  7954. var row = sheet.GetRow(i);
  7955. var cellFirst = row.GetCell(0);
  7956. var thisIndex = i + 1;
  7957. while (thisIndex < sheet.LastRowNum)
  7958. {
  7959. var nextRow = sheet.GetRow(thisIndex);
  7960. var nextCellFirst = nextRow.GetCell(0);
  7961. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7962. {
  7963. thisIndex++;
  7964. }
  7965. else
  7966. {
  7967. break;
  7968. }
  7969. }
  7970. thisIndex--;
  7971. if (thisIndex != i)
  7972. {
  7973. //合并row
  7974. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7975. i, // 起始行索引(0-based)
  7976. thisIndex, // 结束行索引(0-based)
  7977. 0, // 起始列索引(0-based)
  7978. 0 // 结束列索引(0-based)
  7979. );
  7980. sheet.AddMergedRegion(cellRangeAddress);
  7981. i = thisIndex;
  7982. }
  7983. }
  7984. };
  7985. var chaoshiNumber = 0;
  7986. var totalNumber = 0.00M;
  7987. string lastStr = "";
  7988. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7989. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7990. {
  7991. b.IsAuditGM,
  7992. x.Id,
  7993. x.Area,
  7994. b.PayPercentage,
  7995. b.PayMoney,
  7996. }).ToList();
  7997. string yesPayment = "", noPayment = "";
  7998. foreach (var item in queryCarArrByCityAndDiid)
  7999. {
  8000. if (item.IsAuditGM == 1)
  8001. {
  8002. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  8003. }
  8004. else
  8005. {
  8006. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  8007. }
  8008. }
  8009. lastStr = yesPayment + noPayment;
  8010. foreach (var item in arr)
  8011. {
  8012. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  8013. {
  8014. if (thisSid != item.SId)
  8015. {
  8016. if (thisSid == -1)
  8017. {
  8018. thisSid = item.SId;
  8019. }
  8020. else
  8021. {
  8022. //合并小计行
  8023. //创建合并区域的实例
  8024. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8025. rowStartIndex, // 起始行索引(0-based)
  8026. rowStartIndex, // 结束行索引(0-based)
  8027. 0, // 起始列索引(0-based)
  8028. 3 // 结束列索引(0-based)
  8029. );
  8030. sheet.AddMergedRegion(cellRangeAddress);
  8031. var CellStyle = workbook.CreateCellStyle();
  8032. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8033. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8034. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8035. for (int i = 0; i <= clounmCount; i++)
  8036. {
  8037. if (i > 6)
  8038. {
  8039. var CellStyle1 = workbook.CreateCellStyle();
  8040. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8041. IFont Font = workbook.CreateFont(); // 创建字体
  8042. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8043. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8044. CellStyle1.SetFont(Font);
  8045. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8046. }
  8047. else
  8048. {
  8049. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8050. }
  8051. }
  8052. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8053. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8054. //超时合计
  8055. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8056. //超时数
  8057. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8058. //超时合计费用
  8059. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8060. thisSid = item.SId;
  8061. cloneRowFn();
  8062. chaoshiNumber = 0;
  8063. totalNumber = 0;
  8064. }
  8065. }
  8066. IRow row = sheet.GetRow(rowStartIndex);
  8067. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8068. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  8069. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  8070. if (isOpenOverspendSoure)
  8071. {
  8072. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8073. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  8074. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  8075. }
  8076. for (int i = 0; i <= clounmCount; i++)
  8077. {
  8078. var cell = row.GetCell(i);
  8079. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  8080. if (cell == null)
  8081. {
  8082. cell = row.CreateCell(i);
  8083. }
  8084. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  8085. fontRed.CloneStyleFrom(cell.CellStyle);
  8086. IFont Font = workbook.CreateFont(); // 创建字体
  8087. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  8088. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8089. fontRed.SetFont(Font);
  8090. byte[] rgb = new byte[3] { 255, 242, 204 };
  8091. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  8092. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  8093. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  8094. if (workbook is XSSFWorkbook)
  8095. {
  8096. BackgroundColor255_242_204.FillForegroundColor = 0;
  8097. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  8098. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  8099. }
  8100. else
  8101. {
  8102. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  8103. }
  8104. if (i == 1 || i > 6)
  8105. {
  8106. if (i > 6)
  8107. {
  8108. fontRed.FillForegroundColor = 0;
  8109. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  8110. fontRed.FillPattern = FillPattern.SolidForeground;
  8111. }
  8112. cell.CellStyle = fontRed;
  8113. }
  8114. if (i > 2 && i < 7)
  8115. {
  8116. cell.CellStyle = BackgroundColor255_242_204;
  8117. }
  8118. cell.SetCellValue(setCellValue); //写入单元格
  8119. }
  8120. if (overspendSoure.ContainsKey(thisSid))
  8121. {
  8122. var overspendId = overspendSoure[thisSid];
  8123. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8124. }
  8125. cloneRowFn();
  8126. existsId.Add(new CarCompare
  8127. {
  8128. DataPrice = item.DatePrice.ObjToDate(),
  8129. Sid = item.SId
  8130. });
  8131. }
  8132. if (item.Equals(lastElem))
  8133. {
  8134. //合并小计行
  8135. //创建合并区域的实例
  8136. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8137. rowStartIndex, // 起始行索引(0-based)
  8138. rowStartIndex, // 结束行索引(0-based)
  8139. 0, // 起始列索引(0-based)
  8140. 3 // 结束列索引(0-based)
  8141. );
  8142. sheet.AddMergedRegion(cellRangeAddress);
  8143. var CellStyle = workbook.CreateCellStyle();
  8144. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8145. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8146. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8147. for (int i = 0; i <= clounmCount; i++)
  8148. {
  8149. if (i > 6)
  8150. {
  8151. var CellStyle1 = workbook.CreateCellStyle();
  8152. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8153. IFont Font = workbook.CreateFont(); // 创建字体
  8154. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8155. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8156. CellStyle1.SetFont(Font);
  8157. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8158. }
  8159. else
  8160. {
  8161. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8162. }
  8163. }
  8164. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8165. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8166. //超时合计
  8167. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8168. //超时数
  8169. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8170. //超时合计费用
  8171. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8172. cloneRowFn();
  8173. // 创建合并区域的实例
  8174. cellRangeAddress = new CellRangeAddress(
  8175. rowStartIndex, // 起始行索引(0-based)
  8176. rowStartIndex, // 结束行索引(0-based)
  8177. 0, // 起始列索引(0-based)
  8178. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  8179. );
  8180. // 添加合并区域
  8181. sheet.AddMergedRegion(cellRangeAddress);
  8182. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  8183. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  8184. }
  8185. }
  8186. mergeRow();
  8187. // 保存修改后的Excel文件到新文件
  8188. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  8189. // new FileStream(newFilePath, FileMode.CreateNew)
  8190. using (var stream = new MemoryStream())
  8191. {
  8192. workbook.Write(stream, true);
  8193. stream.Flush();
  8194. stream.Seek(0, SeekOrigin.Begin);
  8195. MemoryStream memoryStream = new MemoryStream();
  8196. stream.CopyTo(memoryStream);
  8197. memoryStream.Seek(0, SeekOrigin.Begin);
  8198. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  8199. }
  8200. workbook.Close();
  8201. workbook.Dispose();
  8202. }
  8203. catch (Exception ex)
  8204. {
  8205. jw.Msg = "出现异常!" + ex.Message;
  8206. return Ok(jw);
  8207. }
  8208. }
  8209. if (Zips.Count > 0)
  8210. {
  8211. IOOperatorHelper io = new IOOperatorHelper();
  8212. var byts = io.ConvertZipStream(Zips);
  8213. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  8214. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  8215. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  8216. }
  8217. else
  8218. {
  8219. jw.Msg = "暂无生成文件!";
  8220. }
  8221. return Ok(jw);
  8222. }
  8223. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  8224. {
  8225. string outStr = string.Empty;
  8226. switch (i)
  8227. {
  8228. case 0:
  8229. outStr = arr[0].SidName;
  8230. break;
  8231. case 1:
  8232. outStr = arr[0].DataPriceStr;
  8233. break;
  8234. case 2:
  8235. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  8236. break;
  8237. case 4:
  8238. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  8239. break;
  8240. case 7:
  8241. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8242. {
  8243. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  8244. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  8245. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  8246. }
  8247. break;
  8248. case 8:
  8249. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8250. {
  8251. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  8252. }
  8253. break;
  8254. case 9:
  8255. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8256. {
  8257. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  8258. }
  8259. break;
  8260. case 10:
  8261. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8262. {
  8263. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  8264. }
  8265. break;
  8266. }
  8267. return outStr;
  8268. }
  8269. #region OP行程单
  8270. /// <summary>
  8271. /// OP行程单初始化
  8272. /// </summary>
  8273. /// <param name="dto"></param>
  8274. /// <returns></returns>
  8275. [HttpPost]
  8276. public IActionResult InitOpTravel(InitOpTravelDto dto)
  8277. {
  8278. var jw = JsonView(false);
  8279. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  8280. var group = groupList.First();
  8281. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  8282. if (group == null)
  8283. {
  8284. jw.Msg = "暂无团组!";
  8285. return Ok(jw);
  8286. }
  8287. group = groupList.Find(x => x.Id == diid);
  8288. if (group == null)
  8289. {
  8290. jw.Msg = "请输入正确的团组ID!";
  8291. return Ok(jw);
  8292. }
  8293. string city = string.Empty;
  8294. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  8295. if (blackCode.Count > 0)
  8296. {
  8297. var black = blackCode.First();
  8298. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  8299. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  8300. if (blackSp.Length > 0)
  8301. {
  8302. try
  8303. {
  8304. var cityArrCode = new List<string>(20);
  8305. foreach (var item in blackSp)
  8306. {
  8307. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  8308. var IndexSelect = itemSp[2];
  8309. var cityArrCodeLength = cityArrCode.Count - 1;
  8310. var startCity = IndexSelect.Substring(0, 3);
  8311. if (cityArrCodeLength > 0)
  8312. {
  8313. var arrEndCity = cityArrCode[cityArrCodeLength];
  8314. if (arrEndCity != startCity)
  8315. {
  8316. cityArrCode.Add(startCity.ToUpper());
  8317. }
  8318. }
  8319. else
  8320. {
  8321. cityArrCode.Add(startCity.ToUpper());
  8322. }
  8323. var endCity = IndexSelect.Substring(3, 3);
  8324. cityArrCode.Add(endCity.ToUpper());
  8325. }
  8326. var cityThree = string.Empty;
  8327. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  8328. cityThree = cityThree.TrimEnd(',');
  8329. if (string.IsNullOrWhiteSpace(cityThree))
  8330. {
  8331. throw new
  8332. Exception("error");
  8333. }
  8334. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  8335. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  8336. foreach (var item in cityArrCode)
  8337. {
  8338. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  8339. if (find != null)
  8340. {
  8341. city += find.City + "/";
  8342. }
  8343. else
  8344. {
  8345. city += item + "三字码未收入/";
  8346. }
  8347. }
  8348. city = city.TrimEnd('/');
  8349. }
  8350. catch (Exception e)
  8351. {
  8352. city = "黑屏代码格式不正确!";
  8353. }
  8354. }
  8355. }
  8356. else
  8357. {
  8358. city = "未录入黑屏代码";
  8359. }
  8360. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  8361. {
  8362. Date = x.Date,
  8363. Days = x.Days,
  8364. Diffgroup = x.Diffgroup,
  8365. Diid = x.Diid,
  8366. Traffic_First = x.Traffic_First,
  8367. Traffic_Second = x.Traffic_Second,
  8368. Trip = x.Trip,
  8369. WeekDay = x.WeekDay,
  8370. Id = x.Id
  8371. }).ToList();
  8372. jw.Data = new
  8373. {
  8374. groupList = groupList.Select(x => new
  8375. {
  8376. x.Id,
  8377. x.TeamName,
  8378. x.TourCode
  8379. }).ToList(),
  8380. groupInfo = new
  8381. {
  8382. group.VisitDays,
  8383. group.TourCode,
  8384. group.VisitPNumber,
  8385. group.TeamName,
  8386. city
  8387. },
  8388. OpTravelList
  8389. };
  8390. jw.Code = 200;
  8391. jw.Msg = "操作成功!";
  8392. return Ok(jw);
  8393. }
  8394. /// <summary>
  8395. /// 删除团组行程单
  8396. /// </summary>
  8397. /// <returns></returns>
  8398. [HttpPost]
  8399. public IActionResult DelTravel(DelOpTravelDto dto)
  8400. {
  8401. var jw = JsonView(false);
  8402. if (dto.UserId <= 0 || dto.Diid <= 0)
  8403. {
  8404. jw.Msg = "请输入正确的参数!";
  8405. return Ok(jw);
  8406. }
  8407. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  8408. .SetColumns(x => new Grp_TravelList
  8409. {
  8410. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8411. DeleteUserId = dto.UserId,
  8412. IsDel = 1,
  8413. }).ExecuteCommand();
  8414. jw = JsonView(true);
  8415. return Ok(jw);
  8416. }
  8417. /// <summary>
  8418. /// 行程单保存
  8419. /// </summary>
  8420. /// <returns></returns>
  8421. [HttpPost]
  8422. public IActionResult TravelSave(TravelSaveDto dto)
  8423. {
  8424. var jw = JsonView(false);
  8425. if (dto.Arr.Count > 0)
  8426. {
  8427. try
  8428. {
  8429. _sqlSugar.BeginTran();
  8430. foreach (var item in dto.Arr)
  8431. {
  8432. if (item.Id == 0)
  8433. {
  8434. throw new Exception("请传入正确的Id");
  8435. }
  8436. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  8437. .SetColumns(x => new Grp_TravelList
  8438. {
  8439. Trip = item.Trip
  8440. }).ExecuteCommand();
  8441. }
  8442. _sqlSugar.CommitTran();
  8443. jw = JsonView(true);
  8444. }
  8445. catch (Exception ex)
  8446. {
  8447. _sqlSugar.RollbackTran();
  8448. jw.Msg = "程序异常!" + ex.Message;
  8449. }
  8450. }
  8451. else
  8452. {
  8453. jw.Msg = "请传入正确的参数!";
  8454. }
  8455. return Ok(jw);
  8456. }
  8457. /// <summary>
  8458. /// 导出行程单
  8459. /// </summary>
  8460. /// <param name="dto"></param>
  8461. /// <returns></returns>
  8462. [HttpPost]
  8463. public IActionResult ExportTravel(ExportTravelDto dto)
  8464. {
  8465. var jw = JsonView(false);
  8466. jw.Data = "";
  8467. int diid = 0;
  8468. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  8469. if (Find == null)
  8470. {
  8471. jw.Msg = "请选择正确的团组!";
  8472. return Ok(jw);
  8473. }
  8474. else
  8475. {
  8476. diid = Find.Id;
  8477. }
  8478. //数据源
  8479. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  8480. DataTable dtBlack = null;
  8481. try
  8482. {
  8483. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  8484. }
  8485. catch (Exception)
  8486. {
  8487. jw.Msg = "机票黑屏代码有误!";
  8488. return Ok(jw);
  8489. }
  8490. string CityStr = string.Empty;
  8491. if (dtBlack.Rows.Count == 0)
  8492. {
  8493. jw.Msg = "机票黑屏代码有误!";
  8494. return Ok(jw);
  8495. }
  8496. else
  8497. {
  8498. foreach (DataRow row in dtBlack.Rows)
  8499. {
  8500. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  8501. {
  8502. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  8503. return Ok(jw);
  8504. }
  8505. }
  8506. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  8507. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  8508. }
  8509. //创建数据源Table
  8510. DataTable dtSource = new DataTable();
  8511. dtSource.Columns.Add("Days", typeof(string));
  8512. dtSource.Columns.Add("Date", typeof(string));
  8513. dtSource.Columns.Add("Week", typeof(string));
  8514. dtSource.Columns.Add("Traffic", typeof(string));
  8515. dtSource.Columns.Add("Trip", typeof(string));
  8516. //获取数据,放到datatable
  8517. foreach (var item in _travelList)
  8518. {
  8519. DataRow dr = dtSource.NewRow();
  8520. dr["Days"] = item.Days;
  8521. dr["Date"] = item.Date;
  8522. dr["Week"] = item.WeekDay;
  8523. dr["Traffic"] = item.Traffic_First
  8524. + "\r\n"
  8525. + item.Traffic_Second;
  8526. dr["Trip"] = item.Trip;
  8527. dtSource.Rows.Add(dr);
  8528. }
  8529. Dictionary<string, string> dic = new Dictionary<string, string>();
  8530. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  8531. dic.Add("City", CityStr);
  8532. dic.Add("Days", Find.VisitDays.ToString());
  8533. dic.Add("DeleCode", Find.TourCode);
  8534. dic.Add("Pnum", Find.VisitPNumber.ToString());
  8535. //模板路径
  8536. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  8537. //载入模板
  8538. Document doc = null;
  8539. DocumentBuilder builder = null;
  8540. try
  8541. {
  8542. //载入模板
  8543. doc = new Document(tempPath);
  8544. builder = new DocumentBuilder(doc);
  8545. }
  8546. catch (Exception)
  8547. {
  8548. jw.Msg = "模板位置不存在!";
  8549. return Ok(jw);
  8550. }
  8551. foreach (var key in dic.Keys)
  8552. {
  8553. Bookmark bookmark = doc.Range.Bookmarks[key];
  8554. if (bookmark != null)
  8555. {
  8556. builder.MoveToBookmark(key);
  8557. builder.Write(dic[key]);
  8558. }
  8559. }
  8560. //获取word里所有表格
  8561. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8562. //获取所填表格的序数
  8563. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8564. try
  8565. {
  8566. //循环赋值
  8567. for (int i = 0; i < dtSource.Rows.Count; i++)
  8568. {
  8569. builder.MoveToCell(0, i + 1, 0, 0);
  8570. builder.Write(dtSource.Rows[i]["Days"].ToString());
  8571. builder.MoveToCell(0, i + 1, 1, 0);
  8572. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  8573. builder.MoveToCell(0, i + 1, 2, 0);
  8574. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  8575. var trip = dtSource.Rows[i]["Trip"].ToString();
  8576. builder.MoveToCell(0, i + 1, 3, 0);
  8577. builder.Write(trip);
  8578. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  8579. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8580. // 获取特定索引的段落
  8581. Paragraph paragraph = (Paragraph)paragraphs[0];
  8582. Run run = paragraph.Runs[0];
  8583. Aspose.Words.Font font = run.Font;
  8584. font.Name = "黑体";
  8585. //设置双休红色
  8586. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  8587. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8588. paragraph = (Paragraph)paragraphs[1];
  8589. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  8590. {
  8591. run = paragraph.Runs[0];
  8592. font = run.Font;
  8593. font.Color = Color.Red;
  8594. }
  8595. }
  8596. }
  8597. catch (Exception ex)
  8598. {
  8599. }
  8600. //删除多余行
  8601. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  8602. {
  8603. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  8604. }
  8605. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  8606. if (!Directory.Exists(savePath))
  8607. {
  8608. try
  8609. {
  8610. Directory.CreateDirectory(savePath);
  8611. }
  8612. catch
  8613. {
  8614. }
  8615. }
  8616. string path = savePath + Find.TeamName + "出访日程";
  8617. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  8618. try
  8619. {
  8620. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  8621. string postfix = ".docx";
  8622. if (dto.IsPDF == 1)
  8623. {
  8624. saveFormat = Aspose.Words.SaveFormat.Pdf;
  8625. postfix = ".pdf";
  8626. }
  8627. doc.Save(path + postfix, saveFormat);
  8628. jw = JsonView(true, "导出成功", ftpPath + postfix);
  8629. }
  8630. catch (Exception)
  8631. {
  8632. jw = JsonView(false);
  8633. }
  8634. return Ok(jw);
  8635. }
  8636. /// <summary>
  8637. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  8638. /// </summary>
  8639. /// <param name="num"></param>
  8640. /// <returns></returns>
  8641. string GetNum(string num)
  8642. {
  8643. string str = "";
  8644. switch (num)
  8645. {
  8646. case "1":
  8647. str = "一";
  8648. break;
  8649. case "2":
  8650. str = "二";
  8651. break;
  8652. case "3":
  8653. str = "三";
  8654. break;
  8655. case "4":
  8656. str = "四";
  8657. break;
  8658. case "5":
  8659. str = "五";
  8660. break;
  8661. case "6":
  8662. str = "六";
  8663. break;
  8664. case "7":
  8665. str = "七";
  8666. break;
  8667. case "8":
  8668. str = "八";
  8669. break;
  8670. case "9":
  8671. str = "九";
  8672. break;
  8673. case "10":
  8674. str = "十";
  8675. break;
  8676. case "11":
  8677. str = "十一";
  8678. break;
  8679. case "12":
  8680. str = "十二";
  8681. break;
  8682. case "一":
  8683. str = "1";
  8684. break;
  8685. case "二":
  8686. str = "2";
  8687. break;
  8688. case "三":
  8689. str = "3";
  8690. break;
  8691. case "四":
  8692. str = "4";
  8693. break;
  8694. case "五":
  8695. str = "5";
  8696. break;
  8697. case "六":
  8698. str = "6";
  8699. break;
  8700. case "七":
  8701. str = "7";
  8702. break;
  8703. case "八":
  8704. str = "8";
  8705. break;
  8706. case "九":
  8707. str = "9";
  8708. break;
  8709. case "十":
  8710. str = "10";
  8711. break;
  8712. case "十一":
  8713. str = "11";
  8714. break;
  8715. case "十二":
  8716. str = "12";
  8717. break;
  8718. }
  8719. return str;
  8720. }
  8721. #endregion
  8722. #endregion
  8723. #region 团组成本
  8724. /// <summary>
  8725. /// 团组成本数据初始化
  8726. /// </summary>
  8727. /// <param name="dto"></param>
  8728. /// <returns></returns>
  8729. [HttpPost]
  8730. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  8731. {
  8732. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  8733. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  8734. WHEN COUNT(*) >= 0 THEN 'True'
  8735. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  8736. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  8737. ").ToList(); //团组列表
  8738. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  8739. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  8740. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  8741. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  8742. if (groupinfoValue != null)
  8743. {
  8744. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  8745. var spArr = new string[1] { countryArr };
  8746. if (countryArr.Contains("|"))
  8747. {
  8748. spArr = countryArr.Split("|");
  8749. }
  8750. else if (countryArr.Contains("、"))
  8751. {
  8752. spArr = countryArr.Split("、");
  8753. }
  8754. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  8755. {
  8756. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  8757. if (dbQueryCountry != null)
  8758. {
  8759. visaCountryInfoArr.Add(dbQueryCountry);
  8760. }
  8761. }
  8762. }
  8763. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  8764. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  8765. var create = _GroupCostRepository.
  8766. CreateGroupCostByBlackCode(dto.Diid);
  8767. if (groupCost.Count == 0 && create.Code == 0)
  8768. {
  8769. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  8770. }
  8771. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  8772. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  8773. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  8774. groupCostMap = groupCostMap.Select(x =>
  8775. {
  8776. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  8777. {
  8778. x.Date = dataForamt.ToString("yyyy-MM-dd");
  8779. }
  8780. return x;
  8781. }).ToList();
  8782. //GroupCostParameter.Add(new
  8783. // Grp_GroupCostParameter());
  8784. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  8785. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  8786. return Ok(JsonView(new
  8787. {
  8788. groupList,
  8789. groupInfo,
  8790. groupChecks,
  8791. groupCost = groupCostMap,
  8792. hotelNumber,
  8793. GroupCostParameter = GroupCostParameterMap,
  8794. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  8795. {
  8796. x.VisaCountry,
  8797. x.VisaPrice,
  8798. x.Id,
  8799. }).ToList(),
  8800. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  8801. blackCodeIsTrue = create.Code == 0 ? true : false,
  8802. hotelIsTrue = hotelIsTrue,
  8803. }));
  8804. }
  8805. /// <summary>
  8806. /// 团组成本信息保存
  8807. /// </summary>
  8808. /// <param name="dto"></param>
  8809. /// <returns></returns>
  8810. [HttpPost]
  8811. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  8812. {
  8813. if (dto.Diid <= 0 || dto.Userid <= 0)
  8814. {
  8815. return Ok(JsonView(false));
  8816. }
  8817. JsonView jw = null;
  8818. bool isTrue = false;
  8819. #region 复制团组成本
  8820. //if (dto.Diid == 2581)
  8821. //{
  8822. // dto.Diid = 2599;
  8823. // dto.CheckBoxs.ForEach(x =>
  8824. // {
  8825. // x.Diid = 2599;
  8826. // });
  8827. // dto.GroupCosts.ForEach(x =>
  8828. // {
  8829. // x.Diid = 2599;
  8830. // });
  8831. // dto.CostTypeHotelNumbers.ForEach(x =>
  8832. // {
  8833. // x.Diid = 2599;
  8834. // });
  8835. // dto.GroupCostParameters.ForEach(x =>
  8836. // {
  8837. // x.DiId = 2599;
  8838. // });
  8839. //}
  8840. #endregion
  8841. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  8842. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  8843. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  8844. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  8845. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  8846. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  8847. try
  8848. {
  8849. _sqlSugar.BeginTran();
  8850. isTrue = await _GroupCostRepository.
  8851. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  8852. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  8853. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  8854. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  8855. _sqlSugar.CommitTran();
  8856. jw = JsonView(true, "保存成功!", isTrue);
  8857. }
  8858. catch (Exception)
  8859. {
  8860. _sqlSugar.RollbackTran();
  8861. jw = JsonView(false);
  8862. }
  8863. return Ok(jw);
  8864. }
  8865. /// <summary>
  8866. /// 司兼导数据
  8867. /// </summary>
  8868. /// <param name="dto"></param>
  8869. /// <returns></returns>
  8870. [HttpPost]
  8871. public IActionResult GetCarGuides(CarGuidesDto dto)
  8872. {
  8873. JsonView jw = null;
  8874. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  8875. jw = JsonView(true, "获取成功!", Data);
  8876. return Ok(jw);
  8877. }
  8878. /// <summary>
  8879. /// 导游数据
  8880. /// </summary>
  8881. /// <param name="dto"></param>
  8882. /// <returns></returns>
  8883. [HttpPost]
  8884. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  8885. {
  8886. JsonView jw = null;
  8887. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  8888. // 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
  8889. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  8890. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  8891. jw = JsonView(true, "获取成功!", Data);
  8892. return Ok(jw);
  8893. }
  8894. /// <summary>
  8895. /// 成本车数据
  8896. /// </summary>
  8897. /// <param name="dto"></param>
  8898. /// <returns></returns>
  8899. [HttpPost]
  8900. public IActionResult GetCarInfo(CarGuidesDto dto)
  8901. {
  8902. JsonView jw = null;
  8903. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  8904. jw = JsonView(true, "获取成功!", Data);
  8905. return Ok(jw);
  8906. }
  8907. /// <summary>
  8908. /// 景点数据
  8909. /// </summary>
  8910. /// <param name="dto"></param>
  8911. /// <returns></returns>
  8912. [HttpPost]
  8913. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  8914. {
  8915. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  8916. return Ok(JsonView(true, "获取成功!", Data));
  8917. }
  8918. /// <summary>
  8919. /// 成本通知
  8920. /// </summary>
  8921. /// <param name="dto"></param>
  8922. /// <returns></returns>
  8923. [HttpPost]
  8924. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8925. {
  8926. if (dto.Diid < 0)
  8927. {
  8928. return Ok(JsonView(false));
  8929. }
  8930. JsonView jw = null;
  8931. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8932. if (GroupCostParameter != null)
  8933. {
  8934. int IsShare = 0;
  8935. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8936. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8937. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8938. string msg = string.Empty;
  8939. if (isTrue)
  8940. {
  8941. if (IsShare == 0)
  8942. {
  8943. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8944. }
  8945. else
  8946. {
  8947. #region 企微通知对应岗位用户
  8948. try
  8949. {
  8950. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8951. }
  8952. catch (Exception ex)
  8953. {
  8954. }
  8955. #endregion
  8956. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8957. }
  8958. jw = JsonView(isTrue, msg, new { IsShare });
  8959. }
  8960. else
  8961. {
  8962. msg = "修改失败!";
  8963. jw = JsonView(isTrue, msg);
  8964. }
  8965. }
  8966. else
  8967. {
  8968. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8969. }
  8970. return Ok(jw);
  8971. }
  8972. /// <summary>
  8973. /// 导出报价单
  8974. /// </summary>
  8975. /// <param name="dto"></param>
  8976. /// <returns></returns>
  8977. [HttpPost]
  8978. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8979. {
  8980. if (dto.Diid == 0)
  8981. {
  8982. return Ok(JsonView(false, "请传递团组id"));
  8983. }
  8984. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8985. if (deleInfo.Code != 0)
  8986. {
  8987. return Ok(JsonView(false, "团组信息查询失败!"));
  8988. }
  8989. var di = deleInfo.Data as DelegationInfoWebView;
  8990. if (di != null)
  8991. {
  8992. di.TeamName = di.TeamName.Replace("|", "、");
  8993. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8994. //文件名
  8995. string strFileName = di.TeamName + "-收款账单.doc";
  8996. //获取模板
  8997. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  8998. //载入模板
  8999. Document doc = new Document(tmppath);
  9000. decimal TotalPrice = 0.00M;
  9001. string itemStr = string.Empty;
  9002. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  9003. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  9004. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  9005. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  9006. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  9007. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  9008. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  9009. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  9010. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  9011. foreach (var cost in groupCostType)
  9012. {
  9013. var List = cost.ToList();
  9014. if (cost.Key == "A")
  9015. {
  9016. foreach (var ListItem in List)
  9017. {
  9018. if (ListItem.number > 0)
  9019. {
  9020. if (ListItem.code.Contains("TBR"))
  9021. {
  9022. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9023. }
  9024. else
  9025. {
  9026. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9027. }
  9028. TotalPrice += (ListItem.number * ListItem.price);
  9029. }
  9030. }
  9031. }
  9032. else
  9033. {
  9034. itemStr = itemStr.Insert(0, "A段\r\n");
  9035. itemStr += "B段\r\n";
  9036. foreach (var ListItem in List)
  9037. {
  9038. if (ListItem.number > 0)
  9039. {
  9040. if (ListItem.code.Contains("TBR"))
  9041. {
  9042. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9043. }
  9044. else
  9045. {
  9046. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  9047. }
  9048. TotalPrice += (ListItem.number * ListItem.price);
  9049. }
  9050. }
  9051. }
  9052. }
  9053. #region 替换Word模板书签内容
  9054. Dictionary<string, string> marks = new Dictionary<string, string>();
  9055. marks.Add("To", di.ClientUnit);//付款方
  9056. marks.Add("ToTel", di.TellPhone);//付款方电话
  9057. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  9058. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  9059. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  9060. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  9061. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  9062. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  9063. marks.Add("PayItemContent", itemStr);//详细信息
  9064. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  9065. #endregion
  9066. ////注
  9067. //if (doc.Range.Bookmarks["Attention"] != null)
  9068. //{
  9069. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  9070. // mark.Text = frList[0].Attention;
  9071. //}
  9072. foreach (var item in marks.Keys)
  9073. {
  9074. if (doc.Range.Bookmarks[item] != null)
  9075. {
  9076. Bookmark mark = doc.Range.Bookmarks[item];
  9077. mark.Text = marks[item];
  9078. }
  9079. }
  9080. byte[] bytes = null;
  9081. using (MemoryStream stream = new MemoryStream())
  9082. {
  9083. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9084. bytes = stream.ToArray();
  9085. }
  9086. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  9087. return Ok(JsonView(true, "", new
  9088. {
  9089. Data = bytes,
  9090. strFileName,
  9091. }));
  9092. }
  9093. else
  9094. {
  9095. return Ok(JsonView(false, "团组信息不存在!"));
  9096. }
  9097. }
  9098. /// <summary>
  9099. /// 导出团组成本
  9100. /// </summary>
  9101. /// <param name="dto"></param>
  9102. /// <returns></returns>
  9103. [HttpPost]
  9104. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  9105. {
  9106. var jw = JsonView(false);
  9107. if (dto.Diid == 0)
  9108. {
  9109. return Ok(JsonView(false, "请传递团组id"));
  9110. }
  9111. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9112. if (deleInfo.Code != 0)
  9113. {
  9114. return Ok(JsonView(false, "团组信息查询失败!"));
  9115. }
  9116. var di = deleInfo.Data as DelegationInfoWebView;
  9117. if (di == null)
  9118. {
  9119. return Ok(JsonView(false, "团组信息查询失败!"));
  9120. }
  9121. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  9122. WorkbookDesigner designer = new WorkbookDesigner();
  9123. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  9124. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  9125. for (int i = 0; i < List_GC.Count; i++)
  9126. {
  9127. GroupCost_Excel gc = new GroupCost_Excel();
  9128. gc.Id = List_GC[i].Id;
  9129. gc.Diid = List_GC[i].Diid.ToString();
  9130. gc.DAY = List_GC[i].DAY;
  9131. string week = "";
  9132. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  9133. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  9134. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  9135. gc.ITIN = List_GC[i].ITIN;
  9136. gc.CarType = List_GC[i].CarType;
  9137. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  9138. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  9139. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  9140. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  9141. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  9142. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  9143. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  9144. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  9145. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  9146. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  9147. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  9148. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  9149. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9150. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9151. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  9152. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  9153. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  9154. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  9155. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  9156. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  9157. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  9158. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  9159. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  9160. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  9161. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  9162. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  9163. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  9164. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  9165. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  9166. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  9167. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  9168. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  9169. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  9170. List_GC1.Add(gc);
  9171. }
  9172. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  9173. dt.TableName = "TB";
  9174. //报表标题等不用dt的值
  9175. designer.SetDataSource("TeamName", dto.title.TeamName);
  9176. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  9177. designer.SetDataSource("Tax", dto.title.Tax);
  9178. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  9179. designer.SetDataSource("Currency", dto.title.Currency);
  9180. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  9181. designer.SetDataSource("Rate", dto.title.Rate);
  9182. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  9183. var Aparams = hotels.Find(x => x.Type == "Default");
  9184. if (Aparams == null)
  9185. {
  9186. return Ok(jw);
  9187. }
  9188. //酒店数量
  9189. var txtSGRNumber = Aparams.SGR.ToString();
  9190. var txtTBRNumber = Aparams.TBR.ToString();
  9191. var txtJSESNumber = Aparams.JSES.ToString();
  9192. var txtSUITENumbe = Aparams.SUITE.ToString();
  9193. if (dto.costType == "B")
  9194. {
  9195. Aparams = hotels.Find(x => x.Type == "A");
  9196. var Bparams = hotels.Find(x => x.Type == "B");
  9197. if (Aparams == null || Bparams == null)
  9198. {
  9199. return Ok(jw);
  9200. }
  9201. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  9202. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  9203. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  9204. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  9205. }
  9206. designer.SetDataSource("SGRNumber", txtSGRNumber);
  9207. designer.SetDataSource("TBRNumber", txtTBRNumber);
  9208. designer.SetDataSource("JSESNumber", txtJSESNumber);
  9209. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  9210. var ws = designer.Workbook.Worksheets[0];
  9211. int Row = List_GC.Count;
  9212. int startIndex = 11;
  9213. int HideRows = 0;
  9214. List<int> hideRowsList = new List<int>();
  9215. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  9216. #region A段left数据
  9217. var left = dto.leftInfo.Find(x => x.Type == "A");
  9218. if (left == null)
  9219. {
  9220. return Ok(jw);
  9221. }
  9222. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  9223. if (leftBindData != null)
  9224. {
  9225. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  9226. designer.SetDataSource("VisaRS", leftBindData.rs);
  9227. designer.SetDataSource("VisaXS", leftBindData.xs);
  9228. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9229. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9230. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9231. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9232. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9233. }
  9234. else
  9235. {
  9236. hideRowsList.Add(Row + startIndex + HideRows);
  9237. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9238. }
  9239. HideRows += 2;
  9240. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  9241. if (leftBindData != null)
  9242. {
  9243. designer.SetDataSource("BXDRCB", leftBindData.cb);
  9244. designer.SetDataSource("BXRS", leftBindData.rs);
  9245. designer.SetDataSource("BXXS", leftBindData.xs);
  9246. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9247. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9248. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9249. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9250. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9251. }
  9252. else
  9253. {
  9254. hideRowsList.Add(Row + startIndex + HideRows);
  9255. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9256. }
  9257. HideRows += 2;
  9258. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9259. if (leftBindData != null)
  9260. {
  9261. designer.SetDataSource("HSDRCB", leftBindData.cb);
  9262. designer.SetDataSource("HSRS", leftBindData.rs);
  9263. designer.SetDataSource("HSXS", leftBindData.xs);
  9264. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9265. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9266. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9267. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9268. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9269. }
  9270. else
  9271. {
  9272. hideRowsList.Add(Row + startIndex + HideRows);
  9273. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9274. }
  9275. HideRows += 2;
  9276. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9277. if (leftBindData != null)
  9278. {
  9279. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  9280. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  9281. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  9282. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9283. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9284. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9285. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9286. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9287. }
  9288. else
  9289. {
  9290. hideRowsList.Add(Row + startIndex + HideRows);
  9291. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9292. }
  9293. HideRows += 2;
  9294. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9295. if (leftBindData != null)
  9296. {
  9297. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  9298. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  9299. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  9300. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9301. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9302. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9303. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9304. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9305. }
  9306. else
  9307. {
  9308. hideRowsList.Add(Row + startIndex + HideRows);
  9309. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9310. }
  9311. HideRows += 2;
  9312. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9313. if (leftBindData != null)
  9314. {
  9315. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  9316. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  9317. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  9318. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9319. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9320. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9321. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9322. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9323. }
  9324. else
  9325. {
  9326. hideRowsList.Add(Row + startIndex + HideRows);
  9327. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9328. }
  9329. HideRows += 2;
  9330. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9331. if (leftBindData != null)
  9332. {
  9333. ////TBR
  9334. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  9335. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  9336. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  9337. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9338. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9339. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9340. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9341. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9342. }
  9343. else
  9344. {
  9345. hideRowsList.Add(Row + startIndex + HideRows);
  9346. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9347. }
  9348. HideRows += 2;
  9349. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9350. if (leftBindData != null)
  9351. {
  9352. ////SGR
  9353. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  9354. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  9355. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  9356. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9357. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9358. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9359. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9360. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9361. }
  9362. else
  9363. {
  9364. hideRowsList.Add(Row + startIndex + HideRows);
  9365. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9366. }
  9367. HideRows += 2;
  9368. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9369. if (leftBindData != null)
  9370. {
  9371. ////JS/ES
  9372. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  9373. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  9374. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  9375. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9376. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9377. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9378. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9379. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9380. }
  9381. else
  9382. {
  9383. hideRowsList.Add(Row + startIndex + HideRows);
  9384. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9385. }
  9386. HideRows += 2;
  9387. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9388. if (leftBindData != null)
  9389. {
  9390. ////SUITE
  9391. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  9392. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  9393. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  9394. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9395. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9396. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9397. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9398. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9399. }
  9400. else
  9401. {
  9402. hideRowsList.Add(Row + startIndex + HideRows);
  9403. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9404. }
  9405. HideRows += 2;
  9406. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9407. if (leftBindData != null)
  9408. {
  9409. designer.SetDataSource("DJDRCB", leftBindData.cb);
  9410. designer.SetDataSource("DJRS", leftBindData.rs);
  9411. designer.SetDataSource("DJXS", leftBindData.xs);
  9412. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9413. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9414. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9415. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9416. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9417. }
  9418. else
  9419. {
  9420. hideRowsList.Add(Row + startIndex + HideRows);
  9421. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9422. }
  9423. HideRows += 2;
  9424. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9425. if (leftBindData != null)
  9426. {
  9427. designer.SetDataSource("HCPCB", leftBindData.cb);
  9428. designer.SetDataSource("HCPRS", leftBindData.rs);
  9429. designer.SetDataSource("HCPXS", leftBindData.xs);
  9430. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9431. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9432. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9433. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9434. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9435. }
  9436. else
  9437. {
  9438. hideRowsList.Add(Row + startIndex + HideRows);
  9439. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9440. }
  9441. HideRows += 2;
  9442. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9443. if (leftBindData != null)
  9444. {
  9445. designer.SetDataSource("CPCB", leftBindData.cb);
  9446. designer.SetDataSource("CPRS", leftBindData.rs);
  9447. designer.SetDataSource("CPXS", leftBindData.xs);
  9448. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9449. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9450. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9451. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9452. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9453. }
  9454. else
  9455. {
  9456. hideRowsList.Add(Row + startIndex + HideRows);
  9457. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9458. }
  9459. HideRows += 2;
  9460. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9461. if (leftBindData != null)
  9462. {
  9463. designer.SetDataSource("GWDRCD", leftBindData.cb);
  9464. designer.SetDataSource("GWRS", leftBindData.rs);
  9465. designer.SetDataSource("GWXS", leftBindData.xs);
  9466. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9467. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9468. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9469. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9470. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9471. }
  9472. else
  9473. {
  9474. hideRowsList.Add(Row + startIndex + HideRows);
  9475. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9476. }
  9477. HideRows += 2;
  9478. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9479. if (leftBindData != null)
  9480. {
  9481. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  9482. designer.SetDataSource("LYJRS", leftBindData.rs);
  9483. designer.SetDataSource("LYJXS", leftBindData.xs);
  9484. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9485. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9486. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9487. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9488. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9489. }
  9490. else
  9491. {
  9492. hideRowsList.Add(Row + startIndex + HideRows);
  9493. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9494. }
  9495. #endregion
  9496. #region A段Right信息
  9497. var right = dto.rightInfo.Find(x => x.Type == "A");
  9498. if (right == null)
  9499. {
  9500. return Ok(jw);
  9501. }
  9502. HideRows += 4;
  9503. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9504. if (rightBindData != null)
  9505. {
  9506. //经济舱 + 双人间 TBR
  9507. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  9508. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  9509. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9510. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  9511. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9512. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9513. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9514. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9515. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9516. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9517. }
  9518. else
  9519. {
  9520. hideRowsList.Add(Row + startIndex + HideRows);
  9521. }
  9522. HideRows += 2;
  9523. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9524. if (rightBindData != null)
  9525. {
  9526. //经济舱 + 单人间 SGR
  9527. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  9528. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  9529. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9530. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  9531. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9532. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9533. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9534. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9535. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9536. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9537. }
  9538. else
  9539. {
  9540. hideRowsList.Add(Row + startIndex + HideRows);
  9541. }
  9542. HideRows += 2;
  9543. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9544. if (rightBindData != null)
  9545. {
  9546. //公务舱 + 单人间 SGR
  9547. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  9548. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  9549. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9550. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  9551. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9552. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9553. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9554. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9555. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9556. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9557. }
  9558. else
  9559. {
  9560. hideRowsList.Add(Row + startIndex + HideRows);
  9561. }
  9562. HideRows += 2;
  9563. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9564. if (rightBindData != null)
  9565. {
  9566. //公务舱 + 小套房 JSES
  9567. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  9568. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  9569. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9570. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  9571. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9572. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9573. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9574. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9575. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9576. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9577. }
  9578. else
  9579. {
  9580. hideRowsList.Add(Row + startIndex + HideRows);
  9581. }
  9582. HideRows += 2;
  9583. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9584. if (rightBindData != null)
  9585. {
  9586. //公务舱 + 小套房 JSES
  9587. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  9588. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  9589. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9590. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  9591. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9592. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9593. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9594. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9595. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9596. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9597. }
  9598. else
  9599. {
  9600. hideRowsList.Add(Row + startIndex + HideRows);
  9601. }
  9602. HideRows += 2;
  9603. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9604. if (rightBindData != null)
  9605. {
  9606. //经济舱 + 大套房
  9607. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  9608. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  9609. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9610. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  9611. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9612. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9613. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9614. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9615. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9616. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9617. }
  9618. else
  9619. {
  9620. hideRowsList.Add(Row + startIndex + HideRows);
  9621. }
  9622. HideRows += 2;
  9623. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9624. if (rightBindData != null)
  9625. {
  9626. //头等舱 + 小套房 JSES
  9627. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  9628. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  9629. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9630. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  9631. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9632. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9633. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9634. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9635. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9636. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9637. }
  9638. else
  9639. {
  9640. hideRowsList.Add(Row + startIndex + HideRows);
  9641. }
  9642. HideRows += 2;
  9643. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9644. if (rightBindData != null)
  9645. {
  9646. //头等舱 + 大套房
  9647. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  9648. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  9649. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9650. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  9651. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9652. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9653. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9654. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9655. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9656. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9657. }
  9658. else
  9659. {
  9660. hideRowsList.Add(Row + startIndex + HideRows);
  9661. }
  9662. #endregion
  9663. #region B段标题清空
  9664. designer.SetDataSource("CostBDRCB", "");
  9665. designer.SetDataSource("CostBRS", "");
  9666. designer.SetDataSource("CostBXS", "");
  9667. designer.SetDataSource("CostBZCB", "");
  9668. designer.SetDataSource("CostBDRBJ", "");
  9669. designer.SetDataSource("CostBZBJ", "");
  9670. designer.SetDataSource("CostBDRLR", "");
  9671. designer.SetDataSource("CostBZLR", "");
  9672. designer.SetDataSource("CostBDRCBOM", "");
  9673. designer.SetDataSource("CostBRSOM", "");
  9674. designer.SetDataSource("CostBZCBOM", "");
  9675. designer.SetDataSource("CostBDRBJOM", "");
  9676. designer.SetDataSource("CostBZBJOM", "");
  9677. designer.SetDataSource("CostBDRLROM", "");
  9678. designer.SetDataSource("CostBZLROM", "");
  9679. #endregion
  9680. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  9681. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  9682. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  9683. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  9684. designer.SetDataSource("DJName", "地接(CNY)");
  9685. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  9686. designer.SetDataSource("CPName", "地接-船票(CNY)");
  9687. designer.SetDataSource("GWName", "公务(CNY)");
  9688. designer.SetDataSource("YQHName", "邀请函(CNY)");
  9689. designer.SetDataSource("LYJName", "零用金(CNY)");
  9690. designer.SetDataSource("HSName", "核酸检测(CNY)");
  9691. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  9692. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  9693. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  9694. designer.SetDataSource("BXName", "保险(CNY)");
  9695. designer.SetDataSource("VisaName", "签证(CNY)");
  9696. #region B段基本数据
  9697. if (dto.costType == "B")
  9698. {
  9699. left = dto.leftInfo.Find(x => x.Type == "B");
  9700. if (left == null)
  9701. {
  9702. return Ok(jw);
  9703. }
  9704. #region B段left数据
  9705. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9706. if (leftBindData != null)
  9707. {
  9708. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  9709. designer.SetDataSource("BHSRS", leftBindData.rs);
  9710. designer.SetDataSource("BHSXS", leftBindData.xs);
  9711. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9712. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9713. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9714. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9715. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9716. }
  9717. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9718. if (leftBindData != null)
  9719. {
  9720. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  9721. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  9722. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  9723. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9724. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9725. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9726. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9727. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9728. }
  9729. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9730. if (leftBindData != null)
  9731. {
  9732. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  9733. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  9734. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  9735. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9736. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9737. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9738. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9739. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9740. }
  9741. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9742. if (leftBindData != null)
  9743. {
  9744. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  9745. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  9746. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  9747. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9748. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9749. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9750. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9751. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9752. }
  9753. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9754. if (leftBindData != null)
  9755. {
  9756. designer.SetDataSource("BHCPCB", leftBindData.cb);
  9757. designer.SetDataSource("BHCPRS", leftBindData.rs);
  9758. designer.SetDataSource("BHCPXS", leftBindData.xs);
  9759. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9760. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9761. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9762. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9763. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9764. }
  9765. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9766. if (leftBindData != null)
  9767. {
  9768. designer.SetDataSource("BCPCB", leftBindData.cb);
  9769. designer.SetDataSource("BCPRS", leftBindData.rs);
  9770. designer.SetDataSource("BCPXS", leftBindData.xs);
  9771. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9772. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9773. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9774. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9775. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9776. }
  9777. //TBR
  9778. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9779. if (leftBindData != null)
  9780. {
  9781. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  9782. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  9783. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  9784. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9785. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9786. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9787. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9788. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9789. }
  9790. //SGR
  9791. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9792. if (leftBindData != null)
  9793. {
  9794. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  9795. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  9796. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  9797. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9798. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9799. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9800. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9801. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9802. }
  9803. //JS/ES
  9804. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9805. if (leftBindData != null)
  9806. {
  9807. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  9808. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  9809. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  9810. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9811. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9812. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9813. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9814. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9815. }
  9816. //SUITE
  9817. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9818. if (leftBindData != null)
  9819. {
  9820. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  9821. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  9822. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  9823. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9824. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9825. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9826. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9827. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9828. }
  9829. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9830. if (leftBindData != null)
  9831. {
  9832. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  9833. designer.SetDataSource("BDJRS", leftBindData.rs);
  9834. designer.SetDataSource("BDJXS", leftBindData.xs);
  9835. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9836. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9837. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9838. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9839. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9840. }
  9841. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9842. if (leftBindData != null)
  9843. {
  9844. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  9845. designer.SetDataSource("BGWRS", leftBindData.rs);
  9846. designer.SetDataSource("BGWXS", leftBindData.xs);
  9847. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9848. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9849. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9850. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9851. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9852. }
  9853. #region 优化方案
  9854. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  9855. //excelBind.Add("零用金", new {
  9856. //cb="",
  9857. //rs="",
  9858. //xs ="",
  9859. //zcb = "",
  9860. //});
  9861. #endregion
  9862. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9863. if (leftBindData != null)
  9864. {
  9865. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  9866. designer.SetDataSource("BLYJRS", leftBindData.rs);
  9867. designer.SetDataSource("BLYJXS", leftBindData.xs);
  9868. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9869. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9870. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9871. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9872. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9873. }
  9874. #endregion
  9875. #region B段Right信息
  9876. right = dto.rightInfo.Find(x => x.Type == "B");
  9877. if (right == null)
  9878. {
  9879. return Ok(jw);
  9880. }
  9881. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9882. if (rightBindData != null)
  9883. {
  9884. //经济舱 + 双人间 TBR
  9885. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  9886. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  9887. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9888. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  9889. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9890. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9891. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9892. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9893. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9894. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9895. }
  9896. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9897. if (rightBindData != null)
  9898. {
  9899. //经济舱 + 单人间 SGR
  9900. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  9901. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  9902. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9903. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  9904. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9905. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9906. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9907. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9908. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9909. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9910. }
  9911. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9912. if (rightBindData != null)
  9913. {
  9914. //公务舱 + 单人间 SGR
  9915. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  9916. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  9917. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9918. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  9919. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9920. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9921. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9922. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9923. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9924. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9925. }
  9926. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9927. if (rightBindData != null)
  9928. {
  9929. //公务舱 + 小套房 JSES
  9930. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9931. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9932. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9933. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9934. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9935. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9936. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9937. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9938. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9939. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9940. }
  9941. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9942. if (rightBindData != null)
  9943. {
  9944. //公务舱 + 小套房 JSES
  9945. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9946. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9947. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9948. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9949. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9950. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9951. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9952. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9953. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9954. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9955. }
  9956. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9957. if (rightBindData != null)
  9958. {
  9959. //经济舱 + 大套房
  9960. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9961. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9962. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9963. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9964. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9965. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9966. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9967. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9968. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9969. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9970. }
  9971. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9972. if (rightBindData != null)
  9973. {
  9974. //头等舱 + 小套房 JSES
  9975. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9976. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9977. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9978. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9979. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9980. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9981. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9982. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9983. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9984. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9985. }
  9986. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9987. if (rightBindData != null)
  9988. {
  9989. //头等舱 + 大套房
  9990. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9991. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9992. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9993. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9994. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9995. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9996. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9997. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9998. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9999. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  10000. }
  10001. #endregion
  10002. #region 标题
  10003. designer.SetDataSource("CostBDRCB", "单人成本");
  10004. designer.SetDataSource("CostBRS", "人数");
  10005. designer.SetDataSource("CostBXS", "系数");
  10006. designer.SetDataSource("CostBZCB", "总成本");
  10007. designer.SetDataSource("CostBDRBJ", "单人报价");
  10008. designer.SetDataSource("CostBZBJ", "总报价");
  10009. designer.SetDataSource("CostBDRLR", "单人利润");
  10010. designer.SetDataSource("CostBZLR", "总利润");
  10011. designer.SetDataSource("CostBDRCBOM", "单人成本");
  10012. designer.SetDataSource("CostBRSOM", "人数");
  10013. designer.SetDataSource("CostBZCBOM", "总成本");
  10014. designer.SetDataSource("CostBDRBJOM", "单人报价");
  10015. designer.SetDataSource("CostBZBJOM", "总报价");
  10016. designer.SetDataSource("CostBDRLROM", "单人利润");
  10017. designer.SetDataSource("CostBZLROM", "总利润");
  10018. #endregion
  10019. }
  10020. #endregion
  10021. designer.SetDataSource("TzZCB2", TzZCB2);
  10022. designer.SetDataSource("TzZBJ2", TzZBJ2);
  10023. designer.SetDataSource("TzZLR2", TzZLR2);
  10024. string[] dataSourceKeys = new string[]
  10025. {
  10026. "VF",
  10027. "TGS",
  10028. "TGOF",
  10029. "TGM",
  10030. "TGA",
  10031. "TGTF",
  10032. "TGEF",
  10033. "CFM",
  10034. "CFOF",
  10035. "B",
  10036. "L",
  10037. "D",
  10038. "TBR",
  10039. "SGR",
  10040. "JSES",
  10041. "Suite",
  10042. "TV",
  10043. "1L",
  10044. "IF",
  10045. "EF",
  10046. "BRF",
  10047. "TE",
  10048. "TGT",
  10049. "DRVT",
  10050. "PC",
  10051. "TLF",
  10052. "ECT"
  10053. };
  10054. foreach (var item in dataSourceKeys)
  10055. {
  10056. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  10057. if (find != null)
  10058. {
  10059. designer.SetDataSource(item, find.text);
  10060. }
  10061. else
  10062. {
  10063. designer.SetDataSource(item, 0);
  10064. }
  10065. }
  10066. designer.SetDataSource(dt);
  10067. //根据数据源处理生成报表内容
  10068. designer.Process();
  10069. designer.Workbook.Worksheets[0].Name = "清单";
  10070. Worksheet sheet = designer.Workbook.Worksheets[0];
  10071. foreach (var Rowindex in hideRowsList)
  10072. {
  10073. ws.Cells.HideRows(Rowindex, 2);
  10074. }
  10075. byte[] bytes = null;
  10076. string strFileName = di.TeamName + "-团组-成本.xls";
  10077. using (MemoryStream stream = new MemoryStream())
  10078. {
  10079. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  10080. bytes = stream.ToArray();
  10081. }
  10082. return Ok(JsonView(true, "", new
  10083. {
  10084. Data = bytes,
  10085. strFileName,
  10086. }));
  10087. }
  10088. /// <summary>
  10089. /// 导出客户报表
  10090. /// </summary>
  10091. /// <returns></returns>
  10092. [HttpPost]
  10093. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  10094. {
  10095. var jw = JsonView(false);
  10096. if (dto.Diid == 0)
  10097. {
  10098. return Ok(JsonView(false, "请传递团组id"));
  10099. }
  10100. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10101. if (deleInfo.Code != 0)
  10102. {
  10103. return Ok(JsonView(false, "团组信息查询失败!"));
  10104. }
  10105. var di = deleInfo.Data as DelegationInfoWebView;
  10106. if (di == null)
  10107. {
  10108. return Ok(JsonView(false, "团组信息查询失败!"));
  10109. }
  10110. //文件名
  10111. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  10112. //获取模板
  10113. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  10114. //载入模板
  10115. Document doc = new Document(tmppath);
  10116. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  10117. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  10118. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  10119. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  10120. var AParameter = ParameterList.Find(x => x.CostType == "A");
  10121. var BParameter = ParameterList.Find(x => x.CostType == "B");
  10122. if (AParameter == null)
  10123. {
  10124. return Ok(JsonView(false, "系数不存在!"));
  10125. }
  10126. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  10127. , TzAirDesc, TzZCost;
  10128. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  10129. = TzAirDesc = TzZCost = string.Empty;
  10130. TzNumber = AParameter.CostTypenumber.ToString();
  10131. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  10132. CarGuides1 = dto.CarGuides1;
  10133. Meal = dto.Meal;
  10134. SubsidizedMeals = dto.SubsidizedMeals;
  10135. NightRepair = dto.NightRepair;
  10136. AttractionsTickets = dto.AttractionsTickets;
  10137. MiscellaneousFees = dto.MiscellaneousFees;
  10138. ATip = dto.ATip;
  10139. TzHotelDesc = "";
  10140. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  10141. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  10142. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  10143. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  10144. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  10145. TzAirDesc = "";
  10146. TzZCost = dto.TzZCost;
  10147. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  10148. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  10149. var index = 1;
  10150. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  10151. foreach (var item in TzHotelDescArr)
  10152. {
  10153. if (AinfoArr != null)
  10154. {
  10155. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10156. if (Ainfo != null)
  10157. {
  10158. if (int.Parse(Ainfo.rs) <= 0)
  10159. {
  10160. continue;
  10161. }
  10162. var hotelText = string.Empty;
  10163. switch (item)
  10164. {
  10165. case "SGR":
  10166. hotelText = "单人间";
  10167. break;
  10168. case "JSES":
  10169. hotelText = "小套房";
  10170. break;
  10171. case "SUITE":
  10172. hotelText = "套房";
  10173. break;
  10174. case "TBR":
  10175. hotelText = "双人间";
  10176. break;
  10177. }
  10178. if (item != "TBR")
  10179. {
  10180. 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";
  10181. }
  10182. else
  10183. {
  10184. 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";
  10185. }
  10186. index++;
  10187. }
  10188. }
  10189. }
  10190. index = 1;
  10191. foreach (var item in TzAirDescArr)
  10192. {
  10193. if (AinfoArr != null)
  10194. {
  10195. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10196. if (Ainfo != null)
  10197. {
  10198. if (int.Parse(Ainfo.rs) <= 0)
  10199. {
  10200. continue;
  10201. }
  10202. 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";
  10203. index++;
  10204. }
  10205. }
  10206. }
  10207. if (dto.costType == "B")
  10208. {
  10209. if (BParameter == null)
  10210. {
  10211. return Ok(JsonView(false, "B段系数不存在!"));
  10212. }
  10213. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  10214. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  10215. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  10216. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  10217. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  10218. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  10219. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  10220. foreach (var item in TzHotelDescArr)
  10221. {
  10222. if (AinfoArr != null)
  10223. {
  10224. TzHotelDesc += "B段信息 \r\n";
  10225. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10226. if (Ainfo != null)
  10227. {
  10228. if (int.Parse(Ainfo.rs) <= 0)
  10229. {
  10230. continue;
  10231. }
  10232. var hotelText = string.Empty;
  10233. switch (item)
  10234. {
  10235. case "SGR":
  10236. hotelText = "单人间";
  10237. break;
  10238. case "JSES":
  10239. hotelText = "小套房";
  10240. break;
  10241. case "SUITE":
  10242. hotelText = "套房";
  10243. break;
  10244. case "TBR":
  10245. hotelText = "双人间";
  10246. break;
  10247. }
  10248. if (item != "TBR")
  10249. {
  10250. 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";
  10251. }
  10252. else
  10253. {
  10254. 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";
  10255. }
  10256. index++;
  10257. }
  10258. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  10259. }
  10260. }
  10261. index = 1;
  10262. foreach (var item in TzAirDescArr)
  10263. {
  10264. if (AinfoArr != null)
  10265. {
  10266. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10267. if (Ainfo != null)
  10268. {
  10269. if (int.Parse(Ainfo.rs) <= 0)
  10270. {
  10271. continue;
  10272. }
  10273. 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";
  10274. index++;
  10275. }
  10276. }
  10277. }
  10278. }
  10279. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  10280. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  10281. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  10282. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  10283. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  10284. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  10285. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  10286. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  10287. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  10288. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  10289. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  10290. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  10291. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  10292. DickeyValue.Add("Visa", Visa); // 签证单人报价
  10293. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  10294. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  10295. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  10296. DickeyValue.Add("TzZCost", TzZCost);
  10297. foreach (var key in DickeyValue.Keys)
  10298. {
  10299. if (doc.Range.Bookmarks[key] != null)
  10300. {
  10301. Bookmark mark = doc.Range.Bookmarks[key];
  10302. mark.Text = DickeyValue[key];
  10303. }
  10304. }
  10305. byte[] bytes = null;
  10306. string strFileName = di.TeamName + "-客户报价.doc";
  10307. using (MemoryStream stream = new MemoryStream())
  10308. {
  10309. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10310. bytes = stream.ToArray();
  10311. }
  10312. return Ok(JsonView(true, "", new
  10313. {
  10314. Data = bytes,
  10315. strFileName,
  10316. }));
  10317. }
  10318. /// <summary>
  10319. /// 团组成本 各模块(酒店,地接,机票)成本提示
  10320. /// </summary>
  10321. /// <param name="dto"></param>
  10322. /// <returns></returns>
  10323. [HttpPost]
  10324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10325. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  10326. {
  10327. try
  10328. {
  10329. #region 参数验证
  10330. if (dto.DiId < 0)
  10331. {
  10332. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  10333. }
  10334. List<int> cTableIds = new List<int>() {
  10335. 76 ,//酒店预订
  10336. 77 ,//行程
  10337. 79 ,//车/导游地接
  10338. 80 ,//签证
  10339. 81 ,//邀请/公务活
  10340. 82 ,//团组客户保险
  10341. 85 ,//机票预订
  10342. 98 ,//其他款项
  10343. 285 ,//收款退还
  10344. 751 ,//酒店早餐
  10345. 1015 // 超支费用
  10346. };
  10347. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  10348. {
  10349. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  10350. }
  10351. #endregion
  10352. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  10353. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  10354. if (_GroupCostParameters.Count <= 0)
  10355. {
  10356. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  10357. }
  10358. if (_GroupCostParameters[0].IsShare == 0)
  10359. {
  10360. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  10361. }
  10362. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10363. //处理date为空问题
  10364. if (_GroupCosts.Count > 0)
  10365. {
  10366. for (int i = 0; i < _GroupCosts.Count; i++)
  10367. {
  10368. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  10369. {
  10370. if (i > 0)
  10371. {
  10372. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  10373. }
  10374. }
  10375. }
  10376. }
  10377. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  10378. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  10379. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  10380. string currCode = "";
  10381. #region currCode 验证
  10382. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  10383. if (isInt)
  10384. {
  10385. var currData = currDatas.Find(it => it.Id == intCurrency);
  10386. if (currData != null)
  10387. {
  10388. currCode = currData.Name;
  10389. }
  10390. }
  10391. else
  10392. {
  10393. currCode = _GroupCostParameters[0].Currency.Trim();
  10394. }
  10395. #endregion
  10396. //op,酒店单段模式存储
  10397. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  10398. {
  10399. CurrencyCode = currCode,
  10400. Rate = _GroupCostParameters[0].Rate,
  10401. CostType = _GroupCostParameters[0].CostType,
  10402. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  10403. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  10404. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  10405. };
  10406. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  10407. if (_GroupCostParameters.Count == 2)
  10408. {
  10409. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  10410. }
  10411. foreach (var item in _GroupCostParameters)
  10412. {
  10413. decimal _rate = 1;
  10414. decimal _rate1 = item.Rate;
  10415. decimal _scale = 1;
  10416. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  10417. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  10418. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  10419. //if (userInfo != null)
  10420. //{
  10421. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  10422. // {
  10423. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  10424. // {
  10425. // _scale = 1.00M;
  10426. // }
  10427. // }
  10428. //}
  10429. #endregion
  10430. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  10431. {
  10432. CurrencyCode = currCode,
  10433. Rate = _rate1,
  10434. CostType = item.CostType,
  10435. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  10436. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  10437. CostTypeNumber = item.CostTypenumber
  10438. };
  10439. if (_GroupCostParameters.Count > 1)
  10440. {
  10441. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  10442. }
  10443. else
  10444. {
  10445. modulePromptInfo.CostTypeNumber = item.LYJRS;
  10446. }
  10447. if (dto.CTable == 79)//
  10448. {
  10449. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  10450. modulePromptInfo.TotalCost = item.DJCB;
  10451. }
  10452. List<string> costTypes = new List<string>() { "A", "B" };
  10453. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  10454. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  10455. if (_GroupCostsDuplicates.Count() == 1)
  10456. {
  10457. _GroupCostsTypeData = _GroupCosts;
  10458. }
  10459. else
  10460. {
  10461. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  10462. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  10463. }
  10464. /*
  10465. * 76 酒店预订
  10466. * 77 行程
  10467. * 79 车/导游地接
  10468. * 80 签证
  10469. * 81 邀请/公务活动
  10470. * 82 团组客户保险
  10471. * 85 机票预订
  10472. * 98 其他款项
  10473. * 285 收款退还
  10474. * 751 酒店早餐
  10475. * 1015 超支费用
  10476. */
  10477. switch (dto.CTable)
  10478. {
  10479. case 76: // 酒店预订
  10480. _ModuleSubPromptInfo.AddRange(
  10481. _GroupCostsTypeData.Select(it => new
  10482. {
  10483. it.DAY,
  10484. it.Date,
  10485. it.ACCON,
  10486. it.ITIN,
  10487. it.SGR,
  10488. it.TBR,
  10489. it.JS_ES,
  10490. it.Suite
  10491. })
  10492. );
  10493. break;
  10494. case 79: // 车/导游地接
  10495. _ModuleSubPromptInfo.AddRange(
  10496. _GroupCostsTypeData.Select(it => new
  10497. {
  10498. Date = it.Date, //日期
  10499. CarFee = it.CarCost * _rate * _scale, //车费用
  10500. CarType = it.CarType, //车型
  10501. DriverFee = it.CFS * _rate * _scale, //司机工资
  10502. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  10503. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  10504. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  10505. GuideFee = it.TGS * _rate * _scale, //导游费用
  10506. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  10507. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  10508. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  10509. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  10510. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  10511. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  10512. Breakfast = it.B * _rate * _scale, //早餐费
  10513. Lunch = it.L * _rate * _scale, //午餐费
  10514. Dinner = it.D * _rate * _scale, //晚餐费
  10515. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  10516. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  10517. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  10518. TicketFee = it.EF * _rate * _scale, //门票费
  10519. TicketRemark = it.EFR, //门票费描述
  10520. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  10521. TravelSupplies = it.TE * _rate * _scale, //出行物资
  10522. SpentCash = it.PC * _rate * _scale, //零用金
  10523. LeadersFee = it.TLF * _rate * _scale, //领队费
  10524. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  10525. })
  10526. );
  10527. break;
  10528. case 85: // 机票
  10529. List<dynamic> datas = new List<dynamic>();
  10530. datas.Add(
  10531. new
  10532. {
  10533. AirType = "经济舱",
  10534. AirNum = item.JJCRS,
  10535. AirDRCB = item.JJCCB,
  10536. AirZCB = (item.JJCRS * item.JJCCB)
  10537. }
  10538. );
  10539. datas.Add(
  10540. new
  10541. {
  10542. AirType = "公务舱",
  10543. AirNum = item.GWCRS,
  10544. AirDRCB = item.GWCCB,
  10545. AirZCB = (item.GWCRS * item.GWCCB)
  10546. }
  10547. );
  10548. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10549. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  10550. modulePromptInfo.Data = new
  10551. {
  10552. airFeeData = datas,
  10553. airInitData = initDatas
  10554. };
  10555. _ModulePromptInfos.Add(modulePromptInfo);
  10556. break;
  10557. default:
  10558. break;
  10559. }
  10560. }
  10561. if (dto.CTable != 85)
  10562. {
  10563. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  10564. _ModulePromptInfos.Add(_ModulePromptInfo);
  10565. }
  10566. _view.ModulePromptInfos = _ModulePromptInfos;
  10567. return Ok(JsonView(true, "操作成功!", _view));
  10568. }
  10569. catch (Exception ex)
  10570. {
  10571. return Ok(JsonView(false, ex.Message));
  10572. }
  10573. }
  10574. /// <summary>
  10575. /// 根据黑屏代码重新生成行程
  10576. /// </summary>
  10577. /// <param name="dto"></param>
  10578. /// <returns></returns>
  10579. [HttpPost]
  10580. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  10581. {
  10582. var jw = JsonView(false);
  10583. var Create = _GroupCostRepository.
  10584. CreateGroupCostByBlackCode(dto.Diid);
  10585. jw.Msg = Create.Msg;
  10586. if (Create.Code == 0)
  10587. {
  10588. jw.Code = 200;
  10589. jw.Data = new
  10590. {
  10591. groupCost = Create.Data,
  10592. blackCodeIsTrue = true
  10593. };
  10594. }
  10595. else
  10596. {
  10597. jw.Code = 400;
  10598. jw.Data = new
  10599. {
  10600. groupCost = Create.Data,
  10601. blackCodeIsTrue = false,
  10602. };
  10603. }
  10604. return Ok(jw);
  10605. }
  10606. /// <summary>
  10607. /// 成本获取OP历史车费用
  10608. /// </summary>
  10609. /// <param name="dto"></param>
  10610. /// <returns></returns>
  10611. [HttpPost]
  10612. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  10613. {
  10614. var jw = JsonView(false);
  10615. try
  10616. {
  10617. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  10618. //获取现有所有车的数据
  10619. if (!dto.Param.IsNullOrWhiteSpace())
  10620. {
  10621. string sql = $@"
  10622. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  10623. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  10624. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  10625. 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
  10626. AND gctggr.ServiceEndTime is not NULL
  10627. ORDER by gctggrc.id DESC
  10628. ";
  10629. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  10630. var numeberResult = await Task.Run(() =>
  10631. {
  10632. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  10633. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  10634. return numberArr;
  10635. });
  10636. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  10637. foreach (var item in numeberResult)
  10638. {
  10639. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  10640. {
  10641. Country = "数据异常!",
  10642. City = string.Empty,
  10643. };
  10644. item.Area = find.Country + " " + find.City;
  10645. }
  10646. dbResult.AddRange(numeberResult);
  10647. if (dto.Param.Contains("、"))
  10648. {
  10649. var sp = dto.Param.Split("、");
  10650. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10651. .Where(x =>
  10652. {
  10653. return System.Array.Exists(sp, e =>
  10654. {
  10655. bool where = false;
  10656. if (x.Area != null)
  10657. {
  10658. where = x.Area.Contains(e);
  10659. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10660. {
  10661. return false;
  10662. }
  10663. }
  10664. if (x.PriceName != null && !where)
  10665. {
  10666. where = x.PriceName.Contains(e);
  10667. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10668. {
  10669. return false;
  10670. }
  10671. }
  10672. return where;
  10673. });
  10674. }).ToList();
  10675. }
  10676. else
  10677. {
  10678. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10679. .Where(x =>
  10680. {
  10681. bool where = false;
  10682. if (x.Area != null)
  10683. {
  10684. where = x.Area.Contains(dto.Param);
  10685. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10686. {
  10687. return false;
  10688. }
  10689. }
  10690. if (x.PriceName != null && !where)
  10691. {
  10692. where = x.PriceName.Contains(dto.Param);
  10693. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10694. {
  10695. return false;
  10696. }
  10697. }
  10698. return where;
  10699. }
  10700. )
  10701. .ToList();
  10702. }
  10703. }
  10704. var view = dbResult.Select(x =>
  10705. {
  10706. decimal dp = 0.00M;
  10707. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  10708. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  10709. if (string.IsNullOrWhiteSpace(x.DatePrice))
  10710. {
  10711. if (startB && endB)
  10712. {
  10713. var timesp = endD.Subtract(startD);
  10714. if ((timesp.Days + 1) != 0)
  10715. {
  10716. dp = x.Price / (timesp.Days + 1);
  10717. }
  10718. }
  10719. }
  10720. else
  10721. {
  10722. dp = x.Price;
  10723. }
  10724. return new
  10725. {
  10726. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  10727. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  10728. x.Area,
  10729. x.id,
  10730. price = x.Price.ToString("F2"),
  10731. x.PriceName,
  10732. x.PriceContent,
  10733. x.TeamName,
  10734. x.DatePrice,
  10735. dayPrice = dp.ToString("F2"),
  10736. };
  10737. }).OrderByDescending(x => x.id).ToList();
  10738. jw = JsonView(true, "获取成功!", view);
  10739. }
  10740. catch (Exception e)
  10741. {
  10742. jw = JsonView(false, e.Message);
  10743. }
  10744. return Ok(jw);
  10745. }
  10746. #endregion
  10747. #region 酒店预订 新 雷怡 2023-12-28 17:45
  10748. /// <summary>
  10749. /// 酒店预订
  10750. /// 酒店费用列表 根据团组Id查询
  10751. /// </summary>
  10752. /// <param name="_dto"></param>
  10753. /// <returns></returns>
  10754. [HttpPost]
  10755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10756. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  10757. {
  10758. #region 参数验证
  10759. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10760. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10761. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10762. #region 团组操作权限验证 76 酒店预定模块
  10763. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10764. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10765. #endregion
  10766. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10767. #region 页面操作权限验证
  10768. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10769. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10770. #endregion
  10771. #endregion
  10772. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  10773. }
  10774. /// <summary>
  10775. /// 酒店预订
  10776. /// 基础数据
  10777. /// </summary>
  10778. /// <param name="_dto"></param>
  10779. /// <returns></returns>
  10780. [HttpPost]
  10781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10782. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  10783. {
  10784. #region 参数验证
  10785. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10786. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10787. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10788. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10789. #region 页面操作权限验证
  10790. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10791. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10792. #endregion
  10793. #region 团组操作权限验证 76 酒店预定模块
  10794. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10795. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10796. #endregion
  10797. #endregion
  10798. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  10799. }
  10800. /// <summary>
  10801. /// 酒店预订
  10802. /// 创建 入住卷号码
  10803. /// </summary>
  10804. /// <param name="_dto"></param>
  10805. /// <returns></returns>
  10806. [HttpPost]
  10807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10808. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  10809. {
  10810. #region 参数验证
  10811. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10812. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10813. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10814. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10815. #region 页面操作权限验证
  10816. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10817. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10818. #endregion
  10819. #region 团组操作权限验证 76 酒店预定模块
  10820. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10821. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10822. #endregion
  10823. #endregion
  10824. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  10825. if (data.Code != 0)
  10826. {
  10827. return Ok(JsonView(false, data.Msg));
  10828. }
  10829. return Ok(JsonView(true, data.Msg, data.Data));
  10830. }
  10831. /// <summary>
  10832. /// 酒店预订
  10833. /// 详情
  10834. /// </summary>
  10835. /// <param name="_dto"></param>
  10836. /// <returns></returns>
  10837. [HttpPost]
  10838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10839. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  10840. {
  10841. #region 参数验证
  10842. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  10843. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10844. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  10845. #region 团组操作权限验证 76 酒店预定模块
  10846. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10847. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10848. #endregion
  10849. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10850. #region 页面操作权限验证
  10851. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10852. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10853. #endregion
  10854. #endregion
  10855. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  10856. }
  10857. /// <summary>
  10858. /// 酒店预订
  10859. /// Add Or Edit
  10860. /// </summary>
  10861. /// <param name="_dto"></param>
  10862. /// <returns></returns>
  10863. [HttpPost]
  10864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10865. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  10866. {
  10867. #region 参数验证
  10868. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10869. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10870. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10871. #region 团组操作权限验证 76 酒店预定模块
  10872. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10873. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10874. #endregion
  10875. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10876. #region 页面操作权限验证
  10877. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10878. if (_dto.Id == 0) // Add
  10879. {
  10880. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10881. }
  10882. else if (_dto.Id > 1) // Edit
  10883. {
  10884. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10885. }
  10886. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  10887. #endregion
  10888. #endregion
  10889. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  10890. if (_view.Code != 200)
  10891. {
  10892. return Ok(_view);
  10893. }
  10894. #region 成本无酒店价格数据进入超支
  10895. _sqlSugar.BeginTran();
  10896. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  10897. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  10898. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  10899. for (int i = 0; i < groupCost.Count; i++)
  10900. {
  10901. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  10902. {
  10903. groupCost[i].Date = groupCost[i - 1].Date;
  10904. }
  10905. }
  10906. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  10907. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  10908. List<Fin_GroupExtraCostDto_OP>();
  10909. if (start_Bool && end_Bool)
  10910. {
  10911. while (start_Time < end_Time)
  10912. {
  10913. foreach (var item in groupCost_Grp)
  10914. {
  10915. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  10916. {
  10917. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  10918. {
  10919. extraCostList.Add(new
  10920. Fin_GroupExtraCostDto_OP
  10921. {
  10922. Area = _dto.AreaId,
  10923. coefficient = 1.5M,
  10924. createUser = _dto.UserId,
  10925. currency = _dto.CardPriceCurrency,
  10926. diId = _dto.DiId,
  10927. ManagerConfirm = 0,
  10928. SupervisorConfirm = 0,
  10929. SYsupervisorConfirm = 0,
  10930. editType = 1,
  10931. PortType = 1,
  10932. price = _dto.CardPrice,
  10933. PriceCount = 1,
  10934. priceType = 1027,
  10935. priceDetailType = 1044,
  10936. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  10937. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  10938. });
  10939. }
  10940. }
  10941. }
  10942. start_Time = start_Time.AddDays(1);
  10943. }
  10944. }
  10945. if (extraCostList.Any())
  10946. {
  10947. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  10948. }
  10949. _sqlSugar.CommitTran();
  10950. #endregion
  10951. #region 应用推送
  10952. try
  10953. {
  10954. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10955. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10956. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10957. var diId = _dto.DiId;
  10958. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10959. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10960. #region 操作记录
  10961. var opInfo = new Crm_TableOperationRecord() {
  10962. TableName = "Grp_HotelReservations",
  10963. PortType = _dto.PortType,
  10964. DataId = hotelId,
  10965. CreateUserId = _dto.UserId
  10966. };
  10967. var opStatus = OperationEnum.NoOperation;
  10968. if (_dto.Id<1) //添加操作
  10969. {
  10970. opInfo.OperationItem = OperationEnum.Add;
  10971. }
  10972. else if (_dto.Id > 0)
  10973. {
  10974. opInfo.OperationItem = OperationEnum.Edit;
  10975. }
  10976. string opRemark = string.Empty;
  10977. if (ccpInfo != null)
  10978. {
  10979. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  10980. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  10981. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  10982. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  10983. }
  10984. opInfo.Remark = opRemark;
  10985. await _tableorRep.AddAsync(opInfo);
  10986. #endregion
  10987. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  10988. //2024-10-21 新增LZ UID
  10989. var userIds = new List<int>() { 21 };
  10990. string title = $"费用审核";
  10991. string content = "";
  10992. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10993. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10994. try
  10995. {
  10996. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10997. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  10998. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  10999. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  11000. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  11001. }
  11002. catch (Exception ex )
  11003. {
  11004. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  11005. }
  11006. }
  11007. catch (Exception ex)
  11008. {
  11009. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  11010. }
  11011. try
  11012. {
  11013. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  11014. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  11015. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  11016. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11017. //自动审核
  11018. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  11019. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  11020. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  11021. //2024-10-21 新增LZ UID
  11022. var userIds = new List<int>() { 21 };
  11023. string title = $"系统通知";
  11024. var diId = _dto.DiId;
  11025. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11026. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11027. string content = "";
  11028. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11029. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11030. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11031. }
  11032. catch (Exception ex)
  11033. {
  11034. }
  11035. #endregion
  11036. return Ok(_view);
  11037. }
  11038. /// <summary>
  11039. /// 酒店自动审核测试
  11040. /// Add Or Edit
  11041. /// </summary>
  11042. /// <param name="_dto"></param>
  11043. /// <returns></returns>
  11044. [HttpPost]
  11045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11046. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  11047. {
  11048. #region 应用推送
  11049. try
  11050. {
  11051. //自动审核
  11052. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  11053. }
  11054. catch (Exception ex)
  11055. {
  11056. return Ok(JsonView(false, "操作失败"));
  11057. }
  11058. #endregion
  11059. return Ok(JsonView(false, "操作成功"));
  11060. }
  11061. /// <summary>
  11062. /// 酒店预订
  11063. /// Del
  11064. /// </summary>
  11065. /// <param name="_dto"></param>
  11066. /// <returns></returns>
  11067. [HttpPost]
  11068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11069. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  11070. {
  11071. #region 参数验证
  11072. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11073. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11074. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11075. #region 团组操作权限验证 76 酒店预定模块
  11076. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11077. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11078. #endregion
  11079. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11080. #region 页面操作权限验证
  11081. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11082. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11083. #endregion
  11084. #endregion
  11085. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  11086. #region 操作记录
  11087. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  11088. {
  11089. TableName = "Grp_HotelReservations",
  11090. PortType = _dto.PortType,
  11091. OperationItem = OperationEnum.Del,
  11092. DataId = _dto.Id,
  11093. CreateUserId = _dto.UserId
  11094. });
  11095. #endregion
  11096. return Ok(data);
  11097. }
  11098. /// <summary>
  11099. /// 酒店预订
  11100. /// 生成VOUCHER
  11101. /// 2024.05.06 之前版本
  11102. /// </summary>
  11103. /// <param name="_dto"></param>
  11104. /// <returns></returns>
  11105. [HttpPost]
  11106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11107. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  11108. {
  11109. try
  11110. {
  11111. #region 参数验证
  11112. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11113. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11114. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11115. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  11116. #region 团组操作权限验证 76 酒店预定模块
  11117. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11118. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11119. #endregion
  11120. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11121. #region 页面操作权限验证
  11122. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11123. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11124. #endregion
  11125. #endregion
  11126. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  11127. //判断数据是否完整
  11128. if (hr != null)
  11129. {
  11130. if (!string.IsNullOrEmpty(hr.DetermineNo))
  11131. {
  11132. string strFileName = "HotelStatement/";
  11133. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11134. if (dele != null)
  11135. strFileName += dele.TourCode;
  11136. //载入模板
  11137. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  11138. Document doc = new Document(sss);
  11139. DocumentBuilder builder = new DocumentBuilder(doc);
  11140. #region 替换Word模板书签内容
  11141. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  11142. //入住卷预定号码
  11143. if (doc.Range.Bookmarks["VNO"] != null)
  11144. {
  11145. Bookmark mark = doc.Range.Bookmarks["VNO"];
  11146. mark.Text = hr.CheckNumber;
  11147. }
  11148. //酒店时间
  11149. if (doc.Range.Bookmarks["Date"] != null)
  11150. {
  11151. Bookmark mark = doc.Range.Bookmarks["Date"];
  11152. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11153. }
  11154. //团号
  11155. if (doc.Range.Bookmarks["TNo"] != null)
  11156. {
  11157. Bookmark mark = doc.Range.Bookmarks["TNo"];
  11158. mark.Text = dele.TourCode;
  11159. }
  11160. //预定号码
  11161. if (doc.Range.Bookmarks["BookingId"] != null)
  11162. {
  11163. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  11164. mark.Text = hr.ReservationsNo;
  11165. }
  11166. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  11167. {
  11168. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  11169. mark.Text = hr.DetermineNo;
  11170. }
  11171. //酒店城市
  11172. if (doc.Range.Bookmarks["City"] != null)
  11173. {
  11174. Bookmark mark = doc.Range.Bookmarks["City"];
  11175. mark.Text = hr.City;
  11176. }
  11177. //酒店名称
  11178. if (doc.Range.Bookmarks["HName"] != null)
  11179. {
  11180. Bookmark mark = doc.Range.Bookmarks["HName"];
  11181. mark.Text = hr.HotelName;
  11182. }
  11183. //酒店地址
  11184. if (doc.Range.Bookmarks["Address"] != null)
  11185. {
  11186. Bookmark mark = doc.Range.Bookmarks["Address"];
  11187. mark.Text = hr.HotelAddress;
  11188. }
  11189. //酒店电话
  11190. if (doc.Range.Bookmarks["Tel"] != null)
  11191. {
  11192. Bookmark mark = doc.Range.Bookmarks["Tel"];
  11193. mark.Text = hr.HotelTel;
  11194. }
  11195. //酒店传真
  11196. if (doc.Range.Bookmarks["Fax"] != null)
  11197. {
  11198. Bookmark mark = doc.Range.Bookmarks["Fax"];
  11199. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  11200. {
  11201. mark.Text = hr.HotelFax;
  11202. }
  11203. }
  11204. //入住时间
  11205. if (doc.Range.Bookmarks["CIn"] != null)
  11206. {
  11207. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11208. Bookmark mark = doc.Range.Bookmarks["CIn"];
  11209. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  11210. }
  11211. //退房时间
  11212. if (doc.Range.Bookmarks["COut"] != null)
  11213. {
  11214. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11215. Bookmark mark = doc.Range.Bookmarks["COut"];
  11216. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11217. }
  11218. //客户名称
  11219. if (doc.Range.Bookmarks["GName"] != null)
  11220. {
  11221. string guestName = "";
  11222. string[] clients = new string[] { };
  11223. if (hr.GuestName.Contains(","))
  11224. {
  11225. clients = hr.GuestName.Split(",");
  11226. }
  11227. else
  11228. {
  11229. clients = new string[] { hr.GuestName };
  11230. }
  11231. List<int> clientIds_int = new List<int>();
  11232. if (clients.Length > 0)
  11233. {
  11234. foreach (var item in clients)
  11235. {
  11236. if (item.IsNumeric())
  11237. {
  11238. clientIds_int.Add(int.Parse(item));
  11239. }
  11240. }
  11241. }
  11242. if (clientIds_int.Count > 0)
  11243. {
  11244. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  11245. foreach (var client in _clientDatas)
  11246. {
  11247. //男
  11248. if (client.Sex == 0) guestName += $"Mr.";
  11249. //女
  11250. else if (client.Sex == 1) guestName += $"Ms.";
  11251. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  11252. {
  11253. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  11254. }
  11255. //guestName += $"{client.Pinyin},";
  11256. }
  11257. if (guestName.Length > 0)
  11258. {
  11259. guestName = guestName.Substring(0, guestName.Length - 1);
  11260. }
  11261. }
  11262. else
  11263. {
  11264. guestName = hr.GuestName;
  11265. }
  11266. Bookmark mark = doc.Range.Bookmarks["GName"];
  11267. mark.Text = guestName;
  11268. }
  11269. //房间介绍
  11270. if (doc.Range.Bookmarks["ROOM"] != null)
  11271. {
  11272. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  11273. mark.Text = hr.RoomExplanation;
  11274. }
  11275. //报价描述
  11276. if (doc.Range.Bookmarks["NOTE"] != null)
  11277. {
  11278. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  11279. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  11280. if (ss != null)
  11281. mark.Text = ss.Name;
  11282. }
  11283. //入住时间
  11284. if (doc.Range.Bookmarks["CheckIn"] != null)
  11285. {
  11286. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11287. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  11288. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11289. }
  11290. //退房时间
  11291. if (doc.Range.Bookmarks["CheckOut"] != null)
  11292. {
  11293. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11294. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  11295. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11296. }
  11297. //日期
  11298. if (doc.Range.Bookmarks["DT"] != null)
  11299. {
  11300. Bookmark mark = doc.Range.Bookmarks["DT"];
  11301. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11302. }
  11303. //名称
  11304. if (doc.Range.Bookmarks["VName"] != null)
  11305. {
  11306. Bookmark mark = doc.Range.Bookmarks["VName"];
  11307. mark.Text = hr.HotelName;
  11308. }
  11309. //号码
  11310. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  11311. {
  11312. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  11313. mark.Text = hr.CheckNumber;
  11314. }
  11315. #endregion
  11316. strFileName += "VOUCHER.doc";
  11317. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11318. doc.Save(fileDir);
  11319. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11320. return Ok(JsonView(true, "操作成功!", Url));
  11321. }
  11322. else
  11323. {
  11324. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  11325. }
  11326. }
  11327. else
  11328. {
  11329. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  11330. }
  11331. }
  11332. catch (Exception ex)
  11333. {
  11334. return Ok(JsonView(false, ex.Message));
  11335. }
  11336. }
  11337. /// <summary>
  11338. /// 酒店预订
  11339. /// 生成VOUCHER
  11340. /// 2024.05.06 之后版本
  11341. /// </summary>
  11342. /// <param name="_dto"></param>
  11343. /// <returns></returns>
  11344. [HttpPost]
  11345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11346. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  11347. {
  11348. #region 参数验证
  11349. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11350. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11351. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11352. #region 团组操作权限验证 76 酒店预定模块
  11353. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11354. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11355. #endregion
  11356. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11357. #region 页面操作权限验证
  11358. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11359. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11360. #endregion
  11361. #endregion
  11362. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  11363. //判断数据是否完整
  11364. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11365. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11366. string strFileName = "HotelStatement/";
  11367. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11368. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  11369. #region 数据处理
  11370. List<int> guestIds = new List<int>();
  11371. int index = 0;
  11372. foreach (var item in hrDtas)
  11373. {
  11374. if (item.GuestName.Contains(","))
  11375. {
  11376. string[] guestIdArr = item.GuestName.Split(',');
  11377. foreach (var guestIdStr in guestIdArr)
  11378. {
  11379. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  11380. if (guestBool)
  11381. {
  11382. guestIds.Add(guestId);
  11383. }
  11384. }
  11385. }
  11386. else guestNames += item.GuestName;
  11387. var voucherInfo = new HotelVoucherInfoView()
  11388. {
  11389. HotelName = item.HotelName,
  11390. CheckInDate = item.CheckInDate,
  11391. CheckOutDate = item.CheckOutDate,
  11392. ConfirmationNumber = item.DetermineNo.Trim(),
  11393. RoomType = item.RoomExplanation
  11394. };
  11395. vouchers.Add(voucherInfo);
  11396. }
  11397. if (guestIds.Count > 0)
  11398. {
  11399. guestIds = guestIds.Distinct().ToList();
  11400. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  11401. if (guestDatas.Count > 0)
  11402. {
  11403. guestNames = "";
  11404. foreach (var guest in guestDatas)
  11405. {
  11406. string guestName = "";
  11407. if (guest.Sex == 0) guestName += @"MR.";
  11408. else if (guest.Sex == 1) guestName += @"MS.";
  11409. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11410. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11411. guestNames += @$"{guestName.Trim()}、";
  11412. }
  11413. if (guestNames.Length > 0)
  11414. {
  11415. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11416. }
  11417. }
  11418. }
  11419. #endregion
  11420. //载入模板
  11421. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  11422. Document doc = new Document(sss);
  11423. DocumentBuilder builder = new DocumentBuilder(doc);
  11424. if (doc.Range.Bookmarks["GuestName"] != null)
  11425. {
  11426. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  11427. mark.Text = guestNames;
  11428. }
  11429. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11430. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  11431. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  11432. for (int i = 1; i <= vouchers.Count; i++)
  11433. {
  11434. HotelVoucherInfoView hviv = vouchers[i - 1];
  11435. builder.MoveToCell(0, i, 0, 0);
  11436. builder.Write(hviv.HotelName);
  11437. builder.MoveToCell(0, i, 1, 0);
  11438. builder.Write(hviv.CheckInDate);
  11439. builder.MoveToCell(0, i, 2, 0);
  11440. builder.Write(hviv.CheckOutDate);
  11441. builder.MoveToCell(0, i, 3, 0);
  11442. builder.Write(hviv.RoomType);
  11443. builder.MoveToCell(0, i, 4, 0);
  11444. builder.Write(hviv.ConfirmationNumber);
  11445. }
  11446. //删除多余行
  11447. int currRowIndex = vouchers.Count + 1;
  11448. int delRows = 21 - currRowIndex;
  11449. if (delRows > 0)
  11450. {
  11451. for (int i = 0; i < delRows; i++)
  11452. {
  11453. table.Rows.RemoveAt(currRowIndex);
  11454. //cultivateRowIndex++;
  11455. }
  11456. }
  11457. strFileName += "VOUCHER.docx";
  11458. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11459. doc.Save(fileDir);
  11460. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11461. return Ok(JsonView(true, "操作成功!", Url));
  11462. }
  11463. /// <summary>
  11464. /// 酒店预订
  11465. /// 生成VOUCHER 批量生成
  11466. /// New
  11467. /// </summary>
  11468. /// <param name="_dto"></param>
  11469. /// <returns></returns>
  11470. [HttpPost]
  11471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11472. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  11473. {
  11474. #region 参数验证
  11475. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11476. if (_dto.PageId < 1) _dto.PageId = 28;
  11477. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11478. #region 团组操作权限验证 76 酒店预定模块
  11479. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11480. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11481. #endregion
  11482. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11483. #region 页面操作权限验证
  11484. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11485. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11486. #endregion
  11487. #endregion
  11488. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  11489. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  11490. .OrderBy(x => x.CheckInDate)
  11491. .ToListAsync();
  11492. //判断数据是否完整
  11493. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11494. string strFileName = "HotelStatement/";
  11495. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11496. if (dele != null)
  11497. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  11498. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  11499. for (int i = 0; i < hrDtas.Count; i++)
  11500. {
  11501. string guestNames = string.Empty;
  11502. List<int> guestIds = new List<int>();
  11503. var item = hrDtas[i];
  11504. //处理客户姓名
  11505. if (item.GuestName.Contains(","))
  11506. {
  11507. string[] guestIdArr = item.GuestName.Split(',');
  11508. foreach (var guestIdStr in guestIdArr)
  11509. if (int.TryParse(guestIdStr, out int guestId))
  11510. guestIds.Add(guestId);
  11511. }
  11512. else
  11513. {
  11514. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  11515. if (guestIdBool)
  11516. {
  11517. guestIds.Add(guestId);
  11518. }
  11519. //NaN
  11520. if (item.GuestName.Contains("NaN"))
  11521. {
  11522. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  11523. }
  11524. }
  11525. if (guestIds.Count > 0)
  11526. {
  11527. guestIds = guestIds.Distinct().ToList();
  11528. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  11529. if (guestDatas1.Count > 0)
  11530. {
  11531. guestNames = "";
  11532. foreach (var guest in guestDatas1)
  11533. {
  11534. string guestName = "";
  11535. if (guest.Sex == 0) guestName += @"MR.";
  11536. else if (guest.Sex == 1) guestName += @"MS.";
  11537. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11538. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11539. guestNames += @$"{guestName.Trim()}、";
  11540. }
  11541. if (guestNames.Length > 0)
  11542. {
  11543. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11544. }
  11545. }
  11546. }
  11547. //if (!string.IsNullOrEmpty(guestNames))
  11548. //{
  11549. hrDtas[i].GuestName = guestNames;
  11550. //}
  11551. }
  11552. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11553. Document doc = new Document();
  11554. DocumentBuilder builder = new DocumentBuilder(doc);
  11555. try
  11556. {
  11557. builder.MoveToDocumentStart();
  11558. foreach (var item in hrDtas)
  11559. {
  11560. //标题
  11561. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11562. builder.ParagraphFormat.LineSpacing = 1;
  11563. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11564. builder.ParagraphFormat.Style.Font.Size = 9;
  11565. builder.ParagraphFormat.Style.Font.Bold = true;
  11566. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11567. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  11568. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11569. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11570. builder.ParagraphFormat.LineSpacing = 1;
  11571. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11572. builder.ParagraphFormat.Style.Font.Size = 9;
  11573. builder.ParagraphFormat.Style.Font.Bold = true;
  11574. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  11575. builder.StartTable();
  11576. // 设置边框颜色
  11577. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  11578. //设置边框样式
  11579. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  11580. //表格
  11581. #region 第一行
  11582. builder.InsertCell();
  11583. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11584. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11585. //builder.CellFormat.AllowAutoFit = false;
  11586. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11587. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11588. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11589. builder.CellFormat.WrapText = true; //自动换行
  11590. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11591. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  11592. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11593. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11594. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11595. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11596. builder.Write("TOUR NO:");
  11597. builder.InsertCell();
  11598. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11599. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11600. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11601. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11602. builder.ParagraphFormat.Style.Font.Bold = false;
  11603. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11604. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11605. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11606. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11607. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11608. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11609. builder.Write($"{dele?.TourCode ?? "-"}");
  11610. builder.InsertCell();
  11611. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11612. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11613. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11614. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11615. builder.ParagraphFormat.Style.Font.Bold = false;
  11616. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11617. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11618. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11619. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11620. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11621. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11622. builder.Write($"CITY:");
  11623. builder.InsertCell();
  11624. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11625. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11626. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11627. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11628. builder.ParagraphFormat.Style.Font.Bold = false;
  11629. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11630. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11631. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11632. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11633. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11634. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11635. builder.Write($"{item.City}");
  11636. builder.EndRow();
  11637. #endregion
  11638. #region 第二行
  11639. builder.InsertCell();
  11640. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11641. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11642. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11643. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11644. builder.ParagraphFormat.Style.Font.Bold = false;
  11645. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11646. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11647. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11648. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11649. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11650. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11651. builder.Write("CONFIRMATION NO:");
  11652. builder.InsertCell();
  11653. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11654. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11655. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11656. builder.ParagraphFormat.Style.Font.Bold = false;
  11657. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11658. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11659. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11660. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11661. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11662. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11663. builder.CellFormat.VerticalMerge = CellMerge.None;
  11664. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11665. builder.Write($"{item.DetermineNo}");
  11666. builder.InsertCell();
  11667. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11668. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11669. builder.InsertCell();
  11670. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11671. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11672. builder.EndRow();
  11673. #endregion
  11674. #region 第三行
  11675. builder.InsertCell();
  11676. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11677. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11678. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11679. builder.ParagraphFormat.Style.Font.Bold = false;
  11680. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11681. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11682. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11683. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11684. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11685. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11686. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11687. builder.Write($"HOTEL NAME:");
  11688. builder.InsertCell();
  11689. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11690. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11691. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11692. builder.ParagraphFormat.Style.Font.Bold = false;
  11693. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11694. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11695. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11696. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11697. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11698. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11699. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11700. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11701. builder.Write($"{item.HotelName}");
  11702. builder.InsertCell();
  11703. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11704. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11705. builder.InsertCell();
  11706. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11707. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11708. builder.EndRow();
  11709. #endregion
  11710. #region 第四行
  11711. builder.InsertCell();
  11712. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11713. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11714. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11715. builder.ParagraphFormat.Style.Font.Bold = false;
  11716. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11717. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11718. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11719. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11720. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11721. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11722. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11723. builder.Write($"HOTEL ADDRESS:");
  11724. builder.InsertCell();
  11725. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11726. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11727. builder.ParagraphFormat.Style.Font.Size = 8;
  11728. builder.ParagraphFormat.Style.Font.Bold = false;
  11729. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11730. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11731. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11732. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11733. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11734. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11735. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11736. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11737. builder.Write($"{item.HotelAddress}");
  11738. builder.InsertCell();
  11739. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11740. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11741. builder.InsertCell();
  11742. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11743. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11744. builder.EndRow();
  11745. #endregion
  11746. #region 第五行
  11747. builder.InsertCell();
  11748. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11749. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11750. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11751. builder.ParagraphFormat.Style.Font.Bold = false;
  11752. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11753. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11754. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11755. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11756. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11757. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11758. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11759. builder.Write("TEL:");
  11760. builder.InsertCell();
  11761. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11762. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11763. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11764. builder.ParagraphFormat.Style.Font.Bold = false;
  11765. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11766. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11767. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11768. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11769. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11770. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11771. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11772. builder.Write($"{item.HotelTel}");
  11773. builder.InsertCell();
  11774. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11775. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11776. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11777. builder.ParagraphFormat.Style.Font.Bold = false;
  11778. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11779. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11780. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11781. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11782. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11783. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11784. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11785. builder.Write($"FAX:");
  11786. builder.InsertCell();
  11787. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11788. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11789. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11790. builder.ParagraphFormat.Style.Font.Bold = false;
  11791. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11792. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11793. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11794. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11795. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11796. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11797. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11798. builder.Write($"{item.HotelFax}");
  11799. builder.EndRow();
  11800. #endregion
  11801. #region 第六行
  11802. builder.InsertCell();
  11803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11804. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11805. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11806. builder.ParagraphFormat.Style.Font.Bold = false;
  11807. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11808. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11809. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11810. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11811. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11812. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11813. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11814. builder.Write("CHECK IN:");
  11815. builder.InsertCell();
  11816. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11817. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11818. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11819. builder.ParagraphFormat.Style.Font.Bold = false;
  11820. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11821. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11822. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11823. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11824. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11825. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11826. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11827. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  11828. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11829. builder.Write($"{checkInStr}");
  11830. builder.InsertCell();
  11831. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11832. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11833. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11834. builder.ParagraphFormat.Style.Font.Bold = false;
  11835. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11836. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11837. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11838. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11839. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11840. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11841. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11842. builder.Write($"CHECK OUT:");
  11843. builder.InsertCell();
  11844. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11845. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11846. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11847. builder.ParagraphFormat.Style.Font.Bold = false;
  11848. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11849. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11850. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11851. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11852. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11853. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11854. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11855. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  11856. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  11857. builder.Write($"{checkOutStr}");
  11858. builder.EndRow();
  11859. #endregion
  11860. #region 第七行
  11861. builder.InsertCell();
  11862. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11863. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11864. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11865. builder.ParagraphFormat.Style.Font.Bold = false;
  11866. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11867. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11868. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11869. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11870. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11871. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11872. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11873. builder.Write($"GUEST NAME:");
  11874. builder.InsertCell();
  11875. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11876. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11877. builder.ParagraphFormat.Style.Font.Size = 8;
  11878. builder.ParagraphFormat.Style.Font.Bold = false;
  11879. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11880. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11881. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11882. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11883. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11884. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11885. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11886. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11887. builder.Write($"{item.GuestName}");
  11888. builder.InsertCell();
  11889. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11890. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11891. builder.InsertCell();
  11892. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11893. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11894. builder.EndRow();
  11895. #endregion
  11896. #region 第八行
  11897. builder.InsertCell();
  11898. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11899. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11900. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11901. builder.ParagraphFormat.Style.Font.Bold = false;
  11902. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11903. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11904. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11905. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11906. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11907. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11908. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11909. builder.Write($"ROOM TYPE:");
  11910. builder.InsertCell();
  11911. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11912. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11913. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11914. builder.ParagraphFormat.Style.Font.Bold = false;
  11915. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11916. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11917. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11918. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11919. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11920. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11921. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11922. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11923. builder.Write($"{item.RoomExplanation}");
  11924. builder.InsertCell();
  11925. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11926. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11927. builder.InsertCell();
  11928. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11929. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11930. builder.EndRow();
  11931. #endregion
  11932. #region 第九行
  11933. builder.InsertCell();
  11934. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11935. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11936. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11937. builder.ParagraphFormat.Style.Font.Bold = false;
  11938. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11939. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11940. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11941. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11942. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11943. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11944. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11945. builder.Write($"NOTE:");
  11946. builder.InsertCell();
  11947. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11948. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11949. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11950. builder.ParagraphFormat.Style.Font.Bold = false;
  11951. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11952. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11953. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11954. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11955. 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.");
  11956. builder.InsertCell();
  11957. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11958. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11959. builder.InsertCell();
  11960. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11961. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11962. builder.EndRow();
  11963. #endregion
  11964. builder.EndTable();
  11965. //换行
  11966. builder.Writeln("");
  11967. builder.Writeln("");
  11968. }
  11969. #region 获取文档中的所有表格 设置文字自适应
  11970. // 获取文档中的所有表格。
  11971. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11972. {
  11973. // 遍历表格中的所有行。
  11974. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11975. {
  11976. foreach (Cell cell in row.Cells)
  11977. {
  11978. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  11979. cellFormat.Width = 0;
  11980. }
  11981. }
  11982. }
  11983. #endregion
  11984. #region 设置页眉
  11985. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  11986. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  11987. if (System.IO.File.Exists(voucherHeaderPath))
  11988. {
  11989. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  11990. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  11991. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  11992. Shape shape = builder.InsertImage(imageBytes);
  11993. // 调整图片位置
  11994. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  11995. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  11996. shape.Top = 50; // 将图片距离页眉上边缘的距离
  11997. shape.Left = 0; // 将图片距离页面左边缘的距离
  11998. shape.Width = 81; // 设置图片宽度
  11999. shape.Height = 36; // 设置图片高度
  12000. }
  12001. //靠右
  12002. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  12003. //// 设置页脚上下边距
  12004. //builder.PageSetup.HeaderDistance = 42;
  12005. // 添加页眉线
  12006. Aspose.Words.Border borderHeader = null;
  12007. try
  12008. {
  12009. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  12010. }
  12011. catch (Exception e)
  12012. {
  12013. // TODO Auto-generated catch block
  12014. //e.printStackTrace();
  12015. }
  12016. borderHeader.Shadow = true;
  12017. borderHeader.DistanceFromText = 2;
  12018. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  12019. #endregion
  12020. }
  12021. catch (Exception ex)
  12022. {
  12023. }
  12024. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12025. doc.Save(fileDir);
  12026. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12027. return Ok(JsonView(true, "操作成功!", Url));
  12028. }
  12029. /// <summary>
  12030. /// 酒店预订
  12031. /// 生成 预定成本 Excel
  12032. /// </summary>
  12033. /// <param name="_dto"></param>
  12034. /// <returns></returns>
  12035. [HttpPost]
  12036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12037. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  12038. {
  12039. #region 参数验证
  12040. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  12041. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  12042. if (!vadalitorRes.IsValid)
  12043. {
  12044. var errors = new StringBuilder();
  12045. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  12046. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  12047. }
  12048. #region 团组操作权限验证 76 酒店预定模块
  12049. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12050. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12051. #endregion
  12052. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12053. #region 页面操作权限验证
  12054. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12055. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12056. #endregion
  12057. #endregion
  12058. decimal _rate = 1.00M;
  12059. string _currency = string.Empty;
  12060. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  12061. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  12062. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  12063. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  12064. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  12065. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  12066. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  12067. if (_GroupCostParameter == null)
  12068. {
  12069. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  12070. bool isIntType = int.TryParse(_currency, out int currId);
  12071. if (isIntType)
  12072. {
  12073. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12074. }
  12075. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12076. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12077. if (currInfo == null)
  12078. {
  12079. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12080. }
  12081. else _rate = currInfo.Rate;
  12082. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  12083. {
  12084. _rate = _GroupCostParameter.Rate;
  12085. }
  12086. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12087. string strFileName = "HotelStatement/";
  12088. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12089. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12090. var rateDatas = new List<dynamic>();
  12091. #region 数据处理
  12092. foreach (var item in hrDtas)
  12093. {
  12094. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12095. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12096. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12097. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12098. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12099. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  12100. {
  12101. continue;
  12102. }
  12103. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12104. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  12105. string singleRoomFeeStr = string.Empty,
  12106. doubleRoomFeeStr = string.Empty,
  12107. suiteRoomFeeStr = string.Empty,
  12108. otherRoomFeeStr = string.Empty,
  12109. payMoneyStr = string.Empty,
  12110. cardPriceStr = string.Empty;
  12111. if (roomCurr.Equals("CNY"))
  12112. {
  12113. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  12114. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12115. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12116. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12117. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12118. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  12119. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  12120. }
  12121. else
  12122. {
  12123. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12124. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12125. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12126. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12127. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12128. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12129. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12130. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12131. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12132. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12133. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  12134. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  12135. if (ccpPaymentCurrency.Equals("CNY"))
  12136. {
  12137. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  12138. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12139. }
  12140. else
  12141. {
  12142. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  12143. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  12144. }
  12145. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  12146. if (hotelcardPriceCurrency.Equals("CNY"))
  12147. {
  12148. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12149. }
  12150. else
  12151. {
  12152. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  12153. }
  12154. }
  12155. string breakfastPriceStr = string.Empty,
  12156. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12157. governmentRentStr = string.Empty,
  12158. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12159. cityTaxStr = string.Empty,
  12160. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12161. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  12162. if (!string.IsNullOrEmpty(breakfastCurrency1))
  12163. {
  12164. if (breakfastCurrency1.Equals("CNY"))
  12165. {
  12166. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12167. }
  12168. else
  12169. {
  12170. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  12171. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  12172. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  12173. }
  12174. }
  12175. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12176. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  12177. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  12178. {
  12179. if (governmentRentCurrency.Equals("CNY"))
  12180. {
  12181. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12182. }
  12183. else
  12184. {
  12185. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  12186. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  12187. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  12188. }
  12189. }
  12190. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12191. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  12192. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  12193. {
  12194. if (cityTaxStrCurrency1.Equals("CNY"))
  12195. {
  12196. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12197. }
  12198. else
  12199. {
  12200. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  12201. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  12202. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  12203. }
  12204. }
  12205. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12206. int payDId = roomInfo?.PayDId ?? 0;
  12207. pcfds.Add(new HotelReservations_PCFD_View()
  12208. {
  12209. City = item.City,
  12210. HotelName = item.HotelName,
  12211. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12212. // SingleRoomCount = item.SingleRoomCount,
  12213. SingleRoomPrice = singleRoomFeeStr,
  12214. // DoubleRoomCount = item.DoubleRoomCount,
  12215. DoubleRoomPrice = doubleRoomFeeStr,
  12216. //SuiteRoomCount = item.SuiteRoomCount,
  12217. SuiteRoomPrice = suiteRoomFeeStr,
  12218. OtherRoomPrice = otherRoomFeeStr,
  12219. //OtherRoomCount = item.OtherRoomCount,
  12220. BreakfastPrice = breakfastPriceStr,
  12221. GovernmentRent = governmentRentStr,
  12222. CityTax = cityTaxStr,
  12223. RoomExplanation = item.RoomExplanation,
  12224. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12225. PayTime = roomInfo?.ConsumptionDate,
  12226. BankNo = roomInfo?.BankNo,
  12227. PayMoney = payMoneyStr,
  12228. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12229. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12230. CardPrice = cardPriceStr,
  12231. Remark = ccpInfo.Remark
  12232. });
  12233. }
  12234. #endregion
  12235. //载入模板
  12236. WorkbookDesigner designer = new WorkbookDesigner();
  12237. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12238. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12239. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12240. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12241. var rateDatas1 = rateDatas.Distinct();
  12242. var rateStr = string.Empty;
  12243. foreach (var item in rateDatas1)
  12244. {
  12245. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  12246. }
  12247. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  12248. designer.SetDataSource("Opertor", userInfo.CnName);
  12249. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12250. dt.TableName = "ViewMyHotelReservations";
  12251. designer.SetDataSource(dt);
  12252. designer.Process();
  12253. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12254. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12255. designer.Workbook.Save(serverPath);
  12256. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12257. #region 删除指定行
  12258. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12259. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12260. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12261. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12262. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12263. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12264. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12265. cssIndex = dt.Columns["CityTax"].Ordinal,
  12266. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12267. remarkIndex = dt.Columns["Remark"].Ordinal;
  12268. //删除指定列
  12269. foreach (DataRow item in dt.Rows)
  12270. {
  12271. string singleStr = item["SingleRoomPrice"].ToString();
  12272. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12273. if (containsDigitButNotZero1) singleDel = false;
  12274. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12275. string doubleStr = item["DoubleRoomPrice"].ToString();
  12276. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12277. if (containsDigitButNotZero2) doubleDel = false;
  12278. string suiteStr = item["SuiteRoomPrice"].ToString();
  12279. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12280. if (containsDigitButNotZero3) suiteDel = false;
  12281. string otherStr = item["OtherRoomPrice"].ToString();
  12282. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12283. if (containsDigitButNotZero4) otherDel = false;
  12284. string zcStr = item["BreakfastPrice"].ToString();
  12285. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12286. if (containsDigitButNotZero5) zcDel = false;
  12287. string dsStr = item["GovernmentRent"].ToString();
  12288. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12289. if (containsDigitButNotZero6) dsDel = false;
  12290. string cssStr = item["CityTax"].ToString();
  12291. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12292. if (containsDigitButNotZero7) cssDel = false;
  12293. string cpStr = item["ConsumptionPatterns"].ToString();
  12294. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12295. string remarkStr = item["Remark"].ToString();
  12296. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12297. }
  12298. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12299. DeleteColumn(serverPath, cpIndex, cpDel);
  12300. DeleteColumn(serverPath, dsIndex, dsDel);
  12301. DeleteColumn(serverPath, cssIndex, cssDel);
  12302. DeleteColumn(serverPath, zcIndex, zcDel);
  12303. DeleteColumn(serverPath, otherIndex, otherDel);
  12304. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12305. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12306. DeleteColumn(serverPath, singleIndex, singleDel);
  12307. #endregion
  12308. //只保留第一个表格
  12309. DeleteSheet(serverPath);
  12310. return Ok(JsonView(true, "操作成功", url = rst));
  12311. }
  12312. else
  12313. {
  12314. _currency = _GroupCostParameter.Currency;
  12315. bool isIntType = int.TryParse(_currency, out int currId);
  12316. if (isIntType)
  12317. {
  12318. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12319. }
  12320. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12321. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12322. if (currInfo == null)
  12323. {
  12324. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12325. }
  12326. if (!_currency.ToUpper().Equals("CNY"))
  12327. {
  12328. _rate = _GroupCostParameter.Rate;
  12329. }
  12330. _rate = currInfo.Rate;
  12331. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12332. string strFileName = "HotelStatement/";
  12333. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12334. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12335. #region 数据处理
  12336. foreach (var item in hrDtas)
  12337. {
  12338. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12339. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12340. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12341. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12342. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12343. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12344. string singleRoomFeeStr = string.Empty,
  12345. doubleRoomFeeStr = string.Empty,
  12346. suiteRoomFeeStr = string.Empty,
  12347. otherRoomFeeStr = string.Empty,
  12348. payMoneyStr = string.Empty,
  12349. cardPriceStr = string.Empty;
  12350. if (roomCurr.Equals(_currency))
  12351. {
  12352. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  12353. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  12354. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  12355. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  12356. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  12357. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  12358. }
  12359. else
  12360. {
  12361. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12362. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12363. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12364. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12365. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12366. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12367. }
  12368. string breakfastPriceStr = string.Empty,
  12369. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12370. governmentRentStr = string.Empty,
  12371. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12372. cityTaxStrStr = string.Empty,
  12373. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12374. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  12375. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  12376. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  12377. int payDId = roomInfo?.PayDId ?? 0;
  12378. pcfds.Add(new HotelReservations_PCFD_View()
  12379. {
  12380. City = item.City,
  12381. HotelName = item.HotelName,
  12382. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12383. // SingleRoomCount = item.SingleRoomCount,
  12384. SingleRoomPrice = singleRoomFeeStr,
  12385. // DoubleRoomCount = item.DoubleRoomCount,
  12386. DoubleRoomPrice = doubleRoomFeeStr,
  12387. //SuiteRoomCount = item.SuiteRoomCount,
  12388. SuiteRoomPrice = suiteRoomFeeStr,
  12389. OtherRoomPrice = otherRoomFeeStr,
  12390. //OtherRoomCount = item.OtherRoomCount,
  12391. BreakfastPrice = breakfastPriceStr,
  12392. GovernmentRent = governmentRentStr,
  12393. CityTax = cityTaxStrStr,
  12394. RoomExplanation = item.RoomExplanation,
  12395. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12396. PayTime = roomInfo?.ConsumptionDate,
  12397. BankNo = roomInfo?.BankNo,
  12398. PayMoney = payMoneyStr,
  12399. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12400. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12401. CardPrice = cardPriceStr,
  12402. Remark = ccpInfo.Remark
  12403. });
  12404. }
  12405. #endregion
  12406. //载入模板
  12407. WorkbookDesigner designer = new WorkbookDesigner();
  12408. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12409. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12410. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12411. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12412. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  12413. designer.SetDataSource("Opertor", userInfo.CnName);
  12414. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12415. dt.TableName = "ViewMyHotelReservations";
  12416. designer.SetDataSource(dt);
  12417. designer.Process();
  12418. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12419. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12420. designer.Workbook.Save(serverPath);
  12421. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12422. #region 删除指定行
  12423. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12424. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12425. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12426. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12427. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12428. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12429. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12430. cssIndex = dt.Columns["CityTax"].Ordinal,
  12431. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12432. remarkIndex = dt.Columns["Remark"].Ordinal;
  12433. //删除指定列
  12434. foreach (DataRow item in dt.Rows)
  12435. {
  12436. string singleStr = item["SingleRoomPrice"].ToString();
  12437. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12438. if (containsDigitButNotZero1) singleDel = false;
  12439. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12440. string doubleStr = item["DoubleRoomPrice"].ToString();
  12441. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12442. if (containsDigitButNotZero2) doubleDel = false;
  12443. string suiteStr = item["SuiteRoomPrice"].ToString();
  12444. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12445. if (containsDigitButNotZero3) suiteDel = false;
  12446. string otherStr = item["OtherRoomPrice"].ToString();
  12447. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12448. if (containsDigitButNotZero4) otherDel = false;
  12449. string zcStr = item["BreakfastPrice"].ToString();
  12450. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12451. if (containsDigitButNotZero5) zcDel = false;
  12452. string dsStr = item["GovernmentRent"].ToString();
  12453. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12454. if (containsDigitButNotZero6) dsDel = false;
  12455. string cssStr = item["CityTax"].ToString();
  12456. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12457. if (containsDigitButNotZero7) cssDel = false;
  12458. string cpStr = item["ConsumptionPatterns"].ToString();
  12459. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12460. string remarkStr = item["Remark"].ToString();
  12461. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12462. }
  12463. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12464. DeleteColumn(serverPath, cpIndex, cpDel);
  12465. DeleteColumn(serverPath, dsIndex, dsDel);
  12466. DeleteColumn(serverPath, cssIndex, cssDel);
  12467. DeleteColumn(serverPath, zcIndex, zcDel);
  12468. DeleteColumn(serverPath, otherIndex, otherDel);
  12469. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12470. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12471. DeleteColumn(serverPath, singleIndex, singleDel);
  12472. #endregion
  12473. //只保留第一个表格
  12474. DeleteSheet(serverPath);
  12475. return Ok(JsonView(true, "操作成功", url = rst));
  12476. }
  12477. return Ok(JsonView(false));
  12478. }
  12479. /// <summary>
  12480. /// 删除指定列
  12481. /// </summary>
  12482. /// <param name="file"></param>
  12483. /// <param name="columnIndex"></param>
  12484. /// <param name="isDel"></param>
  12485. private void DeleteColumn(string file, int columnIndex, bool isDel)
  12486. {
  12487. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12488. //wb.Save(file);
  12489. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  12490. if (sheet1 != null)
  12491. {
  12492. if (isDel)
  12493. {
  12494. Cells cells = sheet1.Cells;
  12495. cells.DeleteColumn(columnIndex);
  12496. }
  12497. }
  12498. wb.Save(file);
  12499. }
  12500. /// <summary>
  12501. /// 删除sheet
  12502. /// </summary>
  12503. /// <param name="file"></param>
  12504. /// <param name="sheetName"></param>
  12505. private void DeleteSheet(string file, string sheetName = "")
  12506. {
  12507. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12508. //wb.Save(file);
  12509. List<string> sheets = new List<string>();
  12510. foreach (var item in wb.Worksheets)
  12511. {
  12512. sheets.Add(item.Name);
  12513. }
  12514. if (sheets.Count > 0)
  12515. {
  12516. sheets.RemoveAt(0);//不删除第一个sheet
  12517. foreach (var item in sheets)
  12518. {
  12519. wb.Worksheets.RemoveAt(item);
  12520. }
  12521. }
  12522. wb.Save(file);
  12523. }
  12524. /// <summary>
  12525. /// 酒店预订
  12526. /// 确认单
  12527. /// </summary>
  12528. /// <param name="_dto"></param>
  12529. /// <returns></returns>
  12530. [HttpPost]
  12531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12532. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  12533. {
  12534. try
  12535. {
  12536. #region 参数验证
  12537. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12538. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12539. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12540. #region 团组操作权限验证 76 酒店预定模块
  12541. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12542. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12543. #endregion
  12544. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12545. #region 页面操作权限验证
  12546. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12547. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12548. #endregion
  12549. #endregion
  12550. //团组信息
  12551. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  12552. //酒店数据
  12553. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  12554. if (listhoteldata.Count < 0)
  12555. {
  12556. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  12557. }
  12558. //利datatable存储
  12559. DataTable dt = new DataTable();
  12560. dt.Columns.Add("CheckInDate", typeof(string));
  12561. dt.Columns.Add("City", typeof(string));
  12562. dt.Columns.Add("Hotel", typeof(string));
  12563. dt.Columns.Add("Room", typeof(string));
  12564. for (int i = 0; i < listhoteldata.Count; i++)
  12565. {
  12566. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  12567. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  12568. while (dayStart < dayEnd)
  12569. {
  12570. string temp = "";
  12571. DataRow row = dt.NewRow();
  12572. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  12573. row["City"] = listhoteldata[i].City;
  12574. row["Hotel"] = listhoteldata[i].HotelName;
  12575. if (listhoteldata[i].SingleRoomCount > 0)
  12576. {
  12577. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  12578. }
  12579. if (listhoteldata[i].DoubleRoomCount > 0)
  12580. {
  12581. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  12582. }
  12583. if (listhoteldata[i].SuiteRoomCount > 0)
  12584. {
  12585. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  12586. }
  12587. if (listhoteldata[i].OtherRoomCount > 0)
  12588. {
  12589. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  12590. }
  12591. row["Room"] = temp;
  12592. dt.Rows.Add(row);
  12593. dayStart = dayStart.AddDays(1);
  12594. }
  12595. }
  12596. Dictionary<string, string> dic = new Dictionary<string, string>();
  12597. dic.Add("Dele", di.TeamName);
  12598. dic.Add("City", di.VisitCountry);
  12599. //模板路径
  12600. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  12601. //载入模板
  12602. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  12603. DocumentBuilder builder = new DocumentBuilder(doc);
  12604. foreach (var key in dic.Keys)
  12605. {
  12606. builder.MoveToBookmark(key);
  12607. builder.Write(dic[key]);
  12608. }
  12609. //获取word里所有表格
  12610. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12611. //获取所填表格的序数
  12612. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12613. var rowStart = tableOne.Rows[0]; //获取第1行
  12614. //循环赋值
  12615. for (int i = 0; i < dt.Rows.Count; i++)
  12616. {
  12617. builder.MoveToCell(0, i + 1, 0, 0);
  12618. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  12619. builder.MoveToCell(0, i + 1, 1, 0);
  12620. builder.Write(dt.Rows[i]["City"].ToString());
  12621. builder.MoveToCell(0, i + 1, 2, 0);
  12622. builder.Write(dt.Rows[i]["Hotel"].ToString());
  12623. builder.MoveToCell(0, i + 1, 3, 0);
  12624. builder.Write(dt.Rows[i]["Room"].ToString());
  12625. }
  12626. //删除多余行
  12627. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  12628. {
  12629. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  12630. }
  12631. string strFileName = di.TeamName + "酒店确认单.doc";
  12632. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  12633. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  12634. return Ok(JsonView(true, "成功", url));
  12635. }
  12636. catch (Exception ex)
  12637. {
  12638. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  12639. }
  12640. }
  12641. #endregion
  12642. #region 团组状态
  12643. /// <summary>
  12644. /// 团组状态列表 Page
  12645. /// </summary>
  12646. /// <param name="dto">团组列表请求dto</param>
  12647. /// <returns></returns>
  12648. [HttpPost]
  12649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12650. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  12651. {
  12652. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12653. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  12654. {
  12655. string sqlWhere = string.Empty;
  12656. if (dto.IsSure == 0) //未完成
  12657. {
  12658. sqlWhere += string.Format(@" And IsSure = 0");
  12659. }
  12660. else if (dto.IsSure == 1) //已完成
  12661. {
  12662. sqlWhere += string.Format(@" And IsSure = 1");
  12663. }
  12664. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  12665. {
  12666. string tj = dto.SearchCriteria;
  12667. 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}%')",
  12668. tj, tj, tj, tj, tj);
  12669. }
  12670. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  12671. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  12672. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  12673. From (
  12674. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  12675. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  12676. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  12677. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  12678. From Grp_DelegationInfo gdi
  12679. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  12680. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  12681. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  12682. Where gdi.IsDel = 0 {0}
  12683. ) temp ", sqlWhere);
  12684. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  12685. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  12686. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  12687. }
  12688. else
  12689. {
  12690. return Ok(JsonView(false, "查询失败"));
  12691. }
  12692. }
  12693. /// <summary>
  12694. /// 团组状态
  12695. /// 设置操作完成
  12696. /// </summary>
  12697. /// <param name="dto">团组列表请求dto</param>
  12698. /// <returns></returns>
  12699. [HttpPost]
  12700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12701. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  12702. {
  12703. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12704. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  12705. {
  12706. Id = dto.Id,
  12707. IsSure = 1
  12708. };
  12709. var result = await _sqlSugar.Updateable(_DelegationInfo)
  12710. .UpdateColumns(it => new { it.IsSure })
  12711. .WhereColumns(it => new { it.Id })
  12712. .ExecuteCommandAsync();
  12713. if (result > 0)
  12714. {
  12715. return Ok(JsonView(true, "操作完成!"));
  12716. }
  12717. return Ok(JsonView(false, "操作失败!"));
  12718. }
  12719. #endregion
  12720. #region 保险费用录入
  12721. /// <summary>
  12722. /// 根据团组Id查询保险费用列表
  12723. /// </summary>
  12724. /// <param name="dto"></param>
  12725. /// <returns></returns>
  12726. [HttpPost]
  12727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12728. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  12729. {
  12730. Result groupData = await _customersRep.CustomersByDiId(dto);
  12731. if (groupData.Code != 0)
  12732. {
  12733. return Ok(JsonView(false, groupData.Msg));
  12734. }
  12735. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12736. }
  12737. /// <summary>
  12738. /// 根据保险费用Id查询保险费用详细
  12739. /// </summary>
  12740. /// <param name="dto"></param>
  12741. /// <returns></returns>
  12742. [HttpPost]
  12743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12744. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  12745. {
  12746. try
  12747. {
  12748. Result groupData = await _customersRep.CustomersById(dto);
  12749. if (groupData.Code != 0)
  12750. {
  12751. return Ok(JsonView(false, groupData.Msg));
  12752. }
  12753. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12754. }
  12755. catch (Exception ex)
  12756. {
  12757. return Ok(JsonView(false, ex.Message));
  12758. }
  12759. }
  12760. /// <summary>
  12761. /// 保险费用录入页面初始化绑定
  12762. /// </summary>
  12763. /// <param name="dto"></param>
  12764. /// <returns></returns>
  12765. [HttpPost]
  12766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12767. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  12768. {
  12769. try
  12770. {
  12771. Result groupData = await _customersRep.CustomersInitialize(dto);
  12772. if (groupData.Code != 0)
  12773. {
  12774. return Ok(JsonView(false, groupData.Msg));
  12775. }
  12776. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12777. }
  12778. catch (Exception ex)
  12779. {
  12780. return Ok(JsonView(false, ex.Message));
  12781. }
  12782. }
  12783. /// <summary>
  12784. /// 保险费用操作(Status:1.新增,2.修改)
  12785. /// </summary>
  12786. /// <param name="dto"></param>
  12787. /// <returns></returns>
  12788. [HttpPost]
  12789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12790. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  12791. {
  12792. Result groupData = await _customersRep.OpCustomers(dto);
  12793. if (groupData.Code != 0)
  12794. {
  12795. return Ok(JsonView(false, groupData.Msg));
  12796. }
  12797. #region 应用推送
  12798. try
  12799. {
  12800. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12801. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12802. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  12803. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12804. //自动审核
  12805. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  12806. //2024-10-21 新增LZ UID
  12807. var userIds = new List<int>() { 21 };
  12808. string title = $"系统通知";
  12809. var diId = dto.DiId;
  12810. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12811. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12812. string content = "";
  12813. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12814. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12815. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12816. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12817. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12818. }
  12819. catch (Exception ex)
  12820. {
  12821. }
  12822. #endregion
  12823. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12824. }
  12825. /// <summary>
  12826. /// 保险文件上传
  12827. /// </summary>
  12828. /// <param name="file"></param>
  12829. /// <returns></returns>
  12830. [HttpPost]
  12831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12832. public async Task<IActionResult> UploadCus(IFormFile file)
  12833. {
  12834. try
  12835. {
  12836. if (file != null)
  12837. {
  12838. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12839. //文件名称
  12840. string projectFileName = file.FileName;
  12841. //上传的文件的路径
  12842. string filePath = "";
  12843. if (!Directory.Exists(fileDir))
  12844. {
  12845. Directory.CreateDirectory(fileDir);
  12846. }
  12847. //上传的文件的路径
  12848. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  12849. using (FileStream fs = System.IO.File.Create(filePath))
  12850. {
  12851. file.CopyTo(fs);
  12852. fs.Flush();
  12853. }
  12854. return Ok(JsonView(true, "上传成功!", projectFileName));
  12855. }
  12856. else
  12857. {
  12858. return Ok(JsonView(false, "上传失败!"));
  12859. }
  12860. }
  12861. catch (Exception ex)
  12862. {
  12863. return Ok(JsonView(false, "程序错误!"));
  12864. throw;
  12865. }
  12866. }
  12867. /// <summary>
  12868. /// 保险删除指定文件
  12869. /// </summary>
  12870. /// <param name="dto"></param>
  12871. /// <returns></returns>
  12872. [HttpPost]
  12873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12874. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  12875. {
  12876. try
  12877. {
  12878. string filePath = "";
  12879. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12880. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  12881. //int id = 0;
  12882. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  12883. // 删除该文件
  12884. try
  12885. {
  12886. System.IO.File.Delete(filePath);
  12887. 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()
  12888. {
  12889. Attachment = "",
  12890. }).ExecuteCommandAsync();
  12891. if (result != 0)
  12892. {
  12893. return Ok(JsonView(true, "成功!"));
  12894. }
  12895. else
  12896. {
  12897. return Ok(JsonView(false, "失败!"));
  12898. }
  12899. }
  12900. catch (Exception)
  12901. {
  12902. 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()
  12903. {
  12904. Attachment = "",
  12905. }).ExecuteCommandAsync();
  12906. if (result != 0)
  12907. {
  12908. return Ok(JsonView(true, "成功!"));
  12909. }
  12910. else
  12911. {
  12912. return Ok(JsonView(false, "失败!"));
  12913. }
  12914. }
  12915. }
  12916. catch (Exception ex)
  12917. {
  12918. return Ok(JsonView(false, "程序错误!"));
  12919. throw;
  12920. }
  12921. }
  12922. /// <summary>
  12923. /// 保险费用操作(删除)
  12924. /// </summary>
  12925. /// <param name="dto"></param>
  12926. /// <returns></returns>
  12927. [HttpPost]
  12928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12929. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  12930. {
  12931. try
  12932. {
  12933. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  12934. if (!res)
  12935. {
  12936. return Ok(JsonView(false, "删除失败"));
  12937. }
  12938. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  12939. {
  12940. IsDel = 1,
  12941. DeleteUserId = dto.DeleteUserId,
  12942. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12943. }).ExecuteCommandAsync();
  12944. return Ok(JsonView(true, "删除成功!"));
  12945. }
  12946. catch (Exception ex)
  12947. {
  12948. return Ok(JsonView(false, "程序错误!"));
  12949. throw;
  12950. }
  12951. }
  12952. #endregion
  12953. #region 接团客户名单 PageId 104
  12954. /// <summary>
  12955. /// 接团客户名单
  12956. /// 迁移数据(慎用!)
  12957. /// </summary>
  12958. /// <param name="dto"></param>
  12959. /// <returns></returns>
  12960. [HttpPost]
  12961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12962. public async Task<IActionResult> PostTourClientListChange()
  12963. {
  12964. try
  12965. {
  12966. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  12967. //var groupClinetData1
  12968. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  12969. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  12970. int updateCount = 0;
  12971. if (oldOAClientList.Count > 0)
  12972. {
  12973. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  12974. _sqlSugar.BeginTran();
  12975. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  12976. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  12977. foreach (var item in oldOAClientList)
  12978. {
  12979. int comId = 0;
  12980. string format = "yyyy-MM-dd HH:mm:ss";
  12981. string data11 = "1990-01-01 00:00";
  12982. var data1 = IsValidDate(item.OPdate, format);
  12983. if (data1) data11 = item.OPdate;
  12984. //客户公司验证
  12985. if (!string.IsNullOrEmpty(item.Company))
  12986. {
  12987. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  12988. if (clientComInfo == null) // add
  12989. {
  12990. var addInfo = new Crm_CustomerCompany()
  12991. {
  12992. CompanyAbbreviation = "",
  12993. CompanyFullName = item.Company,
  12994. Address = "",
  12995. PostCodes = "",
  12996. LastedOpUserId = item.OPer,
  12997. LastedOpDt = Convert.ToDateTime(data11),
  12998. CreateUserId = item.OPer,
  12999. CreateTime = Convert.ToDateTime(data11),
  13000. IsDel = 0
  13001. };
  13002. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  13003. if (comId1 > 0) comId = comId1;
  13004. }
  13005. else comId = clientComInfo.Id;
  13006. }
  13007. //客户人员验证
  13008. int clientId = 0;
  13009. string name = item.LastName + item.Name;
  13010. if (!string.IsNullOrEmpty(name))
  13011. {
  13012. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  13013. if (clientInfo == null)
  13014. {
  13015. DateTime? dateTime = null;
  13016. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  13017. if (isDt) dateTime = birthDayDt;
  13018. var addInfo1 = new Crm_DeleClient()
  13019. {
  13020. CrmCompanyId = comId,
  13021. DiId = -1,
  13022. LastName = item.LastName,
  13023. FirstName = item.Name,
  13024. OldName = "",
  13025. Pinyin = item.Pinyin,
  13026. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  13027. Marriage = 0,
  13028. Phone = item.Phone,
  13029. Job = item.Job,
  13030. BirthDay = dateTime
  13031. };
  13032. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  13033. if (clientId1 > 0) clientId = clientId1;
  13034. }
  13035. else clientId = clientInfo.Id;
  13036. }
  13037. if (clientId < 1)
  13038. {
  13039. continue;
  13040. }
  13041. int airType = 0;
  13042. if (item.AirType == "超经舱") airType = 459;
  13043. else if (item.AirType == "公务舱") airType = 458;
  13044. else if (item.AirType == "经济舱") airType = 460;
  13045. else if (item.AirType == "其他") airType = 565;
  13046. else if (item.AirType == "头等舱") airType = 457;
  13047. var _TourClientListEntity = new Grp_TourClientList()
  13048. {
  13049. DiId = item.Diid,
  13050. ClientId = clientId,
  13051. CreateUserId = item.OPer,
  13052. CreateTime = Convert.ToDateTime(data11),
  13053. Remark = item.Remark,
  13054. IsDel = item.Isdel,
  13055. ShippingSpaceTypeId = airType,
  13056. ShippingSpaceSpecialNeeds = item.AirRemark,
  13057. HotelSpecialNeeds = item.RoomType
  13058. };
  13059. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  13060. if (_TourClientList > 0)
  13061. {
  13062. updateCount++;
  13063. }
  13064. }
  13065. _sqlSugar.CommitTran();
  13066. }
  13067. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  13068. }
  13069. catch (Exception ex)
  13070. {
  13071. _sqlSugar.RollbackTran();
  13072. return Ok(JsonView(false, ex.Message));
  13073. }
  13074. return Ok(JsonView(true));
  13075. }
  13076. private bool IsValidDate(string dateString, string format)
  13077. {
  13078. DateTime dateValue;
  13079. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  13080. return valid;
  13081. }
  13082. /// <summary>
  13083. /// 接团客户名单
  13084. /// 根据团组Id查询List
  13085. /// </summary>
  13086. /// <param name="dto"></param>
  13087. /// <returns></returns>
  13088. [HttpPost]
  13089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13090. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  13091. {
  13092. #region 参数验证
  13093. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  13094. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  13095. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  13096. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13097. #region 页面操作权限验证
  13098. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13099. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13100. #endregion
  13101. #endregion
  13102. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  13103. if (viewData.Code != 0)
  13104. {
  13105. return Ok(JsonView(false, viewData.Msg));
  13106. }
  13107. return Ok(JsonView(viewData.Data));
  13108. }
  13109. /// <summary>
  13110. /// 接团客户名单
  13111. /// 基础数据 Init
  13112. /// </summary>
  13113. /// <param name="_dto"></param>
  13114. /// <returns></returns>
  13115. [HttpPost]
  13116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13117. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  13118. {
  13119. #region 参数验证
  13120. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13121. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13122. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13123. #region 页面操作权限验证
  13124. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13125. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13126. #endregion
  13127. #endregion
  13128. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  13129. }
  13130. /// <summary>
  13131. /// 接团客户名单
  13132. /// 根据 Id查询 Details
  13133. /// </summary>
  13134. /// <param name="_dto"></param>
  13135. /// <returns></returns>
  13136. [HttpPost]
  13137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13138. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  13139. {
  13140. #region 参数验证
  13141. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13142. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13143. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13144. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13145. #region 页面操作权限验证
  13146. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13147. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13148. #endregion
  13149. #endregion
  13150. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  13151. if (viewData.Code != 0)
  13152. {
  13153. return Ok(JsonView(false, viewData.Msg));
  13154. }
  13155. return Ok(JsonView(viewData.Data));
  13156. }
  13157. /// <summary>
  13158. /// 接团客户名单
  13159. /// Add Or Edit
  13160. /// </summary>
  13161. /// <param name="_dto"></param>
  13162. /// <returns></returns>
  13163. [HttpPost]
  13164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13165. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  13166. {
  13167. #region 参数验证
  13168. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13169. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13170. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13171. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13172. #region 页面操作权限验证
  13173. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13174. if (_dto.Id == 0) //添加
  13175. {
  13176. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13177. }
  13178. else if (_dto.Id >= 0) //修改
  13179. {
  13180. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13181. }
  13182. #endregion
  13183. #endregion
  13184. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  13185. if (viewData.Code != 0)
  13186. {
  13187. return Ok(JsonView(false, viewData.Msg));
  13188. }
  13189. return Ok(JsonView(true));
  13190. }
  13191. /// <summary>
  13192. /// 接团客户名单
  13193. /// AddMultiple(添加多个)
  13194. /// </summary>
  13195. /// <param name="_dto"></param>
  13196. /// <returns></returns>
  13197. [HttpPost]
  13198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13199. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  13200. {
  13201. #region 参数验证
  13202. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13203. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13204. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13205. #region 页面操作权限验证
  13206. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13207. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13208. #endregion
  13209. #endregion
  13210. var viewData = await _tourClientListRep._AddMultiple(_dto);
  13211. if (viewData.Code != 0)
  13212. {
  13213. return Ok(JsonView(false, viewData.Msg));
  13214. }
  13215. return Ok(JsonView(true));
  13216. }
  13217. /// <summary>
  13218. /// 接团客户名单
  13219. /// Del
  13220. /// </summary>
  13221. /// <param name="_dto"></param>
  13222. /// <returns></returns>
  13223. [HttpPost]
  13224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13225. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  13226. {
  13227. #region 参数验证
  13228. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13229. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13230. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13231. #region 页面操作权限验证
  13232. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13233. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13234. #endregion
  13235. #endregion
  13236. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  13237. if (viewData.Code != 0)
  13238. {
  13239. return Ok(JsonView(false, viewData.Msg));
  13240. }
  13241. return Ok(JsonView(true));
  13242. }
  13243. /// <summary>
  13244. /// 接团客户名单
  13245. /// 文件下载 客户名单
  13246. /// </summary>
  13247. /// <param name="_dto"></param>
  13248. /// <returns></returns>
  13249. [HttpPost]
  13250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13251. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  13252. {
  13253. #region 参数验证
  13254. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13255. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13256. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  13257. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13258. #region 页面操作权限验证
  13259. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13260. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13261. #endregion
  13262. #endregion
  13263. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  13264. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  13265. From Grp_TourClientList tcl
  13266. Left Join
  13267. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  13268. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  13269. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  13270. From Crm_DeleClient dc
  13271. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  13272. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  13273. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  13274. Where dc.IsDel = 0) temp
  13275. On temp.DcId =tcl.ClientId
  13276. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  13277. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  13278. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  13279. //载入模板
  13280. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  13281. if (_dto.Language == 1)
  13282. {
  13283. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  13284. }
  13285. //载入模板
  13286. var doc = new Document(tempPath);
  13287. DocumentBuilder builder = new DocumentBuilder(doc);
  13288. //获取word里所有表格
  13289. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13290. //获取所填表格的序数
  13291. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13292. var rowStart = tableOne.Rows[0]; //获取第1行
  13293. if (_dto.Language == 0)
  13294. {
  13295. //循环赋值
  13296. for (int i = 0; i < DcList.Count; i++)
  13297. {
  13298. EncryptionProcessor.DecryptProperties(DcList[i]);
  13299. builder.MoveToCell(0, i + 1, 0, 0);
  13300. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  13301. builder.MoveToCell(0, i + 1, 1, 0);
  13302. int sex = DcList[i].Sex;
  13303. string sexStr = string.Empty;
  13304. if (sex == 0) sexStr = "男";
  13305. else if (sex == 1) sexStr = "女";
  13306. else sexStr = "未设置";
  13307. builder.Write(sexStr);
  13308. builder.MoveToCell(0, i + 1, 2, 0);
  13309. string birthDay = DcList[i].BirthDay;
  13310. string birthDayStr = string.Empty;
  13311. if (!string.IsNullOrEmpty(birthDay))
  13312. {
  13313. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  13314. }
  13315. builder.Write(birthDayStr);
  13316. builder.MoveToCell(0, i + 1, 3, 0);
  13317. string company = "";
  13318. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13319. {
  13320. company = DcList[i].CompanyFullName.ToString();
  13321. }
  13322. builder.Write(company);
  13323. builder.MoveToCell(0, i + 1, 4, 0);
  13324. builder.Write(DcList[i].Job);
  13325. }
  13326. }
  13327. else if (_dto.Language == 1)
  13328. {
  13329. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  13330. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  13331. List<string> transArrayStr = new List<string>();
  13332. string transStrRes1 = "";
  13333. for (int i = 0; i < DcList.Count; i++)
  13334. {
  13335. var dc = DcList[i];
  13336. EncryptionProcessor.DecryptProperties(dc);
  13337. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  13338. if (dc.Job.Equals("暂无")) dc.Job = "-";
  13339. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  13340. if (DcList.Count - 1 == i) transStrRes1 += str1;
  13341. else transStrRes1 += $"{str1}|";
  13342. }
  13343. //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";
  13344. string transStrRes = "";
  13345. if (transStrRes1.Length > 0)
  13346. {
  13347. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  13348. }
  13349. //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
  13350. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  13351. //List<string> transArray = new List<string> { };
  13352. List<TranslateInfo> transArray = new List<TranslateInfo>();
  13353. if (transStrRes.Contains("|"))
  13354. {
  13355. string[] transArray1 = transStrRes.Split('|');
  13356. if (transArray1.Length > 0)
  13357. {
  13358. foreach (var item in transArray1)
  13359. {
  13360. if (item.Contains("&"))
  13361. {
  13362. string[] transArray2 = item.Split('&');
  13363. int index = 0;
  13364. string companyName = "", job = "";
  13365. if (transArray2.Length > 0)
  13366. {
  13367. bool success = int.TryParse(transArray2[0].Trim(), out index);
  13368. if (1 < transArray2.Length) companyName = transArray2[1];
  13369. if (2 < transArray2.Length) job = transArray2[2];
  13370. }
  13371. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  13372. }
  13373. }
  13374. }
  13375. }
  13376. //循环赋值
  13377. for (int i = 0; i < DcList.Count; i++)
  13378. {
  13379. string PYName = "";
  13380. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  13381. {
  13382. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  13383. string PY_First = DcList[i].Pinyin.Split('/')[1];
  13384. PYName = PY_First + " " + PY_Last;
  13385. }
  13386. else
  13387. {
  13388. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  13389. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  13390. PYName = PY_First + " " + PY_Last;
  13391. }
  13392. builder.MoveToCell(0, i + 1, 0, 0);
  13393. builder.Write(PYName);
  13394. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  13395. builder.MoveToCell(0, i + 1, 1, 0);
  13396. builder.Write(sex);
  13397. DateTime birthDt;
  13398. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  13399. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  13400. builder.MoveToCell(0, i + 1, 2, 0);
  13401. builder.Write(birthday);
  13402. string company = string.Empty, job = string.Empty;
  13403. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  13404. if (dcTransInfo != null)
  13405. {
  13406. company = dcTransInfo.CompanyName;
  13407. job = dcTransInfo.Job;
  13408. }
  13409. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13410. {
  13411. //查询对照表
  13412. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  13413. if (tempCec != null)
  13414. {
  13415. company = tempCec.enName;
  13416. }
  13417. //翻译
  13418. else
  13419. {
  13420. }
  13421. }
  13422. builder.MoveToCell(0, i + 1, 3, 0);
  13423. builder.Write(company);
  13424. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  13425. {
  13426. //查询对照表
  13427. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  13428. if (tempPec != null)
  13429. {
  13430. job = tempPec.enName;
  13431. }
  13432. //翻译
  13433. else
  13434. {
  13435. }
  13436. }
  13437. builder.MoveToCell(0, i + 1, 4, 0);
  13438. builder.Write(job);
  13439. }
  13440. }
  13441. //删除多余行
  13442. while (tableOne.Rows.Count > DcList.Count + 1)
  13443. {
  13444. tableOne.Rows.RemoveAt(DcList.Count + 1);
  13445. }
  13446. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  13447. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  13448. doc.Save(fileDir);
  13449. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  13450. return Ok(JsonView(true, "操作成功!", Url));
  13451. }
  13452. private class TranslateInfo
  13453. {
  13454. public int Index { get; set; }
  13455. public string CompanyName { get; set; }
  13456. public string Job { get; set; }
  13457. }
  13458. #endregion
  13459. #region 团组倒推表
  13460. /// <summary>
  13461. /// 倒推表基础数据
  13462. /// Init
  13463. /// </summary>
  13464. /// <param name="dto"></param>
  13465. /// <returns></returns>
  13466. [HttpPost]
  13467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13468. public async Task<IActionResult> PostInvertedListInit()
  13469. {
  13470. var viewData = await _invertedListRep._Init();
  13471. if (viewData.Code != 0)
  13472. {
  13473. return Ok(JsonView(false, viewData.Msg));
  13474. }
  13475. return Ok(JsonView(viewData.Data));
  13476. }
  13477. /// <summary>
  13478. /// 倒推表
  13479. /// Info
  13480. /// </summary>
  13481. /// <param name="dto"></param>
  13482. /// <returns></returns>
  13483. [HttpPost]
  13484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13485. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  13486. {
  13487. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  13488. if (viewData.Code != 0)
  13489. {
  13490. return Ok(JsonView(false, viewData.Msg));
  13491. }
  13492. return Ok(JsonView(viewData.Data));
  13493. }
  13494. /// <summary>
  13495. /// 倒推表
  13496. /// Create
  13497. /// </summary>
  13498. /// <param name="dto"></param>
  13499. /// <returns></returns>
  13500. [HttpPost]
  13501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13502. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  13503. {
  13504. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  13505. if (viewData.Code != 0)
  13506. {
  13507. return Ok(JsonView(false, viewData.Msg));
  13508. }
  13509. return Ok(JsonView(viewData.Data));
  13510. }
  13511. /// <summary>
  13512. /// 倒推表
  13513. /// Update
  13514. /// </summary>
  13515. /// <param name="dto"></param>
  13516. /// <returns></returns>
  13517. [HttpPost]
  13518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13519. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  13520. {
  13521. var viewData = await _invertedListRep._Update(dto);
  13522. if (viewData.Code != 0)
  13523. {
  13524. return Ok(JsonView(false, viewData.Msg));
  13525. }
  13526. return Ok(JsonView(viewData.Data));
  13527. }
  13528. /// <summary>
  13529. /// 倒推表
  13530. /// File Download
  13531. /// </summary>
  13532. /// <param name="dto"></param>
  13533. /// <returns></returns>
  13534. [HttpPost]
  13535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13536. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  13537. {
  13538. var info2 = await _invertedListRep._Info(1, dto.DiId);
  13539. if (info2.Code != 0)
  13540. {
  13541. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  13542. }
  13543. var info1 = info2.Data as InvertedListInfoView;
  13544. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  13545. string teamName = "";
  13546. if (info != null) teamName = info.TeamName;
  13547. //载入模板
  13548. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  13549. DocumentBuilder builder = new DocumentBuilder(doc);
  13550. //利用键值对存放数据
  13551. Dictionary<string, string> dic = new Dictionary<string, string>();
  13552. dic.Add("TeamName", teamName);
  13553. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  13554. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  13555. dic.Add("BPRemark", info1.ApprovalDataRemark);
  13556. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  13557. dic.Add("SQRemark", info1.ApprovalRemark);
  13558. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  13559. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  13560. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  13561. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  13562. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  13563. dic.Add("QZRemark", info1.VisaInformationRemark);
  13564. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  13565. dic.Add("SQQZRemark", info1.SendVisaRemark);
  13566. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  13567. dic.Add("CQRemark", info1.IssueVisaRemark);
  13568. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  13569. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  13570. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  13571. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  13572. #region 填充word模板书签内容
  13573. foreach (var key in dic.Keys)
  13574. {
  13575. builder.MoveToBookmark(key);
  13576. builder.Write(dic[key]);
  13577. }
  13578. #endregion
  13579. var fileDir = AppSettingsHelper.Get("WordBasePath");
  13580. string fileName = $"{teamName}团出行准备流程表.doc";
  13581. string filePath = fileDir + $@"InvertedList/{fileName}";
  13582. doc.Save(filePath);
  13583. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  13584. return Ok(JsonView(true, "操作成功!", Url));
  13585. }
  13586. #endregion
  13587. #region 三公签证费用(签证费、代办费)
  13588. /// <summary>
  13589. /// 三公签证费用(签证费、代办费)
  13590. /// List
  13591. /// </summary>
  13592. /// <returns></returns>
  13593. [HttpPost]
  13594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13595. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  13596. {
  13597. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  13598. if (_view.Code != 0)
  13599. {
  13600. return Ok(JsonView(false, _view.Msg));
  13601. }
  13602. return Ok(JsonView(true, "操作成功!", _view.Data));
  13603. }
  13604. /// <summary>
  13605. /// 三公签证费用(签证费、代办费)
  13606. /// Add Or Update
  13607. /// </summary>
  13608. /// <returns></returns>
  13609. [HttpPost]
  13610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13611. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  13612. {
  13613. var _view = await _visaFeeInfoRep._Update(_dto);
  13614. if (_view.Code != 0)
  13615. {
  13616. return Ok(JsonView(false, _view.Msg));
  13617. }
  13618. return Ok(JsonView(true, _view.Msg));
  13619. }
  13620. #endregion
  13621. #region 酒店询价
  13622. /// <summary>
  13623. /// 酒店询价
  13624. /// Init
  13625. /// </summary>
  13626. /// <param name="dto"></param>
  13627. /// <returns></returns>
  13628. [HttpPost]
  13629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13630. public async Task<IActionResult> PostHotelInquiryInit()
  13631. {
  13632. var res = await _hotelInquiryRep._Init();
  13633. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13634. return Ok(JsonView(true, res.Msg, res.Data));
  13635. }
  13636. /// <summary>
  13637. /// 酒店询价
  13638. /// page Item
  13639. /// </summary>
  13640. /// <param name="_dto"></param>
  13641. /// <returns></returns>
  13642. [HttpPost]
  13643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13644. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  13645. {
  13646. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  13647. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13648. var view = res.Data as PageDataViewBase;
  13649. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  13650. }
  13651. /// <summary>
  13652. /// 酒店询价
  13653. /// info
  13654. /// </summary>
  13655. /// <param name="_dto"></param>
  13656. /// <returns></returns>
  13657. [HttpPost]
  13658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13659. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  13660. {
  13661. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  13662. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13663. return Ok(JsonView(true, res.Msg, res.Data));
  13664. }
  13665. /// <summary>
  13666. /// 酒店询价
  13667. /// Add Or Edit
  13668. /// </summary>
  13669. /// <param name="_dto"></param>
  13670. /// <returns></returns>
  13671. [HttpPost]
  13672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13673. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  13674. {
  13675. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  13676. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13677. return Ok(JsonView(true, res.Msg, res.Data));
  13678. }
  13679. /// <summary>
  13680. /// 酒店询价
  13681. /// Del
  13682. /// </summary>
  13683. /// <param name="_dto"></param>
  13684. /// <returns></returns>
  13685. [HttpPost]
  13686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13687. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  13688. {
  13689. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  13690. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13691. return Ok(JsonView(true, res.Msg, res.Data));
  13692. }
  13693. #endregion
  13694. #region 下载匹配op行程单
  13695. /// <summary>
  13696. /// 匹配op行程单
  13697. /// Init
  13698. /// </summary>
  13699. /// <param name="dto">团组列表请求dto</param>
  13700. /// <returns></returns>
  13701. [HttpPost]
  13702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13703. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  13704. {
  13705. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13706. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13707. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  13708. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  13709. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  13710. .Where(it => it.IsDel == 0)
  13711. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  13712. .OrderByDescending(it => it.CreateUserId)
  13713. .ToList();
  13714. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  13715. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13716. var diids = groupInfos.Select(it => it.Id).ToList();
  13717. List<string> countrys = new List<string>();
  13718. foreach (var item in country)
  13719. {
  13720. var data = _groupRepository.FormartTeamName(item);
  13721. var dataArray = _groupRepository.GroupSplitCountry(data);
  13722. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13723. }
  13724. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  13725. List<string> areaArray = new List<string>(); //GetGroupCityLine
  13726. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  13727. foreach (var item in areaItem)
  13728. {
  13729. string areaStr = item.Value;
  13730. if (!string.IsNullOrEmpty(areaStr))
  13731. {
  13732. string[] str1 = areaStr.Split("-");
  13733. if (str1.Length > 0)
  13734. {
  13735. areaArray.AddRange(str1);
  13736. }
  13737. }
  13738. }
  13739. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  13740. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  13741. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  13742. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  13743. .ToList();
  13744. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  13745. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  13746. .Where(it => countriesIds.Contains(it.Id))
  13747. .Select(it => new { it.Id, Name = it.Name_CN })
  13748. .ToList();
  13749. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  13750. .Select(it => it.TeamName).ToList();
  13751. stopwatch.Stop();
  13752. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  13753. }
  13754. ///// <summary>
  13755. ///// 匹配op行程单
  13756. ///// Init 查询区域数据
  13757. ///// </summary>
  13758. ///// <param name="dto">团组列表请求dto</param>
  13759. ///// <returns></returns>
  13760. //[HttpPost]
  13761. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13762. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  13763. //{
  13764. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13765. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  13766. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  13767. // if (string.IsNullOrEmpty(countriesDataStr))
  13768. // {
  13769. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  13770. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  13771. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  13772. // }
  13773. // else
  13774. // {
  13775. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  13776. // }
  13777. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  13778. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  13779. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  13780. // List<dynamic> childList = new List<dynamic>();
  13781. // int parentId = dto.CountriesId;
  13782. // if (provinceData.Count > 1)
  13783. // {
  13784. // foreach (var item1 in provinceData)
  13785. // {
  13786. // List<dynamic> childList1 = new List<dynamic>();
  13787. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  13788. // foreach (var item2 in citiesData1)
  13789. // {
  13790. // List<dynamic> childList2 = new List<dynamic>();
  13791. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13792. // foreach (var item3 in countiesData1)
  13793. // {
  13794. // childList2.Add(new
  13795. // {
  13796. // id = item3.Id,
  13797. // parentId = item2.Id,
  13798. // level = "district",
  13799. // name = item3.Name_CN,
  13800. // });
  13801. // }
  13802. // childList1.Add(new
  13803. // {
  13804. // id = item2.Id,
  13805. // parentId = item1.Id,
  13806. // level = "city",
  13807. // name = item2.Name_CN,
  13808. // childList = childList2
  13809. // });
  13810. // }
  13811. // childList.Add(new
  13812. // {
  13813. // id = item1.Id,
  13814. // parentId = parentId,
  13815. // level = "province",
  13816. // name = item1.Name_CN,
  13817. // childList = childList1
  13818. // });
  13819. // }
  13820. // //城市
  13821. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  13822. // foreach (var item2 in citiesData2)
  13823. // {
  13824. // List<dynamic> childList22 = new List<dynamic>();
  13825. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13826. // foreach (var item3 in countiesData1)
  13827. // {
  13828. // childList22.Add(new
  13829. // {
  13830. // id = item3.Id,
  13831. // parentId = item2.Id,
  13832. // level = "district",
  13833. // name = item3.Name_CN,
  13834. // });
  13835. // }
  13836. // childList.Add(new
  13837. // {
  13838. // id = item2.Id,
  13839. // parentId = parentId,
  13840. // level = "city",
  13841. // name = item2.Name_CN,
  13842. // childList = childList22
  13843. // });
  13844. // }
  13845. // }
  13846. // else
  13847. // {
  13848. // foreach (var item2 in citiesData)
  13849. // {
  13850. // string cname = item2.Name_CN;
  13851. // List<dynamic> childList1 = new List<dynamic>();
  13852. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13853. // foreach (var item3 in countiesData1)
  13854. // {
  13855. // childList1.Add(new
  13856. // {
  13857. // Id = item3.Id,
  13858. // parentId = item2.Id,
  13859. // level = "district",
  13860. // name = item3.Name_CN
  13861. // });
  13862. // }
  13863. // childList.Add(new
  13864. // {
  13865. // id = item2.Id,
  13866. // parentId = parentId,
  13867. // level = "city",
  13868. // name = item2.Name_CN,
  13869. // childList = childList1
  13870. // });
  13871. // }
  13872. // }
  13873. // stopwatch.Stop();
  13874. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  13875. //}
  13876. /// <summary>
  13877. /// 匹配op行程单
  13878. /// 接团信息列表 Page
  13879. /// </summary>
  13880. /// <param name="dto">团组列表请求dto</param>
  13881. /// <returns></returns>
  13882. [HttpPost]
  13883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13884. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  13885. {
  13886. var swatch = new Stopwatch();
  13887. swatch.Start();
  13888. #region 参数验证
  13889. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13890. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13891. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13892. #region 页面操作权限验证
  13893. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13894. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  13895. #endregion
  13896. #endregion
  13897. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13898. {
  13899. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  13900. string sqlWhere = "";
  13901. if (!string.IsNullOrEmpty(dto.Country))
  13902. {
  13903. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  13904. }
  13905. if (!string.IsNullOrEmpty(dto.Area))
  13906. {
  13907. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  13908. }
  13909. if (!string.IsNullOrEmpty(dto.TeamName))
  13910. {
  13911. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  13912. }
  13913. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  13914. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  13915. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  13916. swatch.Stop();
  13917. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  13918. }
  13919. else
  13920. {
  13921. return Ok(JsonView(false, "查询失败"));
  13922. }
  13923. }
  13924. /// <summary>
  13925. /// 匹配op行程单
  13926. /// 行程单下载
  13927. /// </summary>
  13928. /// <param name="dto">团组列表请求dto</param>
  13929. /// <returns></returns>
  13930. [HttpPost]
  13931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13932. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  13933. {
  13934. #region 参数验证
  13935. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13936. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13937. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13938. #region 页面操作权限验证
  13939. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13940. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  13941. #endregion
  13942. #endregion
  13943. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13944. {
  13945. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  13946. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  13947. }
  13948. else
  13949. {
  13950. return Ok(JsonView(false, "下载失败!"));
  13951. }
  13952. }
  13953. #endregion
  13954. #region 国家信息 数据 注释
  13955. //[HttpPost]
  13956. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  13957. //{
  13958. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  13959. // foreach (var item in dto)
  13960. // {
  13961. // infos.Add(new Grp_GroupsTaskAssignment()
  13962. // {
  13963. // DIId = item,
  13964. // CTId = 82,
  13965. // UId = 248,
  13966. // IsEnable = 1,
  13967. // CreateUserId = 233,
  13968. // CreateTime = DateTime.Now,
  13969. // IsDel = 0
  13970. // });
  13971. // infos.Add(new Grp_GroupsTaskAssignment()
  13972. // {
  13973. // DIId = item,
  13974. // CTId = 82,
  13975. // UId = 286,
  13976. // IsEnable = 1,
  13977. // CreateUserId = 233,
  13978. // CreateTime = DateTime.Now,
  13979. // IsDel = 0
  13980. // });
  13981. // }
  13982. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  13983. // return Ok("操作成功");
  13984. //}
  13985. //public class paramJsonDto
  13986. //{
  13987. // public List<CountriesInfo> str { get; set; }
  13988. //}
  13989. //[HttpPost]
  13990. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  13991. //{
  13992. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  13993. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  13994. // List<Sys_Cities> cities = new List<Sys_Cities>();
  13995. // List<Sys_Cities> districts = new List<Sys_Cities>();
  13996. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  13997. // _sqlSugar.BeginTran();
  13998. // int countitiesIndex = 0;
  13999. // foreach (var item in dto.str)
  14000. // {
  14001. // dynamic data = item.c;
  14002. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  14003. // if (data != null)
  14004. // {
  14005. // countitiesIndex++;
  14006. // foreach (var item1 in data)
  14007. // {
  14008. // string cnname = item1.cn;
  14009. // string enname = item1.en;
  14010. // Sys_Cities provinceInfo = new Sys_Cities()
  14011. // {
  14012. // CountriesId = countriesId,
  14013. // Name_CN = cnname,
  14014. // Name_EN = enname,
  14015. // ParentId = 0,
  14016. // IsCapital = 1,
  14017. // CreateUserId = 208,
  14018. // CreateTime = DateTime.Now,
  14019. // IsDel = 0
  14020. // };
  14021. // if (item1.lv == "province") //省份
  14022. // {
  14023. // provinceInfo.Level = 1;
  14024. // int provinceId = 0;
  14025. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  14026. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  14027. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14028. // var data1 = item1.c;
  14029. // foreach (var item2 in data1)
  14030. // {
  14031. // if (item2.lv == "city")
  14032. // {
  14033. // string citycnname = item2.cn;
  14034. // string cityenname = item2.en;
  14035. // Sys_Cities cityInfo = new Sys_Cities()
  14036. // {
  14037. // CountriesId = countriesId,
  14038. // ParentId = provinceId,
  14039. // Level = 2,
  14040. // Name_CN = citycnname,
  14041. // Name_EN = cityenname,
  14042. // IsCapital = 1,
  14043. // CreateUserId = 208,
  14044. // CreateTime = DateTime.Now,
  14045. // IsDel = 0
  14046. // };
  14047. // if (item2.c != null)
  14048. // {
  14049. // int cityId = 0;
  14050. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  14051. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14052. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  14053. // foreach (var item3 in item2.c)
  14054. // {
  14055. // if (item3.lv == "district")
  14056. // {
  14057. // var districtInfo = new Sys_Cities()
  14058. // {
  14059. // CountriesId = countriesId,
  14060. // Name_CN = item3.cn,
  14061. // Name_EN = item3.en,
  14062. // Level = 3,
  14063. // ParentId = cityId,
  14064. // IsCapital = 1,
  14065. // CreateUserId = 208,
  14066. // CreateTime = DateTime.Now,
  14067. // IsDel = 0
  14068. // };
  14069. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14070. // //{
  14071. // districts.Add(districtInfo);
  14072. // //}
  14073. // }
  14074. // }
  14075. // }
  14076. // else
  14077. // {
  14078. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  14079. // //{
  14080. // cities.Add(cityInfo);
  14081. // //}
  14082. // }
  14083. // }
  14084. // }
  14085. // }
  14086. // else if (item1.lv == "city")//城市
  14087. // {
  14088. // provinceInfo.Level = 2;
  14089. // if (item1.c != null)
  14090. // {
  14091. // int cityId = 0;
  14092. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  14093. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14094. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14095. // foreach (var item3 in item1.c)
  14096. // {
  14097. // if (item3.lv == "district")
  14098. // {
  14099. // var districtInfo = new Sys_Cities()
  14100. // {
  14101. // CountriesId = countriesId,
  14102. // Name_CN = item3.cn,
  14103. // Name_EN = item3.en,
  14104. // Level = 3,
  14105. // ParentId = cityId,
  14106. // IsCapital = 1,
  14107. // CreateUserId = 208,
  14108. // CreateTime = DateTime.Now,
  14109. // IsDel = 0
  14110. // };
  14111. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14112. // //{
  14113. // districts.Add(districtInfo);
  14114. // //}
  14115. // }
  14116. // }
  14117. // }
  14118. // else
  14119. // {
  14120. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  14121. // //{
  14122. // cities.Add(provinceInfo);
  14123. // //}
  14124. // }
  14125. // }
  14126. // }
  14127. // }
  14128. // }
  14129. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  14130. // cities = cities.Distinct().ToList();
  14131. // districts = districts.Distinct().ToList();
  14132. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  14133. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  14134. // cities.AddRange(districts);
  14135. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  14136. // //_sqlSugar.RollbackTran();
  14137. // _sqlSugar.CommitTran();
  14138. // return Ok(JsonView(false, "操作成功!"));
  14139. //}
  14140. //[HttpPost]
  14141. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  14142. //{
  14143. // List<CountitiesInfo> infos = dto.MyProperty;
  14144. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  14145. // _sqlSugar.BeginTran();
  14146. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  14147. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  14148. // foreach (var item in infos)
  14149. // {
  14150. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  14151. // if (countryInfo != null)
  14152. // {
  14153. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  14154. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  14155. // if (cityInfo1 != null)
  14156. // {
  14157. // cityInfo1.IsCapital = 0;
  14158. // cityInfos.Add(cityInfo1);
  14159. // }
  14160. // }
  14161. // }
  14162. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  14163. // .UpdateColumns(it => it.IsCapital)
  14164. // .WhereColumns(it => it.Id)
  14165. // .ExecuteCommand();
  14166. // //_sqlSugar.RollbackTran();
  14167. // _sqlSugar.CommitTran();
  14168. // return Ok(JsonView(false, "操作成功!"));
  14169. //}
  14170. //public class CounrtiesDto
  14171. //{
  14172. // public List<CountitiesInfo> MyProperty { get; set; }
  14173. //}
  14174. //public class CountitiesInfo
  14175. //{
  14176. // /// <summary>
  14177. // /// 圣约翰
  14178. // /// </summary>
  14179. // public string capital_name_chinese { get; set; }
  14180. // /// <summary>
  14181. // ///
  14182. // /// </summary>
  14183. // public string capital_name { get; set; }
  14184. // /// <summary>
  14185. // ///
  14186. // /// </summary>
  14187. // public string country_type { get; set; }
  14188. // /// <summary>
  14189. // /// 安提瓜和巴布达
  14190. // /// </summary>
  14191. // public string country_name_chinese { get; set; }
  14192. // /// <summary>
  14193. // /// 安提瓜和巴布达
  14194. // /// </summary>
  14195. // public string country_name_chinese_short { get; set; }
  14196. // /// <summary>
  14197. // /// 安提瓜和巴布达
  14198. // /// </summary>
  14199. // public string country_name_chinese_UN { get; set; }
  14200. // /// <summary>
  14201. // ///
  14202. // /// </summary>
  14203. // public string country_name_english_abbreviation { get; set; }
  14204. // /// <summary>
  14205. // ///
  14206. // /// </summary>
  14207. // public string country_name_english_formal { get; set; }
  14208. // /// <summary>
  14209. // ///
  14210. // /// </summary>
  14211. // public string country_name_english_UN { get; set; }
  14212. // /// <summary>
  14213. // ///
  14214. // /// </summary>
  14215. // public string continent_name { get; set; }
  14216. // /// <summary>
  14217. // ///
  14218. // /// </summary>
  14219. // public string subregion_name { get; set; }
  14220. // /// <summary>
  14221. // ///
  14222. // /// </summary>
  14223. // public string country_code2 { get; set; }
  14224. // /// <summary>
  14225. // ///
  14226. // /// </summary>
  14227. // public string country_code3 { get; set; }
  14228. // /// <summary>
  14229. // ///
  14230. // /// </summary>
  14231. // public string phone_code { get; set; }
  14232. //}
  14233. //public class CountriesInfo : BasicInfo
  14234. //{
  14235. // public List<CitiesInfo> c { get; set; }
  14236. //}
  14237. //public class CitiesInfo : BasicInfo
  14238. //{
  14239. // public List<AreaInfo> c { get; set; }
  14240. //}
  14241. //public class AreaInfo : BasicInfo
  14242. //{
  14243. // public List<AreaInfo> c { get; set; }
  14244. //}
  14245. //public class BasicInfo
  14246. //{
  14247. // public string code { get; set; }
  14248. // public string cn { get; set; }
  14249. // public string lv { get; set; }
  14250. // public string en { get; set; }
  14251. //}
  14252. #endregion
  14253. #region 查看邀请方
  14254. /// <summary>
  14255. /// 查看邀请方
  14256. /// 邀请方信息 Init
  14257. /// </summary>
  14258. /// <param name="dto"></param>
  14259. /// <returns></returns>
  14260. [HttpPost]
  14261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14262. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  14263. {
  14264. string sqlWhere = string.Empty;
  14265. if (!string.IsNullOrEmpty(dto.Search))
  14266. {
  14267. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  14268. }
  14269. string sql = string.Format($@"Select
  14270. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  14271. Id,
  14272. UnitName
  14273. From Res_InvitationOfficialActivityData
  14274. Where IsDel = 0
  14275. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  14276. RefAsync<int> total = 0;
  14277. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14278. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  14279. }
  14280. /// <summary>
  14281. /// 查看邀请方
  14282. /// 国家信息 Init
  14283. /// </summary>
  14284. /// <param name="dto"></param>
  14285. /// <returns></returns>
  14286. [HttpPost]
  14287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14288. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  14289. {
  14290. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  14291. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  14292. var diids = groupInfos.Select(it => it.Id).ToList();
  14293. List<string> countrys = new List<string>();
  14294. foreach (var item in country)
  14295. {
  14296. var data = _groupRepository.FormartTeamName(item);
  14297. var dataArray = _groupRepository.GroupSplitCountry(data);
  14298. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  14299. }
  14300. countrys = countrys.Distinct().ToList();
  14301. for (int i = 0; i < countrys.Count; i++)
  14302. {
  14303. string item = countrys[i];
  14304. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  14305. {
  14306. countrys.Remove(item);
  14307. i--;
  14308. }
  14309. }
  14310. RefAsync<int> total = 0;
  14311. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  14312. .Where(it => countrys.Contains(it.Name_CN))
  14313. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14314. .Select(it => new { id = it.Id, name = it.Name_CN })
  14315. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14316. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14317. }
  14318. /// <summary>
  14319. /// 查看邀请方
  14320. /// 城市信息 Init
  14321. /// </summary>
  14322. /// <param name="dto"></param>
  14323. /// <returns></returns>
  14324. [HttpPost]
  14325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14326. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  14327. {
  14328. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  14329. RefAsync<int> total = 0;
  14330. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  14331. .Where(it => it.CountriesId == dto.CountiesId)
  14332. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14333. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  14334. .Select(it => new { id = it.Id, name = it.Name_CN })
  14335. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14336. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14337. }
  14338. /// <summary>
  14339. /// 查看邀请方
  14340. /// 团组名称 Init
  14341. /// </summary>
  14342. /// <param name="dto"></param>
  14343. /// <returns></returns>
  14344. [HttpPost]
  14345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14346. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  14347. {
  14348. var watch = new Stopwatch();
  14349. watch.Start();
  14350. RefAsync<int> total = 0;
  14351. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  14352. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  14353. .Where((oa, di) => oa.IsDel == 0)
  14354. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  14355. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  14356. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  14357. .Distinct()
  14358. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14359. watch.Stop();
  14360. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  14361. }
  14362. /// <summary>
  14363. /// 查看邀请方
  14364. /// 团组 & 邀请方信息
  14365. /// </summary>
  14366. /// <param name="dto"></param>
  14367. /// <returns></returns>
  14368. [HttpPost]
  14369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14370. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  14371. {
  14372. var watch = new Stopwatch();
  14373. watch.Start();
  14374. RefAsync<int> total = 0;
  14375. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  14376. .AS("Grp_DelegationInfo")
  14377. .Includes(x => x.InvitingInfos)
  14378. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  14379. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  14380. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  14381. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  14382. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  14383. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  14384. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14385. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  14386. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  14387. infos.ForEach(x =>
  14388. {
  14389. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  14390. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  14391. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  14392. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  14393. });
  14394. watch.Stop();
  14395. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  14396. }
  14397. #endregion
  14398. #region 报批行程
  14399. /// <summary>
  14400. /// 报批行程初始化
  14401. /// </summary>
  14402. /// <param name="dto"></param>
  14403. /// <returns></returns>
  14404. [HttpPost]
  14405. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  14406. {
  14407. const int chiNumber = 5;
  14408. var jw = JsonView(false);
  14409. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  14410. var group = groupList.First();
  14411. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14412. group = groupList.First(x => x.Id == diid);
  14413. if (group == null)
  14414. {
  14415. jw.Msg = "暂无团组!";
  14416. return Ok(jw);
  14417. }
  14418. var data = new
  14419. {
  14420. groupList = groupList.Select(x => new
  14421. {
  14422. x.TeamName,
  14423. x.Id
  14424. }),
  14425. content = new ArrayList(),
  14426. groupInfo = new
  14427. {
  14428. group.VisitDays,
  14429. group.TourCode,
  14430. group.VisitPNumber,
  14431. group.TeamName,
  14432. group.Id,
  14433. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  14434. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  14435. },
  14436. };
  14437. var resultArr = new ArrayList();
  14438. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  14439. if (content.Count == 0)
  14440. {
  14441. var stay = "-";
  14442. var cityPath = "-";
  14443. //添加城市路径以及住宿地
  14444. //黑屏代码数据
  14445. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14446. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14447. {
  14448. jw = JsonView(true, "黑屏代码有误!", data);
  14449. return Ok(jw);
  14450. }
  14451. foreach (DataRow row in dtBlack.Rows)
  14452. {
  14453. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14454. {
  14455. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  14456. return Ok(jw);
  14457. }
  14458. }
  14459. //黑屏代码获取时间区间
  14460. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14461. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14462. _sqlSugar.BeginTran();
  14463. for (int i = 0; i < timeArr.Count; i++)
  14464. {
  14465. stay = "-";
  14466. cityPath = "-";
  14467. DateTime NewData = DateTime.Parse(timeArr[i]);
  14468. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14469. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14470. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14471. if (tbSelect.Length > 0)
  14472. {
  14473. List<string> threeCodeStr = new List<string>();
  14474. foreach (var item in tbSelect)
  14475. {
  14476. var threeCode = item["Three"].ToString() ?? "";
  14477. if (threeCode.Length == 6)
  14478. {
  14479. var start = threeCode.Substring(0, 3);
  14480. var end = threeCode.Substring(3, 3);
  14481. if (threeCodeStr.Count == 0)
  14482. {
  14483. threeCodeStr.Add(start);
  14484. threeCodeStr.Add(end);
  14485. }
  14486. else
  14487. {
  14488. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14489. {
  14490. threeCodeStr.Add(end);
  14491. }
  14492. else
  14493. {
  14494. threeCodeStr.Add(start);
  14495. threeCodeStr.Add(end);
  14496. }
  14497. }
  14498. }
  14499. }
  14500. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14501. var last = threeCodeStr.Last();
  14502. foreach (var item in threeCodeStr)
  14503. {
  14504. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14505. if (item.Equals(last))
  14506. {
  14507. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14508. }
  14509. }
  14510. cityPath = cityPath.Trim('-');
  14511. }
  14512. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14513. appro.Diid = diid ?? -1;
  14514. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14515. appro.Id = thisId;
  14516. appro.CreateUserId = dto.UserId;
  14517. appro.CreateTime = DateTime.Now;
  14518. content.Add(appro);
  14519. }
  14520. _sqlSugar.CommitTran();
  14521. }
  14522. foreach (var x in content)
  14523. {
  14524. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  14525. if (chiList.Count < chiNumber)
  14526. {
  14527. for (int i = chiList.Count; i < chiNumber; i++)
  14528. {
  14529. chiList.Add(new Grp_ApprovalTravelDetails());
  14530. }
  14531. }
  14532. resultArr.Add(new
  14533. {
  14534. x.Id,
  14535. x.Date,
  14536. x.Diid,
  14537. chiList = chiList.Select(x1 => new
  14538. {
  14539. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14540. x1.Details,
  14541. x1.ParentId,
  14542. x1.Id
  14543. })
  14544. });
  14545. }
  14546. data = data with
  14547. {
  14548. content = resultArr,
  14549. };
  14550. jw = JsonView(true, "获取成功!", data);
  14551. return Ok(jw);
  14552. }
  14553. /// <summary>
  14554. /// 报批行程删除
  14555. /// </summary>
  14556. /// <param name="dto"></param>
  14557. /// <returns></returns>
  14558. [HttpPost]
  14559. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  14560. {
  14561. var jw = JsonView(false);
  14562. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14563. if (group == null)
  14564. {
  14565. jw.Msg = "团组参数有误!";
  14566. return Ok(jw);
  14567. }
  14568. try
  14569. {
  14570. _sqlSugar.BeginTran();
  14571. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  14572. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  14573. {
  14574. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14575. DeleteUserId = dto.uesrId,
  14576. IsDel = 1
  14577. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  14578. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  14579. {
  14580. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14581. DeleteUserId = dto.uesrId,
  14582. IsDel = 1
  14583. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  14584. _sqlSugar.CommitTran();
  14585. jw = JsonView(true, "删除成功");
  14586. }
  14587. catch (Exception ex)
  14588. {
  14589. jw = JsonView(false, ex.Message);
  14590. }
  14591. return Ok(jw);
  14592. }
  14593. /// <summary>
  14594. /// 报批行程保存
  14595. /// </summary>
  14596. /// <param name="dto"></param>
  14597. /// <returns></returns>
  14598. [HttpPost]
  14599. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  14600. {
  14601. var jw = JsonView(false);
  14602. var Find = dto.Arr.Find(x => x.id == 0);
  14603. if (Find != null)
  14604. {
  14605. jw.Msg = "生成的ID为0!";
  14606. return Ok(jw);
  14607. }
  14608. foreach (var item in dto.Arr)
  14609. {
  14610. foreach (var chi in item.chiList)
  14611. {
  14612. if (chi.parentId == 0)
  14613. {
  14614. chi.parentId = item.id;
  14615. }
  14616. }
  14617. }
  14618. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  14619. _sqlSugar.BeginTran();
  14620. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  14621. {
  14622. var parentIds = dto.Arr.Select(x => x.id).ToList();
  14623. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  14624. {
  14625. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14626. DeleteUserId = dto.UserId,
  14627. IsDel = 1
  14628. }).ExecuteCommand();
  14629. }
  14630. try
  14631. {
  14632. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  14633. {
  14634. CreateTime = DateTime.Now,
  14635. CreateUserId = dto.UserId,
  14636. Details = x.details,
  14637. ParentId = x.parentId,
  14638. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14639. Remark = "",
  14640. IsDel = 0
  14641. }).ToList()).ExecuteCommand();
  14642. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  14643. {
  14644. Id = x.id,
  14645. Details = x.details,
  14646. ParentId = x.parentId,
  14647. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14648. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  14649. {
  14650. Details = x.Details,
  14651. ParentId = x.ParentId,
  14652. Time = x.Time
  14653. }).ExecuteCommand();
  14654. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  14655. {
  14656. Id = x.id,
  14657. Date = x.date,
  14658. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  14659. {
  14660. Date = x.Date
  14661. }).ExecuteCommand();
  14662. _sqlSugar.CommitTran();
  14663. jw = JsonView(true, "保存成功!");
  14664. }
  14665. catch (Exception ex)
  14666. {
  14667. _sqlSugar.RollbackTran();
  14668. jw = JsonView(false, "保存失败!" + ex.Message);
  14669. }
  14670. return Ok(jw);
  14671. }
  14672. /// <summary>
  14673. /// 报批行程生成
  14674. /// </summary>
  14675. /// <param name="dto"></param>
  14676. /// <returns></returns>
  14677. [HttpPost]
  14678. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  14679. {
  14680. var jw = JsonView(false);
  14681. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14682. if (group == null)
  14683. {
  14684. jw.Msg = "暂无该团组!";
  14685. return Ok(jw);
  14686. }
  14687. //黑屏代码数据
  14688. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14689. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14690. {
  14691. jw.Msg = "黑屏代码有误!";
  14692. return Ok(jw);
  14693. }
  14694. foreach (DataRow row in dtBlack.Rows)
  14695. {
  14696. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14697. {
  14698. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  14699. return Ok(jw);
  14700. }
  14701. }
  14702. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14703. var resultArr = new ArrayList();
  14704. if (officialActivitiesArr.Count == 0)
  14705. {
  14706. jw.Msg = "暂无公务出访信息!";
  14707. return Ok(jw);
  14708. }
  14709. try
  14710. {
  14711. _sqlSugar.BeginTran();
  14712. DeleteApprovalJourney(new
  14713. Domain.Dtos.Groups.DeleteApprovalJourney
  14714. {
  14715. Diid = dto.Diid,
  14716. uesrId = dto.Userid
  14717. });
  14718. var stay = "-";
  14719. var cityPath = "-";
  14720. //添加城市路径以及住宿地
  14721. //黑屏代码获取时间区间
  14722. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14723. var empty = "【未收入该三字码!请机票同事录入】";
  14724. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14725. for (int i = 0; i < timeArr.Count; i++)
  14726. {
  14727. stay = "-";
  14728. cityPath = "-";
  14729. var chiarr = new List<Grp_ApprovalTravelDetails>();
  14730. DateTime NewData = DateTime.Parse(timeArr[i]);
  14731. 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();
  14732. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14733. if (tbSelect.Length > 0)
  14734. {
  14735. List<string> threeCodeStr = new List<string>();
  14736. bool isTrade = false;
  14737. string trip = string.Empty;
  14738. var rowLast = tbSelect.Last();
  14739. var rowFirst = tbSelect.First();
  14740. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  14741. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  14742. var takeOffTime = DateTime.Parse(timeArr[i]);
  14743. var fallToTime = DateTime.Parse(timeArr[i]);
  14744. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  14745. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  14746. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  14747. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  14748. foreach (var item in tbSelect)
  14749. {
  14750. var start = string.Empty;
  14751. var end = string.Empty;
  14752. var threeCode = item["Three"].ToString() ?? "";
  14753. if (threeCode.Length == 6)
  14754. {
  14755. start = threeCode.Substring(0, 3);
  14756. end = threeCode.Substring(3, 3);
  14757. if (threeCodeStr.Count == 0)
  14758. {
  14759. threeCodeStr.Add(start);
  14760. threeCodeStr.Add(end);
  14761. }
  14762. else
  14763. {
  14764. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14765. {
  14766. threeCodeStr.Add(end);
  14767. }
  14768. else
  14769. {
  14770. threeCodeStr.Add(start);
  14771. threeCodeStr.Add(end);
  14772. }
  14773. }
  14774. }
  14775. //处理机票信息
  14776. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  14777. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  14778. if (start_Object == null)
  14779. {
  14780. start_Object = new Res_ThreeCode()
  14781. {
  14782. AirPort = empty,
  14783. AirPort_En = empty,
  14784. City = empty,
  14785. Country = empty,
  14786. Four = empty,
  14787. Three = empty,
  14788. };
  14789. }
  14790. if (end_Object == null)
  14791. {
  14792. end_Object = new Res_ThreeCode()
  14793. {
  14794. AirPort = empty,
  14795. AirPort_En = empty,
  14796. City = empty,
  14797. Country = empty,
  14798. Four = empty,
  14799. Three = empty,
  14800. };
  14801. }
  14802. //机型判断
  14803. string airModel = item["AirModel"].ToString();
  14804. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  14805. string flightTime = item["FlightTime"].ToString();
  14806. if (flightTime!.Contains(":"))
  14807. {
  14808. flightTime = flightTime.Replace(":", "小时");
  14809. flightTime += "分钟";
  14810. }
  14811. if (flightTime.Contains("H"))
  14812. {
  14813. flightTime = flightTime.Replace("H", "小时");
  14814. }
  14815. if (flightTime.Contains("M"))
  14816. {
  14817. flightTime = flightTime.Replace("M", "分钟");
  14818. }
  14819. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  14820. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  14821. {
  14822. flightTime = flightDataTime.Hour > 0
  14823. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  14824. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  14825. ? flightDataTime.Minute.ToString() + "分钟" : "";
  14826. }
  14827. //航班号
  14828. string flightcode = item["Fliagtcode"].ToString();
  14829. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  14830. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  14831. if (aircompany == null)
  14832. {
  14833. aircompany = new Res_AirCompany
  14834. {
  14835. CnName = hsEmpty,
  14836. EnName = hsEmpty,
  14837. ShortCode = hsEmpty,
  14838. };
  14839. }
  14840. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  14841. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  14842. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  14843. if (isTrade)
  14844. {
  14845. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  14846. }
  14847. else
  14848. {
  14849. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  14850. }
  14851. }
  14852. chiarr.Add(new Grp_ApprovalTravelDetails
  14853. {
  14854. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  14855. CreateTime = DateTime.Now,
  14856. CreateUserId = dto.Userid,
  14857. ParentId = 0,
  14858. Details = trip
  14859. });
  14860. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14861. var last = threeCodeStr.Last();
  14862. foreach (var item in threeCodeStr)
  14863. {
  14864. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14865. if (item.Equals(last))
  14866. {
  14867. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14868. }
  14869. }
  14870. cityPath = cityPath.Trim('-');
  14871. }
  14872. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14873. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14874. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14875. appro.Diid = dto.Diid;
  14876. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14877. appro.Id = thisId;
  14878. appro.CreateUserId = dto.Userid;
  14879. appro.CreateTime = DateTime.Now;
  14880. foreach (var item in gwinfo)
  14881. {
  14882. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  14883. chi.Details = "拜访" + item.Client;
  14884. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  14885. {
  14886. chi.Details += "," + item.ReqSample;
  14887. }
  14888. chi.ParentId = thisId;
  14889. chi.Time = item.Time;
  14890. chiarr.Add(chi);
  14891. }
  14892. if (chiarr.Count < 5)
  14893. {
  14894. for (int j = chiarr.Count; j < 5; j++)
  14895. {
  14896. chiarr.Add(new
  14897. Grp_ApprovalTravelDetails());
  14898. }
  14899. }
  14900. resultArr.Add(new
  14901. {
  14902. appro.Id,
  14903. appro.Date,
  14904. appro.Diid,
  14905. chiList = chiarr.Select(x1 => new
  14906. {
  14907. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14908. x1.Details,
  14909. x1.ParentId,
  14910. x1.Id
  14911. })
  14912. });
  14913. }
  14914. _sqlSugar.CommitTran();
  14915. jw = JsonView(true, "生成成功!", resultArr);
  14916. }
  14917. catch (Exception ex)
  14918. {
  14919. jw.Code = 400;
  14920. jw.Msg = "生成失败!" + ex.Message;
  14921. }
  14922. return Ok(jw);
  14923. }
  14924. /// <summary>
  14925. /// 报批行程word导出
  14926. /// </summary>
  14927. /// <param name="dto"></param>
  14928. /// <returns></returns>
  14929. [HttpPost]
  14930. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  14931. {
  14932. var jw = JsonView(false);
  14933. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14934. if (group == null)
  14935. {
  14936. jw.Msg = "暂无该团组!";
  14937. return Ok(jw);
  14938. }
  14939. //模板路径
  14940. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  14941. //载入模板
  14942. Document doc = new Document(tempPath);
  14943. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14944. //获取所填表格的序数
  14945. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14946. Aspose.Words.Tables.Row titleRowClone = null;
  14947. Aspose.Words.Tables.Row CenterRowClone = null;
  14948. int index = 0;
  14949. int indexChi = 0;
  14950. int SetIndex = 0;
  14951. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  14952. //获取数据,放到datatable
  14953. foreach (var item in ApprovalTravelArr)
  14954. {
  14955. if (index > 0)
  14956. {
  14957. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  14958. tableOne.AppendChild(titleRowClone);
  14959. }
  14960. var textTime = item.Date;
  14961. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  14962. SetCells(tableOne, doc, SetIndex, 0, textTime);
  14963. SetIndex++;
  14964. if (ChiRep.Count > 0)
  14965. {
  14966. foreach (var itemChi in ChiRep)
  14967. {
  14968. var txtTime = itemChi.Time;
  14969. var txtDetail = itemChi.Details;
  14970. if (indexChi > 0)
  14971. {
  14972. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14973. tableOne.AppendChild(CenterRowClone);
  14974. }
  14975. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  14976. {
  14977. SetCells(tableOne, doc, SetIndex, 0, "");
  14978. SetCells(tableOne, doc, SetIndex, 1, "");
  14979. indexChi++;
  14980. SetIndex++;
  14981. break;
  14982. }
  14983. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  14984. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  14985. indexChi++;
  14986. SetIndex++;
  14987. }
  14988. }
  14989. else
  14990. {
  14991. if (indexChi > 0)
  14992. {
  14993. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14994. tableOne.AppendChild(CenterRowClone);
  14995. }
  14996. SetCells(tableOne, doc, SetIndex, 0, "");
  14997. SetCells(tableOne, doc, SetIndex, 1, "");
  14998. indexChi++;
  14999. SetIndex++;
  15000. }
  15001. index++;
  15002. }
  15003. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  15004. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  15005. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  15006. jw.Code = 200;
  15007. jw.Msg = "";
  15008. return Ok(jw);
  15009. }
  15010. private string intToString(int numberVal)
  15011. {
  15012. string numberval = numberVal.ToString();
  15013. Dictionary<char, string> Number = new Dictionary<char, string>();
  15014. Number.Add('1', "一");
  15015. Number.Add('2', "二");
  15016. Number.Add('3', "三");
  15017. Number.Add('4', "四");
  15018. Number.Add('5', "五");
  15019. Number.Add('6', "六");
  15020. Number.Add('7', "七");
  15021. Number.Add('8', "八");
  15022. Number.Add('9', "九");
  15023. string stringNumberVal = string.Empty;
  15024. for (int i = 0; i < numberval.Length; i++)
  15025. {
  15026. if (i == 0)
  15027. {
  15028. stringNumberVal += Number[numberval[i]];
  15029. }
  15030. else if (i >= 1)
  15031. {
  15032. if (numberval[i] == '0')
  15033. {
  15034. stringNumberVal = "十";
  15035. }
  15036. else
  15037. {
  15038. stringNumberVal += "十" + Number[numberval[i]];
  15039. }
  15040. }
  15041. }
  15042. return stringNumberVal;
  15043. }
  15044. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  15045. {
  15046. //获取table中的某个单元格,从0开始
  15047. Cell lshCell = table.Rows[rows].Cells[cells];
  15048. //将单元格中段落移除
  15049. foreach (Node item in lshCell.Paragraphs)
  15050. {
  15051. lshCell.Paragraphs.Remove(item);
  15052. }
  15053. if (val.Contains("\r\n"))
  15054. {
  15055. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  15056. foreach (var item in spArr)
  15057. {
  15058. //新建一个段落
  15059. Paragraph p = new Paragraph(doc);
  15060. var r = new Run(doc, item);
  15061. //把设置的值赋给之前新建的段落
  15062. p.AppendChild(r);
  15063. //将此段落加到单元格内
  15064. lshCell.AppendChild(p);
  15065. }
  15066. }
  15067. else
  15068. {
  15069. //新建一个段落
  15070. Paragraph p = new Paragraph(doc);
  15071. var r = new Run(doc, val);
  15072. //把设置的值赋给之前新建的段落
  15073. p.AppendChild(r);
  15074. //将此段落加到单元格内
  15075. lshCell.AppendChild(p);
  15076. }
  15077. }
  15078. [HttpPost]
  15079. public async Task<IActionResult> ServerHttp(string paramStr)
  15080. {
  15081. paramStr = paramStr.TrimEnd('\'');
  15082. paramStr = paramStr.TrimStart('\'');
  15083. JsonView jw = JsonView(false);
  15084. JObject param = JObject.Parse(paramStr);
  15085. if (!param.ContainsKey("url"))
  15086. {
  15087. jw.Msg = "url null";
  15088. return Ok(jw);
  15089. }
  15090. string url = param["url"]!.ToString();
  15091. var methon = "get";
  15092. Dictionary<string, string> headValues = null;
  15093. string bodyStr = string.Empty;
  15094. if (param.ContainsKey("methon"))
  15095. {
  15096. methon = param["methon"]!.ToString().ToLower();
  15097. }
  15098. if (param.ContainsKey("header"))
  15099. {
  15100. var header = param["header"]!.ToString();
  15101. JObject headerJobject = JObject.Parse(header);
  15102. headValues = new Dictionary<string, string>();
  15103. foreach (JProperty item in headerJobject.Properties())
  15104. {
  15105. var value = item.Value.ToString();
  15106. var head = item.Path;
  15107. headValues.Add(head, value);
  15108. }
  15109. }
  15110. HttpClient client = new HttpClient();
  15111. string responseString = string.Empty;
  15112. StringContent content = null;
  15113. if (headValues != null)
  15114. {
  15115. foreach (var item in headValues.Keys)
  15116. {
  15117. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  15118. {
  15119. if (param.ContainsKey("body"))
  15120. {
  15121. bodyStr = param["body"]!.ToString();
  15122. }
  15123. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  15124. }
  15125. else
  15126. {
  15127. client.DefaultRequestHeaders.Add(item, headValues[item]);
  15128. }
  15129. }
  15130. }
  15131. try
  15132. {
  15133. if (methon == "get")
  15134. {
  15135. responseString = await client.GetStringAsync(url);
  15136. }
  15137. else if (methon == "post")
  15138. {
  15139. var request = new HttpRequestMessage(HttpMethod.Post, url)
  15140. {
  15141. Content = content
  15142. };
  15143. var response = await client.SendAsync(request);
  15144. try
  15145. {
  15146. Stream responseStream = await response.Content.ReadAsStreamAsync();
  15147. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  15148. {
  15149. using (StreamReader reader = new StreamReader(gzipStream))
  15150. {
  15151. responseString = await reader.ReadToEndAsync();
  15152. }
  15153. }
  15154. }
  15155. catch (Exception)
  15156. {
  15157. responseString = await response.Content.ReadAsStringAsync();
  15158. }
  15159. }
  15160. else
  15161. {
  15162. responseString = "methon error";
  15163. }
  15164. jw = JsonView(true, "success", responseString);
  15165. }
  15166. catch (Exception ex)
  15167. {
  15168. jw.Msg = "error " + ex.Message;
  15169. jw.Data = ex.StackTrace;
  15170. }
  15171. finally
  15172. {
  15173. client.Dispose();
  15174. }
  15175. return Ok(jw);
  15176. }
  15177. #endregion
  15178. #region 团组接待意见调查
  15179. /// <summary>
  15180. /// 团组接待意见调查 - 信息管理
  15181. /// 基础数据(团组)
  15182. /// </summary>
  15183. /// <param name="dto"></param>
  15184. /// <returns></returns>
  15185. [HttpGet]
  15186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15187. public async Task<IActionResult> OpinionaireInit()
  15188. {
  15189. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  15190. .Select(x => new
  15191. {
  15192. x.Id,
  15193. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  15194. })
  15195. .OrderByDescending(x => x.Id)
  15196. .ToListAsync();
  15197. return Ok(JsonView(groupData, groupData.Count));
  15198. }
  15199. /// <summary>
  15200. /// 团组接待意见调查 - 信息管理
  15201. /// 列表
  15202. /// </summary>
  15203. /// <param name="groupId"></param>
  15204. /// <returns></returns>
  15205. [HttpGet("{groupId}")]
  15206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15207. public async Task<IActionResult> OpinionaireManageList(int groupId)
  15208. {
  15209. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15210. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  15211. .Select(x => new
  15212. {
  15213. x.Id,
  15214. x.TourGuideName,
  15215. x.CityName,
  15216. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  15217. x.CreateTime
  15218. })
  15219. .OrderBy(x => x.Id)
  15220. .ToListAsync();
  15221. return Ok(JsonView(data));
  15222. }
  15223. /// <summary>
  15224. /// 团组接待意见调查 - 信息管理
  15225. /// 保存
  15226. /// </summary>
  15227. /// <param name="dto"></param>
  15228. /// <returns></returns>
  15229. [HttpPost]
  15230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15231. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  15232. {
  15233. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15234. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15235. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15236. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  15237. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  15238. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  15239. _opinionaireRep.BeginTran();
  15240. if (addData != null && addData.Count > 0)
  15241. {
  15242. foreach (var item in addData)
  15243. {
  15244. item.CreateUserId = currUserInfo.UserId;
  15245. item.DiId = dto.DiId;
  15246. }
  15247. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  15248. }
  15249. if (updData != null && updData.Count > 0)
  15250. {
  15251. var upd = await _opinionaireRep._sqlSugar
  15252. .Updateable(updData)
  15253. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  15254. .WhereColumns(x => new { x.Id })
  15255. .ExecuteCommandAsync();
  15256. }
  15257. _opinionaireRep.CommitTran();
  15258. return Ok(JsonView("操作成功!"));
  15259. }
  15260. /// <summary>
  15261. /// 团组接待意见调查 - 信息管理
  15262. /// 删除
  15263. /// </summary>
  15264. /// <param name="id"></param>
  15265. /// <returns></returns>
  15266. [HttpDelete("{id}")]
  15267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15268. public async Task<IActionResult> OpinionaireManageDel(int id)
  15269. {
  15270. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15271. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15272. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  15273. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  15274. if (!del) return Ok(JsonView("操作失败!"));
  15275. return Ok(JsonView("操作成功!"));
  15276. }
  15277. /// <summary>
  15278. /// 团组接待意见调查 - 用户
  15279. /// 列表
  15280. /// </summary>
  15281. /// <param name="id"></param>
  15282. /// <returns></returns>
  15283. [HttpGet("{diId}")]
  15284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15285. public async Task<IActionResult> OpinionaireUserList(int diId)
  15286. {
  15287. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15288. var sql = string.Format(@"
  15289. SELECT
  15290. o.Id,
  15291. o.DiId,
  15292. di.TeamName AS 'GroupName',
  15293. di.VisitPNumber AS 'PeopleNumber',
  15294. di.ClientName AS 'LeadGroup',
  15295. di.VisitCountry AS 'Travel',
  15296. di.VisitDays AS 'Days',
  15297. o.CityName,
  15298. o.TourGuideName,
  15299. o.Catering,
  15300. o.CateringReason,
  15301. o.Stay,
  15302. o.StayReason,
  15303. o.[Route],
  15304. o.RouteReason,
  15305. o.OfficialActivity,
  15306. o.OfficialActivityReason,
  15307. o.TourGuide,
  15308. o.TourGuideReason,
  15309. o.[Translate],
  15310. o.TranslateReason,
  15311. o.Trip,
  15312. o.TripReason,
  15313. o.ESFileName,
  15314. o.SignatureDate,
  15315. o.Remark
  15316. FROM
  15317. Grp_Opinionaire o
  15318. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  15319. WHERE
  15320. o.IsDel = 0
  15321. AND o.DiId = {0}
  15322. ORDER BY
  15323. o.Id ASC", diId);
  15324. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  15325. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  15326. return Ok(JsonView(data));
  15327. }
  15328. /// <summary>
  15329. /// 团组接待意见调查 - 用户
  15330. /// 保存
  15331. /// </summary>
  15332. /// <param name="id"></param>
  15333. /// <returns></returns>
  15334. [HttpPost]
  15335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15336. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  15337. {
  15338. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  15339. foreach (var item in dto)
  15340. {
  15341. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  15342. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  15343. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  15344. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  15345. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  15346. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  15347. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  15348. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  15349. }
  15350. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  15351. if (!Directory.Exists(filePathBase))
  15352. {
  15353. Directory.CreateDirectory(filePathBase);
  15354. }
  15355. #region 上传文件
  15356. var filePaths = new List<string>();
  15357. foreach (var item in dto)
  15358. {
  15359. var file = item.File;
  15360. // 将文件保存到指定位置
  15361. var filePath = Path.Combine(filePathBase, file.FileName);
  15362. using (var stream = new FileStream(filePath, FileMode.Create))
  15363. {
  15364. await file.CopyToAsync(stream);
  15365. }
  15366. //验证文件是否上传成功
  15367. if (!System.IO.File.Exists(filePath))
  15368. {
  15369. foreach (var filePathStr in filePaths)
  15370. {
  15371. System.IO.File.Delete(filePathStr);
  15372. }
  15373. return Ok(JsonView(false, "文件上传失败!"));
  15374. }
  15375. item.ESFileName = file.FileName;
  15376. }
  15377. #endregion
  15378. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  15379. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  15380. .UpdateColumns(x => new
  15381. {
  15382. x.Catering,
  15383. x.CateringReason,
  15384. x.Stay,
  15385. x.StayReason,
  15386. x.Route,
  15387. x.RouteReason,
  15388. x.OfficialActivity,
  15389. x.OfficialActivityReason,
  15390. x.TourGuide,
  15391. x.TourGuideReason,
  15392. x.Translate,
  15393. x.TranslateReason,
  15394. x.Trip,
  15395. x.TripReason,
  15396. x.ESFileName,
  15397. x.SignatureDate,
  15398. x.Remark
  15399. })
  15400. .WhereColumns(x => new { x.Id })
  15401. .ExecuteCommandAsync();
  15402. if (upd < 1)
  15403. {
  15404. foreach (var filePathStr in filePaths)
  15405. {
  15406. System.IO.File.Delete(filePathStr);
  15407. }
  15408. return Ok(JsonView(false));
  15409. }
  15410. return Ok(JsonView(true));
  15411. }
  15412. #endregion
  15413. // /// <summary>
  15414. // ///
  15415. // /// </summary>
  15416. // /// <param name="_dto"></param>
  15417. // /// <returns></returns>
  15418. // [HttpPost]
  15419. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15420. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15421. // {
  15422. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15423. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  15424. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  15425. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15426. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  15427. // dic_psg.Add("客人", 974);
  15428. // dic_psg.Add("司机", 975);
  15429. // dic_psg.Add("导游", 976);
  15430. // dic_psg.Add("公司内部人员", 977);
  15431. // dic_psg.Add("司机/导游/公司内部人员", 978);
  15432. // foreach (var item in list_visa)
  15433. // {
  15434. // Grp_VisaInfo temp = new Grp_VisaInfo();
  15435. // temp.Id = item.Id;
  15436. // temp.DIId = item.DIId;
  15437. // temp.VisaClient = item.VisaClient;
  15438. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  15439. // temp.VisaCurrency = item.VisaCurrency;
  15440. // temp.IsThird = item.IsThird;
  15441. // if (dic_psg.ContainsKey(item.PassengerType))
  15442. // {
  15443. // temp.PassengerType = dic_psg[item.PassengerType];
  15444. // }
  15445. // else {
  15446. // temp.PassengerType = -1;
  15447. // }
  15448. // temp.VisaNumber = item.VisaNumber;
  15449. // temp.VisaFreeNumber = item.VisaFreeNumber;
  15450. // temp.CreateUserId = item.Operators;
  15451. // DateTime dt_ct;
  15452. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  15453. // if (b_ct)
  15454. // {
  15455. // temp.CreateTime = dt_ct;
  15456. // }
  15457. // else
  15458. // {
  15459. // temp.CreateTime = DateTime.Now;
  15460. // }
  15461. // temp.DeleteTime = "";
  15462. // temp.DeleteUserId = 0;
  15463. // temp.Remark = item.Remark;
  15464. // if (string.IsNullOrEmpty(temp.Remark)) {
  15465. // temp.Remark = "";
  15466. // }
  15467. // temp.IsDel = item.IsDel;
  15468. // temp.VisaDescription = item.VisaAttachment;
  15469. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  15470. //([Id]
  15471. // ,[DIId]
  15472. // ,[VisaClient]
  15473. // ,[VisaPrice]
  15474. // ,[VisaCurrency]
  15475. // ,[IsThird]
  15476. // ,[PassengerType]
  15477. // ,[VisaNumber]
  15478. // ,[VisaFreeNumber]
  15479. // ,[CreateUserId]
  15480. // ,[CreateTime]
  15481. // ,[DeleteTime]
  15482. // ,[DeleteUserId]
  15483. // ,[Remark]
  15484. // ,[IsDel]
  15485. // ,[visaDescription])
  15486. // VALUES
  15487. // ({0},{1},'{2}',{3},{4}
  15488. //,{5},{6},{7},{8},{9}
  15489. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  15490. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  15491. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  15492. //);
  15493. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  15494. // }
  15495. // return Ok(JsonView(true, "操作成功!"));
  15496. // }
  15497. /// <summary>
  15498. /// 123132123
  15499. /// </summary>
  15500. /// <param name="_dto"></param>
  15501. /// <returns></returns>
  15502. [HttpPost]
  15503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15504. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15505. {
  15506. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15507. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  15508. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  15509. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15510. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  15511. dicDetail.Add(789, 1034);
  15512. dicDetail.Add(790, 1035);
  15513. dicDetail.Add(791, 1036);
  15514. dicDetail.Add(792, 1037);
  15515. dicDetail.Add(793, 1038);
  15516. dicDetail.Add(794, 1039);
  15517. dicDetail.Add(795, 1040);
  15518. dicDetail.Add(796, 1041);
  15519. dicDetail.Add(797, 1042);
  15520. dicDetail.Add(798, 1043);
  15521. dicDetail.Add(801, 1044);
  15522. dicDetail.Add(802, 1045);
  15523. dicDetail.Add(803, 1046);
  15524. Dictionary<int, int> dic = new Dictionary<int, int>();
  15525. dic.Add(806, 1027);
  15526. dic.Add(807, 1028);
  15527. dic.Add(808, 1029);
  15528. dic.Add(809, 1030);
  15529. dic.Add(810, 1031);
  15530. dic.Add(811, 1032);
  15531. dic.Add(812, 1033);
  15532. foreach (var item in list_visa)
  15533. {
  15534. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  15535. temp.Coefficient = item.coefficient;
  15536. DateTime dtCrt;
  15537. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  15538. if (b1)
  15539. {
  15540. temp.CreateTime = dtCrt;
  15541. }
  15542. else
  15543. {
  15544. temp.CreateTime = DateTime.Now;
  15545. }
  15546. temp.CreateUserId = item.Operators;
  15547. temp.DeleteTime = "";
  15548. temp.DeleteUserId = 0;
  15549. temp.DiId = int.Parse(item.DIID);
  15550. temp.FilePath = item.FilePath;
  15551. temp.IsDel = item.IsDel;
  15552. temp.Price = item.Price;
  15553. temp.PriceCount = 1;
  15554. temp.PriceCurrency = item.Currency;
  15555. int detailId = 0;
  15556. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  15557. {
  15558. detailId = dicDetail[item.PriceTypeDetail];
  15559. }
  15560. temp.PriceDetailType = detailId;
  15561. temp.PriceDt = DateTime.Now;
  15562. temp.PriceName = item.PriceName;
  15563. temp.PriceSum = item.Price;
  15564. int tid = 0;
  15565. if (dic.ContainsKey(item.PriceType))
  15566. {
  15567. tid = dic[item.PriceType];
  15568. }
  15569. temp.PriceType = tid;
  15570. temp.Remark = item.Remark;
  15571. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  15572. }
  15573. return Ok(JsonView(true, "操作成功!"));
  15574. }
  15575. [HttpPost]
  15576. public IActionResult TimeTest()
  15577. {
  15578. var jw = JsonView(false, "error");
  15579. _sqlSugar.BeginTran();
  15580. try
  15581. {
  15582. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  15583. .Select(x => new Crm_NewClientData
  15584. {
  15585. Id = x.Id,
  15586. Client = x.Client,
  15587. Contact = x.Contact,
  15588. Location = x.Location,
  15589. })
  15590. .ToList();
  15591. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  15592. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  15593. Stopwatch stopwatch = new Stopwatch();
  15594. // 开始计时
  15595. stopwatch.Start();
  15596. foreach (var item in clientList)
  15597. {
  15598. EncryptionProcessor.DecryptProperties(item);
  15599. }
  15600. stopwatch.Stop();
  15601. jw.Code = 200;
  15602. jw.Data = stopwatch.ElapsedMilliseconds;
  15603. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  15604. }
  15605. catch (Exception ex)
  15606. {
  15607. jw.Code = 400;
  15608. jw.Msg = ex.Message;
  15609. }
  15610. return Ok(jw);
  15611. }
  15612. }
  15613. }